def _get_future_trading_minutes(self, trading_date):
     trading_minutes = set()
     universe = self._get_universe()
     for order_book_id in universe:
         if get_account_type(order_book_id) == DEFAULT_ACCOUNT_TYPE.STOCK.name:
             continue
         trading_minutes.update(self._env.data_proxy.get_trading_minutes_for(order_book_id, trading_date))
     return set([convert_int_to_datetime(minute) for minute in trading_minutes])
Exemple #2
0
 def get_position(self, order_book_id, direction):
     account_type = get_account_type(order_book_id)
     if account_type == DEFAULT_ACCOUNT_TYPE.STOCK.name:
         return StockSimulationBookingPosition(
             self._positions[order_book_id], direction)
     elif account_type == DEFAULT_ACCOUNT_TYPE.FUTURE.name:
         return FutureSimulationBookingPosition(
             self._positions[order_book_id], direction)
     else:
         raise NotImplementedError
Exemple #3
0
 def _get_frontend_validator_for(self, order_book_id):
     account_type = get_account_type(order_book_id)
     try:
         return self._frontend_validator[account_type]
     except KeyError:
         if account_type == ACCOUNT_TYPE.STOCK:
             validator = StockFrontendValidator(self.mod_config)
         elif account_type == ACCOUNT_TYPE.FUTURE:
             validator = FutureFrontendValidator(self.mod_config)
         else:
             raise RuntimeError(
                 'account type {} not supported yet'.format(account_type))
         self._frontend_validator[account_type] = validator
         return validator
 def get_future_trading_points(env, trading_date, frequency):
     if frequency == "1m":
         trading_minutes = set()
         universe = env.get_universe()
         for order_book_id in universe:
             if get_account_type(
                     order_book_id) == DEFAULT_ACCOUNT_TYPE.STOCK:
                 continue
             trading_minutes.update(
                 env.data_proxy.get_trading_minutes_for(
                     order_book_id, trading_date))
         return set([
             convert_int_to_datetime(minute) for minute in trading_minutes
         ])
     # TODO future hours
     return set()
Exemple #5
0
 def order(self, order_book_id, quantity, style, target=False):
     account_type = get_account_type(order_book_id)
     return self.accounts[account_type].order(order_book_id, quantity,
                                              style, target)
Exemple #6
0
 def __missing__(self, key):
     account_type = get_account_type(key)
     for a_type in self._accounts:
         if a_type == account_type:
             return self._accounts[a_type].positions[key]
     return None
Exemple #7
0
 def order(self, order_book_id, quantity, style, target=False):
     account_type = get_account_type(order_book_id)
     return self.accounts[account_type].order(order_book_id, quantity, style, target)
Exemple #8
0
 def __missing__(self, key):
     account_type = get_account_type(key)
     for a_type in self._accounts:
         if a_type == account_type:
             return self._accounts[a_type].positions[key]
     return None
Exemple #9
0
 def get_account(self, order_book_id):
     if not self.portfolio:
         raise NotImplementedError
     account_type = get_account_type(order_book_id)
     return self.portfolio.accounts[account_type]
Exemple #10
0
 def get_account_type(self, order_book_id):
     # 如果新的account_type 可以通过重写该函数来进行扩展
     return get_account_type(order_book_id)
 def _get_account_for(self, order_book_id):
     account_type = get_account_type(order_book_id)
     return self._accounts[account_type]
Exemple #12
0
 def get_account(self, order_book_id):
     account_type = get_account_type(order_book_id)
     return self.portfolio.accounts[account_type]
Exemple #13
0
 def get_account_type(self, order_book_id):
     # 如果新的account_type 可以通过重写该函数来进行扩展
     return get_account_type(order_book_id)
Exemple #14
0
 def get_account(self, order_book_id):
     account_type = get_account_type(order_book_id)
     return self.portfolio.accounts[account_type]
Exemple #15
0
 def get_account(self, order_book_id):
     if not self.portfolio:
         raise NotImplementedError
     account_type = get_account_type(order_book_id)
     return self.portfolio.accounts[account_type]