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.1.0.tar.gz (39.7 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.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trading_core_types-0.1.0.tar.gz
  • Upload date:
  • Size: 39.7 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.1.0.tar.gz
Algorithm Hash digest
SHA256 61e09ba54c5b9f13cffa3818bbf862e0c0173c93fe99974a2db41b7a7ca9f435
MD5 3435c5fd1c76f15019d3ec641997adcf
BLAKE2b-256 35999b4e9a9196dcc535ded580d374f48c708eafe20b520a8e5e9954d58dba06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trading_core_types-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f5d70c8d48abeb0e097202842bd83d2cf778fdafd763181d4448818fa0fb87c
MD5 86e7c5b93a125bb27bf434e888cbaa6b
BLAKE2b-256 eb70fc6b4fc52cce460b9150135538f911c7eb277740698db5df9b4872ba2c26

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