def kline(): if request.method == "POST": data = json.loads(request.get_data(as_text=True)) elif request.method == "GET": data = request.args else: raise ValueError ts_code = data.get('ts_code') freq = data.get('freq') k = get_kline(symbol=ts_code, freq=freq, k_count=5000) if czsc.__version__ < "0.5": ka = KlineAnalyze(k, bi_mode="new", xd_mode='strict') k = pd.DataFrame(ka.kline_new) else: ka = KlineAnalyze(k, min_bi_k=5, verbose=False) k = ka.to_df(ma_params=(5, 20), use_macd=True, max_count=5000) k = k.fillna("") kline.loc[:, "dt"] = kline.dt.apply(str) columns = ["dt", "open", "close", "low", "high", "vol", 'fx_mark', 'fx', 'bi', 'xd'] res = make_response(jsonify({'kdata': k[columns].values.tolist()})) res.headers['Access-Control-Allow-Origin'] = '*' res.headers['Access-Control-Allow-Method'] = '*' res.headers['Access-Control-Allow-Headers'] = '*' return res
def get(self): ts_code = self.get_argument('ts_code') freq = self.get_argument('freq') asset = self.get_argument('asset', "E") trade_date = self.get_argument('trade_date') if trade_date == 'null': trade_date = datetime.now().date().__str__().replace("-", "") kline = get_kline(ts_code=ts_code, end_date=trade_date, freq=freq, asset=asset) kline.loc[:, "dt"] = pd.to_datetime(kline.dt) if czsc.__version__ < "0.5": ka = KlineAnalyze(kline, bi_mode="new") kline = pd.DataFrame(ka.kline_new) else: ka = KlineAnalyze(kline, verbose=False) kline = ka.to_df(ma_params=(5, 20), use_macd=True, max_count=5000) kline = kline.fillna("") kline.loc[:, "dt"] = kline.dt.apply(str) columns = [ "dt", "open", "close", "low", "high", "vol", 'fx_mark', 'fx', 'bi', 'xd' ] self.finish({'kdata': kline[columns].values.tolist()})
def get(self): ts_code = self.get_argument('ts_code') freq = self.get_argument('freq') trade_date = self.get_argument('trade_date') if trade_date == 'null': trade_date = datetime.now().date().__str__().replace("-", "") kline = get_gm_kline(symbol=ts_code, end_date=trade_date, freq=freq, k_count=3000) ka = KlineAnalyze(kline, bi_mode="new", verbose=False, use_xd=True, max_count=5000) kline = ka.to_df(ma_params=(5, 20), use_macd=True, max_count=5000, mode='new') kline = kline.fillna("") kline.loc[:, "dt"] = kline.dt.apply(str) columns = [ "dt", "open", "close", "low", "high", "vol", 'fx_mark', 'fx', 'bi', 'xd' ] self.finish({'kdata': kline[columns].values.tolist()})
def get(self): ts_code = self.get_argument('ts_code') freq = self.get_argument('freq') trade_date = self.get_argument('trade_date') if trade_date == 'null': trade_date = datetime.now().date() else: trade_date = datetime.strptime(trade_date, "%Y%m%d") kline = get_kline(symbol=ts_code, end_date=trade_date, freq=freq, count=5000) kline.loc[:, "dt"] = pd.to_datetime(kline.dt) # kline.loc[:, "is_end"] = True if czsc.__version__ < "0.5": ka = KlineAnalyze(kline, bi_mode="new", xd_mode='strict') kline = pd.DataFrame(ka.kline_new) else: ka = KlineAnalyze(kline, bi_mode="new", verbose=False) kline = ka.to_df(ma_params=(5, 20), use_macd=True, max_count=5000) kline = kline.fillna("") kline.loc[:, "dt"] = kline.dt.apply(str) columns = [ "dt", "open", "close", "low", "high", "vol", 'fx_mark', 'fx', 'bi', 'xd' ] self.finish({'kdata': kline[columns].values.tolist()})