I put live an automated system today using Interactive Brokers (IB) Paper Trading and NT8, and have a bunch of questions from this first day that I'm hoping to ask for help with please (please let me know if I should break them into different tickets).
1. Disconnected from IB > Failed to Reconnect > Locked out of IB account: I logged into Trader Workstation using my IB Paper Details, connected via Connections, set off a strategy across 50 instruments - it bought/sold various (e.g. established its working). After running ok for an hour I left it alone for the day then after regular hours I came back to my PC to find various errors and Interactive Brokers 'failed login' messages. NT showed the IB Paper connection as red, while IB Trader Workstation was showing 'failed login' and 'password reset' messages. Within connections I clicked to fully disconnect the (now not connected/red) IB Paper Account connection, then closed down Trader Workstation and opened it back up again. I tried to log back into IB Trader Workstation but it wouldn't let me ("Invalid username or password.") despite it 100% being the same password I'd used earlier. I needed to reset my IB password to get back in again. I contacted IB Support to try and see from their end what happened, but most likely the connection dropped with NT and repeated attempts to login probably locked the account (requiring password reset). How can I try to debug what happened here please so that it doesn't happen again? (the log info isn't clear when it tried to reconnect and how many times it attempted to)
2021-11-19 17:35:40:248|1|32|Order='1516746908/DU1529868' Name='ExitBuyLong_NewProfitStoploss1' New state='Accepted' Instrument='RIOT' Action='Sell' Limit price=0 Stop price=0 Quantity=688 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' 2021-11-19 17:36:10:142|1|2|My Paper Interactive Brokers: Primary connection=Connection lost, Price feed=Connected 2021-11-19 19:28:13:231|1|16|NinjaScript strategy 'MyVolumeSRv1/238461238' submitting order 2021-11-19 19:28:13:231|1|32|Order='2bc96a2667804804bccfb05b4 6285526/DU1529868' Name='ExitBuyLong_NewProfitStoploss1' New state='Rejected' Instrument='VIAC' Action='Sell' Limit price=0 Stop price=0 Quantity=744 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='Unable to submit order' Native error='Order '2bc96a2667804804bccfb05b46285526' can't be submitted: account is not connected.' 2021-11-19 19:28:13:231|0|32|DU1529868, Order '2bc96a2667804804bccfb05b46285526' can't be submitted: account is not connected. affected Order: Sell 744 Market 2021-11-19 19:28:13:231|0|4|Strategy 'MyVolumeSRv1/238461238' submitted an order that generated the following error 'Unable to submit order'. Strategy has sent cancel requests, attempted to close the position and terminated itself. 2021-11-19 19:28:13:232|1|4|Disabling NinjaScript strategy 'MyVolumeSRv1/238461238' 2021-11-19 19:28:13:232|1|32|Order='1516746840/DU1529868' Name='Stop loss' New state='Accepted' Instrument='VIAC' Action='Sell' Limit price=0 Stop price=33.51 Quantity=744 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='Unable to cancel order' Native error='Unable to cancel order 1516746840: account is not connected.' 2021-11-19 19:28:13:232|0|32|DU1529868, Unable to cancel order 1516746840: account is not connected. affected Order: Sell 744 StopMarket @ 33.51 2021-11-19 19:28:13:234|1|32|Order='1516746840/DU1529868' Name='Stop loss' New state='Accepted' Instrument='VIAC' Action='Sell' Limit price=0 Stop price=33.51 Quantity=744 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='Unable to cancel order' Native error='Unable to cancel order 1516746840: account is not connected.' 2021-11-19 19:28:13:234|0|32|DU1529868, Unable to cancel order 1516746840: account is not connected. affected Order: Sell 744 StopMarket @ 33.51 2021-11-19 19:28:21:902|0|4|Strategy 'MyVolumeSRv1/238461238' submitted a cancellation request for Order ID 'orderId='1516746840' account='DU1529868' name='Stop loss' orderState=Accepted instrument='VIAC' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=33.51 quantity=744 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=708 time='2021-11-19 19:28:13' gtd='2099-12-01' statementDate='2021-11-19'' which has not been confirmed cancelled. Please check your account orders and positions. 2021-11-19 19:47:51:994|0|2|My Paper Interactive Brokers: Lost or unable to establish communications with IB TWS/GW. Please verify TWS/GW is running on the target machine and try reconnecting or contact support if the issue persists. (Panic) 2021-11-19 19:47:51:994|1|2|My Paper Interactive Brokers: Primary connection=Disconnecting, Price feed=Connected 2021-11-19 19:47:52:016|1|2|My Paper Interactive Brokers: Primary connection=Disconnecting, Price feed=Disconnecting 2021-11-19 19:47:52:033|1|2|My Paper Interactive Brokers: Primary connection=Disconnected, Price feed=Disconnected
2. I'd like to source my live data from IQFeed and place trades with Interactive Brokers. In the strategy pane I couldn't find how to achieve this, I could only select my IB 'account' and then the connection showed as 'My Paper Interactive Brokers'. Please could you advise how I can achieve this?
3. I'm aiming to run my strategy across ~50 instruments, and using the strategy pane (no charts for computing efficiency). If I decide that I want to open up one of the instruments that a strategy is using on a chart, is this possible to do without affecting the trading? E.g. the strategy pane is showing stock ABC is up $1000, I want to check in on it to see what is happening and see on a chart why the position was entered (or why it hasn't stopped). I was nervous that opening ABC in a chart and applying the strategy may cause the system to think the strategy is running twice (and when exiting, it'd accidentally place two sales and inadvertently go short), so wondering the best way to do this please?
4. Likely a silly question so apologies in advance. Today I went to the strategy pane, selected my strategy, selected my instrument list of 50 instruments, and it populated 50 rows in the strategy pane that I had to tick one by one to 'enable'. Am I doing this correctly? (it felt a bit odd that had to do this one by one but couldn't see how to do all in one). Similarly, lets say I want to end the day early, so need to disable all strategies and close all open positions. Is the correct process to A) untick the 'enabled' box one by one, then B) go to the Accounts Tab and 'Close All Selected Positions'?
5a. I understand that getting the available Buying Power of an account is something akin to: "myBuyingPower = Account.Get(AccountItem.BuyingPower, Currency.UsDollar);"
For backtesting I'm currently using "myBuyingPower = 50000;" - how can I code the strategy to detect if its in backtest or live mode please? E.g. I'm hoping to have something like:
if (Live == true) myBuyingPower = Account.Get(AccountItem.BuyingPower, Currency.UsDollar);
if (Live == false) myBuyingPower = 50000;
5b. Is it possible to recreate/reflect Buying Power in the Strategy Analyzer backtesting for a basket of instruments? For example, in backtesting against a list of 50 instruments, to set the Buying Power at $50,000, then after 5x $10,000 positions are open by 10am, to have Buying Power updated to $0 so that a 6th position cannot be opened (as this is what would happen in a live trading environment). I haven't fully wrapped my head around whether Strategy Analyzer is running 50 independent strategies, or running 50 in parallel.
Many thanks in advance
ChainsawDR
Comment