skills/financial/alpaca-api/SKILL.md
--- name: alpaca-api cluster: financial description: "Interact with Alpaca\'s API for stock trading and market data retrieval." tags: ["finance","api","stock-trading","alpaca"] dependencies: [] composes: [] similar_to: [] called_by: [] authorization_required: false scope: general model_hint: claude-sonnet embedding_hint: "alpaca api finance trading stocks market data" --- # alpaca-api ## Purpose This skill allows the AI to interact with Alpaca's API for executing stock trades, retrieving marke
npx skillsauth add alphaonedev/openclaw-graph skills/financial/alpaca-apiInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill allows the AI to interact with Alpaca's API for executing stock trades, retrieving market data, and managing accounts, using HTTP requests to Alpaca's endpoints.
Use this skill for tasks involving real-time financial data, such as fetching stock prices, placing buy/sell orders, or checking account balances in a trading bot or financial analysis workflow. Avoid it for non-financial tasks or when real-time data isn't needed.
Always initialize requests with authentication headers using $ALPACA_API_KEY and $ALPACA_SECRET_KEY as environment variables. For example, set headers like {'APCA-API-KEY-ID': os.environ['ALPACA_API_KEY'], 'APCA-API-SECRET-KEY': os.environ['ALPACA_SECRET_KEY']}. Use GET for data retrieval and POST for actions like trading. Rate limit requests to avoid API throttling (Alpaca's limit is 200 requests per minute per IP). Test in paper trading mode first by switching the base URL.
import requests
response = requests.post('https://api.alpaca.markets/v2/orders', json=order_data, headers=auth_headers)
print(response.json())
Store API keys in environment variables like export ALPACA_API_KEY='your_key' and export ALPACA_SECRET_KEY='your_secret'. Use a library like requests in Python for HTTP interactions. For production, handle base URL differences: use https://api.alpaca.markets for live and https://paper-api.alpaca.markets for testing. Integrate with other skills by piping data, e.g., fetch data from this skill and pass to a 'data-analysis' skill. Config format: Use a .env file with ALPACA_API_KEY=xxx and ALPACA_SECRET_KEY=yyy, then load with python-dotenv.
Check HTTP status codes: 401 for auth errors (retry after verifying $ALPACA_API_KEY), 429 for rate limits (wait and retry with exponential backoff), 404 for invalid endpoints (log and abort). Parse JSON responses for Alpaca-specific errors, e.g., if "code" == "invalid_symbol", suggest checking the stock symbol. Implement try-except blocks around requests, like:
try:
response = requests.get(url, headers=auth_headers)
response.raise_for_status()
except requests.exceptions.HTTPError as err:
print(f"Error: {err.response.status_code} - {err.response.text}")
Log all errors with timestamps and retry transient errors up to 3 times.
tools
Root web development: project structure, tooling selection, deployment decisions
development
WebAssembly: Rust/Go/C to WASM, wasm-bindgen, Emscripten, WASM Component Model
development
Vue 3: Composition API script setup, Pinia, Vue Router 4, SFCs, Vite, Nuxt 3
tools
Tailwind CSS 4: utility classes, config, JIT, arbitrary values, darkMode, plugins, shadcn/ui