if settlement_price is None: if "FUTURE" in str(product): settlement_price = 30000 else: settlement_price = 0 pricey = settlement_price depth_level = 1 while depth_level <= 1: for i in range(0, 2): side = aenums.TT_BUY custDefaults = custDefaults0 kwantiteh = 800 if i == 1: side = aenums.TT_SELL custDefaults = custDefaults1 kwantiteh = 1 pricey = (cppclient.TTTick.PriceIntToInt(pricey, contract, +1)) orderParams = dict(order_qty=kwantiteh, buy_sell=side, order_action=aenums.TT_ORDER_ACTION_ADD, limit_prc=pricey, order_type=aenums.TT_LIMIT_ORDER, tif="GTC", srs=contract, exchange_clearing_account=custDefaults.exchange_clearing_account, clearing_mbr=custDefaults.exchange_sub_account, exchange_sub_account=custDefaults.exchange_sub_account, free_text=custDefaults.free_text, acct_type=cppclient.AEnum_Account.TT_ACCT_AGENT_1) newOrder = TTAPIOrder() newOrder.setFields(**orderParams) if i == 0: orderSession0.send(newOrder) else: orderSession0.send(newOrder) depth_level += 1 if create_depth: pricey = (cppclient.TTTick.PriceIntToInt(pricey, contract, +1)) break break
exchange_clearing_account=custDefaults. exchange_clearing_account) #, stop_prc=stop_pricey) newOrder = TTAPIOrder() newOrder.setFields(**orderParams) # newOrder.order_flags = aenums.TT_IF_TOUCHED_MOD_CODE if restriction is not None: newOrder.order_restrict = restriction if tiffy == 'GTDATE': newOrder.order_exp_date = date2_ttDate( datetime.datetime(year=time.localtime()[0], month=time.localtime()[1], day=time.localtime()[2])) newOrder2 = TTAPIOrder() newOrder2.setFields(**orderParams) newOrder2.order_exp_date = date2_ttDate( datetime.datetime(year=time.localtime()[0], month=time.localtime()[1], day=time.localtime()[2] + 1)) orderSession.send(newOrder2) if tiffy == 'IOC': newOrder.order_restrict = aenums.TT_IOC_ORDER_RES # newOrder.tiffy = 'GTD' if tiffy == 'FOK': newOrder.order_restrict = aenums.TT_FOK_ORDER_RES # newOrder.tiffy = 'GTD' orderSession.send(newOrder) exit() # break
newOrderB2.limit_prc = 20500 newOrderB2.buy_sell = aenums.TT_SELL newOrderC1.setFields(**orderParams) newOrderC1.limit_prc = 21001 newOrderD1.setFields(**orderParams) newOrderD1.limit_prc = 21001 newOrderD1.buy_sell = aenums.TT_SELL orderSession.send(newOrderA1) orderSession.send(newOrderA2) time.sleep(180) orderSession.send(newOrderB1) orderSession.send(newOrderB2) time.sleep(120) orderSession.send(newOrderC1) time.sleep(60)
orderParams = dict( order_qty=40, buy_sell=side, order_action=aenums.TT_ORDER_ACTION_ADD, limit_prc=order_prc, order_type=aenums.TT_LIMIT_ORDER, tif="GTD", srs=contract, exchange_clearing_account=custDefaults. exchange_clearing_account, free_text=custDefaults.free_text, acct_type=cppclient.AEnum_Account. TT_ACCT_AGENT_1) newOrder = TTAPIOrder() newOrder.setFields(**orderParams) orderSession.send(newOrder) depth_level += 1 dd += 1 buy_cross_order_prc = (cppclient.TTTick.PriceIntToInt( pricey, contract, +3)) sell_cross_order_prc = (cppclient.TTTick.PriceIntToInt( pricey, contract, -3)) for side in [aenums.TT_SELL, aenums.TT_BUY]: order_prc = sell_cross_order_prc if "SELL" in str( side) else buy_cross_order_prc orderParams = dict( order_qty=40, buy_sell=side, order_action=aenums.TT_ORDER_ACTION_ADD, limit_prc=order_prc, order_type=aenums.TT_LIMIT_ORDER,