Skip to main content

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

Metadata

Release files for tossinvest 0.1.0

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

Source distribution (sdist)

Source distribution for tossinvest 0.1.0
File Size Uploaded
tossinvest-0.1.0.tar.gz 121.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tossinvest 0.1.0
File Interpreter ABI Platform
tossinvest-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 217.1 kB

Release files / tossinvest-0.1.0.tar.gz

Download URL tossinvest-0.1.0.tar.gz
Size 121.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b00fc0f0aa976057a2540a0f0e458af848aa578ff9fe9efae514c55b0b1f7084
BLAKE2b-256 checksum
How to use checksums
1e3d8ad8db1b9de080c0bb1240e0ffd9a32436d25ad611b34c0964aa5686c78d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / tossinvest-0.1.0-py3-none-any.whl

Download URL tossinvest-0.1.0-py3-none-any.whl
Size 95.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
072b4a6272bd4d2934b1760a351201df529d5f8a0b1f4a24e299d436b70f8992
BLAKE2b-256 checksum
How to use checksums
0434618ec30fa62503611a9a4098c353ad81ddc4d110c81b65d6a67b4c9ef264
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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