示例#1
0
    def toAdmin(self, message, sessionID):
        """Get all the session level messages before they are sent to the FIX server.
		This includes Logon, Logout, Heartbeat etc.
		
		Arguments:
			message {object} -- message object
			sessionID {object} -- Session identifier object
		"""

        self.logger.info(
            f'[KERNEL] Sending the admin message: {parse_fix_message(message)}'
        )

        msgType = fix.MsgType()
        message.getHeader().getField(msgType)

        if msgType.getValue() == fix.MsgType_Logon:
            print(f'{self._client_str} Sending Logon request.')

            message.setField(fix.Username(self.username))
            message.setField(fix.Password(self.password))

        elif msgType.getValue() == fix.MsgType_Logout:
            print(f'{self._client_str} Sending Logout request.')

        elif msgType.getValue() == fix.MsgType_Heartbeat:
            print(f'{self._client_str} Heartbeart!')

        else:
            print(f'[KERNEL] [toAdmin] {parse_fix_message(message)}')
示例#2
0
    def toAdmin(self, m: fix.Message, session_id: fix.SessionID):
        if self.username and self.password:
            if m.getHeader().getField(
                    fix.MsgType().getTag()) == fix.MsgType_Logon:
                m.setField(fix.Username(self.username))
                m.setField(fix.Password(self.password))

        if self.autofix_sequence_numbers:
            text_tag = fix.Text().getTag()
            is_seqnum_too_low = (
                m.getHeader().getField(fix.MsgType().getTag())
                == fix.MsgType_Logout and m.isSetField(text_tag)
                and m.getField(text_tag).startswith("MsgSeqNum too low"))

            if is_seqnum_too_low:
                needed_seqnum = int(
                    re.match(
                        "MsgSeqNum too low, expecting (\d+) but received (\d+)",
                        m.getField(text_tag))[2])

                self.log_message("toAdmin", m, session_id, levelize=False)
                logger.warning(
                    f"Resetting MsgSeqNum to {needed_seqnum} as needed. Wait for reconnect..."
                )

                self.session.setNextTargetMsgSeqNum(needed_seqnum)
                return

        self.log_message("toAdmin", m, session_id)
        self.outgoing_messages.put(fix.Message(m))
示例#3
0
    def toAdmin(self, message, sessionID):

        if self.verbose:
            print(f'[toAdmin] {sessionID} | {read_FIX_message(message)}')

        log(self.logger,
            f'[toAdmin] {sessionID} | {read_FIX_message(message)}')

        msgType = fix.MsgType()
        message.getHeader().getField(msgType)

        base_str = self._client_str + ' ' + sessionID.toString() + ' | '

        if msgType.getValue() == fix.MsgType_Logon:

            print(self._client_str + 'Sending LOGON Request')

            # set login credentials
            username = self.settings.get(sessionID).getString('Username')
            password = self.settings.get(sessionID).getString('Password')
            message.setField(fix.Username(username))
            message.setField(fix.Password(password))

        elif msgType.getValue() == fix.MsgType_Logout:

            print(self._client_str + 'Sending LOGOUT Request')

        elif (msgType.getValue() == fix.MsgType_Heartbeat):

            if self.verbose:
                print(self._client_str + 'Heartbeat!')

        else:
            print(f'[toAdmin] {sessionID} | {read_FIX_message(message)}')
 def toAdmin(self, message, sessionID):
     username = fix.Username("YOUR API KEY")
     mypass = fix.Password("YOUR API SECRET")
     message.setField(username)
     message.setField(mypass)
     msg = message.toString().replace(__SOH__, "|")
     return
示例#5
0
    def toAdmin(self, message, sessionID):
        username = fix.Username(api_key)
        password = fix.Password(secret_key)
        message.setField(username)
        message.setField(password)

        #print "Sent the Admin following message: %s" % message.toString()
        return
示例#6
0
    def toAdmin(self, message, sessionID):
        msgType = fix.MsgType ()
        message.getHeader().getField(msgType)
        if (msgType.getValue () == fix.MsgType_Logon):
            print('Logging on.')
   
            message.setField(fix.Password('WHITE@2020'))
            message.setField(fix.Username('WHITE_FIX_QS'))        
            message.setField (fix.ResetSeqNumFlag (True))   

        # logfix.info("S toAdmin >> %s" % message.toString())
        return
