check_l_in_l0(l, l0) >>> True ''' l_ = set(l) l0_ = set(l0) return len(l_ - l0_) == 0 if __name__ == '__main__': from utils_hoo import load_csv from utils_hoo.utils_fin.utils_fin import CCI from utils_hoo.utils_plot.plot_Common import plot_Series # 50ETF日线行情------------------------------------------------------------ fpath = './test/510050_daily_pre_fq.csv' data = load_csv(fpath) data.set_index('date', drop=False, inplace=True) data['cci'] = CCI(data) data['cci_100'] = data['cci'].apply(lambda x: 1 if x > 100 else \ (-1 if x < -100 else 0)) plot_Series( data.iloc[-200:, :], {'close': ('.-k', False)}, cols_styl_low_left={'cci': ('.-c', False)}, cols_to_label_info={ 'cci': [['cci_100', (-1, 1), ('r^', 'bv'), False]] }, xparls_info={'cci': [(100, 'r', '-', 1.3), (-100, 'r', '-', 1.3)]}, figsize=(8, 7), grids=True)
def T_transform(df, T=5): ''' 数据周期转化 df应包含列['open', 'high', 'low', 'close'] ''' raise NotImplementedError dfT = df.reindex(columns=['open', 'high', 'low', 'close']) if __name__ == '__main__': strt_tm = time.time() # 50ETF日线行情 fpath = '../test/510050_daily_pre_fq.csv' df = load_csv(fpath) df.set_index('date', drop=False, inplace=True) # df = df.reindex(columns=['high', 'low', 'close']) # CCI -------------------------------------------------------------------- N = 14 r = 0.015 df['cci'] = CCI(df, N=N, r=r) plot_Series( df.iloc[-200:, :], {'close': ('.-k', False)}, cols_styl_low_left={'cci': ('.-b', False)}, xparls_info={'cci': [(100, 'r', '-', 1.3), (-100, 'r', '-', 1.3)]}, figsize=(8.5, 7), grids=True)
plt.xlabel('时间', {'fontsize': fontsize}) plt.tight_layout() if fig_save_path: plt.savefig(fig_save_path) plt.show() if __name__ == '__main__': from utils_hoo import load_csv daily_50etf_pre_fq_path = '../test/510050_daily_pre_fq.csv' data = load_csv(daily_50etf_pre_fq_path) data.rename(columns={'date': 'time'}, inplace=True) N = 100 # args_ma = None args_ma = [5, 10, 20, 30, 50] args_boll = None # args_boll = [15, 2] # plot_below = None plot_below = 'volume' # args_ma_below = None args_ma_below = [3, 5, 10] figsize = (11, 10) # fig_save_path = None fig_save_path = './plot_test/Candle_test.png' title = '50ETF'
func_confirm = confirm_high if ktype == -1 else confirm_low k, OK_mid, OK_right = func_confirm(k) if OK_mid and OK_right: df.loc[df.index[k], 'zigzag'] = -ktype ktype = -ktype elif OK_mid: df.loc[df.index[k], 'zigzag'] = -ktype * 0.5 break return df['zigzag'] if __name__ == '__main__': # zigzig测试-------------------------------------------------------------- fpath = '../test/510050_daily_pre_fq.csv' his_data = load_csv(fpath) his_data.rename(columns={'date': 'time'}, inplace=True) his_data.set_index('time', drop=False, inplace=True) # N = his_data.shape[0] N = 100 col = 'close' data = his_data.iloc[-N:-1, :].copy() high_col, low_col, up_pct, down_pct = 'high', 'low', 3 / 100, 3 / 100 data['zigzag'] = ZigZag(data, high_col, low_col, up_pct, down_pct) plot_Candle_zz(data, N=data.shape[0], zz_high=high_col, zz_low=low_col, args_ma=None,