Skip to content

Ktx main - #135

Open
ceze wants to merge 28 commits into
OpenByteInc:mainfrom
ceze:ktx-main
Open

Ktx main#135
ceze wants to merge 28 commits into
OpenByteInc:mainfrom
ceze:ktx-main

Conversation

@ceze

@ceze ceze commented Jun 2, 2026

Copy link
Copy Markdown

Summary

Add integration for KTX Crypto Exchange.

Changes

  • Added KTX Crypto Exchange API integration
  • Implemented account and market data support
  • Added trading functionality support
  • Updated related configurations and documentation
    move config file .env to ./configs/.env

Test plan

  • Tested locally with docker compose up -d --build
  • Backend logs show no errors
  • Relevant pytest tests pass

API documentation (if routes/schemas changed)

  • Regenerated docs/api/openapi.yaml (cd backend_api_python && python scripts/export_openapi.py)
  • Updated docs/agent/agent-openapi.json if /api/agent/v1 routes changed
  • Breaking API changes called out below (oasdiff will fail CI otherwise)

Screenshots (if UI change)

ceze added 28 commits May 27, 2026 11:53
Covers:
- Symbol normalization (to_ktx_symbol)
- Client initialization & validation
- Numeric helpers (Decimal, step floor, precision)
- Authentication & signing (HMAC-SHA256, raw body)
- Market data endpoints (products, ticker, ping)
- Account endpoints (balance, positions)
- Order lifecycle (place market/limit, get, cancel, open orders)
- wait_for_fill polling
- set_leverage
- get_fee_rate

Note: Tests bypass Flask dependency by loading modules directly.
…rade_balance

- get_account() now uses /v1/main/accounts (wallet/main account)
- New get_trade_balance(asset?) uses /v1/trade/accounts (futures collateral)
- get_positions() now calls get_trade_balance() internally
- Add real API tests for trade balance (all assets + single asset)
- Total 38 tests passing
- get_positions(position_id?, market?, symbol?) now calls /v1/positions
- market defaults to 'lpc' for swap market_type
- symbol defaults to all symbols (no filter)
- Add real API test for single-symbol position query
- 39 tests passing
…slots

- Always set market=lpc when no explicit market given (prevents returning all markets)
- Filter out closed position slots where quantity=0 (KTX returns empty shells after close)
- Now correctly returns 1 real BTC position (0.000972 BTC, long, entry 79036.5)
- 39 tests passing
…ints, POST main/accounts

KTX is a unified account: spot + futures assets together.
- market param now required on all order-related methods (spot=lpc required)
- Add get_spot_balance() using POST /v1/main/accounts (wallet account)
- Add spot_transfer() for WALLET_TRADE / TRADE_WALLET transfers
- Add get_ledger() for bill records (transfers, trades, fees, funding)
- Add get_history_orders() for settled/filled/cancelled orders
- Fix get_open_orders() -> /v1/pending/orders (was /v1/orders)
- Fix cancel_order() -> /v1/order/delete (was DELETE /v1/orders/{id})
- Fix get_order() -> /v1/order?id={id} (was /v1/orders/{id})
- Fix set_leverage() -> /v1/change/leverage (was /v1/trade/leverage)
- Fix POST body: empty body sends {} instead of Invalid JSON error
- 42 tests passing
- KTX unified account: spot+futures assets are in /v1/trade/accounts (trade account)
- get_spot_balance() -> alias for get_trade_balance() (trade account)
- get_wallet_balance() -> uses POST /v1/main/accounts (separate wallet)
- get_account() -> calls get_wallet_balance()
- 43 tests passing
- Account system: wallet account (/v1/main/accounts) vs trade account (/v1/trade/accounts)
- market parameter: spot/lpc required on all order endpoints
- Account field semantics: withdrawable=实际可用, locked=挂单冻结
- All API methods with correct endpoints
- Known bugs and fix history
- Test suite: 43 tests passing
* commit '7aad07280f499c8460e98a14d1a845bc1618b476':
  v3.0.22
  chore: update repo traffic metrics [skip ci]
  v3.0.22 Signed-off-by: Dinger <quantdinger@gmail.com>
  chore: update repo traffic metrics [skip ci]
  v3.0.22
  v3.0.22
  v3.0.22
  v3.0.21 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.20
  v3.0.19 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.18 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.17
  v3.0.17
  v3.0.17 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.17
  输出用户自定义日志,方便策略跟踪
* main:
  v3.0.26 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.25 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.25 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.25 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.25 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.25 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.25 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.25
  v3.0.24 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.24
  v3.0.22 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.22 Signed-off-by: Dinger <quantdinger@gmail.com>
  v3.0.22 Signed-off-by: Dinger <quantdinger@gmail.com>
* main:
  feat: add LiteLLM to settings UI dropdown
  feat: add LiteLLM as unified LLM provider
  v3.0.29

# Conflicts:
#	backend_api_python/app/routes/credentials.py
#	backend_api_python/app/services/broker_market_policy.py
#	backend_api_python/app/services/exchange_execution.py
#	backend_api_python/app/services/live_trading/execution.py
#	backend_api_python/app/services/live_trading/factory.py
#	backend_api_python/app/services/pending_order_worker.py
#	backend_api_python/app/services/strategy.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant