Skip to main content

Typed gTrade

A fully typed, validated async client for gTrade by Gains Network.

PyPI version Python versions Docs License



from typed_gtrade import GTrade

async with GTrade.new(public=True) as client:
  prices = await client.trading.markets.prices()
  btc = next(p for p in prices if p['market'] == 'BTC/USD')
  print(btc['mark'], btc['updatedAt'])

Why Typed gTrade?

  • 🎯 Precise Types: Typed inputs and responses for the Trading API, the per-chain backend, Backend Global and pricing, not dict/Any.
  • ✅ Runtime Validation: Responses and stream frames validated by default, not just typed on paper.
  • ⚡ Async First: Async HTTP plus three WebSocket feeds (Trading API channels, backend contract events, live prices), built for concurrent workflows.
  • 📚 Full Surface: Every native Trading API endpoint and channel (markets, account, orders, positions, agents, API keys), plus the per-chain backend's trading-state reads and event stream, pricing, and a read subset of Backend Global (stats, history, leaderboards, contests, referrals).

Installation

pip install typed-gtrade

Surfaces

GTrade.new(chain=...) binds one chain and composes four surfaces:

Attribute Serves Credentials
client.trading The official Trading API: markets, account, orders, positions, agents, API keys, and its WebSocket channels (client.trading.streams) None for market data, system.* and agents.get. None for agents.create, agents.revoke and api_keys.issue either: a master-wallet signature goes in the request. An agent key or read-only API key for private reads and channels; an agent key for order and position writes
client.backend The chain's trading backend: trading variables, open trades, per-trader variables, and its contract-event stream (client.backend.streams) None
client.backend_global A read subset: protocol stats, trading history, trader history and stats, leaderboards, contests, referral reads None
client.pricing Price snapshots and the live price stream, indexed by pairIndex None

The Trading API serves Arbitrum (chain='arbitrum', the default). On base, polygon and megaeth, until it launches there, its REST calls other than system.health and system.ready raise BadRequest (CHAIN_NOT_FOUND), and its channels raise NetworkError. The per-chain backend covers arbitrum, base, polygon and megaeth; arbitrum-sepolia targets the testnet deployment, whose backend is live but whose Trading API host is currently unreachable. To use two chains, build two clients. Backend Global and pricing are not chain-bound: Backend Global's stats, trading-history and trader reads take an explicit chain_id (42161 Arbitrum, 8453 Base, 137 Polygon); its contests, referrals and stats.total_supply take none.

Numbers differ by surface: the Trading API returns Decimal, the per-chain backend mostly raw contract-precision integers, Backend Global and pricing mostly floats. See Numbers & Precision for the exceptions.

Trading writes return an unsigned EVM transaction: the client never signs or broadcasts transactions. See Place & Manage Orders.

How To

Reference

Design Philosophy

Typed gTrade follows the principles outlined in this blog post.

Details matter. Developer experience matters.

License

MIT — see LICENSE.

Metadata

Release files for typed-gtrade 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for typed-gtrade 0.1.1
File Size Uploaded Provenance Actions
typed_gtrade-0.1.1.tar.gz 84.2 kB With provenance Details for typed_gtrade-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for typed-gtrade 0.1.1
File Interpreter ABI Platform Actions
typed_gtrade-0.1.1-py3-none-any.whl Python 3 none any Details for typed_gtrade-0.1.1-py3-none-any.whl

Total release size: 245.4 kB

Release files / typed_gtrade-0.1.1.tar.gz

Download URL typed_gtrade-0.1.1.tar.gz
Size 84.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7c641a8ad1a44a33423aa8a37a8be7b1eb350e7e02d5c3fb64178c4e494475fe
BLAKE2b-256 checksum
How to use checksums
beffd414229c015eb412ab8b4604b6e0bdcd4650a500fc4ac3108761f44d1e27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / typed_gtrade-0.1.1-py3-none-any.whl

Download URL typed_gtrade-0.1.1-py3-none-any.whl
Size 161.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5aef5f1adf109454c0142cc4807adb67798c4855d10928b0af6d579a55b8556b
BLAKE2b-256 checksum
How to use checksums
3f6f4f30803810514d1a2505ccccd1aec2ea53a3df9c0ee19a4ba2936d1f18d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for typed-gtrade 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for typed_gtrade-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page