Exemplo n.º 1
0
def saveFundWorth():
    collection = "worth"
    data = MongoDBUtil.query({}, "fundList")
    amount = data.count()
    skip = 0
    count = 0
    for fund in data:
        print("get %d :: %d" % (count, amount))
        count = count + 1
        if count < skip:
            continue

        number = fund["number"]
        name = fund["name"]
        try:
            # MongoDBUtil.insert({"name": name, "number": number, "worth": get_fund_worth(number)}, collection)
            MongoDBUtil.replace({"number": number}, {
                "name": name,
                "number": number,
                "worth": get_fund_worth(number)
            }, collection)
        except Exception as e:
            print(e)
            traceback.print_exc()
            print('traceback.format_exc():\n%s' % traceback.format_exc())
Exemplo n.º 2
0
def get_fund_detail():
    data = MongoDBUtil.query({}, "fundList")
    count = 0
    fund_numbers = []
    for fund in data:
        print(fund)
        count = count + 1
        fund_numbers.append(fund['number'])
        print("count:", count)
    print("基金数量:", count)

    count = 0
    for fund in fund_numbers:
        count = count + 1
        try:
            number = fund
            situation_data = get_situation(number)
            earn_data = get_history_earn(number)
            worth_data = get_fund_worth(number)
            MongoDBUtil.replace({"number": number},
                                {'number': number, 'situation': situation_data, 'earn': earn_data,
                                 'worth': worth_data},
                                "fundDetail", True)
        except Exception as e:
            print(e)
            traceback.print_exc()
            print('traceback.format_exc():\n%s' % traceback.format_exc())

        time.sleep(1)
        print("count:", count, len(fund_numbers))
Exemplo n.º 3
0
def save():
    fundList = MongoDBUtil.query({}, "fundList")
    count = 0
    amount = fundList.count()
    for item in fundList:
        data, name, number = getFundDetail(item["number"])
        print(name, number, date)
        MongoDBUtil.replace({"number": number}, {"name": name, "number": number, "worth": data}, "worth_tt", True)

        print("save %d :: %d" % (count, amount))
        count = count + 1