Spaces:
Sleeping
Sleeping
File size: 976 Bytes
d96a847 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # file: agent_system/debug_alpaca.py
import ccxt
import os
from dotenv import load_dotenv
load_dotenv()
def debug():
api_key = os.getenv("ALPACA_API_KEY")
secret = os.getenv("ALPACA_SECRET")
exchange = ccxt.alpaca({
'apiKey': api_key,
'secret': secret,
})
if api_key.startswith("PK"):
exchange.set_sandbox_mode(True)
m = exchange.load_markets()
crypto_symbols = [s for s in m if m[s].get('type') == 'crypto']
print(f"Total Markets: {len(m)}")
print(f"Crypto Symbols Found: {len(crypto_symbols)}")
print(f"Sample Crypto: {crypto_symbols[:10]}")
if crypto_symbols:
try:
print(f"Testing fetch_ohlcv for {crypto_symbols[0]}...")
ohlcv = exchange.fetch_ohlcv(crypto_symbols[0], timeframe='1h', limit=5)
print(f"Success! {len(ohlcv)} candles fetched.")
except Exception as e:
print(f"Failed: {e}")
if __name__ == "__main__":
debug()
|