Skip to content


How does Algo application work?

An Algo application loads a configuration file, creates objects based on the configuration, and then initializes them with the properties. Some properties can be the name of another object, and the application uses them to link objects together and forms a calculation tree. The application then drives the calculation tree using market data events and time events, generates trading signals and sends/cancels orders.

Algo users normally get trading logic components from 3rd parties and implement a few additional ones when starting their research process. Once components are there, they mostly spend time on generating configuration files manually, programmingly or through the model fitting process. So configuration becomes the key in the trading strategy development process.

Use Json to create trading logic

Each Apifiny Algo-based application uses a json configuration file to specify its environment and assemble trading logic. Below is an example:

    "instance": {
        "log_path": "./logs/strategy_demo",
        "name": "strategy_demo",
    "servers": {
        "redis_server": ""
    "apikeys": {
        "BINANCEUS": {
            "key": "ccdaskfasdjkfjko",
            "secret": "asdfasdfasdfasdf"
    "fees": {
        "BINANCEUS": {
            "make": 0.0,
            "take": 0.000462
    "risk_formulas": [
        ["Port_Risk", ["RiskFormula", {"components": [[["BTCUSDT", "BINANCEUS"], 1.0]]}]]
    "accounts": [
        [10001, ["Account", {"risk_formulas": ["Port_Risk"], "id": 10001}]]
    "symbols": [
        {"port": ["BTCUSDT", "BINANCEUS"], "cid": 10000}
    "samplers": [
        ["ts_basis", ["TimeSampler", {"halflife": 1, "msecs": 100}]]
    "pricing_models": [
        ["BTCUSDT.midpx", ["MidPx", {"port": ["BTCUSDT", "BINANCEUS"]}]], 
        ["BTCUSDT.Vwap", ["Vwap", {"port": ["BTCUSDT", "BINANCEUS"], "sampler": "ts_basis"}]]
    "variables": [
        ["Zero", ["Const", {"value": 0.0}]]
    "models": [
        ["Zero_m", ["LinearModel", {"variable": "Zero"}]]
    "strategies": [
        ["BTCUSDT.BINANCEUS", ["CCEventMakerStrategy", {"symbol": "BTCUSDT", "trade_market": "BINANCEUS", "account": 10001, "dep_pm": "BTCUSDT.midpx", "model": "Zero_m", "VWap": "BTCUSDT.Vwap", "max_spread_bps": 5, "max_quote_frombbo_bps": 0.001, "update_quote_bps": 2, "quote_bps": 3, "allowed_bps": 5, "order_notional": 500, "max_notional": 2500, "max_risk": 2500, "cooloff": 100, "start_time": "00:30:00", "end_time": "23:59:59", "use_separate_logs": true, "close_mode": "none"}]]

C++ programming interfaces

Apifiny Algo offers rich programming interfaces to users. Conceptually, we can categorize the APIs into 2 groups:

  • High level: Quants/traders use c++ to implement algo components such as samplers, pricing models, variables and strategies.
  • Low level: Traders/developers can directly access various aspects of the libraries, such as market data callbacks, order placing api, historical data player, etc.

Trading Research

Algo offers simulation(back-testing) and data generation functionalities. You can create rule-based trading strategies and run simulation to test it, or generate data and use machine learning methods to fit models.

Quant libraries

The previous tutorials show that Apfiny Algo SDK offers a flexible high-performance trading engine, and you can create sophisticated trading applications on top of it. However, traders still need code algorithms, execution logic, portfolio logic and risk management logic for actual trading. This can be alleviated by quant libraries. Apifiny will offer a standard quant library to users soon. After you install this library, it is quite likely you just need to edit json configuration files for most of your research and live trading.

Apfiny Algo is designed to be extensible, and it allows 3rd parties to develop quant libraries and distribute them to the public. Multiple libraries can be used at the same time.