Skip to content

Commit

Permalink
1)update runner for faster 2)fix init_env.sh for mac 3)fix jq kdata r…
Browse files Browse the repository at this point in the history
…ecorder bug
  • Loading branch information
foolcage committed Nov 14, 2019
1 parent 98d2a8b commit 885c197
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 18 deletions.
18 changes: 11 additions & 7 deletions init_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,32 @@ fi

install_cmd='sudo apt-get install'
if [[ "$platform" == 'mac' ]]; then
install_cmd='sudo brew install'
install_cmd='brew install'
fi

BASEDIR=`dirname $0`

if ! which python3.6 > /dev/null; then
if ! which python > /dev/null; then
echo -e "Python3 not found! Install? (y/n) \c"
read
if [ "$REPLY" = "y" ]; then
$install_cmd install python3.6
$install_cmd install python3
fi
fi

pip_opt=''
#pip_opt='-i http://pypi.douban.com/simple --trusted-host pypi.douban.com'

if ! which virtualenv > /dev/null; then
echo -e "virtualenv not found! Install? (y/n) \c"
read
if [ "$REPLY" = "y" ]; then
$install_cmd python-virtualenv
pip3 install virtualenv $pip_opt
fi
fi

if [ ! -d "$BASEDIR/ve" ]; then
virtualenv -p python3.6 $BASEDIR/ve
virtualenv -p python3 $BASEDIR/ve
echo "Virtualenv created."
fi

Expand All @@ -41,10 +44,11 @@ cd $BASEDIR
export PYTHONPATH=$PYTHONPATH:.

if [ ! -f "$BASEDIR/ve/updated" -o $BASEDIR/requirements.txt -nt $BASEDIR/ve/updated ]; then
pip install -r $BASEDIR/requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip install -r $BASEDIR/requirements.txt $pip_opt
touch $BASEDIR/ve/updated
pip install ipython -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
echo "Requirements installed."
fi

pip install ipython jupyterlab $pip_opt

echo "env ok"
10 changes: 2 additions & 8 deletions zvt/factors/ma/ma_stats_runner4.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@


@sched.scheduled_job('cron', hour=19, minute=30)
def run1():
def run():
cal_ma_states(start='600000', end='600200')


@sched.scheduled_job('cron', hour=20, minute=0)
def run2():
cal_ma_states(start='600200', end='601000')


if __name__ == '__main__':
init_log('ma_stats_runner4.log')

run1()
run2()
run()

sched.start()

Expand Down
4 changes: 2 additions & 2 deletions zvt/factors/ma/ma_stats_runner5.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
sched = BackgroundScheduler()


@sched.scheduled_job('cron', hour=18, minute=0)
@sched.scheduled_job('cron', hour=20, minute=0)
def run():
cal_ma_states(start='601000', end='999999')
cal_ma_states(start='600200', end='601000')


if __name__ == '__main__':
Expand Down
26 changes: 26 additions & 0 deletions zvt/factors/ma/ma_stats_runner6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
import logging

from apscheduler.schedulers.background import BackgroundScheduler

from zvt import init_log
from zvt.factors.ma.common import cal_ma_states

logger = logging.getLogger(__name__)

sched = BackgroundScheduler()


@sched.scheduled_job('cron', hour=20, minute=30)
def run():
cal_ma_states(start='601000', end='999999')


if __name__ == '__main__':
init_log('ma_stats_runner6.log')

run()

sched.start()

sched._thread.join()
2 changes: 1 addition & 1 deletion zvt/recorders/joinquant/quotes/jq_stock_kdata_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def record(self, entity, start, end, size, timestamps):
old = current_df.iloc[0, :]['close']
new = check_df['close'][0]
# 相同时间的close不同,表明前复权需要重新计算
if old != new:
if round(old, 2) != round(new, 2):
self.factor = new / old
self.last_timestamp = pd.Timestamp(check_date)

Expand Down

0 comments on commit 885c197

Please sign in to comment.