def test_order_trade_task(): from jaqs.data.basic import TradeStat, Trade, Task, TaskInd, Order, OrderStatusInd order = Order() order.symbol = 'SPY' order.task_id = 10000001 order.entrust_no = '123' order.entrust_size = 10 order.entrust_action = 'Short' order.entrust_price = 1.2 order.entrust_time = 95055 order.entrust_date = 20171201 order.fill_price = 1.19 order.fill_size = 3 order.commission = 0.001 str(order) o2 = Order(order) o2.entrust_no = '124' o3 = Order.new_order('SPY', 'Buy', 10, 10, 20111111, 143029, 'Limit') oind = OrderStatusInd(order) OrderStatusInd.create_from_dict({'symbol': 'SPY'}) str(oind) task = Task(order.task_id, 'vwap', {'a': 'b'}, order, 'place_order', order.entrust_date) assert (not task.is_finished) task.task_status = common.TASK_STATUS.DONE assert task.is_finished tind = TaskInd(task.task_id, task.task_status, task.algo, 'success') str(tind) tind2 = TaskInd.create_from_dict({'task_id': 2011223}) trade = Trade(order) trade.set_fill_info(15, 20, 20171202, 112311, 12345) str(trade) t2 = Trade.create_from_dict({'symbol': 'SPY'}) tstat = TradeStat() str(tstat)
def on_trade(self, ind_dic): """ Parameters ---------- ind_dic : dict """ # print("\nGateway on trade: ") # print(ind_dic) if 'security' in ind_dic: ind_dic['symbol'] = ind_dic.pop('security') ind = Trade.create_from_dict(ind_dic) self.ctx.strategy.on_trade(ind)
def on_trade(self, ind_dic): """ Parameters ---------- ind_dic : dict """ # print("\nGateway on trade: ") # print(ind_dic) if 'security' in ind_dic: ind_dic['symbol'] = ind_dic.pop('security') ind = Trade.create_from_dict(ind_dic) self.ctx.strategy.on_trade(ind)
def test_order_trade_task(): from jaqs.data.basic import TradeStat, Trade, Task, TaskInd, Order, OrderStatusInd order = Order() order.symbol = 'SPY' order.task_id = 10000001 order.entrust_no = '123' order.entrust_size = 10 order.entrust_action = 'Short' order.entrust_price = 1.2 order.entrust_time = 95055 order.entrust_date = 20171201 order.fill_price = 1.19 order.fill_size = 3 order.commission = 0.001 str(order) o2 = Order(order) o2.entrust_no = '124' o3 = Order.new_order('SPY', 'Buy', 10, 10, 20111111, 143029, 'Limit') oind = OrderStatusInd(order) OrderStatusInd.create_from_dict({'symbol': 'SPY'}) str(oind) task = Task(order.task_id, 'vwap', {'a': 'b'}, order, 'place_order', order.entrust_date) assert (not task.is_finished) task.task_status = common.TASK_STATUS.DONE assert task.is_finished tind = TaskInd(task.task_id, task.task_status, task.algo, 'success') str(tind) tind2 = TaskInd.create_from_dict({'task_id': 2011223}) trade = Trade(order) trade.set_fill_info(15, 20, 20171202, 112311, 12345) str(trade) t2 = Trade.create_from_dict({'symbol': 'SPY'}) tstat = TradeStat() str(tstat)
def on_trade(self, ind_dic): """ Parameters ---------- ind_dic : dict """ # print("\nGateway on trade: ") # print(ind_dic) if 'security' in ind_dic: ind_dic['symbol'] = ind_dic.pop('security') ind = Trade.create_from_dict(ind_dic) ind.task_no = self._task_no_id_map[ind.task_id] e = Event(EVENT_TYPE.TRADE_IND) e.dic['ind'] = ind self.ctx.instance.put(e)