Add Ticker24h support: hourly market snapshots with USD-normalized volume filtering
This commit is contained in:
@@ -92,6 +92,61 @@ All columns below are fully populated for Binance data. Other exchanges provide
|
||||
- `"ticker"` - Market identifier
|
||||
- `"period_seconds"` - Period in seconds
|
||||
|
||||
## Building a Scanner Universe with get_ticker_24h
|
||||
|
||||
**Always pre-filter symbols before fetching OHLC data for scanners.** Fetching OHLC for all ~1800 Binance symbols would exhaust the 2M-bar per-script budget instantly. Use `get_ticker_24h` to get a ranked list of all symbols for free (no OHLC budget cost), then run per-symbol analysis only on the filtered set.
|
||||
|
||||
```python
|
||||
from dexorder.api import get_api
|
||||
import asyncio
|
||||
|
||||
api = get_api()
|
||||
|
||||
# Get top 50 most liquid Binance spot symbols (no OHLC budget used)
|
||||
universe = asyncio.run(api.data.get_ticker_24h(
|
||||
"BINANCE",
|
||||
limit=50,
|
||||
market_type="spot",
|
||||
min_std_quote_volume=10_000_000 # $10M+ daily volume
|
||||
))
|
||||
print(f"Universe: {len(universe)} symbols")
|
||||
print(universe[["ticker", "std_quote_volume", "price_change_pct"]].head(10))
|
||||
|
||||
# Now fetch OHLC only for these symbols
|
||||
tickers = universe["ticker"].tolist()
|
||||
results = {}
|
||||
for ticker in tickers:
|
||||
df = asyncio.run(api.data.historical_ohlc(
|
||||
ticker=ticker,
|
||||
period_seconds=3600,
|
||||
start_time="2024-01-01",
|
||||
end_time="2025-01-01",
|
||||
extra_columns=["volume"]
|
||||
))
|
||||
print(f"[Data] {ticker}: {len(df)} bars")
|
||||
results[ticker] = df
|
||||
```
|
||||
|
||||
### get_ticker_24h filter parameters
|
||||
|
||||
```python
|
||||
# All BTC pairs on Binance (spot + perp)
|
||||
df = asyncio.run(api.data.get_ticker_24h("BINANCE", base_asset_contains="BTC"))
|
||||
|
||||
# Top 100 perp markets with at least $50M daily volume
|
||||
df = asyncio.run(api.data.get_ticker_24h(
|
||||
"BINANCE",
|
||||
limit=100,
|
||||
market_type="perp",
|
||||
min_std_quote_volume=50_000_000
|
||||
))
|
||||
|
||||
# All Coinbase symbols (for a cross-exchange scan)
|
||||
df = asyncio.run(api.data.get_ticker_24h("COINBASE"))
|
||||
```
|
||||
|
||||
The returned DataFrame is sorted by `std_quote_volume` (USD-normalized volume) descending. Symbols without a USD conversion path have `std_quote_volume = NaN` and appear last. Columns: `ticker`, `exchange_id`, `base_asset`, `quote_asset`, `last_price`, `price_change_pct`, `quote_volume_24h`, `std_quote_volume`, `bid_price`, `ask_price`, `open_24h`, `high_24h`, `low_24h`, `volume_24h`, `num_trades`, `timestamp_ms`.
|
||||
|
||||
## Using the Charting API
|
||||
|
||||
The charting API provides styled financial charts with OHLC candlesticks and technical indicators.
|
||||
|
||||
Reference in New Issue
Block a user