Commit Graph

2 Commits

Author SHA1 Message Date
nicolas 46084de4b2 fix: keepalive, connection health check, log file, single-line reports, timings fix
- Move REST keepalive to poll loop (async, not blocking signal execution)
- Fix ensure_connected to detect RST connections (recv < 0, not just == 0)
- Add log_set_file() + log file /tmp/engine.log (background thread writes)
- Single-line FILLED/FAILED reports (no multi-line fills inside brackets)
- Fix timing clock (use CLOCK_REALTIME consistently, not mixing with MONOTONIC)
- Add ORDER/FILL/REJECTED intermediate output lines
- Add session warmup at executor_thread_create
- Fix FILL latency (use order-fire time, not signal-received time)
- Paper mode: add clientOid to test endpoint, fix fee simulation
- Concurrency: add primary_quote isolation
2026-05-27 00:15:08 -03:00
nicolas 03b5daa003 migrate: absorb all executor functions into fused_engine (C)
Replace the Python executor with direct C execution in a dedicated
executor thread. Removes UDS JSON serialization, Python async
overhead, and the 2+ms pipeline gap between signal creation and
order fire.

New components:
- src/rest_client.c/h: Keepalive HTTPS, HMAC-SHA256 signing,
  order_place, order_test, Content-Length response parsing
- src/fill_handler.c/h: SPSC ring buffer for WS match events,
  hot thread -> executor thread fill dispatch
- src/executor.c/h: execute_triangle() cascade, fee hold
  reduction, increment floor, paper mode simulation, PnL,
  concurrency isolation, reporting

Modified:
- src/ws_client.c: Subscribe to tradeOrdersV2 + account.balance,
  dispatch orderChange match events to fill SPSC, private token
  fetch via bullet-private, token cleared on reconnect
- src/http_client.c: Added https_post_auth() for signed POST
- src/events.c: Cold thread replaced with executor thread
  (poll on wake_fd + fill_fd, direct execution)
- config.yaml.example: initial_capital moved to fused_engine,
  added cooldown_seconds, kcs_discount_active

Removed:
- src/kucoin_sign.c/h (redundant with http_client.c helpers)
2026-05-26 19:54:41 -03:00