예제 #1
0
def start_bp():
    st3 = TsStrategy3()
    history_capital.append(capital_base)
    # 初始化时间轴
    date_list = date_range("2017-01-01", "2017-12-31")
    for index in range(len(date_list)):
        cur_date = date_list[index]
        fun_sell(cur_date)
        if datetime.datetime.strptime(cur_date, "%Y-%m-%d").weekday() == 0:
            buy_list = st3.get_buy_list(cur_date)
            if buy_list:
                fun_buy(buy_list, cur_date)
    net_rate = (history_capital[-1] -
                history_capital[0]) / history_capital[0]  # 计算回测结果
    print(round(net_rate * 100, 2), "%")
예제 #2
0
def fun_timer():
    # 每分钟与系统进行对时(数据更新时间为16:00 & 22:00)
    cur_time = datetime.datetime.now().time()
    print(cur_time)
    hour = str(cur_time).split(":")[0]
    minute = str(cur_time).split(":")[1]
    if (hour == "16" or hour == "22") and minute == "00":
        # 开始基础数据爬虫业务
        dc = ENDataCrawl()
        dc.start_crawl()
        # 同步基础数据到redis
        rm = RedisManager()
        rm.update_data()
        # 开始指标数据计算业务
        wu = WmacdUtils()
        wu.update_w_macd()
        # 同步指标数据到redis
        st3 = TsStrategy3()
        st3.update_redis(datetime.datetime.now().date())
    global timer
    timer = threading.Timer(time_interval, fun_timer)
    timer.start()
예제 #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__title__ = '补丁20180521'
__author__ = 'JN Zhang'
__mtime__ = '2018/05/21'
"""
import datetime

from core.c_strategy.strategy_3 import TsStrategy3
from core.wmacd_utils import WmacdUtils

if __name__ == "__main__":
    # 恢复20180521的数据
    wu = WmacdUtils()
    wu.update_w_macd("2018-05-12")
    # 重新计算strategy_3
    st3 = TsStrategy3()
    st3.update_redis("2018-05-19")