Skip to content

Codon API Reference

Flox Codon bindings provide a Python-like API compiled to native code via the Codon compiler.

Modules

Module Description
flox.strategy Strategy base class for event-driven strategies
flox.types Core types: Price, Quantity, TradeData
flox.indicators Technical indicators (batch and streaming)

Quick Start

from flox.strategy import Strategy
from flox.context import SymbolContext
from flox.types import TradeData

class MyStrategy(Strategy):
    def on_trade(self, ctx: SymbolContext, trade: TradeData):
        if trade.price.to_double() > 100.0:
            self.emit_market_buy(self._symbols[0], 1.0)

Compile with:

codon build -exe -o my_strategy -lflox_capi my_strategy.codon

Architecture

Codon strategies call the C API (libflox_capi.so) via Codon's C FFI. Strategy callbacks are compiled to native code with no interpreter overhead.

See How-To: Codon Bindings for build instructions.