Пример #1
0
def get_industry_descendant(industry_code='110000'):
    intern = util.get_all_pkl()
    stock_SWICS = intern['InstrumentInfo']['SWICS']
    pattern = re.compile(industry_code[0:2])
    descendant = []
    for index, stock in zip(intern['InstrumentInfo'].index, stock_SWICS):
        if re.match(pattern, stock):
            descendant.append(index)
    return np.asarray(descendant)
Пример #2
0
def get_stock_index(stock_code=['000001'], name=False):
    intern = util.get_all_pkl()
    all_stock_index = intern['InstrumentInfo']
    stock_index = [
        all_stock_index.index.get_loc(code_i) for code_i in stock_code
    ]
    stock_name = [all_stock_index.loc[code_j, 'Name'] for code_j in stock_code]
    if not name:
        return np.asarray(stock_index)
    elif name:
        return np.asarray(stock_name)
Пример #3
0
def get_stock_feature(stock_code=['000002'], feature='all'):
    intern = util.get_all_pkl()
    all_stock_index = intern['InstrumentInfo']
    temp = []
    if feature == 'all':
        for code in stock_code:
            stock_index = all_stock_index.index.get_loc(code)
            stock_all_feature = intern['MktData'].iloc[:, stock_index *
                                                       9:(stock_index + 1) * 9]
            temp.append(stock_all_feature)
    else:
        for code in stock_code:
            stock_index = all_stock_index.index.get_loc(code)
            stock_all_feature = intern['MktData'].iloc[:, stock_index *
                                                       9:(stock_index + 1) * 9]
            temp.append(stock_all_feature[feature])
    return pd.concat(temp, axis=1)