def test(): pl = publish.Publish() base_boll_up = get_boll_up_base() base_boll_lower = get_boll_lower_base() def get_data(): code = jx.HCGD df = tdx.getFive(code) return df key = myredis.gen_keyname(__file__, Recognize_boll.test) df = myredis.createRedisVal(key, get_data).get() df = stock.TDX_BOLL_df(df) for i in range(60, len(df)): df_cur = df[:i] c = Recognize_boll(base_boll_up, df_cur) c2 = Recognize_boll(base_boll_lower, df_cur) b = c._calc_beta_up() b2 = c._calc_beta_lower() #if c2.is_matched(): #print(b2) if abs(c.sign()) > 0 or abs(c2.sign()) > 0: df_cur = df_cur[['c', 'boll_up', 'boll_mid', 'boll_lower']] df_cur.index = range(len(df_cur)) df_cur.plot() pl.show()
def watch_four(): """观察当前数据源的four情况""" from autoxd.pinyin import stock_pinyin3 as jx code = jx.ZXJT df = stock.getFiveHisdatDf(code, method='tdx') #print(df) four = stock.FOUR(df['c'].values) print(four) from autoxd import ui from autoxd.pypublish import publish pl = publish.Publish() ui.DrawTs(pl, four)
def _test_recog_boll(self): from pypublish import publish pl = publish.Publish() from policy_report import df_to_html_table report = [] for i in range(200): try: recog_boll(pl, report) except: continue df = pd.DataFrame(report) df = df[df[df.columns[0]] > 0.7] pl.reset(df_to_html_table(df)) pl.publish()
def df_to_img_martix(df, n): """生成df到目录img return: np.ndarray shape(n,n)""" pl = publish.Publish(explicit=True, is_clear_path=True) df.plot(legend=False) pl.axis('off') pl.show() fname = pl.get_CurImgFname() pl.close() #print(fname) img = cv2.imread(fname, cv2.IMREAD_GRAYSCALE) img = cv2.resize(img, (n,n)) return img
def show_first(): fname = 'center_indexs_mid.csv' datas = pearson_clust.load_data() df = pd.read_csv(fname) df = df['0'] indexs = df.get_values() print(len(indexs)) #print(len(indexs)) #print(len(datas)) pl = publish.Publish() for index in indexs: pl.figure pearson_clust.draw(datas[index]) pl.show() pl.close()
def test(): width = 300 height = 300 a = np.random.rand(30,4)*100 print(a) df = pd.DataFrame(a) pl = publish.Publish() df.plot() pl.show() pl.close() v = convert(width, height, df) #filter(lambda x:pl.scatter(x[0],x[1]), v ) for x in v: pl.scatter(x[:,0], x[:,1]) pl.show() pl.close() print("")
def test_recog_history_boll(): from pypublish import publish pl = publish.Publish(explicit=True) code = jx.ZCKJ.b def get_local_codes(): data_path = 'cnn_boll/datasources/' return np.array([str(f).split('.')[0] for f in os.listdir(data_path)]) from sklearn.utils import shuffle key = myredis.gen_keyname(__file__, test_recog_history_boll) codes = myredis.createRedisVal(key, get_local_codes).get() code = shuffle(codes)[0] #ui.DrawTs(pl, x) #x = get_boll_up_base() x = get_boll_lower_base() p = 0.75 #report = ['init', pl.get_CurImgFname()] report = recog_history_boll(pl, x, p, code) pl.RePublish(report)
输出符合技术指标组合的结果 """ from autoxd import stock, ui, myredis, agl, sign_observation from autoxd.cnn_boll.judge_boll_sign import getBolls from autoxd.pinyin import stock_pinyin3 as jx from autoxd.myenum import MYCOLS_NAME as colname from autoxd.hard_recog import kurtosis from autoxd.cnn_boll.judge_boll_sign import g_scope_len import pylab as pl import pandas as pd import random import numpy as np from collections.abc import Iterator, Iterable from autoxd.pypublish import publish pl = publish.Publish(is_clear_path=True) #需要处理的字段 #col_names = [""] #cols = ["close_zz_0", "close_zz_1", "boll_low_zz_0", "boll_low_zz_1", "boll_w"] class calc_property: close_zz_0 = np.nan close_zz_1 = np.nan boll_low_zz_0 = np.nan boll_low_zz_1 = np.nan boll_w = np.nan adx = 0 boll_x = 0 # x, 时间周期 boll_y = 0.1 # (mid-v)/(mid-low)
def setParams(s): if 0: s = Strategy_Boll s.setParams(pl=publish.Publish(), )
def setParams(s): if 0: s = Strategy_Boll s.setParams( trade_num=300, pl=publish.Publish(explicit=True), )
def setParams(s): s.setParams( pl=publish.Publish(), )