Skip to main content

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 datetime objects
  • 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

trading_core_types-0.2.0.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trading_core_types-0.2.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file trading_core_types-0.2.0.tar.gz.

File metadata

  • Download URL: trading_core_types-0.2.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

Hashes for trading_core_types-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5ea748df84285f6c49604239ad776393273c902778158f5ffb06d5fc91c69a72
MD5 23289326649ace554c95d15dd1f3248c
BLAKE2b-256 11424bc2cf2f7e905cf141158929649298f4c745f54aad24c1d680d07d059235

See more details on using hashes here.

File details

Details for the file trading_core_types-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for trading_core_types-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39f8d32e7971dc20e5a3e63aea61a451bf7d04aab9d392722bcd8bd1297dbc63
MD5 971ec390e24739d42712662225dcd6df
BLAKE2b-256 38095ce3d4683b25c0c57e2e91090f9a525323c052c62329f03ee766a5a5ec65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page