A lightweight Python client for the Amherst College Quant Club Live Trading Engine.
Project description
purpletrader
A lightweight Python client for the Live Trading Engine HTTP API.
Installation
pip install purpletrader
Usage
from purpletrader import TradingEngineClient, Order, Timeframe
# Optionally set a default user_id so you don't have to provide it per order
client = TradingEngineClient(base_url="http://localhost:8080", user_id="trader_123")
# Submit order
resp = client.submit_order(Order(
id="order_001",
symbol="AAPL",
type="LIMIT",
side="BUY",
quantity=100,
price=150.25,
))
print(resp)
# Fetch data
print(client.get_orderbook("AAPL"))
print(client.get_stats("AAPL"))
print(client.get_stats_timeframe("AAPL", Timeframe.ONE_MINUTE))
print(client.get_all_stats())
print(client.get_stats_summary())
print(client.get_leaderboard())
print(client.health())
Notes
- Raises
HTTPErroron non-2xx responses withstatus_code,message, andbody. - Default timeout is 30s; override via
TradingEngineClient(timeout=...). - You can still override
userIdper order by passing it in theOrder.
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
purpletrader-0.1.0.tar.gz
(6.5 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 purpletrader-0.1.0.tar.gz.
File metadata
- Download URL: purpletrader-0.1.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a94219da3a122f86621e5066cb8615d06cbc99817470beb22f50fe9fe2be66d
|
|
| MD5 |
a94b1098cef765e3ded42de59371ffab
|
|
| BLAKE2b-256 |
7f7831cd636e4e792c2c6b790e28c2fd158208c70a5c696c99e96c6efb4d2c5b
|
File details
Details for the file purpletrader-0.1.0-py3-none-any.whl.
File metadata
- Download URL: purpletrader-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ced2ad2f3486187fe755ba4a61fbfbc66c85a295a1f5b009a86a07069c6c23a
|
|
| MD5 |
fc5a587f025f7adf6652c301d2bb0a60
|
|
| BLAKE2b-256 |
17f00e1ca3b4bc794a24aed760464e0ec177dd6571de20e606be6425099cf03d
|