Skip to content

2、文件结构

woldy edited this page Dec 28, 2023 · 5 revisions

一、框架文件结构

image

二、项目文件结构

image

三、配置文件示例

我们通过如下代码遍历出data/config目录下所有配置文件,具体每个配置项的含义很容易通过语义理解,后面的文档中也会介绍,再次不多做解释。

counter=1
for file in *; do
    if [ -f "$file" ]; then
        echo # 输出一个空行
        echo "## 3.$counter、$file"
        while IFS= read -r line || [[ -n "$line" ]]; do
            echo "    $line"
        done < "$file"
        
        ((counter++))
    fi
done

3.1、alert.conf

[default]
#是否启用告警,值为True时启用
enable=True

#发送通知消息时的关键字,请在飞书/钉钉机器人中同步配置
key=【FinHack】

#飞书webhook地址,使用请参考 https://www.feishu.cn/hc/zh-CN/articles/360024984973
feishu_webhook=https://open.feishu.cn/open-apis/bot/v2/hook/a37a22f2-c094-4cdf-88e5-06c21a92ae73

#钉钉webhook地址,使用请参考 https://developers.dingtalk.com/document/robots/custom-robot-access
dingtalk_webhook=

3.2、args.conf

[global]
globalarg=test

[testmodule]
testarg1=this is a test key
testarg2=this is also a test key

[trainer]
start_date=20000101
valid_date=20080101
end_date=20100101
features=
label=abs
shift=10
param=
loss=ds
filter_name=
replace=False


[trader]
strategy=DemoStrategy
market=astock
start_time=2020-01-01 00:00:00
end_time=2023-06-30 59:59:59
benchmark=000001.SH
username=username
password=password
open_tax=0,
close_tax=0.001,
open_commission=0.0003,
close_commission=0.0003,
close_today_commission=0, 
min_commission=5
slip=0.005
sliptype='pricerelated'
cash=1000000
order_volume_ratio=0.1
data_source=file
rule_list=delist,stop,limit,slip,volume_ratio,cost,volume_num,t1
#TRACE,DEBUG,INFO,SUCCESS,WARNING,ERROR,CRITICAL
log_level=INFO
args=

3.3、constant.conf

FRAMEWORK_DIR={FRAMEWORK_DIR}
BASE_DIR={BASE_DIR}
DATA_DIR=BASE_DIR+"/data/"
CACHE_DIR=DATA_DIR+"cache/"
CONFIG_DIR=DATA_DIR+"config/"
MODELS_DIR=DATA_DIR+"models/"
PREDS_DIR=DATA_DIR+"preds/"
LOGS_DIR=DATA_DIR+"logs/"
USER_DIR=BASE_DIR+"/user/"
RUNNING_DIR=DATA_DIR+"running/"
FACTORS_DIR=DATA_DIR+"factors/"
CODE_FACTORS_DIR=FACTORS_DIR+"code_factors/"
DATE_FACTORS_DIR=FACTORS_DIR+"date_factors/"
SINGLE_FACTORS_DIR=FACTORS_DIR+"single_factors/"
FACTORS_CACHE_DIR=CACHE_DIR+"factors/"
PRICE_CACHE_DIR=CACHE_DIR+"price/"
CHOICE_CACHE_DIR=CACHE_DIR+"choice/"
KV_CACHE_DIR=CACHE_DIR+"kv/"

3.4、core.conf

[cache]
type=redis

3.5、db.conf

[tushare]
host=127.0.0.1
port=3306
user=root
password=******
db=tushare
charset=utf8mb4

[finhack]
host=127.0.0.1
port=3306
user=root
password=******
db=finhack
charset=utf8mb4

[woldycvm]
host=woldy.net
port=3366
user=root
password=******
db=finhack
charset=utf8mb4

[redis]
host=127.0.0.1
port=6379
password=******
db=6

[memcached]
host=127.0.0.1
port=11211

3.6、global_var.conf

hash=None
pid=None
module_name=None
action_name=None
args=None

3.7、task.conf

[all]
list=woldy,alphaA,alpha101,alpha191

3.8、train.conf

[lightgbm]
device=cpu

3.9、ts.conf

[default]
#Tushare数据存取的位置,需与db.conf中配置一致
db=tushare

#Tushare的token,https://waditu.com个人信息中获取
token=******