示例#7
0
 def logout_msg(sender_comp_id, target_comp_id, username_client, ):
     global ntwk_id
     logout_req = fix.Message()
     logout_req.getHeader().setField(fix.BeginString(fix.BeginString_FIXT11))
     logout_req.getHeader().setField(fix.MsgType(fix.MsgType_Logout))
     logout_req.setField(fix.SenderCompID(sender_comp_id))
     logout_req.setField(fix.TargetCompID(target_comp_id))
     logout_req.setField(fix.MsgSeqNum(5))
     logout_req.setField(fix.Username(username_client))
     logout_req.setField(fix.NetworkResponseID("%s" % ntwk_id))
     logout_req = bytes(logout_req.toString(), encoding="UTF-8")
     return logout_req
示例#8
0
 def toAdmin(self, message, sessionID):
     self.sessionID = sessionID
     self.message = message
     print("toAdmin - message: " + message.toString() + " sessionID:" + sessionID.toString())
     
     beginString = fix.BeginString()
     msgType = fix.MsgType()
     message.getHeader().getField(beginString)
     message.getHeader().getField(msgType)
     if msgType.getValue() == 'A':
         message.setField(fix.Username('sgmmDEMOSOMFXTRADESTR1'))
         message.setField(fix.Password('Stater123'))
         pass
示例#9
0
    def toAdmin(self, message, sessionID):
        msg = message.toString().replace(__SOH__, "|")
        print("to admin called:" + msg)
        msgType = message.getHeader().getField(quickfix.MsgType().getField())
        print("Message Type : " + str(msgType))

        if msgType == quickfix.MsgType_Logon:

            sender_comp_id = message.getHeader().getField(
                quickfix.SenderCompID().getField())
            message.setField(quickfix.Username(sender_comp_id))
            message.setField(quickfix.Password("TEST"))

        msg = message.toString().replace(__SOH__, "|")
        print("to admin called:")
        print("Thread ID: " + str(threading.get_ident()))
        print("to admin called: " + sessionID.toString() + " : " + msg)
        return
示例#10
0
文件: initiator.py 项目: xbee/parity
    def put_order(self):
        print("Creating the following order: ")
        trade = fix.Message()
        trade.getHeader().setField(fix.BeginString(fix.BeginString_FIX44))  #
        trade.getHeader().setField(fix.MsgType(
            fix.MsgType_NewOrderSingle))  #39=D
        trade.setField(fix.ClOrdID(self.genExecID()))  #11=Unique order

        trade.setField(fix.HandlInst(fix.HandlInst_MANUAL_ORDER_BEST_EXECUTION)
                       )  #21=3 (Manual order, best executiona)
        trade.setField(fix.Symbol('BTC-USD'))  #55=SMBL ?
        trade.setField(fix.Side(fix.Side_BUY))  #43=1 Buy
        trade.setField(fix.OrdType(fix.OrdType_LIMIT))  #40=2 Limit order
        trade.setField(fix.OrderQty(10))  #38=100
        trade.setField(fix.Price(9000))
        trade.setField(fix.Username("pairty"))
        trade.setField(fix.Password("pairty"))
        print trade.toString()
        fix.Session.sendToTarget(trade, self.sessionID)
示例#11
0
 def logon_msg(sender_comp_id, target_comp_id, username_client, response_id_network):
     if response_id_network is None:
         response_id_network = int((numpy.random.random()) * 100000)
     global ntwk_id
     ntwk_id = response_id_network
     _message_logger.info("Logon with response id: %s" % response_id_network)
     _message_logger.debug("Building logon message")
     logon_req = fix.Message()
     logon_req.getHeader().setField(fix.BeginString(fix.BeginString_FIXT11))
     logon_req.getHeader().setField(fix.MsgType(fix.MsgType_Logon))
     logon_req.setField(fix.SenderCompID(sender_comp_id))
     logon_req.setField(fix.TargetCompID(target_comp_id))
     logon_req.setField(fix.MsgSeqNum(1))
     logon_req.setField(fix.UserRequestType(1))
     logon_req.setField(fix.HeartBtInt(1))
     logon_req.setField(fix.Username(username_client))
     logon_req.setField(fix.NetworkResponseID("%s" % response_id_network))
     logon_req.setField(fix.DefaultApplVerID(fix.ApplVerID_FIX50SP2))
     logon_req.setField(1701, "1")
     logon_req.getTrailer().setField(fix.MarketID("2"))
     logon_req.setField(fix.DefaultApplVerID("FIX.5.0SP2"))
     logon_req = bytes(logon_req.toString(), encoding="UTF-8")
     _message_logger.debug("Logon message built")
     return logon_req
 def toAdmin(self, message, sessionID):
     msg_type = message.getHeader().getField(fix.MsgType()).getString()
     if msg_type == fix.MsgType_Logon:
         message.setField(fix.Username(USERNAME))
         message.setField(fix.ResetSeqNumFlag(True))