def get_tushare_pro(): import xcsc_tushare as xc xc_token_pro = config.get('xc_token_pro') xc_server = config.get('xc_server') xc.set_token(xc_token_pro) pro = xc.pro_api(env='prd', server=xc_server) return pro
'out_date']).reset_index(drop=True) index_members2.to_pickle(pname) def get_sw_index_data(): pass def get_zx_index_data(): pass if __name__ == '__main__': token_xcts_prd = '2a876aa6da3590a5ebebc55e4f852cd5e17813a3390bd3cd642ec29e' token_ts = '9cbff072025ae17a12e05b84235202a7af807f3a3e074124c8a0aae0' xcts.set_token(token_xcts_prd) pro = xcts.pro_api(env='prd') begin_date = 20060410 # xctushare 的数据开始日期 end_date = 20201029 root_path = 'D:/python projects/quandomo/data_center/data/xctushare/' # trade_dt = pro.trade_cal(exchange='SSE', start_date=begin_date, end_date=end_date) # trade_date_list = list(trade_dt['trade_date'].values) # 下载300指数成分股及其权重数据 # fields = "con_ts_code,trade_date,i_weight" # get_hs300_members_xctushare(begin_date, end_date, root_path + r'hs300_classify.pkl', fields) # 从 akshare 获取沪深300成分股 exchange = 'sh'
# -*- coding: utf-8 -*- """ Created on Sun May 9 11:54:31 2021 @author: fkvzl E-mail: [email protected] Tel: 15257442134 """ import xcsc_tushare as ts ts.set_token('db359948bb4351fe9731151b3ad7925b240419250d16094af141acd5') pro = ts.pro_api(env='prd') #获取每日涨跌数量,横轴日期,绘制曲线 df_s = pro.stock_basic(exchange='SSE') #df_s = df_s[df_s.ts_code.str.contains('^60')] #print (df_s) df = pro.daily(ts_code='600001.SH',trade_date='20210507') df = df[df.ts_code.str. ] print(sum(df['pct_chg']<0))
# -*- coding: utf-8 -*- # @Time : 2021/4/2 20:02 # @File : Base.py # @Author : Rocky [email protected] import xcsc_tushare as xc import sys sys.path.append('..') from configure.settings import config xc_token_pro=config.get('xc_token_pro') xc.set_token(xc_token_pro) simulation_server = config.get('xc_server') pro =xc.pro_api(env='prd',server=simulation_server) __all__=('pro',)
#!/usr/bin/env python # coding: utf-8 import pandas as pd import xcsc_tushare as xc from datetime import datetime xc.set_token('a974d1ebb145840ead809fbf098db57a31d4d51ec4dda6beaadefd5f') pro = xc.pro_api(env='prd') def preN_indx(trade_date, FirstDeclareDate_ls): ''' trade_date: 交易日历的列表 FirstDeclareDate_ls: 首次并购日的列表 ''' # 获取FirstDeclareDate_ls中每个元素在trade_date中的索引 indx = [] for date in FirstDeclareDate_ls: try: indx.append(trade_date.index(date)) # 如果日期不在交易日历内,将该日期移到了下一个交易日 except: indx.append(sum(dd < date for dd in trade_date)) return indx def add_stkCode(stkCode): ''' stkCode: list格式,存储着未加后缀的证券代码 '''
] LIMIT_PRICE_PERCENT = 1.2 # 当前成交价的20% 限制 USE_UP = True USE_DOWN = True AFTER_HALT_SELL_TIME = 5 # 复牌后5分钟卖 # 强赎列表,当天强赎的转债代码,如果有多个请用逗号隔开 例子:['123004.SZ','123004.SZ'] forced_redemption_list = [ '123000.SH', ] DEBUG = True # ================================================================================= xc.set_token(xc_token) pro = xc.pro_api(env='prd', server=simulation_server) def get_max_time(): result_list = [] for i in strategy_list: result_list.append(i.monitor_time) v = max(result_list) print(v) return v class Bond: def modify_sh_code(self, x): return re.sub('SH', 'SS', x)
# -*- coding: utf-8 -*- """ Created on Sun Mar 28 10:23:10 2021 @author: Administrator """ import xcsc_tushare as ts import talib as tl from sqlalchemy import create_engine import pymysql import numpy as np import matplotlib.pyplot as plt import pandas as pd ts.set_token('a5cec5a238e77dabe416e44b53bb9fd679aa3c00a148cd47e315ef8e') pro = ts.pro_api(env='prd') ip = '127.0.0.1' user = '******' pwd = 'stock' db = 'stockdb' engine = create_engine(f'mysql+pymysql://{user}:{pwd}@{ip}:3306/{db}') def myMACD(price, fastperiod, slowperiod, signalperiod): ewma12 = price.ewm(span=fastperiod, adjust=False).mean() ewma60 = price.ewm(span=slowperiod, adjust=False).mean() dif = ewma12 - ewma60 dea = dif.ewm(span=signalperiod, adjust=False).mean() bar = (dif - dea) * 2 #有些地方的bar = (dif-dea)*2,但是talib中MACD的计算是bar = (dif-dea)*1