Esempio n. 1
0
def save_index(code: str, mongo=None):
    if not mongo:
        mongo = Mongo()
    if code == 'sh000985':
        df = AkData.index_price_daily(code, 'em')
    else:
        df = ak.stock_zh_index_daily(code)
    if mongo.has_collection(code):
        mongo.drop(code)
    mongo.save(code, df)
Esempio n. 2
0
def save_fund_nav(codes: list, mongo=None):
    if not mongo:
        mongo = Mongo()
    for code in codes:
        collection = 'otc_' + code
        if mongo.has_collection(collection):
            print(collection + ' is already in')
            continue
        print(collection)
        if re.match(r'\d{6}', code) is not None:
            df = JqData.fund_nav_daily(code)
            mongo.save(collection, df)
            time.sleep(1)