indicators and plots
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
Test script for CCXT DataSource adapter (Free Version).
|
||||
|
||||
This demonstrates how to use the free CCXT adapter (not ccxt.pro) with various
|
||||
exchanges. It uses polling instead of WebSocket for real-time updates and
|
||||
verifies that Decimal precision is maintained throughout.
|
||||
exchanges. It uses polling instead of WebSocket for real-time updates.
|
||||
|
||||
CCXT is configured to use Decimal mode internally for precision, but OHLCV data
|
||||
is converted to float for optimal DataFrame/analysis performance.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
@@ -73,10 +75,10 @@ async def test_binance_datasource():
|
||||
print(f" Close: {latest.data['close']} (type: {type(latest.data['close']).__name__})")
|
||||
print(f" Volume: {latest.data['volume']} (type: {type(latest.data['volume']).__name__})")
|
||||
|
||||
# Verify Decimal precision
|
||||
assert isinstance(latest.data['close'], Decimal), "Price should be Decimal type!"
|
||||
assert isinstance(latest.data['volume'], Decimal), "Volume should be Decimal type!"
|
||||
print(f" ✓ Numerical precision verified: using Decimal types")
|
||||
# Verify OHLCV uses float (converted from Decimal for DataFrame performance)
|
||||
assert isinstance(latest.data['close'], float), "OHLCV price should be float type!"
|
||||
assert isinstance(latest.data['volume'], float), "OHLCV volume should be float type!"
|
||||
print(f" ✓ OHLCV data type verified: using native float (CCXT uses Decimal internally)")
|
||||
|
||||
# Test 5: Polling subscription (brief test)
|
||||
print("\n5. Testing polling-based subscription...")
|
||||
@@ -87,7 +89,7 @@ async def test_binance_datasource():
|
||||
tick_count[0] += 1
|
||||
if tick_count[0] == 1:
|
||||
print(f" Received tick: close={data['close']} (type: {type(data['close']).__name__})")
|
||||
assert isinstance(data['close'], Decimal), "Polled data should use Decimal!"
|
||||
assert isinstance(data['close'], float), "Polled OHLCV data should use float!"
|
||||
|
||||
subscription_id = await binance.subscribe_bars(
|
||||
symbol="BTC/USDT",
|
||||
|
||||
Reference in New Issue
Block a user