Example #1
0
def change_position(inv1_df, inv2_df, columns, string):
    col_name = u'占净值比例'
    elements = []
    for col in columns:
        num = (inv2_df.loc[col, col_name] - inv1_df.loc[col, col_name]) * 100
        if not np.isnan(num) and np.abs(num) > 0.01:
            line = u'%s%s' % (utils.up_down(num), col)
            elements.append(line)
    string += u';'.join(elements)
    return string
Example #2
0
def investment_analysis(inv1_df, inv2_df, fund1_df, fund2_df):
    inv1_df.index = inv1_df.index.map(lambda x: x.strip())
    inv2_df.index = inv2_df.index.map(lambda x: x.strip())

    content = []
    astock1, hk1, gold1, oil1, money1, oversea_stock1, bond1 = fund_position(
        fund1_df)
    astock2, hk2, gold2, oil2, money2, oversea_stock2, bond2 = fund_position(
        fund2_df)
    line = money_management(inv1_df, inv2_df)
    num = (money2 - money1) * 100
    if abs(num) > 0.001:
        line += u";%s货币基金" % (utils.up_down(num))
    content.append(line)
    line = fixed_income_management(inv1_df, inv2_df)
    num = (bond2 - bond1) * 100
    if abs(num) > 0.001:
        line += u";%s债券基金" % (utils.up_down(num))
    content.append(line)
    line = finance_management(inv1_df, inv2_df)
    content.append(line)
    line = u'权益方面:'
    elements = []
    num = (astock2 - astock1) * 100
    if abs(num) > 0.001:
        elements.append(u'%sA股配置' % (utils.up_down(num)))
    num = (hk2 - hk1) * 100
    if abs(num) > 0.001:
        elements.append(u'%s港股配置' % (utils.up_down(num)))
    num = (oversea_stock2 - oversea_stock1) * 100
    if abs(num) > 0.001:
        elements.append(u'%s海外股票配置' % (utils.up_down(num)))
    line += u';'.join(elements)
    content.append(line)
    line = u'商品方面:%s黄金;%s原油' % (utils.up_down(
        (gold2 - gold1) * 100.), utils.up_down((oil2 - oil1) * 100.))
    content.append(line)
    with open(u'%s/本周投资情况分析.txt' % (const.DESKTOP_DIR), 'w') as f:
        f.write('\n'.join(content).encode('utf-8'))