43 lines
2.0 KiB
C
43 lines
2.0 KiB
C
#ifndef FUSED_EVALUATE_H
|
|
#define FUSED_EVALUATE_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "book.h"
|
|
#include "triangle.h"
|
|
#include "config.h"
|
|
#include "slot.h"
|
|
|
|
/* Aggregated evaluation statistics for monitoring */
|
|
typedef struct {
|
|
uint64_t triangles_evaluated; /* total triangles evaluated since start */
|
|
uint64_t signals_fired; /* total signals generated since start */
|
|
uint64_t books_missing; /* count of evaluations skipped due to missing books */
|
|
uint64_t triangles_skipped; /* count of triangles skipped for other reasons */
|
|
double best_net_bps; /* best net profit seen (basis points) */
|
|
double worst_net_bps; /* worst net profit seen (basis points) */
|
|
int64_t last_eval_ts_ms; /* timestamp of last evaluation (milliseconds) */
|
|
char best_triangle_key[48]; /* triangle key that produced best_net_bps */
|
|
} eval_stats_t;
|
|
|
|
/* Runtime state for the triangular arbitrage evaluator */
|
|
typedef struct {
|
|
const triangle_set_t *triangles; /* pre-enumerated triangle set (read-only) */
|
|
const order_book_t *books; /* live order books array (read-only) */
|
|
const config_t *cfg; /* application configuration (read-only) */
|
|
executor_slot_t *slots; /* executor slots array */
|
|
int n_slots; /* number of slots */
|
|
eval_stats_t stats; /* cumulative evaluation statistics */
|
|
double fee_mult; /* combined fee multiplier (includes KCS discount) */
|
|
} evaluator_t;
|
|
|
|
/* Initialise evaluator with triangle set, books, config, and executor slots */
|
|
void evaluator_init(evaluator_t *ev, const triangle_set_t *triangles,
|
|
const order_book_t *books, const config_t *cfg,
|
|
executor_slot_t *slots, int n_slots, bool kcs_discount);
|
|
|
|
/* Evaluate all triangles involving the given symbol; returns true if a signal was fired */
|
|
bool evaluate_symbol(evaluator_t *ev, uint16_t symbol_idx, int64_t t_sock_arrive_ms, int64_t t_arrive_ms);
|
|
|
|
#endif
|