Skip to content

Tutorial: Build a small quant lib and simulate

Download and extract SDK

mkdir -p /data/cc
cd /data/cc
curl https://algoserver.apifiny.com/static/download/release/algo_sdk_1.2.12.tar.gz -o algo_sdk_1.2.12.tar.gz
tar -zxvf algo_sdk_1.2.12.tar.gz

Build sample quant library

cd algo_sdk/examples/alpha02/build_scripts
premake4 gmake
make -j 10 config=release
The library binary will be generated and copied to algo_sdk/bin/xlibs/.

Get sample market data

mkdir -p /data/cc
cd /data/cc
curl https://algoserver.apifiny.com/downloadfile?url=data/sample_cobjson_data.tar.gz -o sample_cobjson_data.tar.gz -L
tar -zxvf sample_cobjson_data.tar.gz

Note

The above commands use directory /data/cc to store data. You can use another diretory to store the data too. You will need modify some path settings in the json configration file in that case. (check the path configuration in node players)

Run simulation

Apfiny Algo depends on several shared libraries, so you need setup some environment variables first.

Set environment variable ALGO_HOME using the path of your algo_sdk. e.g. /data/cc/algo_sdk:

export ALGO_HOME=YOUR_ALGO_SDK_PATH

Setup other environment variables:

export TZ=UTC
export LD_LIBRARY_PATH=${ALGO_HOME}/bin:$LD_LIBRARY_PATH
export PATH=${ALGO_HOME}/bin:$PATH

You can start the application now. It takes two command line arguments: json configuration file and trading date

ccc_sim_trader ${ALGO_HOME}/examples/alpha02/cfg/alpha02_sim_cfg_cobjson.json 20220405

Check simulation results:

cd /data/ccclogs/sim1
ls