-
Notifications
You must be signed in to change notification settings - Fork 55
/
daily_update.sh
44 lines (35 loc) · 1.35 KB
/
daily_update.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
set -e
set -x
[ ! -d "/dolt/investment_data" ] && echo "initializing dolt repo" && cd /dolt && dolt clone chenditc/investment_data
cd /dolt/investment_data
dolt pull
echo "Updating index weight"
startdate=$(dolt sql -q "select * from max_index_date" -r csv | tail -1)
python3 /investment_data/tushare/dump_index_weight.py --start_date=$startdate
for file in $(ls /investment_data/tushare/index_weight/);
do
dolt table import -u ts_index_weight /investment_data/tushare/index_weight/$file;
done
echo "Updating index price"
python3 /investment_data/tushare/dump_index_eod_price.py
for file in $(ls /investment_data/tushare/index/);
do
dolt table import -u ts_a_stock_eod_price /investment_data/tushare/index/$file;
done
echo "Updating stock price"
dolt sql-server &
sleep 5 && python3 /investment_data/tushare/update_a_stock_eod_price_to_latest.py
killall dolt
dolt sql --file /investment_data/tushare/regular_update.sql
dolt add -A
status_output=$(dolt status)
# Check if the status output contains the "nothing to commit, working tree clean" message
if [[ $status_output == *"nothing to commit, working tree clean"* ]]; then
echo "No changes to commit. Working tree is clean."
else
echo "Changes found. Committing and pushing..."
# Run the necessary commands
dolt commit -m "Daily update"
dolt push
echo "Changes committed and pushed."
fi