Esempio n. 1
0
    def save_market_states(self, config_file_path: str, market: ConnectorBase, session: Session):
        market_states: Optional[MarketState] = self.get_market_states(config_file_path, market, session=session)
        timestamp: int = self.db_timestamp

        if market_states is not None:
            market_states.saved_state = market.tracking_states
            market_states.timestamp = timestamp
        else:
            market_states = MarketState(config_file_path=config_file_path,
                                        market=market.display_name,
                                        timestamp=timestamp,
                                        saved_state=market.tracking_states)
            session.add(market_states)
    def save_market_states(self, config_file_path: str, market: MarketBase, no_commit: bool = False):
        session: Session = self.session
        market_states: Optional[MarketState] = self.get_market_states(config_file_path, market)
        timestamp: int = self.db_timestamp

        if market_states is not None:
            market_states.saved_state = market.tracking_states
            market_states.timestamp = timestamp
        else:
            market_states = MarketState(config_file_path=config_file_path,
                                        market=market.name,
                                        timestamp=timestamp,
                                        saved_state=market.tracking_states)
            session.add(market_states)

        if not no_commit:
            session.commit()