Commit Graph

6 Commits

Author SHA1 Message Date
nicolas 2f518d1a2d fix: cascade-based threshold gate, status log, best_net_bps tracking
- Restore post-simulation threshold gate using cascade net_bps (catches
  edge cases where cumulative formula sign differs from cascade result)
- Restore STATUS line with eval count (pre-simulation, every 30s)
- Move best_net_bps/worst tracking before post-simulation gate so all
  cascade-evaluated triangles contribute
- Remove executor idle diagnostic line
- Remove cooldown from evaluator (last_signal_ts_ms field removed)
- Move cooldown check before max_volume computation to save CPU
2026-05-28 10:01:17 -03:00
nicolas 174b7570fa feat: concurrent executor slots; fix: fundsIncrement for market buys, remove double-counted leg0 fee hold
- Add concurrent_slots config (fused_engine section, default 1)
- Create executor_shared_t with shared in_flight table + queue mutex for multi-thread
- Move in_flight state from executor_thread_t to executor_shared_t (cross-thread isolation)
- event_executor_thread: per-thread entry point, N threads created in main.c
- Add fundsIncrement to trading_pair_t, triangle_t, signal_leg_t (fetch from KuCoin API)
- Use funds_increment for rounding market buy quote_cost (evaluate.c) and increment floor (executor.c)
- Fix leg 0: remove double-counted apply_fee_hold (evaluate already accounts via ff)
2026-05-27 13:18:53 -03:00
nicolas 562fddf124 cleanup: remove Python executor, dead config/HTTP server; add balance wait; fix fee hold, PnL, warnings
- Remove executor/ and common/ Python directories (dead code after C migration)
- Remove src/http_server.c/.h (was for Python executor, generates warnings)
- Remove dead config keys: socket_path, executor_socket_path, send_signals, rest_host, rest_port
- Remove dead UDS code in events.c/h (send_signal_to_executor, unix_* functions)
- Fix fee hold on leg 0 buys (apply_fee_hold to prevent Balance insufficient)
- Fix PnL leg0_in to use fills[0][4] instead of wrong currency field
- Fix REST keepalive warmup currency (use initial_capital[0] instead of hardcoded USDT)
- Add balance wait between legs via /account/balance WS + eventfd wake
- Fix all strncpy truncation warnings in config.c, symbols_api.c, ws_client.c
2026-05-27 12:14:10 -03:00
nicolas c1c4aa4be8 docs: add docstrings to ~50 undocumented functions across C source files 2026-05-24 23:32:33 -03:00
nicolas 71ed25fe56 refactor: move order sizing to engine, simplify executor
Engine (evaluate.c):
- Compute per-leg minimum order size from quoteMinSize
  (max(baseMinSize * price, quoteMinSize), rounded to quoteIncrement)
- Convert each leg's minimum to starting-quote via pure-rate product (no fees)
- Viability gate: skip triangle if candidate < min_volume (strictest leg)
- Floor starting_volume at min_volume; supersedes old base_min_size guard

Data (symbols_api.h, triangle.h, symbols_api.c):
- Parse quoteMinSize from KuCoin /api/v2/symbols; propagate to triangle struct

Executor (executor.py):
- Remove _precheck_volume: sizing is the engine's responsibility
- Live mode: don't deduct estimated fee from filled_volume (exchange nets fees)
- Live mode: LegFill.fee always zero
2026-05-24 17:49:09 -03:00
nicolas 2a82086683 Add initial triangular arbitrage bot
Two-process architecture: a C17 fused engine (WebSocket order book
mirror, triangle enumeration, real-time profitability evaluation)
communicating via Unix domain socket to a Python 3 executor (order
placement with paper/live trading modes, REST control API).
Targets KuCoin spot market.
2026-05-24 16:12:04 -03:00