def __init__( self, market_type, frequence, start, end, code_list, commission_fee, ): self.user = QA_User() self.if_settled = False self.account = None self.portfolio = None self.market = QA_Market() self.market_type = market_type self.frequence = frequence self.broker = QA_BacktestBroker(commission_fee) self.broker_name = 'backtest_broker' self.start = start self.end = end self.code_list = code_list if self.market_type is MARKET_TYPE.STOCK_CN and self.frequence is FREQUENCE.DAY: self.ingest_data = QA_fetch_stock_day_adv( self.code_list, self.start, self.end).to_qfq().panel_gen elif self.market_type is MARKET_TYPE.STOCK_CN and self.frequence[ -3:] == 'min': self.ingest_data = QA_fetch_stock_min_adv( self.code_list, self.start, self.end, self.frequence).to_qfq().panel_gen
def __init__( self, market_type, frequence, start, end, code_list, commission_fee, username='******', password='******', portfolio_cookie='qatestportfolio' ): """ :param market_type: 回测的市场 MARKET_TYPE.STOCK_CN , :param frequence: 'day' '1min' '5min' '15min' '30min' '60min' :param start: 开始日期 :param end: 结束日期 :param code_list: 股票代码池 :param commission_fee: 交易佣金 """ self.user = QA_User(username=username, password=password) self.if_settled = False self.account = None self.portfolio = self.user.new_portfolio(portfolio_cookie) # 🛠todo market_type 应该放在 QA_Market对象里的一个属性 self.market = QA_Market(if_start_orderthreading=True) self.market_type = market_type self.frequence = frequence self.broker = QA_BacktestBroker(commission_fee) self.broker_name = 'backtest_broker' self.start = start self.end = end self.code_list = code_list # 🛠todo 检查start日期和结束end日期是否正确 # 🛠todo 检查code list 是否合法 # 根据 市场类型,回测周期频率, 和股票代码列表 获取回测数据 if self.market_type is MARKET_TYPE.STOCK_CN and self.frequence is FREQUENCE.DAY: # 获取日线级别的回测数据 self.ingest_data = QA_fetch_stock_day_adv( self.code_list, self.start, self.end ).to_qfq().panel_gen elif self.market_type is MARKET_TYPE.STOCK_CN and self.frequence[ -3:] == 'min': # 获取分钟级别的回测数据 self.ingest_data = QA_fetch_stock_min_adv( self.code_list, self.start, self.end, self.frequence ).to_qfq().panel_gen else: QA_util_log_info("{} 的市场类型没有实现!".format(market_type))
def __init__(self, market_type, frequence,): self.user = QA_User() self.if_settled = False self.account = None self.portfolio = None self.market = QA_Market() self.market_type = market_type self.frequence = frequence self.broker = QA_SPEBroker() self.broker_name = 'shipane_broker' self.ingest_data = None
def __init__(self, code, market_type, frequence, broker_name=BROKER_TYPE.SHIPANE, broker=None,): self.user = QA_User() self.if_settled = False self.account = None self.portfolio = None self.market = QA_Market(if_start_orderthreading=True) self.market_type = market_type self.frequence = frequence #self.broker = QA_SPEBroker() self.broker_name = broker_name self.ingest_data = None
def __init__( self, market_type, frequence, start, end, code_list, commission_fee, ): """ :param market_type: 回测的市场 MARKET_TYPE.STOCK_CN , :param frequence: 'day' '1min' '5min' '15min' '30min' '60min' :param start: 开始日期 :param end: 结束日期 :param code_list: 股票代码池 :param commission_fee: 交易佣金 """ self.user = QA_User() self.if_settled = False self.account = None self.portfolio = None self.market = QA_Market() self.market_type = market_type self.frequence = frequence self.broker = QA_BacktestBroker(commission_fee) self.broker_name = 'backtest_broker' self.start = start self.end = end self.code_list = code_list if self.market_type is MARKET_TYPE.STOCK_CN and self.frequence is FREQUENCE.DAY: self.ingest_data = QA_fetch_stock_day_adv( self.code_list, self.start, self.end).to_qfq().panel_gen elif self.market_type is MARKET_TYPE.STOCK_CN and self.frequence[ -3:] == 'min': self.ingest_data = QA_fetch_stock_min_adv( self.code_list, self.start, self.end, self.frequence).to_qfq().panel_gen else: QA_util_log_info("{} 的市场类型没有实现!".format(market_type))