-
Notifications
You must be signed in to change notification settings - Fork 55
/
dump_qlib_bin.sh
44 lines (34 loc) · 1.38 KB
/
dump_qlib_bin.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
set -e
set -x
WORKING_DIR=${1}
QLIB_REPO=${2:-https://github.com/microsoft/qlib.git}
if ! command -v dolt &> /dev/null
then
curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash
fi
mkdir -p $WORKING_DIR/dolt
[ ! -d "$WORKING_DIR/dolt/investment_data" ] && cd $WORKING_DIR/dolt && dolt clone chenditc/investment_data
[ ! -d "$WORKING_DIR/qlib" ] && git clone $QLIB_REPO
cd $WORKING_DIR/dolt/investment_data
dolt pull origin
dolt sql-server &
# wait for sql server start
sleep 5s
cd $WORKING_DIR/investment_data
mkdir -p ./qlib/qlib_source
python3 ./qlib/dump_all_to_qlib_source.py
export PYTHONPATH=$PYTHONPATH:$WORKING_DIR/qlib/scripts
python3 ./qlib/normalize.py normalize_data --source_dir ./qlib/qlib_source/ --normalize_dir ./qlib/qlib_normalize --max_workers=16 --date_field_name="tradedate"
python3 $WORKING_DIR/qlib/scripts/dump_bin.py dump_all --csv_path ./qlib/qlib_normalize/ --qlib_dir $WORKING_DIR/qlib_bin --date_field_name=tradedate --exclude_fields=tradedate,symbol
mkdir -p ./qlib/qlib_index/
python3 ./qlib/dump_index_weight.py
python3 ./tushare/dump_day_calendar.py $WORKING_DIR/qlib_bin/
killall dolt
cp qlib/qlib_index/csi* $WORKING_DIR/qlib_bin/instruments/
tar -czvf ./qlib_bin.tar.gz $WORKING_DIR/qlib_bin/
ls -lh ./qlib_bin.tar.gz
if [ -d "/output" ]; then
mv ./qlib_bin.tar.gz /output/
else
echo "Directory /output does not exist."
fi