I’m trying to split a string returned from the Python implementation of Interactive Broker’s API, but I keep getting a:
AttributeError: 'TickPrice' object has no attribute 'split'
def my_price_handler(msg):
fields=msg.split()
print fields[0]
Checked the API code and (1) msg is a string and (2) ‘split’ is not redefined elsewhere. Msg string looks like this <Tick Price tickerId=1, field=1, price=74.0, canAutoExecute=1> and can be printed to console directly. Same error message when using syntax:
def my_price_handler(msg):
fields=string.split(msg)
print fields[0]
I have imported string at the top of the program.
Is this a variable scope issue?
Clearly,
msgis not a string when it entersmy_price_handler; it’s aTickPrice. Putbefore the
splitcall to convince yourself of this fact.(The fact that
msgcan be printed does not mean it’s a string, if that’s what you thought.)