Spaces:
Sleeping
Sleeping
Download debug_alpaca.py from janggi3/agent_system: direct link, hf CLI and curl.
- Browser
- Download file 976 Bytes
-
https://huggingface.co/spaces/janggi3/agent_system/resolve/main/debug_alpaca.py
- Command line
-
hf download hf://spaces/janggi3/agent_system/debug_alpaca.py
-
curl -L -o debug_alpaca.py https://huggingface.co/spaces/janggi3/agent_system/resolve/main/debug_alpaca.py
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() | |