示例#1
0
    def init_account(self) -> AccountStats:
        trader_info = get_trader_info(session=self.session,
                                      trader_name=self.trader_name,
                                      return_type='domain',
                                      limit=1)

        if trader_info:
            self.logger.warning(
                "trader:{} has run before,old result would be deleted".format(
                    self.trader_name))
            self.session.query(TraderInfo).filter(
                TraderInfo.trader_name == self.trader_name).delete()
            self.session.query(AccountStats).filter(
                AccountStats.trader_name == self.trader_name).delete()
            self.session.query(Position).filter(
                Position.trader_name == self.trader_name).delete()
            self.session.query(Order).filter(
                Order.trader_name == self.trader_name).delete()
            self.session.commit()

        return AccountStats(entity_id=f'trader_zvt_{self.trader_name}',
                            timestamp=self.start_timestamp,
                            trader_name=self.trader_name,
                            cash=self.base_capital,
                            input_money=self.base_capital,
                            all_value=self.base_capital,
                            value=0,
                            closing=False)
示例#2
0
    def clear_account(self):
        trader_info = get_trader_info(session=self.session,
                                      trader_name=self.trader_name,
                                      return_type='domain',
                                      limit=1)

        if trader_info:
            self.logger.warning(
                "trader:{} has run before,old result would be deleted".format(
                    self.trader_name))
            clear_trader(session=self.session, trader_name=self.trader_name)
示例#3
0
文件: factor_app.py 项目: zvtvz/zvt
def load_traders():
    global traders
    global trader_names

    traders = get_trader_info(return_type="domain")
    account_readers.clear()
    order_readers.clear()
    for trader in traders:
        account_readers.append(AccountStatsReader(level=trader.level, trader_names=[trader.trader_name]))
        order_readers.append(
            OrderReader(start_timestamp=trader.start_timestamp, level=trader.level, trader_names=[trader.trader_name])
        )

    trader_names = [item.trader_name for item in traders]
示例#4
0
def load_traders(region):
    global traders
    global trader_names

    traders = get_trader_info(region=region, return_type='domain')
    account_readers.clear()
    order_readers.clear()
    for trader in traders:
        account_readers.append(
            AccountStatsReader(region=region,
                               trader_names=[trader.trader_name],
                               level=trader.level))
        order_readers.append(
            OrderReader(region=region,
                        trader_names=[trader.trader_name],
                        level=trader.level,
                        start_timestamp=trader.start_timestamp,
                        end_timestamp=trader.end_timestamp))

    trader_names = [item.trader_name for item in traders]