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.0.tar.gz
(19.3 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.0.tar.gz.
File metadata
- Download URL: stockalert-2.0.0.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74745f879f36d1801146b659c1dbbbc7200bc343903abf0c8a991280cf838f1a
|
|
| MD5 |
33d5aae894762b2bdd4a821d1bd1f84f
|
|
| BLAKE2b-256 |
893582bdad0bf74daed2d3dc9a5ef490f7497787b8895aaef91ca2dd681a1545
|
File details
Details for the file stockalert-2.0.0-py3-none-any.whl.
File metadata
- Download URL: stockalert-2.0.0-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 |
22374ca39221a2b3c17648a99917750bd2ed171e38f9a6dddd49cfabab227e39
|
|
| MD5 |
07d9abbcf6511e4f7b3250f2bd0ca1f9
|
|
| BLAKE2b-256 |
417c500a79ad3322201e451f28211a31d121bca23ceddeccb96615ab21f2c64f
|