Skip to main content

Advanced TradingView historical and live data fetcher for stocks, crypto, forex, and commodities

Project description

XnoxsFetcher

Python Version License: MIT PyPI version Code style: ruff

Advanced TradingView Data Fetcher for Python - Fetch historical and live market data for stocks, crypto, forex, and commodities.

Apa itu XnoxsFetcher?

XnoxsFetcher adalah library Python yang memungkinkan Anda mengambil data pasar keuangan (saham, crypto, forex, komoditas) dari TradingView secara otomatis. Dengan library ini, Anda bisa mendapatkan data harga historis dan data real-time untuk analisis trading atau pembuatan bot trading.

Author: developerxnoxs
Versi: 4.0.0
Lisensi: MIT


Fitur Utama

Fitur Deskripsi
Multi-Asset Support Saham, Crypto, Forex, Komoditas dari berbagai exchange
Auth Manager Login dengan session persistence, auto token refresh
Data Export Export ke CSV, Excel, JSON, Parquet
Parallel Fetch Ambil banyak simbol sekaligus, 5 simbol dalam ~1 detik
WebSocket Manager Auto-reconnect, heartbeat monitoring
Cross-Platform Windows, macOS, Linux

Daftar Isi

  1. Instalasi
  2. Quick Start
  3. Fitur v4.0
  4. Mengambil Data
  5. Timeframe
  6. Live Data Streaming
  7. Daftar Exchange
  8. Development
  9. Contributing
  10. License

Instalasi

Requirements

  • Python 3.9+
  • pip atau uv package manager

Install via pip

pip install git+https://github.com/developerxnoxs/xnoxs_fetcher.git

Install via clone

git clone https://github.com/developerxnoxs/xnoxs_fetcher.git
cd xnoxs_fetcher
pip install -e .

Install dengan export dependencies

pip install -e ".[export]"  # Untuk CSV, Excel, Parquet export

Verifikasi Instalasi

from xnoxs_fetcher import XnoxsFetcher, TimeFrame
print("Instalasi berhasil!")

Quick Start

from xnoxs_fetcher import XnoxsFetcher, TimeFrame

# Buat instance fetcher
fetcher = XnoxsFetcher()

# Ambil data harian Apple
data = fetcher.get_hist(
    symbol="AAPL",
    exchange="NASDAQ",
    interval=TimeFrame.D1,
    n_bars=100
)

print(data)

Output:

                          symbol     open    high       low   close      volume
datetime                                                                       
2025-11-17 14:30:00  NASDAQ:AAPL  268.815  270.49  265.7300  267.46  45018260.0
2025-11-18 14:30:00  NASDAQ:AAPL  269.990  270.71  265.3200  267.44  45677278.0
...

Fitur v4.0

1. Auth Manager

Manajemen session yang robust dengan fitur:

  • Session persistence (simpan ke file)
  • Auto token refresh
  • Rate limit protection
from xnoxs_fetcher import AuthManager

auth = AuthManager()
token = auth.authenticate("email@example.com", "password")

if token:
    info = auth.get_session_info()
    print(f"Username: {info['username']}")
    print(f"Expired: {info['is_expired']}")

2. Data Export

Export data ke berbagai format:

from xnoxs_fetcher import XnoxsFetcher, DataExporter, TimeFrame

fetcher = XnoxsFetcher()
data = fetcher.get_hist("AAPL", "NASDAQ", TimeFrame.D1, 100)

exporter = DataExporter(output_dir="exports")
exporter.to_csv(data, "AAPL_daily")
exporter.to_excel(data, "AAPL_daily")
exporter.to_json(data, "AAPL_daily")
exporter.create_report(data, "AAPL_report")

3. Parallel Fetch

Ambil data banyak simbol secara bersamaan:

from xnoxs_fetcher import XnoxsFetcher, fetch_parallel, TimeFrame

fetcher = XnoxsFetcher()

symbols = [
    ("AAPL", "NASDAQ"),
    ("GOOGL", "NASDAQ"),
    ("MSFT", "NASDAQ"),
    ("AMZN", "NASDAQ"),
    ("META", "NASDAQ"),
]

results = fetch_parallel(
    fetcher=fetcher,
    symbols=symbols,
    timeframe=TimeFrame.D1,
    bars=100,
    max_workers=5
)

for key, data in results.items():
    symbol, exchange = key
    if data is not None:
        print(f"{symbol}: {len(data)} rows")

Mengambil Data

Data Saham

# Saham Amerika
apple = fetcher.get_hist("AAPL", "NASDAQ", TimeFrame.D1, 100)
tesla = fetcher.get_hist("TSLA", "NASDAQ", TimeFrame.H1, 50)

# Saham Indonesia
bbca = fetcher.get_hist("BBCA", "IDX", TimeFrame.D1, 100)
tlkm = fetcher.get_hist("TLKM", "IDX", TimeFrame.D1, 100)

