Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
    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'
    index_code = '000300'
Ejemplo n.º 3
0
# -*- 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))
Ejemplo n.º 4
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格式,存储着未加后缀的证券代码
    '''