agent_system / debug_alpaca.py
janggi3's picture
Upload folder using huggingface_hub
d96a847 verified
Raw History Blame Contribute Delete
976 Bytes
# 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()