Skip to main content

Python client for the Toss Securities (토스증권) Open API

Project description

tossinvest

Async Python client for the Toss Securities (토스증권) Open API — a faithful port of tossinvest-rust.

  • Pure REST client with OAuth2 client_credentials auth
  • Exact decimals (Decimal, never float), unknown-tolerant open enums, status-split envelope decoding
  • Per-group rate limiting (GCRA + adaptive AIMD) with the 09:00–09:10 KST peak-window awareness
  • Account-scoped client handle so the X-Tossinvest-Account header is unforgettable

Status: alpha. Stateless SDK (model → rate → client) and the stateful/observable layer (StateHandle) are implemented.

Install

pip install tossinvest

Quickstart

import asyncio
from tossinvest import TossClient, ClientConfig

async def main():
    async with TossClient(ClientConfig(client_id="...", client_secret="...")) as client:
        prices = await client.prices(["005930"])
        price = prices[0]
        print(price.last_price, price.currency)

asyncio.run(main())

Response models live in tossinvest.model (e.g. from tossinvest.model import PriceResponse).

Stateful layer (StateHandle)

The L4/L5 reconciler maintains a live, single-writer projection of your orders, holdings, and prices, with optimistic mutations and on-demand refresh:

import asyncio
from tossinvest import TossClient, ClientConfig
from tossinvest.state import StateHandle

async def main():
    async with TossClient(ClientConfig(client_id="...", client_secret="...")) as client:
        account = client.account(seq)
        async with await StateHandle.spawn(account) as handle:
            async with handle.watch_prices(["005930"]):   # demand lease
                snap = handle.snapshot()                   # wait-free read
                print(snap.prices.get("005930"))

asyncio.run(main())

License

Apache-2.0

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

tossinvest-0.1.0.tar.gz (121.8 kB view details)

Uploaded Source

Built Distribution

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

tossinvest-0.1.0-py3-none-any.whl (95.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tossinvest-0.1.0.tar.gz
  • Upload date:
  • Size: 121.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for tossinvest-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b00fc0f0aa976057a2540a0f0e458af848aa578ff9fe9efae514c55b0b1f7084
MD5 7011a64c275044e0df6ad66e70ac5007
BLAKE2b-256 1e3d8ad8db1b9de080c0bb1240e0ffd9a32436d25ad611b34c0964aa5686c78d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tossinvest-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 95.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for tossinvest-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 072b4a6272bd4d2934b1760a351201df529d5f8a0b1f4a24e299d436b70f8992
MD5 c6340db6cd7ee3a4ff820da9b862a812
BLAKE2b-256 0434618ec30fa62503611a9a4098c353ad81ddc4d110c81b65d6a67b4c9ef264

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