- ago
Hello,

So I am working on a strategy that will use both long and short positions. The problem is that when experimenting with buying/selling/shorting/covering on Interactive brokers, it only seems to register buying or shorting. The other commands don't seem to register when I enter them manually. I tried setting up a strategy for the first time and it just accumulated short positions (even though it is set to only have one open long and one open short at any time).

Is there something I am missing?

Thanks!
Dandude
0
524
Solved
16 Replies

Reply

Bookmark

Sort
- ago
#1
Hi,

For troubleshooting, we need a sequence of actions and results. So, a number of things are missing:

1. First, what does it mean "doesn't seem to" precisely?
2. Is there an error message? What does the log contain for IB (Tools menu > Log viewer)?
3. What does the strategy look like (assuming Blocks)?
4. What is the data loading range (maybe it's not enough)?
0
Cone8
 ( 4.18% )
- ago
#2
QUOTE:
Is there something I am missing?
We could tell you if we were able to review your code.

It's important to keep your strategy in sync with your live positions. There are some Portfolio Sync Trading Preferences, but it's about to get even better in build 28 with the Live Positions option:


That said, keep in mind that if you place a "Sell" at IB and don't have a Long Position to offset it, you'll get a Short position. In fact, only "Buy" and "Sell" exists for IB and WealthLab's IB Provider adapts the signals for that.
0
- ago
#3
Funny how these things work. I had written the entire response below and then did an experiment and fixed the problem. I was using the IB symbol MNQH3 (MESH3 also has these problems) and it had particular errors described above and below. However when changing to the WL symbol MNQH23 (or MESH23), everything seems to be working correctly! I am providing my description below for the programmers so they can see if its a fix they want to make:

Written before solving:
Hello, thanks for your response. My guess is it is related to some of my other issues trying to trade this futures contract, the MNQH3. It sounds like there may be some fixes coming. I hope there is something I can do on my end to get it working.

1. Doesn't seem to as in it does not put in the order. It does flash the order on the order manager, but nothing happens on the broker's end (using sell or cover). Buy functions correctly on a manual order, and short works as well. As Cone mentioned, IB only uses buy or sell so it appears that buy is functioning correctly, but only "short" works as a sell button. This also prevents block strategies from functioning.

2. I believe the related error is :
"1/17/2023 15:14:22:505" "InteractiveBrokers" "10197: No market data during competing live session" However this message is not appearing exactly when I press the sell or cover buttons.

3. The strategy is simple, as a test basically. Where there is a buy with a single condition, then a sell with a single condition, then a short with a single condition, and finally a cover with a single condition.

4. I don't think the data is the issue, but I have had data issues with this ticker so it is possible.

Finally, I don't think the live positions are related. These buttons do not work regardless of whether I already have a short or long position.

Note: All of these tests are using the paper trading mode on Interactive Brokers.

Hope you guys have some ideas. I think I will now attempt this strategy and manual buying/selling on other symbols.

Thanks!
Daniel

0
Best Answer
Cone8
 ( 4.18% )
- ago
#4
Dandude, I've created thousands of trades (even hundreds today) on those symbols in various strategies. The only difference between the symbols is the futures margin required.

Show us the code, we can't help without starting there. Even a simple strategy can have logic problems.
0
- ago
#5
As I mentioned, the main problem was that the manual orders were not working for sell/cover. This problem was fixed by using MNQH23 instead of MNQH3. I did restart the program a couple of times to get a couple of other bugs to work. Also I should note that MNQ#C is still not allowing me to backtest my ideas (the data will not load).
0
Cone8
 ( 4.18% )
- ago
#6
Sorry that I missed the comment about the symbol. It's recommended to always use the 2-digit year in the symbol, and you should consider that a requirement when trading. It's discussed in the Help (F1) > Interactive Brokers.

If there's trouble with a particular symbol for which you have data permissions, try this:

First, check the Log Viewer for messages (Ctrl+L). Is there any message about the symbol you're requesting? If not...

1. Help > Open Wealth-Lab User Data Folder
2. Close Wealth-Lab
3. Open the IBContracts.txt file
4. Look for a record that starts with your symbol, MNQ#C in this case, and if it exists, delete that line, save the file.
5. If it's it's not a U.S. Stock or Futures symbol (or it's a Futures symbol not found in IBFutures.txt), then you need create the record manually or use the explicit symbology discussed in the Help.
6. Try again - and as always with data from IB, be very patient if you're requesting more than a few thousand bars.
0
Cone8
 ( 4.18% )
- ago
#7
Something to check before you do that procedure. In the IBContracts.txt file, search for GLOBEX. Does it appear in the CME record? Just replace it with CME wherever it appears, save, and then try.
0
- ago
#8
Thanks for your response.

I would prefer to keep my code private so I have deleted the code from my previous post.

The contract MNQ does not appear in the IBContracts.txt file. It does appear in the IBFutures.txt file, but MNQ#C does not. I am not sure what section of help you are referring to but I am now using MNQH23 whenever possible. However I cannot do deep backtesting on that symbol like I could with MNQ#C, which is what I would like to do.

Thanks,
Dandude
0
- ago
#9
GLOBEX does not appear in either file.
0
Cone8
 ( 4.18% )
- ago
#10
What does the Log Viewer say when requesting that #C symbol?

We tried to take care of IB's exchange consolidation changes transparently, but I just found an error that prevented some of it. So do this change manually:

1. In the User Data folder folder open the IBFutures.txt file
2. Close Wealth-Lab.
3. Look for the MNQ record near the top - should be around line 20. Does it look like this with GLOBEX?
MNQ|USD|FUT|GLOBEX||MNQ|||0|2

If that shows GLOBEX, do a global search and replace for GLOBEX and replace with CME. Save the file and try again.

That record should be:
MNQ|USD|FUT|CME||MNQ|||0|2
0
- ago
#11
The record is correct as you described it.
0
Cone8
 ( 4.18% )
- ago
#12
Okay, is anything added to the Log Viewer when your request MNQ#C?
How about NQ#C?

You can quickly open the Log Viewer by striking Ctrl+L.
0
- ago
#13
I just did a bit of experimenting beyond the 5 minute level and found that these symbols will allow me to get data for the daily timeframe all the way down to the 10 minute timefram for a longer period (I have now loaded data back to 9/19/2022 for the 10 minute). However, when using 5 minute bars, I get the same results with both MNQ#C and NQ#C which is it will only give me data back to 12/11/2022.

There is no log entry when the data range fails to load, it simply cuts off at that date. I know I have read in other threads that IB throttles and cuts off data so it is quite possible that that is the problem here (it is well over 10000 bars). It is just unfortunate that it appears to only affect this symbol for whatever reason.

Now that I have discovered I can use the data from the 10 minute, it is a workaround that will allow me to do some more testing but it will not be the exact testing I would like (5 minute and even 1 minute). Hopefully this specific information will help you see where in the code it might be going wrong.

0
Cone8
 ( 4.18% )
- ago
#14
You know, there's a big difference between "(the data will not load)" and "it will only give me data back to 12/11/2022". When IB doesn't return the data for a request, that's all you get.

If you really want to get a bunch of data to work with, get an IQFeed subscription for a month, and download 10 years or more of continuous contract data. Even for the symbols that work, you'll never get more than 2 years of futures from IB.
0
- ago
#15
Sure. Sorry for the confusion. I simply had not tested it. Sounds like IQfeed, while expensive, might be my best option.
0
Cone8
 ( 4.18% )
- ago
#16
For lots of data and reliable streaming, IQFeed is worth the cost, even if only to build histories for backtesting. Later, if you're only trading a few dozen contracts or less, IB works fine for that.
0

Reply

Bookmark

Sort