Hi everyone. I decided to start working again on something that was almost finished on IB API. I´m not the coder, just altering loging and fine tuning it. Turns out I got this error today that wasn´t triggering a few days ago and I dont get why. This is the error, hapening for each ticker the algo trades: in initialise_trade_list_from_broker_data original_order_id = int(entry_order_ref.split('_')[1]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'ENTRY' I have no idea how this has happened, This is the relevant part of the code containing the entry.order.ref stuff: # overwrite __init__ generated values of Trade object t.datetime_stamp = entry_order_ref.split('_')[2] # TODO: trade_datetime must be timezone aware, to enable comparison with live trades t.trade_datetime = datetime.strptime(t.datetime_stamp, '%Y%m%d-%H%M%S').replace(tzinfo=ZoneInfo(key='US/Central')) # reconstruct trades from orphaned callbacks reconstructed_trades = [] for entry_order_ref, order_details in orphaned_orders.items(): if 'ENTRY' in entry_order_ref: # collect trade parameters contract = order_details[1] entry_order_object = order_details[2] trade_id = int(entry_order_ref.split('_')[0]) original_order_id = int(entry_order_ref.split('_')[1]) cancel_price = float(entry_order_ref.split('_')[4]) Any idea what is going on here? Thanks!
You can't convert "ENTRY" into an int. You can convert "7" into an int. You can convert "3" into an int. You can convert "384734" into an int. Trace the code, presumably the split, and see what's going wrong. For more help meet me in the politics forum
I´m sorry, im just fine tuning this logic wise, i didn´t build this but it used to work. I dont understand why it is not running now. Can you help me out? thanks
The benefits of using a shit language like Python. Any proper language that uses strong typing would point straight away that you are trying to convert a string literal to an int. Since you are using a shit language that lets you send anything to that function, it blows up at runtime. A marvelous thing. It will never cease to amaze me that people use Python for trading. Spy actually gave you the reason why it is failing.
I understand, I just don´t know how to fix it and that is why I am asking for your help. Anyways it used to run, I dont get it. What can I do? I get the logic but this is structural, I dont understand it.
Where do I place that print code? here? # overwrite __init__ generated values of Trade object t.datetime_stamp = entry_order_ref.split('_')[2] or here? # collect trade parameters contract = order_details[1] entry_order_object = order_details[2] trade_id = int(entry_order_ref.split('_')[0]) original_order_id = int(entry_order_ref.split('_')[1]) cancel_price = float(entry_order_ref.split('_')[4]) Sorry, this is not my cup of tea... Thanks for helping out!
On that line that you posted there is a function that is converting a value from the array to an int. The value that is being taken from the array is a string literal, it is a different type than an int. So it fails. You have to debug the array and find out which position holds the value you are after. Or hire a developer to fix it for you.
Thanks for your input. I would prefer not to have this going around. The guy that did this and I did not finish 100% in good terms so I would like to avoid asking him. Is it technically difficult to investigate and fix?