# Path: OnePy/builtin_module/backtest_forex/forex_bar.py
# class BarForex(BarBase):
#     pass
# 
# Path: OnePy/builtin_module/backtest_stock/stock_bar.py
# class BarAshares(BarBase):
# 
#     @property
#     def pre_date(self) -> str:
#         return self.previous_ohlc['date']
# 
#     @property
#     def pre_open(self) -> float:
#         return self.previous_ohlc['open']
# 
#     @property
#     def pre_high(self) -> float:
#         return self.previous_ohlc['high']
# 
#     @property
#     def pre_low(self) -> float:
#         return self.previous_ohlc['low']
# 
#     @property
#     def pre_close(self) -> float:
#         return self.previous_ohlc['close']
# 
#     @property
#     def pre_volume(self) -> float:
#         return self.previous_ohlc['volume']
# 
#     @property
#     def limit_up(self):
#         return self.pre_close*1.1
# 
#     @property
#     def limit_down(self):
#         return self.pre_close*0.9
# 
# Path: OnePy/constants.py
# class EVENT(Enum):
#     Market_updated = 'Market_updated'
#     Data_cleaned = 'Data_cleaned'
#     Signal_generated = 'Signal_generated'
#     Submit_order = 'Submit_order'
#     Record_result = 'Record_result'
# 
# Path: OnePy/sys_module/metabase_env.py
# class OnePyEnvBase:
#     """作为基类，提供env共享单例给各个模块"""
#     env = Environment


from OnePy.builtin_module.backtest_forex.forex_bar import BarForex
from OnePy.builtin_module.backtest_stock.stock_bar import BarAshares
from OnePy.constants import EVENT
from OnePy.sys_module.metabase_env import OnePyEnvBase

# 控制事件发生顺序
EVENT_LOOP = [dict(if_event=EVENT.Market_updated,
                   then_event=EVENT.Data_cleaned,
                   module_dict=OnePyEnvBase.env.cleaners),

              dict(if_event=EVENT.Data_cleaned,
                   then_event=EVENT.Signal_generated,
                   module_dict=OnePyEnvBase.env.strategies),

              dict(if_event=EVENT.Signal_generated,
                   then_event=EVENT.Submit_order,
                   module_dict=OnePyEnvBase.env.risk_managers),

              dict(if_event=EVENT.Submit_order,
                   then_event=EVENT.Record_result,
                   module_dict=OnePyEnvBase.env.brokers),

              dict(if_event=EVENT.Record_result,
                   then_event=None,

# Path: OnePy/builtin_module/backtest_forex/forex_bar.py
# class BarForex(BarBase):
#     pass
# 
# Path: OnePy/builtin_module/backtest_stock/stock_bar.py
# class BarAshares(BarBase):
# 
#     @property
#     def pre_date(self) -> str:
#         return self.previous_ohlc['date']
# 
#     @property
#     def pre_open(self) -> float:
#         return self.previous_ohlc['open']
# 
#     @property
#     def pre_high(self) -> float:
#         return self.previous_ohlc['high']
# 
#     @property
#     def pre_low(self) -> float:
#         return self.previous_ohlc['low']
# 
#     @property
#     def pre_close(self) -> float:
#         return self.previous_ohlc['close']
# 
#     @property
#     def pre_volume(self) -> float:
#         return self.previous_ohlc['volume']
# 
#     @property
#     def limit_up(self):
#         return self.pre_close*1.1
# 
#     @property
#     def limit_down(self):
#         return self.pre_close*0.9
# 
# Path: OnePy/constants.py
# class EVENT(Enum):
#     Market_updated = 'Market_updated'
#     Data_cleaned = 'Data_cleaned'
#     Signal_generated = 'Signal_generated'
#     Submit_order = 'Submit_order'
#     Record_result = 'Record_result'
# 
# Path: OnePy/sys_module/metabase_env.py
# class OnePyEnvBase:
#     """作为基类，提供env共享单例给各个模块"""
#     env = Environment


# Path: OnePy/config.py
from OnePy.builtin_module.backtest_forex.forex_bar import BarForex
from OnePy.builtin_module.backtest_stock.stock_bar import BarAshares
from OnePy.constants import EVENT
from OnePy.sys_module.metabase_env import OnePyEnvBase


# 控制事件发生顺序
EVENT_LOOP = [dict(if_event=EVENT.Market_updated,
                   then_event=EVENT.Data_cleaned,
                   module_dict=OnePyEnvBase.env.cleaners),

              dict(if_event=EVENT.Data_cleaned,
                   then_event=EVENT.Signal_generated,
                   module_dict=OnePyEnvBase.env.strategies),

              dict(if_event=EVENT.Signal_generated,
                   then_event=EVENT.Submit_order,
                   module_dict=OnePyEnvBase.env.risk_managers),

              dict(if_event=EVENT.Submit_order,
                   then_event=EVENT.Record_result,
                   module_dict=OnePyEnvBase.env.brokers),

              dict(if_event=EVENT.Record_result,
                   then_event=None,

                   module_dict=OnePyEnvBase.env.recorders)]