# Saham India
reliance = fetcher.get_hist("RELIANCE", "NSE", TimeFrame.D1, 100)

Data Cryptocurrency

# Bitcoin
btc = fetcher.get_hist("BTCUSD", "BINANCE", TimeFrame.H1, 500)

# Ethereum
eth = fetcher.get_hist("ETHUSDT", "BINANCE", TimeFrame.M15, 1000)

# Altcoins
sol = fetcher.get_hist("SOLUSDT", "BINANCE", TimeFrame.H4, 200)

Data Forex

eurusd = fetcher.get_hist("EURUSD", "FX", TimeFrame.H1, 500)
gbpusd = fetcher.get_hist("GBPUSD", "FX", TimeFrame.D1, 200)

Timeframe

Kategori TimeFrame Penjelasan
Menit TimeFrame.M1 1 menit
TimeFrame.M5 5 menit
TimeFrame.M15 15 menit
TimeFrame.M30 30 menit
Jam TimeFrame.H1 1 jam
TimeFrame.H4 4 jam
Harian+ TimeFrame.D1 1 hari
TimeFrame.W1 1 minggu
TimeFrame.MN 1 bulan

Live Data Streaming

from xnoxs_fetcher import XnoxsLiveFeed, TimeFrame

live = XnoxsLiveFeed()

seis = live.create_symbol_set(
    symbol="BTCUSD",
    exchange="BINANCE",
    interval=TimeFrame.M1
)

def on_new_price(symbol_set, data):
    print(f"BTC: ${data['close'].iloc[0]:,.2f}")

consumer = seis.create_consumer(on_new_price)

# Streaming berjalan di background
# Panggil live.shutdown() untuk menghentikan

Daftar Exchange

Saham

Exchange Kode Contoh
NASDAQ NASDAQ AAPL, TSLA, MSFT
NYSE NYSE JPM, BAC, WMT
Indonesia IDX BBCA, TLKM, BBRI
India NSE NSE RELIANCE, TCS
Hong Kong HKEX 0700, 9988

Cryptocurrency

Exchange Kode Contoh
Binance BINANCE BTCUSD, ETHUSDT
Coinbase COINBASE BTCUSD, ETHUSD
Bybit BYBIT BTCUSDT

Forex & Komoditas

Exchange Kode Contoh
FX FX EURUSD, GBPUSD
MCX MCX GOLD, SILVER
COMEX COMEX GC1!, SI1!

Development

Setup Development Environment

# Clone repository
git clone https://github.com/developerxnoxs/xnoxs_fetcher.git
cd xnoxs_fetcher

# Install dengan dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run linter
ruff check .

# Run formatter
ruff format .

# Type checking
mypy xnoxs_fetcher/

Project Structure

xnoxs_fetcher/
├── xnoxs_fetcher/          # Main package
│   ├── __init__.py
│   ├── core.py             # Core fetcher
│   ├── auth.py             # Authentication
│   ├── export.py           # Data export
│   ├── parallel.py         # Parallel fetching
│   ├── live_feed.py        # Live streaming
│   ├── websocket_manager.py
│   ├── models.py
│   └── py.typed            # PEP 561 marker
├── tests/                  # Unit tests
├── .github/                # GitHub configs
│   ├── workflows/ci.yml
│   └── ISSUE_TEMPLATE/
├── pyproject.toml          # Modern Python config
├── README.md
├── CHANGELOG.md
├── CONTRIBUTING.md
├── CODE_OF_CONDUCT.md
├── SECURITY.md
└── LICENSE

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feat/amazing-feature)
  3. Commit changes (git commit -m 'feat: add amazing feature')
  4. Push to branch (git push origin feat/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.


Support


Made with ❤️ by developerxnoxs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xnoxs_fetcher-4.0.0.tar.gz (37.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xnoxs_fetcher-4.0.0-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

Details for the file xnoxs_fetcher-4.0.0.tar.gz.

File metadata

  • Download URL: xnoxs_fetcher-4.0.0.tar.gz
  • Upload date:
  • Size: 37.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for xnoxs_fetcher-4.0.0.tar.gz
Algorithm Hash digest
SHA256 c3502f3672a99fc09dba92880c161edd12b7c641b5668307f0fd969a3726b9cd
MD5 f9e412821cca2d57a619b47ee17c0a2a
BLAKE2b-256 00f038e79285bb7cfd4361cb668836e6a54914b9259304cffd3675cc8ba78175

See more details on using hashes here.

File details

Details for the file xnoxs_fetcher-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: xnoxs_fetcher-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 33.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for xnoxs_fetcher-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ec73def250c625c84f0b7464a03ed3f06a2e0277cf9a30c8eab90a3cdf77ba1
MD5 6558ca3b765e1a3fcef4a45218b34150
BLAKE2b-256 dfe6bca60ed2c0065d39c8dae1fd3114da4ef2cd60817b9142bb3fe523907160

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page