Beispiel #1
0
def fund_invest_timing():
    tips_code = prompt.tips_ask_fund()
    tips_month_amount = "你每月想定投多少钱(按周定投没写,要的话自己改程序)?比如1000块就输入1000:"
    tips_invest_years = "你想定投几年?"
    tips_terminate_years = "从第一笔开始算,几年结束投资?"
    tips_fee_rate = "交易手续费是百分几?输入0.5表示0.5%:"
    tips_target_amount = "你觉得有多少钱算养老自由?比如想100万就输入1000000:"
    tips_fund_error = prompt.tips_fund_error()
    tips_stupid = prompt.tips_stupid()

    fund_code = input(tips_code)
    if not (util_func.isExitCode(fund_code) or util_func.isLs(fund_code)):
        # 先查询历史净值
        fund_nav = internal_fund_data_process.get_nav(fund_code)
        nav_amount = len(fund_nav)
        # 至少需要10个值才有意义处理这个基金
        while nav_amount < 10 and (fund_code != "0"):
            print(tips_fund_error)
            fund_code = input(tips_code)
            fund_nav = internal_fund_data_process.get_nav(fund_code)
            nav_amount = len(fund_nav)

    if util_func.isExitCode(fund_code):
        return const_values.special_code("EXIT"), "0", "0", "0", "0", "0", "0"
    elif util_func.isLs(fund_code):
        return const_values.special_code("LS"), "0", "0", "0", "0", "0", "0"
    else:
        month_amount = int(input(tips_month_amount))
        invest_years = int(input(tips_invest_years))
        terminate_years = int(input(tips_terminate_years))
        fee_rate = float(input(tips_fee_rate)) / 100.0
        target_amount = int(input(tips_target_amount))

        while target_amount < month_amount or invest_years < 1 or terminate_years < invest_years or month_amount < 1 or fee_rate < const_values.zero_float(
                "NEG") or fee_rate > const_values.max_fee_rate():
            print(tips_stupid)
            month_amount = int(input(tips_month_amount))
            invest_years = int(input(tips_invest_years))
            terminate_years = int(input(tips_terminate_years))
            fee_rate = float(input(tips_fee_rate)) / 100.0
            target_amount = int(input(tips_target_amount))
        # 手续费0的修正
        if util_func.is_float_zero(fee_rate):
            fee_rate = 0.0
        return fund_code, fund_nav, month_amount, invest_years, terminate_years, fee_rate, target_amount
Beispiel #2
0
def fund_invest_single():
    tips_code = prompt.tips_ask_fund()
    tips_init_amount = "你想投入多少钱?比如1000块就输入1000:"
    tips_terminate_years = "你想投资几年?"
    tips_fee_rate = "交易手续费是百分几?输入0.5表示0.5%:"
    tips_target_amount = "你的投资目标是:"
    tips_fund_error = prompt.tips_fund_error()
    tips_stupid = prompt.tips_stupid()

    fund_code = input(tips_code)
    if not (util_func.isExitCode(fund_code) or util_func.isLs(fund_code)):
        # 先查询历史净值
        fund_nav = internal_fund_data_process.get_nav(fund_code)
        nav_amount = len(fund_nav)
        # 至少需要10个值才有意义处理这个基金
        while nav_amount < 10 and (fund_code != "0"):
            print(tips_fund_error)
            fund_code = input(tips_code)
            fund_nav = internal_fund_data_process.get_nav(fund_code)
            nav_amount = len(fund_nav)

    if util_func.isExitCode(fund_code):
        return const_values.special_code("EXIT"), "0", "0", "0", "0", "0"
    elif util_func.isLs(fund_code):
        return const_values.special_code("LS"), "0", "0", "0", "0", "0"
    else:
        init_amount = int(input(tips_init_amount))
        terminate_years = int(input(tips_terminate_years))
        fee_rate = float(input(tips_fee_rate)) / 100.0
        target_amount = int(input(tips_target_amount))

        while target_amount < init_amount or terminate_years < 1 or init_amount < 1 or fee_rate < const_values.zero_float(
                "NEG") or fee_rate > const_values.max_fee_rate():
            print(tips_stupid)
            init_amount = int(input(tips_init_amount))
            terminate_years = int(input(tips_terminate_years))
            fee_rate = float(input(tips_fee_rate)) / 100.0
            target_amount = int(input(tips_target_amount))
        # 手续费0的修正
        if util_func.is_float_zero(fee_rate):
            fee_rate = 0.0
        return fund_code, fund_nav, init_amount, terminate_years, fee_rate, target_amount
Beispiel #3
0
def fund_analysis():
    tips_code = prompt.tips_ask_fund()
    tips_fund_error = prompt.tips_fund_error()

    fund_code = input(tips_code)
    if not (util_func.isExitCode(fund_code) or util_func.isLs(fund_code)):
        # 先查询历史净值
        fund_nav = internal_fund_data_process.get_nav(fund_code)
        nav_amount = len(fund_nav)
        # 至少需要10个值才有意义处理这个基金
        while nav_amount < 10 and (not util_func.isExitCode(fund_code)) and (
                not util_func.isLs(fund_code)):
            print(tips_fund_error)
            fund_code = input(tips_code)
            fund_nav = internal_fund_data_process.get_nav(fund_code)
            nav_amount = len(fund_nav)

    if util_func.isExitCode(fund_code):
        return const_values.special_code("EXIT"), "0"
    elif util_func.isLs(fund_code):
        return const_values.special_code("LS"), "0"
    else:
        return fund_code, fund_nav
Beispiel #4
0
# -*- coding: utf-8 -*-
# 基金一次性投资的调试入口

import internal_questionnaire
import internal_fund_data_process
import algorithm_monte_carlo
import internal_timing_invest_simulate
import const_values
import util_func
import output_fund

# 调试入口:单个基金的一次性投资模拟结果输出
if __name__ == "__main__":
    tips = "AI吴小蔚梦游中为你服务,请勿当真。请确保要模拟的基金净值数据已经导入到./history/文件夹。"
    print(tips)
    fund_code, fund_nav, init_amount, terminate_years, fee_rate, target_amount = internal_questionnaire.fund_invest_single(
    )
    while not util_func.isExitCode(fund_code):
        if util_func.isLs(fund_code):
            output_fund.show_list()
        else:
            output_fund.show_single(fund_nav, terminate_years, init_amount,
                                    fee_rate, fund_code, target_amount)
        fund_code, fund_nav, init_amount, terminate_years, fee_rate, target_amount = internal_questionnaire.fund_invest_single(
        )
    exit()