def __init__( self, algo_engine: BaseEngine, algo_name: str, setting: dict ): """""" super().__init__(algo_engine, algo_name, setting) # Parameters self.vt_symbol = setting["vt_symbol"] self.direction = Direction(setting["direction"]) self.stop_price = setting["stop_price"] self.volume = setting["volume"] self.price_add = setting["price_add"] self.offset = Offset(setting["offset"]) # Variables self.vt_orderid = "" self.traded = 0 self.order_status = "" self.subscribe(self.vt_symbol) self.put_parameters_event() self.put_variables_event()
def load_data(self) -> None: """""" position_data = load_json(self.data_filename) for d in position_data: vt_symbol = d["vt_symbol"] direction = Direction(d["direction"]) position = self.get_position(vt_symbol, direction) position.volume = d["volume"] position.price = d["price"]
def start_algo(self): """""" name = self.name_line.text() direction = Direction(self.direction_combo.currentText()) offset = Offset(self.offset_combo.currentText()) price = float(self.price_line.text()) volume = float(self.volume_line.text()) payup = int(self.payup_line.text()) interval = int(self.interval_line.text()) lock_str = self.lock_combo.currentText() if lock_str == "是": lock = True else: lock = False self.spread_engine.start_algo(name, direction, offset, price, volume, payup, interval, lock)
def __init__(self, algo_engine: BaseEngine, algo_name: str, setting: dict): """""" super().__init__(algo_engine, algo_name, setting) # Parameters self.vt_symbol = setting["vt_symbol"] self.direction = Direction(setting["direction"]) self.price = setting["price"] self.volume = setting["volume"] self.time = setting["time"] self.interval = setting["interval"] self.offset = Offset(setting["offset"]) # Variables self.order_volume = self.volume / (self.time / self.interval) self.timer_count = 0 self.total_count = 0 self.traded = 0 self.subscribe(self.vt_symbol) self.put_parameters_event() self.put_variables_event()
def __init__(self, algo_engine: BaseEngine, algo_name: str, setting: dict): """""" super().__init__(algo_engine, algo_name, setting) # Parameters self.vt_symbol = setting["vt_symbol"] self.direction = Direction(setting["direction"]) self.volume = setting["volume"] self.offset = Offset(setting["offset"]) self.min_volume = setting["min_volume"] self.max_volume = setting["max_volume"] if "." in setting["volume_change"]: self.volume_change = float(setting["volume_change"]) else: self.volume_change = int(setting["volume_change"]) # Variables self.vt_orderid = "" self.traded = 0 self.last_tick = None self.order_price = 0 self.put_parameters_event() self.put_variables_event() # Check if min/max volume met if self.min_volume <= 0: self.write_log("最小挂单量必须大于0,算法启动失败") self.stop() return if self.max_volume < self.min_volume: self.write_log("最大挂单量必须不小于最小委托量,算法启动失败") self.stop() return self.subscribe(self.vt_symbol)