def get_loc_hsicsv(s_time, e_time, datapath):
    print('数据地址:', datapath)
    df = pd.read_csv(filepath_or_buffer=datapath)
    df['candle_begin_time'] = df['datetime']
    df['candle_begin_time'] = pd.to_datetime(df['candle_begin_time'])
    df = df[(df['candle_begin_time'] >= pd.to_datetime(s_time))
            & (df['candle_begin_time'] <= pd.to_datetime(e_time))]
    # df = df[df['candle_begin_time'] <= pd.to_datetime(e_time)]
    df = df[['candle_begin_time', 'open', 'high', 'low', 'close', 'volume']]
    df.reset_index(inplace=True, drop=True)
    print('数据大小', df.shape)
    df_day = transfer_to_period_data(df, rule_type='1D')
    df_day['atr_day'] = talib.SMA(
        talib.ATR(df_day['close'], df_day['high'], df_day['low'], 2), 2) * 0.8
    df_day['candle_begin_time'] = df_day['candle_begin_time'].apply(
        lambda x: x + datetime.timedelta(hours=9, minutes=15))
    df = pd.merge(df,
                  df_day[['candle_begin_time', 'atr_day']],
                  how='outer',
                  on='candle_begin_time')
    df = df[df['volume'] > 0]
    df.fillna(method='ffill', inplace=True)
    return df
Example #2
0
    filename = os.path.abspath(__file__).split('\\')[-1].split('.')[0]
    timeer0 = datetime.datetime.fromtimestamp(time.time()).strftime('%m_%d=%H')
    datapath = r'F:\task\恒生股指期货\hsi_data_1min\HSI2011-2019_12.csv'
    dir_path = r'F:\task\恒生股指期货\numba_策略开发\all_day_tri_ma_min'

    # 1.先测试单进程 cpu == 1
    strat_time = np.array([1, 9, 20])
    end_time = np.array([27, 16, 20])
    a = 1
    b = 10
    c = 10
    if True == a:
        df_time_list = [['2019-10-10 09:15:00', '2019-12-10 16:25:00']]
        s_time, e_time = df_time_list[0]
        df = get_local_hsi_csv(s_time, e_time, datapath)  # 获取本地数据
        df = transfer_to_period_data(df, rule_type="3T")
        df000 = df.copy()
        time0 = time.process_time()
        df000 = df.copy()
        df000['ma'] = talib.SMA(df000['close'], 5000)
        # df000['ma2']=talib.MA(df000['close'],5000)
        #[44.000 140.000 30.000 50.000 140.000]
        resdf, res0 = duojincheng_backtesting(
            df000,
            zong_can=[[240, 120, 20, 50.0, 200]],
            strat_time=strat_time,
            end_time=end_time,
            cpu_nums=1)

        mode = 1
        if mode == 1:
Example #3
0
    filename = os.path.abspath(__file__).split('\\')[-1].split('.')[0]
    timeer0 = datetime.datetime.fromtimestamp(time.time()).strftime('%m_%d=%H_%M')
    datapath = r'F:\task\恒生股指期货\hsi_data_1min\HSI2011-2019_12.csv'
    dir_path =r'F:\task\恒生股指期货\numba_策略开发\numba_均线开仓'

    # 1.先测试单进程 cpu == 1
    a = 1
    b = 10
    c = 10
    if True == a:
        info = '金叉'
        to_html_path = r'html_gather\%s_%s' % (filename, info)
        df_time_list = [['2017-10-1 09:20:00', '2017-11-28 16:20:00']]
        s_time, e_time = df_time_list[0]
        df = get_local_hsi_csv(s_time, e_time, datapath)  # 获取本地数据
        df = transfer_to_period_data(df,rule_type='1T')
        df000 = df.copy()
        df["aroondown"],df["aroonup"] = talib.AROON(df['high'],df["low"],14)
        print(df)
        only_index(input_data=df, zhibiaos=["close"],zhibiaos_futu=["aroonup","aroondown"], path='zb.html')

        exit()

        strat_time = np.array([1, 9, 20])
        end_time = np.array([27, 16, 20])
        time0 = time.process_time()
        df000 = df.copy()
        resdf, res0 = duojincheng_backtesting(df000,
                                              zong_can=[[130.0,30.0,59.0,105.0,3000.0,10.0,2.0]],
                                              strat_time=strat_time,
                                              end_time=end_time,
Example #4
0
        canshu_list = []
        for cs1 in range(180, 241, 10):
            for cs2 in range(16, 31, 2):
                for cs3 in range(2000, 3501, 500):
                    for cs4 in range(3, 6, 1):
                        # for cs5 in range(1, 2, 1):
                            # for cs6 in range(1, 3, 1):
                            canshu_list.append([cs1, cs2, cs3, cs4, 10])

        df_time_list = [['2016-1-10 09:15:00', '2019-12-28 16:25:00']]
        s_time, e_time = df_time_list[0]
        name = f'{filename}_{s_time[:4]}_{e_time[:4]}_3min'

        canshu_list = canshu_list[:10]
        df = get_local_hsi_csv(s_time, e_time, datapath)  # 获取本地数据
        df = transfer_to_period_data(df, rule_type='3T')
        print('数据大小', df.shape)
        df_day = transfer_to_period_data(df, rule_type='1D')
        df_day['atr_day'] = talib.SMA(talib.ATR(df_day['close'], df_day['high'], df_day['low'], 2), 2) * 0.8
        df_day['candle_begin_time'] = df_day['candle_begin_time'].apply(lambda x: x + datetime.timedelta(hours=9, minutes=15))
        df = pd.merge(df, df_day[['candle_begin_time', 'atr_day']], how='outer', on='candle_begin_time')
        df = df[df['volume'] > 0]
        df.fillna(method='ffill', inplace=True)
        print(df.tail(10))
        df000 = df.copy()

        if True == 1:
            print('参数列表个数:', len(canshu_list))
            time0 = time.process_time()
            func_canshu = {'zong_can': canshu_list[:], 'cpu_nums': 2, "strat_time": strat_time, "end_time": end_time}
            df_zong = duojieduan_huice(df, duojincheng_backtesting, func_canshu, s_time, e_time, jiange='48MS')
Example #5
0
import dash_core_components as dcc
import dash_html_components as html
import dash_table
import plotly.express as px
import plotly.graph_objects as go

import plotly.figure_factory as ff
from numba_策略开发.功能工具.因子库 import rsi_cci_atr01, std_zdf_tp
from numba_策略开发.功能工具.功能函数 import transfer_to_period_data

import pandas as pd

data_df = pd.read_csv(
    r'F:\vnpy_my_gitee\new_company\hsi_data_1min\HSI2019-2020.csv')
data_df = transfer_to_period_data(data_df,
                                  time_cols="datetime",
                                  rule_type="1H")
data_df['factor'] = rsi_cci_atr01(data_df, 18)

# print(data_df['factor'].shape)
data_df['wl_delter'] = data_df['close']
data_df["wlyl"] = data_df['wl_delter'].diff(1).shift(-5)
adf_seq = data_df['factor']
df_res = facter_deal(data_df, f_s=["factor"], wlsy=["wlyl", "datetime"])
df_res = df_res[[
    'datetime', 'factor', 'wlyl', '一阶差分', '二阶差分', '10_ma', 'tahn', 'sigmoid',
    '一阶差分10_ma', '一阶差分tahn', '一阶差分sigmoid', '二阶差分10_ma', '二阶差分tahn',
    '二阶差分sigmoid'
]]
df_tj = df_res.describe()
df_tj = df_tj.reset_index(drop=False)