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.3.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.3.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trading_core_types-0.3.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.3.0.tar.gz
Algorithm Hash digest
SHA256 9ff748a1b74815ec02397a62258e21dc4bd1a2bfa3109522d297cd357cbfc7bf
MD5 6d682b384848d0bdd0e2cd9726179aea
BLAKE2b-256 50627bf8f7744c1bbd1625c9cb4d5f3267e798b599e6600c8e8933ba995932c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trading_core_types-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8be40c808ad654cfa3b35cdb5273840fc450d761cc13c7388632ddcab4412caf
MD5 0643fcec9d60e7efc6985279008a904b
BLAKE2b-256 ba568d4ceac8c48aeb2fcf02d61f34115c915a5c8cce442a6417acb5e2329a50

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