Skip to content

feat(ton-trading-bot): add 15 algorithmic trading tools (v2.0.0) - #45

Merged
xlabtg merged 3 commits into
xlabtg:mainfrom
konard:issue-43-65b3c68bf2ff
Mar 25, 2026
Merged

feat(ton-trading-bot): add 15 algorithmic trading tools (v2.0.0)#45
xlabtg merged 3 commits into
xlabtg:mainfrom
konard:issue-43-65b3c68bf2ff

Conversation

@konard

@konard konard commented Mar 25, 2026

Copy link
Copy Markdown

Summary

Fixes #43. Expands ton-trading-bot from 6 to 21 atomic tools covering all requested algorithmic trading categories, following the same architecture (LLM composes atomic tools into strategies).

P0 — Cross-DEX Arbitrage

  • ton_trading_get_arbitrage_opportunities — compares prices across StonFi, DeDust, TONCO, swap.coffee; returns opportunities sorted by net profit after fees

P0 — Sniper Trading

  • ton_trading_get_token_listings — fetches recently-listed tokens via GeckoTerminal, filtered by liquidity floor
  • ton_trading_get_token_info — price, market cap, FDV, 24h volume for any token address
  • ton_trading_validate_token — risk score + warnings (low liquidity, low volume, wash-trade signals)

P0 — Copy Trading

  • ton_trading_get_top_traders — scans trending pools for wallets ranked by win rate
  • ton_trading_get_trader_performance — analyses a wallet's on-chain swap history via tonapi.io

P1 — Liquidity & Farming

  • ton_trading_get_active_pools — lists pools sorted by 24h volume, filterable by DEX
  • ton_trading_get_farms_with_apy — estimates APY from fee yield × 365, sorted descending
  • ton_trading_get_pool_volume — 1h/6h/24h volumes, price changes, and buy/sell counts for a pool

P1 — Backtesting

  • ton_trading_backtest — replays buy_and_hold, mean_reversion, or momentum strategy against journal history; returns win rate, PnL, max drawdown, and Sharpe ratio

P2 — Risk Management

  • ton_trading_calculate_risk_metrics — VaR (configurable confidence), max drawdown, Sharpe, profit factor from closed trades
  • ton_trading_set_stop_loss — registers stop-loss / take-profit rules in the journal DB
  • ton_trading_get_optimal_position_size — Kelly Criterion + fixed-fraction sizing from historical win rate

P2 — Automation

  • ton_trading_schedule_trade — stores a pending trade for future execution (validated future ISO datetime)
  • ton_trading_get_scheduled_trades — lists pending trades, flags which are due for execution

Implementation notes

  • migrate() adds two new tables: stop_loss_rules and scheduled_trades
  • manifest.json bumped to v2.0.0 with all 21 tools listed
  • All external API calls use AbortSignal.timeout(15_000) per patterns.md
  • Caching via sdk.storage with appropriate TTLs (30s–5min per data freshness)
  • No strategy logic embedded — all decision-making remains with the LLM

Test plan

  • All 78 unit tests pass locally (node --test plugins/ton-trading-bot/tests/index.test.js)
  • No new lint errors (existing warnings in other plugins are pre-existing)
  • 50 new test cases added covering all 15 new tools
  • Existing 28 tests continue to pass unchanged

🤖 Generated with Claude Code

konard and others added 2 commits March 25, 2026 19:03
Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: xlabtg#43
Resolves xlabtg#43. Expands the plugin from 6 to 21 atomic tools covering all
requested algorithmic trading categories:

P0 — Cross-DEX Arbitrage:
- ton_trading_get_arbitrage_opportunities: finds price diffs across
  StonFi, DeDust, TONCO, swap.coffee; returns sorted net-profit list

P0 — Sniper Trading:
- ton_trading_get_token_listings: fetches recently-listed tokens via
  GeckoTerminal, filtered by minimum liquidity
- ton_trading_get_token_info: price, market cap, volume, FDV for a token
- ton_trading_validate_token: risk-score + warnings (low liquidity,
  low volume, suspicious wash-trade signals)

P0 — Copy Trading:
- ton_trading_get_top_traders: scans trending pools for wallets ranked
  by win rate and minimum trade count
- ton_trading_get_trader_performance: analyses a wallet's on-chain swap
  history via tonapi.io

P1 — Liquidity & Farming:
- ton_trading_get_active_pools: lists pools sorted by 24h volume
- ton_trading_get_farms_with_apy: estimates APY from fee yield × 365
- ton_trading_get_pool_volume: 1h/6h/24h volumes + price changes

P1 — Backtesting:
- ton_trading_backtest: replays buy_and_hold / mean_reversion / momentum
  strategies against journal history; returns win rate, PnL, drawdown,
  Sharpe ratio

P2 — Risk Management:
- ton_trading_calculate_risk_metrics: VaR, max drawdown, Sharpe, profit
  factor from closed trades
- ton_trading_set_stop_loss: registers SL/TP rules in new DB table
- ton_trading_get_optimal_position_size: Kelly criterion + fixed-fraction

P2 — Automation:
- ton_trading_schedule_trade: stores pending trades for future execution
- ton_trading_get_scheduled_trades: lists pending trades, flags due ones

Also:
- migrate() adds stop_loss_rules and scheduled_trades tables
- manifest.json bumped to v2.0.0 with all 21 tools listed
- 78 unit tests pass (added 50 new tests for new tools)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@konard konard changed the title [WIP] 🛠️ Требуется: Улучшение TON Trading Bot — инструменты для алгоритмической торговли feat(ton-trading-bot): add 15 algorithmic trading tools (v2.0.0) Mar 25, 2026
@konard
konard marked this pull request as ready for review March 25, 2026 19:21
@konard

konard commented Mar 25, 2026

Copy link
Copy Markdown
Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $2.382620
  • Calculated by Anthropic: $2.561098 USD
  • Difference: $0.178478 (+7.49%)

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (2014KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Mar 25, 2026

Copy link
Copy Markdown
Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@xlabtg
xlabtg merged commit 4f6ea83 into xlabtg:main Mar 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🛠️ Требуется: Улучшение TON Trading Bot — инструменты для алгоритмической торговли

2 participants