'How can I send an encoded quickfix message in Python?
I want to send a message encoded in EUC-KR.
So, I tried sending a message using an example/ sample below, but I ended up getting an error.
# https://github.com/fvmt/quickfix-python-sample
def put_order(self):
print("Creating the following order: ")
trade = fix.Message()
trade.getHeader().setField(fix.BeginString(fix.BeginString_FIX42)) #
trade.getHeader().setField(fix.MsgType(fix.MsgType_NewOrderSingle)) #39=D
trade.setField(fix.ClOrdID(self.genExecID())) #11=Unique order
test_msg = '한글테스트'
trade.getHeader().setField(fix.MessageEncoding('EUC-KR')) # MessageEncoding
trade.setField(fix.EncodedTextLen(len(test_msg.encode('euc-kr'))))
trade.setField(fix.EncodedText(test_msg.encode('euc-kr')))
trade.setField(fix.HandlInst(fix.HandlInst_MANUAL_ORDER_BEST_EXECUTION)) #21=3 (Manual order, best executiona)
trade.setField(fix.Symbol('SMBL')) #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(100)) #38=100
trade.setField(fix.Price(10))
trade.setField(fix.TransactTime(int(datetime.utcnow().strftime("%s"))))
print (trade.toString() )
fix.Session.sendToTarget(trade, self.sessionID)
I got the following error message
Your Input : Successful Logon to session 'FIX.4.3:CLIENT1->EXECUTOR'.
1
Putin Order
Creating the following order:
Traceback (most recent call last):
File "client.py", line 903, in <module>
args = parser.parse_args()
File "client.py", line 880, in main
print ("Putin Order")
File "client.py", line 142, in put_order
trade.setField(fix.EncodedTextLen(len(test_msg.encode('euc-kr'))))
File "C:\ProgramData\Anaconda3\lib\site-packages\quickfix.py", line 40319, in __init__
quickfix.StringField.__init__(self, 355, data)
File "C:\ProgramData\Anaconda3\lib\site-packages\quickfix.py", line 910, in __init__
this = _quickfix.new_StringField(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_StringField'.
Possible C/C++ prototypes are:
FIX::StringField::StringField(int,std::string const &)
FIX::StringField::StringField(int)
How can I solve this problem?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|