Python implementation of trading-core types with Pydantic validation
Project description
trading-core-types
Python types for trading systems with Pydantic validation and JSON serialization.
Installation
pip install trading-core-types
Features
- Pydantic models for trading types
- Wire format (JSON) with camelCase fields
- Runtime format with snake_case fields and
datetimeobjects - Type-safe conversion between wire and runtime formats
Usage
from trading_core import Asset, AssetWire
# Deserialize from JSON/API (wire format)
asset_wire = AssetWire.model_validate({
"symbol": "AAPL",
"currency": "USD",
"validFrom": 1609459200000 # Unix timestamp in ms
})
# Convert to runtime format
asset = Asset.from_wire(asset_wire)
print(asset.valid_from) # datetime object
# Convert back to wire format
wire_data = asset.to_wire()
json_str = wire_data.model_dump_json(by_alias=True)
Available Types
Market Data: Asset, MarketSnapshot, MarketQuote, MarketBar
Orders: Order, OrderState, Fill
Positions: Position, LongPosition, ShortPosition
Each type has a corresponding *Wire class for JSON serialization.
Example
See examples/main.py for complete usage examples.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 trading_core_types-0.4.0.tar.gz.
File metadata
- Download URL: trading_core_types-0.4.0.tar.gz
- Upload date:
- Size: 39.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f68af60ff3434b77adb7251d1b9d433c1fe7b36572001f484128bcd3828404e
|
|
| MD5 |
0533a7ebb6b8d5e83adb575b06764437
|
|
| BLAKE2b-256 |
26ed0042a5e346b8aa4a4565601225b3a44988b99c3584d5afdcbbddca709a1b
|
File details
Details for the file trading_core_types-0.4.0-py3-none-any.whl.
File metadata
- Download URL: trading_core_types-0.4.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf201a62671f604befe85df96eecc74c50652854d84c658f1c0bceecd5c76dd0
|
|
| MD5 |
ebedf9f46fbe55926c4b8b8fe985b8e8
|
|
| BLAKE2b-256 |
38889644aa020825dd823cbd655fd408ba2648ef6b0dfc08e7d1ae923a05f3e7
|