當前位置: 首頁>>代碼示例>>Python>>正文


Python report.Report類代碼示例

本文整理匯總了Python中mewp.simulate.report.Report的典型用法代碼示例。如果您正苦於以下問題:Python Report類的具體用法?Python Report怎麽用?Python Report使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Report類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_simulation

def run_simulation(param, date_list):
    algo = { 'class': ConstStopWinGuardAlgo }
    algo['param'] = {'x': 'ni1609',
                     'y': 'ni1701',
                     'a': 1,
                     'b': 0,
                     'rolling': param[0],
                     'bollinger': 2,
                     'const': param[1],
                     'stop_win':param[2],
                     'block': 100,
                     'tracker': None
                    }
    settings = { 'date': date_list,
                 'path': DATA_PATH,
                 'tickset': 'top',
                 'algo': algo,
                 'singletick': False}
    settings['exe'] = PairExePlusTick(2)
    runner = PairRunner(settings)
    runner.run()
    report = Report(runner)
    temp = report.get_daily_pnl()
    pnl_list = list(temp.daily_pnl)
    return pnl_list
開發者ID:volpato30,項目名稱:Backtest,代碼行數:25,代碼來源:stopwin_slipery.py

示例2: run_simulation

def run_simulation(params):
    date = '2015-01-01'
    dateend = '2015-05-01'
    ma_diff = []
    dates = [str(x).split(' ')[0] for x in pd.date_range(date, dateend).tolist()]
    algo = { 'class': MyMM }
    temp = {'item': 'au1506'}
    temp['ma_diff_length'] = params[0]
    temp['trigger_diff'] = params[1]
    temp['ma_window'] = params[2]
    temp['spread'] = params[3]
    temp['inv_coef'] = params[4]
    temp['chunk'] = params[5]
    temp['gap'] = params[6]
    algo['param'] = temp
    settings = { 'date': dates, 'algo': algo, 'tickset': 'top', 'verbose' : True,
                     'path': DATA_PATH }
    runner = SingleRunner(settings)
    runner.run()
    report = Report(runner)
    pnl = report.get_final_pnl()
    sharp_ratio = report.get_sharpie_ratio()
    del runner._algo.volatility_finder
    del runner._algo
    runner.close()
    del runner._me
    del runner._price_table
    del runner
    return pnl, sharp_ratio
開發者ID:volpato30,項目名稱:Backtest,代碼行數:29,代碼來源:grid_search_mm.py

示例3: run_simulation

def run_simulation(param, date_list, if_param):
    order_win_list = []
    daily_num_order = []
    order_waiting_list = []
    order_profit_list = []
    master = MasterReport()
    for date in date_list:
        date_pair = get_best_pair(date, market, "cu")
        if type(date_pair) != tuple:
            continue
        else:
            runner = back_test(date_pair, date, param, if_param)
            try:
                report = Report(runner)
            except IndexError:
                print "WTF? {} has IndexError".format(date)
                continue
            report.print_report(to_file=False, to_screen=False, to_master=master)
            order_win_list.append(runner._algo.tracker.order_winning_ratio())
            temp = runner._algo.tracker.analyze_all_waiting()
            order_waiting_list.append(temp[0])
            daily_num_order.append(temp[2])
            order_profit_list.append(runner._algo.tracker.analyze_all_profit()[0])
    [overall, days] = master.print_report(to_file=False, print_days=True)
    final_pnl = float(overall.final_pnl)
    final_return = float(overall.final_return)
    sharpe_ratio = float(overall.sharpe_ratio)
    win_ratio = float(overall.win_ratio)
    daily_draw_down = np.asarray(days.max_draw_down)
    max_draw_down = daily_draw_down.max()
    avg_draw_down = daily_draw_down.mean()
    num_orders = sum(days.order_count)
    order_win_list = np.asarray(order_win_list)
    order_profit_list = np.asarray(order_profit_list)
    order_waiting_list = np.asarray(order_waiting_list)
    daily_num_order = np.asarray(daily_num_order)
    if daily_num_order.sum() < 1:
        order_win = -1
        order_waiting = -1
        order_profit = -1
    else:
        order_win = sum(order_win_list * daily_num_order / daily_num_order.sum())
        order_waiting = sum(order_waiting_list * daily_num_order / daily_num_order.sum())
        order_profit = sum(order_profit_list * daily_num_order / daily_num_order.sum())

    return (
        final_pnl,
        final_return,
        sharpe_ratio,
        win_ratio,
        max_draw_down,
        avg_draw_down,
        num_orders,
        order_win,
        order_waiting,
        order_profit,
    )
開發者ID:Coderx7,項目名稱:CNN,代碼行數:57,代碼來源:cu.py

示例4: run_simulation

