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)}')
    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)}')
Exemple #3
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))
 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
 def toAdmin(self, message, sessionID):
     msgType = fix.MsgType()
     message.getHeader().getField(msgType)
     if (msgType.getValue() == fix.MsgType_Logon):
         message.setField(
             fix.Password(
                 settings.get(self.sessionID).getString("Password")))
         message.setField(fix.ResetSeqNumFlag(True))
Exemple #6
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
Exemple #7
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
Exemple #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
Exemple #9
0
 def toAdmin(self, message, sessionID):
     try:
         msgType = fix.MsgType()
         message.getHeader().getField(msgType)
         if msgType.getValue() == fix.MsgType_Logon:
             uuid = self.Settings.get().getString('Username')
             password = self.Settings.get().getString('Password')
             message.getHeader().setField(fix.Password(password))
             message.getHeader().setField(fix.StringField(12003, uuid))
         self.Logger.info(
             "Sending Admin message to server. Session: %s. Message: %s" %
             (sessionID, message))
         self.__messageStore.addRequest(message)
     except fix.RuntimeError as e:
         self.Logger.error('Error in toAdmin', e)
     return
Exemple #10
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
Exemple #11
0
    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)