Skip to main content

Unified instrument spec parser and venue symbol resolver for crypto markets

Project description

marketspec

Unified instrument spec parser and venue symbol resolver for crypto markets.

  • Parse BTC/USDT:USDT, BTC/USD:USD-20251227, ETH-20251226-2500-C.
  • Resolve symbols for Binance and Bybit.
  • No runtime dependencies. Typed. MIT.

Install

pip install marketspec

Quick start

from marketspec import venue_symbol, parse, resolve_symbol

print(venue_symbol("binance", "BTC/USDT:USDT"))          # BTCUSDT
print(venue_symbol("bybit",   "BTC/USD:USD-20251227"))   # BTCUSD_20251227
print(venue_symbol("binance", "ETH-20251226-2500-C"))    # ETH-20251226-2500-C

# Stable parser + resolver
s = parse("BTC/USDT:USDT")       # -> Spec
print(resolve_symbol("binance", s))  # BTCUSDT

Grammar

  • Spot: BASE/QUOTEBTC/USDT
  • Swap (linear): BASE/QUOTE:SETTLE where SETTLE == QUOTE and is a stable → BTC/USDT:USDT
  • Swap (inverse): BASE/QUOTE:USDBTC/USD:USD
  • Future: append -YYYYMMDD to the swap form → BTC/USDT:USDT-20251227
  • Option: BASE-YYYYMMDD-STRIKE-C|PETH-20251226-2500-C

Supported venues

  • binance
  • bybit

PRs welcome for more venues.

Development

python -m venv .venv && source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -e .
pytest -q

License

MIT

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

marketspec-0.2.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

marketspec-0.2.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: marketspec-0.2.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for marketspec-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6b9c6976a4330b53b44e12bced0908c4db5d1535d9359de13a46a745eedd2637
MD5 8f355e9a6da467d247e123ec212ced36
BLAKE2b-256 72cc399925769311ebad128907f845a0f0dc34535d092a7aaed8a02e96efa851

See more details on using hashes here.

File details

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

File metadata

  • Download URL: marketspec-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for marketspec-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d91e7ff7b88c0c5264e9e6836a8eab404c89cc4e2ecf309c56dc2142ea65a9b3
MD5 462146ce3888f419b010c7d4d8b6f581
BLAKE2b-256 28df158818c26e8535e2661bffe95ca778c6b360250b7fac684ab6bf43ddc339

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