Automated trading with Interactive Broker and ProRealTime – NOW AVAILABLE
Forums › ProRealTime English forum › ProOrder support › Automated trading with Interactive Broker and ProRealTime – NOW AVAILABLE
- This topic has 129 replies, 28 voices, and was last updated 3 months ago by Morpheous.
Tagged: futures, IB, interactive broker, proorder
-
-
09/29/2023 at 1:43 PM #221803
hi Peter,
don’t really know what to tell more specific, above mentioned happened on the very real account with very real money 😀 today in the morning and my algo did not try to turn position from long to short, just another exit order with stop level had to be placed by algo closer to breakeven and that one was rejected, and system stopped by that rejection, with the comment in the order-list: ” The order was rejected for the following reason: Your funds currently available … EUR are insufficient to cover the total margin of … EUR that would be required on your account to place this order. Note : total margin takes into account any already open positions and/or existing pending orders.”
so I am a bit lost, I understood that every pending order is “reserving” some margin, not just margin required to keep a position. as mentioned, I have alsmost double amount in the account vs what’s needed to keep position overnight. strange enough, after re-activing the algo, another trades were triggered, and none of them were closed because of same reason as above but according intended/coded rules. but still all of them were having 2 exit stop orders (not just one), similar like this one currently open which you can see in the printscreen attached. strange, and not funny, because I don’t understand if what happened is “my fault” or did something go wrong with IB execution in the morning.
also what I still don’t know is if my orders, especially those for covering the position, are “real” orders at the exchange, or just “synthetic” orders kept at IB’s site until indicated levels to cover the position are touched. any clue how to verify that? you are mentioning “pending orders” and “fixed orders” – what do you mean by those?
regards
justisan
09/29/2023 at 1:45 PM #22180609/29/2023 at 2:14 PM #221808what IB with futures does: it keeps the first exit order and places a second stop order – with the consequences that it requires/reserves addtional margin: this kicked me out immediately out of the trade due to unssuficient cash on the account.
Could you please send a console ticket through the help menu of the platforme please? We’d like to investigate in this, thank you 🙂
09/29/2023 at 4:00 PM #221810Hi again justisan,you are mentioning “pending orders” and “fixed orders” – what do you mean by those?
A Pending order it an order which needs to be repeated each new bar. If you don’t repeat it, it will be discarded at the end of the bar it was initiated in.
A “fixed” order (per my own terms) would be one of the kind of Set Stop $Loss (and its variations).also what I still don’t know is if my orders, especially those for covering the position, are “real” orders at the exchange, or just “synthetic” orders kept at IB’s site until indicated levels to cover the position are touched.
There’s also the PRT part in this, and this is more vague (for me). So PRT itself knows about your margin, but adjusts the actuality of it with an unknown lag. Also, PRT intelligently tries to prevent you running you into a margin call, and if I am right an example of that is the from 1000 long to 1000 short situation which PRT judges in advance of the broker (IB). Don’t pin me down on this.
Would it be correct that the Stop order at the bottom of your picture implies ~3375 loss ? This seems much to me (if my math is correct in the first place) and your problem could be there to begin with.
That something would be added here (for total possible loss) would be wrong (your top-most selling stop order would be making profit (or break-even I think) so it can’t add to losses.
What I am thinking of now is this :sell at initialstoploss stop // exit A
and then afterwards, depending on conditions which appear on the market/price development / this order has to be adjusted/increased to let’s say to breakeven level:
if onmarket and conditionsmet then
sell at breakevenlevel stop // exit B
endif
If literally done like that, then the condition for the first Stop order is missing (both Sell commands should be in a mutual exclusive If/Esle). So the first will still apply when the second later becomes active (ConditionSet becoming True).
Please notice that I myself am doing these things all over the place, but I take very good care of redundancy and the mutual exclusiveness I just talked about. Never anywhere would emerge the situation that two subsequent order commands are executed. And Yes, IB will deal with this differetly than IG because with IG all sorts of combinations are allowed, while IB just … errors out (well, not “out” really – no wait, it does 😉 ).
Notice that “IB” would merely be PRT which does not anticipate IB very well, as there is way insufficient experience, still (in de AutoTrading department). This is most probably why Nicolas asks you to send this Technical Report (you’d need to send your code to PRT as well).I have learned to find backdoor solutions to these kind of anomalies, assumed it is an anomaly indeed. In this case it may look like double the amount for the Stop order, which is sent to the broker, but very maybe the lowest Stop order in your screenshot also lowered for price (my mentioned 3375 which seems high for 1 piece (contract)).
But first things first; cause your code to never execute two subsequent orders (also not opposite). Never think that the one will overrule the other. To this regard I see this passing by daily, and it is all over wrong :1234If ExitCondition thenSell at MarketExitShort at MarketendifDon’t do that because the situation that both occur or are required can’t exist (hey, with IG it very theoretically can, but never in the given out of context example like I just gave).
In your case (of obviously an also out of context example) :123456789101112If OnMarket and Not InWinningMood then// Set SL nicely low but not too low and do this with Set Stop xLoss (x can e.g. be $).// But If/Else this again for Long vs Short if you use a Pending Order (Sell/ExitShort m Contracts at $$$ Stop)endif// ...If OnMarket and InWinningMood then// Set SL to breakeven and again do this with Set Stop xloss// But If/Else this ... etc.endifHope this helps …
Peter09/29/2023 at 5:19 PM #221813hi Peter,
thanks for your feedbacks. not always understanding them right away, but I hope I will at some moment. anyway (pissed quite heavily and ) still working all the time to figure out what what IG/IB differences are, since partiallialy they are really significant, same code – guite different execution by IG/IB. makes little sense.
regards
jutisan
09/29/2023 at 5:35 PM #221814what IB with futures does: it keeps the first exit order and places a second stop order – with the consequences that it requires/reserves addtional margin: this kicked me out immediately out of the trade due to unssuficient cash on the account.
Could you please send a console ticket through the help menu of the platforme please? We’d like to investigate in this, thank you 🙂
2″”
I will sure not open any ticket on the case precisely mentioned with the real data and code. PRT does not investigate on anything if one does not share the code, and even if sharing the code – in last approx 10 year I never, really never ever received a feedback (even “promissed”) on the issues for which I opened a ticket in the last approx 10 years. this is really sad but true. I would really like everybody to learn from each other, but I do/did not learn anything from PRT/IG (because of completely missing feedback on tickets) except that they do what they do and I have to find the solution on my own based on that.I have to figure out with my money what they are really doing and how they are they are doining their business.09/30/2023 at 12:45 AM #221843Wow.
justisan, I have been reading this 4 times in order to understand it is not a quote from my own thoughts. I refrained from telling exactly this in my last post because I thought it was too negative.
Very special.
And so much more the truth of the (sad) real life with PRT.All what I left of these thoughts was this :
I have learned to find backdoor solutions to these kind of anomalies
because nothing gets solved anyway, and *if* it is solved, you will not be notified. But please notice : if we don’t report these things, we don’t give PRT *and* ourselves the opportunity to solve things to begin with.
anyway (pissed quite heavily and ) still working all the time to figure out what what IG/IB differences are, since partiallialy they are really significant, same code – guite different execution by IG/IB.
All I can say is : don’t hesitate to open topics with dedicated questions regarding this. There won’t be many people with the experience on both IG and IB, but at least I am one and I will grab all I can in order to learn myself. Nothing, really nothing executes the same (always broker related and not really PRT-bug impeded) and we can only find out by trial and error. This obviously costs money in itself. You don’t want to know …
Heads up,
Peter10/02/2023 at 8:33 AM #221926hi Peter,
I am considering advantages and disatvantages of reporting / not reporting the issues I face – and I still don’t see any sense in opening tickets today: after arround a decade of experience I was „forced“ to conclude that in the end I have to figure out on my own exactly those “backdoor solutions” you mention. So basically almost no tickets any more. and so yes, that is my “negative” feedback – from which our service providers could learn if they would like to. but there is even one very positive side related to to experience mentioned: I am kind of pushed to simplify my codes even more than initially intended 😀 so I can detect more easy and precisely what works according my intention and what not. in order to give PRT/IG, me and other traders the opportunity to solve things I still sometimes (like 1x per year) open a ticket – but not with algos I trade live, yet creating some different algo and including there real parts of code (from live algo) which I suppose are failing/creating issues, running them live with smallest position possible until failure occurs and then reporting – and then sharing code as well. while knowing I will never receive any relevant feedback. Nobody will tell me what the issue really is, they will not notify about solution being implemented (like you mention) etc.. solution might come in 6 months or in a year – while I have to deal with specific issues “today”. And my issue with now transiting to futures is that it is much more expensive to run tests just in order to detect failures, compared to cfds where you can experiment live with ultra-low position sizes and have mistakes/failures which cost you few euros. and one has to test everything live, because lot of failures do not show up in backtest mode at all.I am not telling that issues I face are always service providers‘ fault – frequently enough they are my own mistakes, or rather “misunderstandings” about how PRT/IG works with my codes in the live mode vs. backtests. Yet now when I thought I have learnt a lot/enough in the past years, this current move to futures is quite a challange (punch in the face!), as mentioned: same code with significant differences in the execution on cfd vs futures and there is nobody at PRT to tell what the core differences are and how to work around them. So again lot of fun, I am moving forward, not losing my optimism yet, not now at least 😀
10/02/2023 at 9:15 AM #221929one has to test everything live, because lot of failures do not show up in backtest mode at all.
There is a 3rd option … Live data using ProOrder on a Demo Account.
Do you have a Demo Account? In the past I have asked this and members have said, what is a Demo Account?
10/09/2023 at 8:18 AM #222172UPDATE, NEW INSTRUMENTS AVAILABLE
Hello,
We have activated the following futures for IB Auto Trading:
EURUSD, EEURUSD, MEURUSD, NG
3 users thanked author for this post.
11/30/2023 at 12:06 PM #224622Dears,
After few months of experience transferring from cfds to futures some of my automated strategies which I run on dax index, I would like to share my obeservations, pros and cons which I faced on futures trading vs cfd trading. I leave aside the fact that exactly same code is not necessarily executed exactly same way on cfds with IG and on futures with IB: this I would not call pro or con – one just has to figure out those differences and adjust the code.
I hope that nobody takes it as “ultimate truth” what I tell below, and definitely it is not a complete list. these are just my impressions after very few months of development and live trading, which might be wrong in the end, after having more experience. In fact I hope that some of those traders reading my lines will come and tell “what a nonsense!” and share their different observations. I also don’t want to “advertise” rather to trade futures than cfds (or vice versa…). Both have remarkable advantages and disadvantages. Anyway, analyzing how same strategies “behave” with cfds vs futures is a huge source of inspiration for me, enormous learning opportunity.
So here you go, with my pros and cons of futures trading vs cfd:
Pros:
- You trade a real market, and one cannot value this fact high enough… in fact I cannot “quantify” this advantage, but it’s a veeeery good feeling. And I cannot prove it, but I assume that some other advantages are coming from exactly that fact that you trade fair/free market.
- Futures seem not to have some price movement “spikes” which I observe on cfds. With cfds on same instrument with exact same algorithms those spikes cause with my strategies more entries, and with same exit stop distance I am more frequently/earlier kicked out of positions with cfds than with futures. Future prices seem to me being like more “compressed”. Well, for somebody, or let’s say for some strategies it might be a disadvantage.
- Liquidity/slippage: just recently after major economical data release same strategy entered a position with 43 index points of slippage on cfd, while only with 1 point on futures….
- No limitations where/at which price levels you place your orders: no (with over time varying and some times huge) minimum distances for your entries and exits (makes me frequently looking stupid when running algos with cfds…)
- One does not need to deal in the code with over time / during the day/night varying spreads like it’s needed with cfds (at least I do that…)
- Much more data history. And considering that it’s data from real market it has much more “value” and significance when developing and backtesting the strategies, I assume
- No cost for keeping positions overnight. It seems like you don’t pay a lot for that with cfds, but man… these costs cumulate to substantial amounts over weeks and months in this current environment of high interest rates…
Cons:
- No possibility to run more than 1 automated strategy on the same instrument/contract – for me it is THE biggest disadvantage of all.
partial solution: to open several sub-accounts, but there is an oficial limit of 5 (ok, maybe with very good arguments one also could negotiate 50 sub-accounts as well…)
another way to trade more strategies: trade them on different contracts of same instrument (e.g. one on big dax, another on mini dax, another on micro dax). Possible, but not really optimal solution - No possibility to fine tune position sizing like it is perfectly possible with cfds, unless your account goes into many hundred thousands and millions
- No “guaranteed” stops (and no negative account protection).
sophisticated traders might be able to create their own “guaranteed stops”, maybe with options, but I am not that sophisticated…
my kind of solution is to exit positions before weekend, which costs me some of the performance on some strategies, so not a perfect solution. - Need much more cash in the account for margin in order to trade same size, around double. this hurts…
the only solution I see is to move to other brokers which offer much lower margin, but other brokers do not offer PRT tool for automated trading… (to which I am “addicated” :-D)
Regards
justisan
4 users thanked author for this post.
11/30/2023 at 1:08 PM #224634Hi Justisan,
Thank you for your informative insight, I can endorse almost all your points…
About the costs, when you look at the price of a futures contract and the price of the underlying assets, for example an index, that difference in points is the cost you pay for the future. On the way to the expiration date of the future, the difference in points will decrease and on the expiration date, the price of the future will be equal to the underlying assets.
11/30/2023 at 2:03 PM #224640Hello justisan,
There is nothing wrong with your observations. It is only that you could have put the focus on the broker instead of the CFD vs Futures, thus IG vs IB. Example : the spikes you mention are not there at all for IB CFDs. But notice that my experience with those on IB is only for Forex. The spikes on IG are the reason indeed that nothing will workout the same. Nothing.
In addition, for the spikes I ever back compared the real Fx data with the CFD data (they worked alongside for 4 weeks or so). And there was simply no difference to be seen.For me, your mentioned biggest downside of not being ability to run more strategies on the same instrument, will in the end kill the Autotrading for the IB environment. It is just too limited when one needs to try out things. So for IB I need to kill the one System in order to try the other, while for IG I just add another system and can really compare meanwhile.
I still use IB because of again the exact same reason we both FEEL (yep) : the IB environment is more honest. More fluent. More predictable. And more easy to develop a profitable strategy (go figure).
Regards and thank you for a nice post,
Peter1 user thanked author for this post.
12/01/2023 at 11:25 AM #224682thank folks for your feedback and comments!
Peter,
I have a hope, that IB will make it possible in the future to trade multiple strategies on same instrument, also long and short at the same time. I assume it’s just their own artficial limitation, which they implemented for PRT customers. of course, there must be the demand first – and probably a lot of it – from traders needing different setup so they remove that limitation. and therefore my hope “today” is rather weak, because I have no clue how big that demand currently is, but assume it is not yet there. was tallking recently with PRT and guys told me they know just about very few customers having 2-3 sub-accounts…
have a good trading day and nice weekend soon!
justisan
1 user thanked author for this post.
01/04/2024 at 4:43 PM #225957Dear all,
Just tried to create an automated trading strategy with the “RTY Mini Russell 50€/point”.
As stated in earlier posts in this thread RTY should be released, nevertheless I get the following error:
“The instruments which can be used for automated trading are temporarily limited. The instrument you have selected is not yet available. Please contact us if you need more information about its availability.”
Has RTY been taken off the available instrument list or is there a mistake on my side? NQ is working well for me.
Thanks a lot for any feedback.
Simon
-
AuthorPosts