Spaces:
Sleeping
Sleeping
Download test_auth.py from janggi3/agent_system: direct link, hf CLI and curl.
- Browser
- Download file 873 Bytes
-
https://huggingface.co/spaces/janggi3/agent_system/resolve/main/test_auth.py
- Command line
-
hf download hf://spaces/janggi3/agent_system/test_auth.py
-
curl -L -o test_auth.py https://huggingface.co/spaces/janggi3/agent_system/resolve/main/test_auth.py
873 Bytes
| # file: agent_system/test_auth.py | |
| import ccxt | |
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| def test_alpaca_auth(): | |
| api_key = os.getenv("ALPACA_API_KEY") | |
| secret = os.getenv("ALPACA_SECRET") | |
| print(f"Key: {api_key[:5]}...") | |
| exchange = ccxt.alpaca({ | |
| 'apiKey': api_key, | |
| 'secret': secret, | |
| }) | |
| # Alpaca CCXT specific: setting sandbox mode changes the base URL | |
| if api_key.startswith("PK"): | |
| exchange.set_sandbox_mode(True) | |
| print(">>> Sandbox Mode Active (Paper Trading)") | |
| print(f"URLs: {exchange.urls['api']}") | |
| try: | |
| balance = exchange.fetch_balance() | |
| print("✅ Auth Successful!") | |
| print(f"Total Cash: ${balance['total'].get('USD', 0)}") | |
| except Exception as e: | |
| print(f"❌ Auth Failed: {e}") | |
| if __name__ == "__main__": | |
| test_alpaca_auth() | |