Spaces:
Sleeping
Sleeping
Download test_auth_v2.py from janggi3/agent_system: direct link, hf CLI and curl.
- Browser
- Download file 967 Bytes
-
https://huggingface.co/spaces/janggi3/agent_system/resolve/main/test_auth_v2.py
- Command line
-
hf download hf://spaces/janggi3/agent_system/test_auth_v2.py
-
curl -L -o test_auth_v2.py https://huggingface.co/spaces/janggi3/agent_system/resolve/main/test_auth_v2.py
967 Bytes
| # file: agent_system/test_auth_v2.py | |
| import ccxt | |
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| def test(): | |
| api_key = os.getenv("ALPACA_API_KEY", "").strip() | |
| secret = os.getenv("ALPACA_SECRET", "").strip() | |
| print(f"Key: {api_key}") | |
| print(f"Secret: {secret[:5]}...") | |
| exchange = ccxt.alpaca({ | |
| 'apiKey': api_key, | |
| 'secret': secret, | |
| 'options': {'defaultType': 'spot'} | |
| }) | |
| if api_key.startswith("PK"): | |
| exchange.set_sandbox_mode(True) | |
| # Force paper URL | |
| exchange.urls['api']['rest'] = 'https://paper-api.alpaca.markets/v2' | |
| print(f">>> Testing Paper Endpoint @ {exchange.urls['api']['rest']}") | |
| try: | |
| print("Fetching balance...") | |
| bal = exchange.fetch_balance() | |
| print(f"✅ Success! USD balance: {bal.get('USD', {}).get('total', 'N/A')}") | |
| except Exception as e: | |
| print(f"❌ Failed: {e}") | |
| if __name__ == "__main__": | |
| test() | |