Official Python SDK for StockAlert.pro API
Project description
StockAlert.pro Python SDK
Official Python SDK for the StockAlert.pro API.
Installation
pip install stockalert
Quick Start
from stockalert import StockAlert
# Initialize the client
client = StockAlert(api_key="sk_your_api_key")
# List all alerts
alerts = client.alerts.list()
# Create a new alert
alert = client.alerts.create(
symbol="AAPL",
condition="price_above",
threshold=200,
notification="email"
)
# Update alert status
client.alerts.update(alert.id, status="paused")
# Delete alert
client.alerts.delete(alert.id)
Features
- 🐍 Python 3.7+ support
- 🔄 Automatic retries with exponential backoff
- 🛡️ Type hints for better IDE support
- 📦 Minimal dependencies
- 🧪 Comprehensive test suite
- 📚 Detailed documentation
Async Support
The SDK also supports async operations:
import asyncio
from stockalert import AsyncStockAlert
async def main():
async with AsyncStockAlert(api_key="sk_your_api_key") as client:
alerts = await client.alerts.list()
print(f"Found {len(alerts.data)} alerts")
asyncio.run(main())
Documentation
Full documentation is available at https://stockalert.pro/api/docs
License
MIT
🎯 More Examples
Pagination
# Iterate through all alerts efficiently
for alert in client.alerts.iterate():
print(f"{alert.symbol}: {alert.condition}")
Error Handling
from stockalert import StockAlert, APIError, RateLimitError
try:
alert = client.alerts.create(
symbol="AAPL",
condition="price_above",
threshold=200
)
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except APIError as e:
print(f"API error: {e.message} (status: {e.status_code})")
Environment Variables
import os
from stockalert import StockAlert
# API key from environment variable
client = StockAlert(api_key=os.environ["STOCKALERT_API_KEY"])
Async Usage
import asyncio
from stockalert import AsyncStockAlert
async def main():
async with AsyncStockAlert(api_key="sk_your_api_key") as client:
alerts = await client.alerts.list()
print(f"Found {len(alerts['data'])} alerts")
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stockalert-2.0.1.tar.gz
(25.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stockalert-2.0.1.tar.gz.
File metadata
- Download URL: stockalert-2.0.1.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db9700b77c476736ce446a6af872cbfe1a8791111953c387e2bf22d163c57458
|
|
| MD5 |
4c1db069f4f5ac5bbda994ef40455812
|
|
| BLAKE2b-256 |
4fbe5b75030d2986f3f10089408edb926c2e61812489599ff42f64e143f9ce98
|
File details
Details for the file stockalert-2.0.1-py3-none-any.whl.
File metadata
- Download URL: stockalert-2.0.1-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
432fe65d8a28276875f4b0f493d3dd0a4ecfd0e8df437430d0bb1d4933254cca
|
|
| MD5 |
624d93438d16774734bb8d6ac1e0c85b
|
|
| BLAKE2b-256 |
9b435d95b7f219092c3454d04a66aa24a0c34644b91d7184bc9ebd03d3e8d7c3
|