def run_simulation(param, date_list, product):
    order_win_list = []
    daily_num_order = []
    order_waiting_list = []
    order_profit_list = []
    master = MasterReport()
    tracker = get_tracker(date_list, product)


    for date in date_list:
        date_pair = get_best_pair(date, market, product)
        if type(date_pair) != tuple:
            continue
        else:
            runner, _ = back_test(date_pair, date, param, tracker)
            try:
                report = Report(runner)
            except IndexError:
                print 'WTF? {} has IndexError'.format(date)
                continue
            report.print_report(to_file=False, to_screen=False, to_master=master)

    try:
        [overall, days] = master.print_report(to_file=False, print_days=False)
    except TypeError as inst:
        if inst.args[0] == "'NoneType' object has no attribute '__getitem__'":
            return ('NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA')
        else:
            raise Exception("god knows what happens")

    #pnls
    final_pnl = float(overall.final_pnl)
    final_return = float(overall.final_return)
    sharpe_ratio = float(overall.sharpe_ratio)
    win_ratio = float(overall.win_ratio)

    #max draw down
    daily_draw_down = np.asarray(days.max_draw_down)
    max_draw_down = daily_draw_down.max()
    avg_draw_down = daily_draw_down.mean()

    #num orders
    num_orders = sum(days.order_count)

    #order analysis
    order_win = tracker.order_winning_ratio()
    order_waiting = tracker.analyze_all_waiting()[0]
    order_waiting_median = tracker.analyze_all_waiting()[3]
    order_profit = tracker.analyze_all_profit()[0]
    order_profit_median = tracker.analyze_all_profit()[3]
    num_rounds = tracker.analyze_all_profit()[2]

    return final_pnl, final_return, sharpe_ratio, win_ratio, max_draw_down,\
        avg_draw_down, num_orders, num_rounds, order_win, order_waiting, order_waiting_median, \
        order_profit, order_profit_median
開發者ID:Coderx7,項目名稱:CNN,代碼行數:55,代碼來源:al.py

示例5: run_simulation

def run_simulation(param, date_list, product):
    order_win_list = []
    daily_num_order = []
    order_waiting_list = []
    order_profit_list = []
    master = MasterReport()
    for date in date_list:
        date_pair = get_best_pair(date,market, product)
        if type(date_pair) != tuple:
            continue
        else:
            runner = back_test(date_pair, date, param)
            try:
                report = Report(runner)
            except IndexError:
                print 'WTF? {} has IndexError'.format(date)
                continue
            report.print_report(to_file=False, to_screen=False, to_master=master)
            order_win_list.append(runner._algo.tracker.order_winning_ratio())
            temp = runner._algo.tracker.analyze_all_waiting()
            order_waiting_list.append(temp[0])
            daily_num_order.append(temp[2])
            order_profit_list.append(runner._algo.tracker.analyze_all_profit()[0])
    try:
        [overall, days] = master.print_report(to_file=False, print_days=False)
    except TypeError as inst:
        if inst.args[0] == "'NoneType' object has no attribute '__getitem__'":
            return ('NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA')
        else:
            raise Exception("god knows what happens")
    final_pnl = float(overall.final_pnl)
    final_return = float(overall.final_return)
    sharpe_ratio = float(overall.sharpe_ratio)
    win_ratio = float(overall.win_ratio)
    daily_draw_down = np.asarray(days.max_draw_down)
    max_draw_down = daily_draw_down.max()
    avg_draw_down = daily_draw_down.mean()
    num_orders = sum(days.order_count)
    order_win_list = np.asarray(order_win_list)
    order_profit_list = np.asarray(order_profit_list)
    order_waiting_list = np.asarray(order_waiting_list)
    daily_num_order= np.asarray(daily_num_order)
    if daily_num_order.sum() < 1:
        order_win = -1
        order_waiting = -1
        order_profit = -1
    else:
        order_win = sum(order_win_list * daily_num_order/daily_num_order.sum())
        order_waiting = sum(order_waiting_list * daily_num_order/daily_num_order.sum())
        order_profit = sum(order_profit_list * daily_num_order/daily_num_order.sum())

    return final_pnl, final_return, sharpe_ratio, win_ratio, max_draw_down,\
        avg_draw_down, num_orders, order_win, order_waiting, order_profit
開發者ID:Coderx7,項目名稱:CNN,代碼行數:53,代碼來源:czce.py

示例6: run_simulation

def run_simulation(param, date_list, product):
    pnl_list = []
    order_win_list = []
    order_profit_list = []
    num_rounds_list = []
    master = MasterReport()
    for date in date_list:
        date_pair = get_best_pair(date,market, product)
        if type(date_pair) != tuple:
            continue
        else:
            result = back_test(date_pair, date, param)
            pnl_list.append(result[0])
            order_win_list.append(result[1])
            order_profit_list.append(result[2])
            num_rounds_list.append(result[3])
            runner = result[4]
            try:
                report = Report(runner)
            except IndexError:
                print 'WTF? {} has IndexError'.format(date)
                continue
            report.print_report(to_file=False, to_screen=False, to_master=master)
    return pnl_list, order_win_list, order_profit_list, num_rounds_list, master
開發者ID:Coderx7,項目名稱:CNN,代碼行數:24,代碼來源:pb.py

示例7: run_simulation

def run_simulation(p):
    runner.run(algo_param={'rolling': p[0], 'bollinger': p[1], 'stop_win': p[2]})
    report = Report(runner)
    runner._algo.tracker.order_winning_ratio()
    pnl = float(report.get_final_pnl())
    final_return = float(report.get_final_return())
    sharpe_ratio = float(report.get_sharpie_ratio())
    avg_draw_down = float(report.get_avg_max_draw_down())
    max_draw_down = float(report.get_max_max_draw_down()[0])
    order_winning_ratio = float(runner._algo.tracker.order_winning_ratio())
    waiting_time = float(runner._algo.tracker.analyze_all_waiting()[0])
    avg_profit = float(runner._algo.tracker.analyze_all_profit()[0])
    num_orders = int(runner._algo.tracker.analyze_all_profit()[2])

    return pnl, final_return, sharpe_ratio, avg_draw_down, max_draw_down, \
        order_winning_ratio, waiting_time, avg_profit, num_orders
開發者ID:Coderx7,項目名稱:CNN,代碼行數:16,代碼來源:trailing_stopwin.py


注:本文中的mewp.simulate.report.Report類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。