Skip to content


An Algo-based application uses a json configuration file to specify its environment and assemble trading logic.

The json configuration file contains two types of top nodes: The first type nodes provides information, and their formats are node specific; The second type nodes create component objects for the application, and their formats are more standard.

Information nodes


specify instance name, log path and other information for the whole instance.

"instance": {
    "log_path": "./logs/strategy_demo",
    "name": "strategy_demo",
    "latency_enable": false
Field Description Mandatory
name The name of the trading instance. It is used to construct names of log files and strategies Yes
log_path The directory that log files are written to. Yes
log_level The level of logging.
Values: 0: all, 1: debug, 2: info, 3: warnning, 4: error
license_id The license id from your Apifiny account Yes
license_key The license key from your Apifiny account Yes
latency_enable The enable flag of latency file. Default is false No


You can put license_key and other common items in a separate file and then put the path in the includes node mentioned below.


You may break your json configuration into multiple files and use includes tag to link them togenther. Algo parses json files listed in the node, and combine them together. If an item appears more than once, the included ones will be overwritten.

"includes": [


It contains configuration for additional server software that the instance may connect to.

Field Description Mandatory
redis_server Algo instance uses this redis server to publish stats information. Set its IP address here No


It lists the exchanges that this instance will subscribe for market data and/or place orders.


Each item contains the following fields:

Field Description Mandatory
exchange The exchange name. Yes
trade_type How we place order.
"Direct": place orders on this exchange.
"None": no order placing.
market_data_type How we handle market data.
"Direct": subscribe market data directly.
"Exchange_Setting": Use the exchange's configuration settings(Use the exchange's configuration settings (refer to the value in market_data_channel))
"None": no market data.
market_data_channel What we handle market data channel.
BINANCE: "depth@100ms", "depth@1000ms" and "bookTicker".
BINANCE_SWAP: "depth@100ms", "depth@1000ms" and "bookTicker".
BINANCE_FUTURES: "depth@100ms", "depth@1000ms" and "bookTicker".
BINANCEUS: "depth@100ms", "depth@1000ms" and "bookTicker".
FTX: "orderbook", "ticker".
FTX_SWAP: "orderbook", "ticker".
FTX_FUTURES: "orderbook", "ticker".
HUOBI: "ticker", "bbo".
HUOBI_SWAP: "depth.size_20.high_freq", "depth.size_150.high_freq", "bbo".
HUOBI_FUTURES: depth.size_20.high_freq", "depth.size_150.high_freq", "bbo".
OKCOIN: "depth", "ticker", "depth_l2_tbt".
OKEX: "books", "books-l2-tbt", "books50-l2-tbt", "bbo-tbt","books5".
OKEX_SWAP: "books", "books-l2-tbt", "books50-l2-tbt", "bbo-tbt","books5".
OKEX_FUTURES: "books", "books-l2-tbt", "books50-l2-tbt", "bbo-tbt","books5".


It contains the exchange api keys. Each exchange that the instance will place orders need have an item in the map.

"apikeys": {
    "OKEX_SWAP": {
        "key": "enter your api key",
        "secret": "enter your api secert",
        "pass": "enter your api passphrase"

Each configured exchange needs the following fields:

Field Description Mandatory
key the api key Yes
secret the api secret Yes
pass the passphrase that some exchanges require No


It lists the make fee and take fee for each exchanges that the instance will place orders.

"fees": {
    "OKEX_SWAP": {
        "make": 0.0,
        "take": 0.0002

Each configured exchange needs the following fields:

Field Description Mandatory
make make fee rate Yes
take take fee rate Yes


It holds security master infomration such as tick size. It is optional. The SDK loads secutiry master data it manages by default. You can use this node to overwrite them.

"symbol_info": {
    "BTCUSDT.HUOBI": {"ticksize": 0.01, "lotsize": 0.0001, "price_precision": 2, "min_order_size": 0.0001, "qty_precision": 6, "multiple": 1.0, "coin": "BTC", "base_coin": "USDT", "local_name": "BTC-USDT", "ct_type": true, "lever": 2}
Field Description Mandatory
ticksize The minimum price change. Yes
lotsize The minimum order quantity that offers good fees. Same as min_order_size for cryptocurrencies Yes
min_order_size The minimum order quantity Yes
price_precision The maximum number of decimal digits to represent a order price Yes
qty_precision The maximum number of decimal digits to represent an order quantity Yes
coin The left side of trading pair, i.e. trading currency. Yes
base_coin The right side of trading pair, i.e. quote currency. Yes
local_name The symbol name used in the exchange. Yes
ct_type contract type, true for standard contract, false for inverse contract. Yes
multiple The contract mulitplier for derivatives. The default value is 1. No
lever The leverage for margin trade. Note that it is only used for the QuantLib system and better to be consistent with the real leverage used in the exchange. The default value is 1. No


You can skip to config symbol_info in spot trade. However, if you want to do margin trade, you need to manually specify "lever" in symbol_info as well as setup "use_margin" and "margin_source" in strategies component.


It holds a list of symbols that this instance uses. Each symbol should have a cid, which needs to be unique in the current instance.

"symbols": [
    {"port": ["BTCUSDT", "HUOBI"], "cid": 10000}
Field Description Mandatory
port A tuple that represents a trading symbol. Its formart is [ticker, exchange] Yes
cid An unique number to represent the trading symbol No

Component nodes

The second type nodes are a list of items, and each item contains a name and its definition. The definition contains a class name and a map of properties. Algo applicaiton will create an object from the class and initialize it using the properties, and give it the specified name.


It contains historical data players. They are used in back-testing and the warmup period of live trading.

"players": [
    ["BTCUSDT.HUOBI_Player", ["CobJsonPlayer", {"port": ["BTCUSDT", "HUOBI"], "path": "/data/cc/prod/ccc_record_2"}]]

Standard properties of a player:

Field Description Mandatory
port A tuple that represents a trading symbol. Its formart is [ticker, exchange] Yes
path The directory contains historical market data Yes

Players shipped with Algo SDK:

Class Description
CobJsonPlayer Play historical data that Algo's mktpub generates.
TardisPlayer Play snapshot historical data from


It contains risk formulas. A risk formula calculate risk for a portfolio, and they are used in account components.

"risk_formulas": [
    ["RF01", ["RiskFormula", {"components": [[["BTCUSDT", "HUOBI"], 1.0]]}]]

Standard properties of a risk formula:

Field Description Mandatory
components A list of tuple [port, weight] Yes

RiskFormulas shipped with Algo SDK:

Class Description
RiskFormula Calculate the weighted sum of notionals for symbols listed in components.


It contains accounts. An account groups symbols and calculates their positions, notionals and risks. Each account has an id, and you specify this account id to a strategy when creating it. The symbol managed by the strategy will then be included in the account.

"accounts": [
    [10001, ["Account", {"risk_formulas": ["RF01"], "id": 10001}]]

Standard properties of an account:

Field Description Mandatory
risk_formulas A list of risk formula names. Yes
id A number representing the account, same as the name of the account. Yes

Account shipped with Algo SDK:

Class Description
Account Manage the position and notional for each symbol and risk for the portfolio.


It contains samplers. A sampler triggers an onSample() callback when a sampling event happens, such as a time duration passed. It also calculates a decay value for this event. Samplers are widely used in the system for signal calculation and data generation. They can be based on time or other events.

"samplers": [
    ["ts_basis", ["TimeSampler", {"halflife": 1, "msecs": 100}]]

Click here to see all samplers


It contains pricing models. A pricing model generates the fair value of an asset. It can be calculated from books, trades or portfolios.

"pricing_models": [
    ["BTCUSDT.HUOBI_midpx", ["MidPx", {"port": ["BTCUSDT", "HUOBI"]}]]

Click here to see all pricing models


It contains variables. A variable generates a single number at any moment. It can be used as a standalone feature or an intermediated value to calculate a feature.

"variables": [
    ["Zero", ["Const", {"value": 0.0}]]

Click here to see all variables


It contains models. A model is a value generated from one or more variables. Its value represents the predicted forward return and is used by ModelStrategy.

"models": [
    ["Zero_m", ["LinearModel", {"variable": "Zero"}]]

Click here to see all models


It contains strategies. A strategy implements the execution logic for trading a symbol. It is driven by time and market events, makes order placing/canceling decisions based on model value and other information.

"strategies": [                                 
        "SimpleTakerStrategy", {
            "symbol": "BTCUSDTSWAP",
            "trade_market": "OKEX_SWAP",
            "order_size": 0.0001,
            "signal": "BTCUSDTSWAP.OKEX_SWAP_trend30"

Click here to see all strategies