def list_cancel_request(self): message = fix.Message() header = message.getHeader() header.setField(fix.BeginString(fix.BeginString_FIX42)) header.setField(fix.MsgType(fix.MsgType_ListCancelRequest)) #35=K message.setField(fix.ListID("List123Test")) message.setField( fix.StringField( 60, (datetime.utcnow().strftime("%Y%m%d-%H:%M:%S.%f"))[:-3]) ) #60 TransactTime, not supported in python, so use tag number print(message.toString()) try: fix.Session.sendToTarget(message, self.sessionID) except (fix.ConfigError, fix.RuntimeError) as e: print(e)
def test_replaceGroup(self): self.object.setField( fix.ListID( "1" ) ) self.object.setField( fix.BidType( 0 ) ) self.object.setField( fix.TotNoOrders( 3 ) ) group = fix42.NewOrderList.NoOrders() group.setField( fix.ClOrdID( "A" ) ) group.setField( fix.ListSeqNo( 1 ) ) group.setField( fix.Symbol( "DELL" ) ) group.setField( fix.Side( '1' ) ) self.object.addGroup( group ) group.setField( fix.ClOrdID( "B" ) ) group.setField( fix.ListSeqNo( 2 ) ) group.setField( fix.Symbol( "LNUX" ) ) group.setField( fix.Side( '2' ) ) self.object.addGroup( group ); group.setField( fix.ClOrdID( "C" ) ) group.setField( fix.ListSeqNo( 3 ) ) group.setField( fix.Symbol( "RHAT" ) ) group.setField( fix.Side( '3' ) ) self.object.addGroup( group ); group.setField( fix.ClOrdID( "D" ) ) group.setField( fix.ListSeqNo( 4 ) ) group.setField( fix.Symbol( "AAPL" ) ) group.setField( fix.Side( '4' ) ) self.object.replaceGroup( 2, group ); noOrders = fix.NoOrders() assert( self.object.hasGroup(1, group) ) assert( self.object.hasGroup(2, group) ) assert( self.object.hasGroup(3, group) ) self.assertEqual( 3, self.object.groupCount(fix.NoOrders().getTag()) ) self.object.getField( noOrders ) self.assertEqual( 3, noOrders.getValue() ) clOrdID = fix.ClOrdID() self.object.getGroup( 1, group ) self.assertEqual( "A", group.getField(clOrdID).getString() ) self.object.getGroup( 2, group ) self.assertEqual( "D", group.getField(clOrdID).getString() ) self.object.getGroup( 3, group ) self.assertEqual( "C", group.getField(clOrdID).getString() )