# Path: OnePy/constants.py
# class ActionType(Enum):
# 
#     Buy = 'Buy'
#     Sell = 'Sell'
#     Short = 'Short'
#     Cover = 'Cover'
# 
#     Exit_all = 'Exit_all'
#     Cancel = 'Cancel'
# 
# class OrderType(Enum):
# 
#     Market = 'Market'
#     Limit = 'Limit'
#     Stop = 'Stop'
#     Trailing_stop = 'Trailing_stop'
# 
#     Limit_pct = 'Limit_pct'
#     Stop_pct = 'Stop_pct'
#     Trailing_stop_pct = 'Trailing_stop_pct'
# 
# Path: OnePy/sys_module/metabase_env.py
# class OnePyEnvBase:
#     """作为基类，提供env共享单例给各个模块"""
#     env = Environment
# 
# Path: OnePy/utils/memo_for_cache.py
# def memo(key):
#     cache = Environment.cache
# 
#     def decorate(func):
#         @wraps(func)
#         def wrapper(*args, **kwargs):
#             if key not in cache:
#                 cache[key] = func(*args, **kwargs)
# 
#             return cache[key]
# 
#         return wrapper
# 
#     return decorate


import json
import arrow
import numpy as np
import pandas as pd
from collections import defaultdict
from OnePy.constants import ActionType, OrderType
from OnePy.sys_module.metabase_env import OnePyEnvBase
from OnePy.utils.memo_for_cache import memo
        from OnePy.custom_module.trade_log_analysis import APP
            Total_trading_days=add_days(total_trading_days),

            Max_drawdown=add_percent(max_drawdown),
            Max_drawdown_date=max_drawdown_date,
            Max_duration_in_drawdown=add_days(max_duration_in_drawdown),
            Max_margin=add_dollar(max_margin),
            Max_win_holding_pnl=add_dollar(max_win_holding_pnl),
            Max_loss_holding_pnl=add_dollar(max_loss_holding_pnl),

            Sharpe_ratio=add_none(sharpe_ratio),
            Sortino_ratio=add_none(sortino_ratio),

            Number_of_trades=add_none(number_of_trades),
            Number_of_daily_trades=add_none(number_of_daily_trades),
            Number_of_profit_days=add_days(number_of_profit_days),
            Number_of_loss_days=add_days(number_of_loss_days),

            Avg_daily_pnl=add_dollar(avg_daily_pnl),
            Avg_daily_commission=add_dollar(avg_daily_commission),
            Avg_daily_return=add_percent(avg_daily_return),
            Avg_daily_std=add_percent(avg_daily_std),

            Annual_compound_return=add_percent(annual_coumpond_return),
            Annual_average_return=add_percent(annual_average_return),
            Annual_std=add_percent(annual_std),
            Annual_pnl=add_dollar(annual_pnl),
        )

        return general_result


# Path: OnePy/constants.py
# class ActionType(Enum):
# 
#     Buy = 'Buy'
#     Sell = 'Sell'
#     Short = 'Short'
#     Cover = 'Cover'
# 
#     Exit_all = 'Exit_all'
#     Cancel = 'Cancel'
# 
# class OrderType(Enum):
# 
#     Market = 'Market'
#     Limit = 'Limit'
#     Stop = 'Stop'
#     Trailing_stop = 'Trailing_stop'
# 
#     Limit_pct = 'Limit_pct'
#     Stop_pct = 'Stop_pct'
#     Trailing_stop_pct = 'Trailing_stop_pct'
# 
# Path: OnePy/sys_module/metabase_env.py
# class OnePyEnvBase:
#     """作为基类，提供env共享单例给各个模块"""
#     env = Environment
# 
# Path: OnePy/utils/memo_for_cache.py
# def memo(key):
#     cache = Environment.cache
# 
#     def decorate(func):
#         @wraps(func)
#         def wrapper(*args, **kwargs):
#             if key not in cache:
#                 cache[key] = func(*args, **kwargs)
# 
#             return cache[key]
# 
#         return wrapper
# 
#     return decorate


# Path: OnePy/custom_module/analysis.py
import json
import arrow
import numpy as np
import pandas as pd
from collections import defaultdict
from OnePy.constants import ActionType, OrderType
from OnePy.sys_module.metabase_env import OnePyEnvBase
from OnePy.utils.memo_for_cache import memo
        from OnePy.custom_module.trade_log_analysis import APP

            Total_trading_days=add_days(total_trading_days),

            Max_drawdown=add_percent(max_drawdown),
            Max_drawdown_date=max_drawdown_date,
            Max_duration_in_drawdown=add_days(max_duration_in_drawdown),
            Max_margin=add_dollar(max_margin),
            Max_win_holding_pnl=add_dollar(max_win_holding_pnl),
            Max_loss_holding_pnl=add_dollar(max_loss_holding_pnl),

            Sharpe_ratio=add_none(sharpe_ratio),
            Sortino_ratio=add_none(sortino_ratio),

            Number_of_trades=add_none(number_of_trades),
            Number_of_daily_trades=add_none(number_of_daily_trades),
            Number_of_profit_days=add_days(number_of_profit_days),
            Number_of_loss_days=add_days(number_of_loss_days),

            Avg_daily_pnl=add_dollar(avg_daily_pnl),
            Avg_daily_commission=add_dollar(avg_daily_commission),
            Avg_daily_return=add_percent(avg_daily_return),
            Avg_daily_std=add_percent(avg_daily_std),

            Annual_compound_return=add_percent(annual_coumpond_return),
            Annual_average_return=add_percent(annual_average_return),
            Annual_std=add_percent(annual_std),
            Annual_pnl=add_dollar(annual_pnl),
        )

        return general_result


    @memo('detail_summary')