def save_data():
    global GDP
    total_value = total_market_value()
    buffett_index = str(round(total_value/GDP, 6) * 100) + '%'
    bi = BuffettIndex(date=datetime.date.today(), buffett_index=buffett_index, total_value=total_value)
    try:
        bi.save()
    except Exception, e:
        logging.error('Error when save BuffettIndex data:' + str(e))
def save_data():
    global GDP
    total_value = total_market_value()
    buffett_index = str(round(total_value / GDP, 6) * 100) + '%'
    bi = BuffettIndex(date=datetime.date.today(),
                      buffett_index=buffett_index,
                      total_value=total_value)
    try:
        bi.save()
    except Exception, e:
        logging.error('Error when save BuffettIndex data:' + str(e))
def cal_buffett_index():
    today = datetime.date.today()
    sdt = SDT.objects(date=today)
    if not sdt:
        return

    bi = BuffettIndex.objects(date=today)
    if bi:
        return

    save_data()
def cal_buffett_index():
    today = datetime.date.today()
    sdt = SDT.objects(date=today)
    if not sdt:
        return

    bi = BuffettIndex.objects(date=today)
    if bi:
        return

    save_data()