-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addition of Interactive Brokers Algorithmic orders #1203
Conversation
…etholdings is synchronous by design and may work poorly with IB Algos however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this requires some thought/design/input by others on the QC team. @StefanoRaggi - perhaps this is another use case for the order parameters stuff you did for FA accounts?
List<AlgoParams> AlgoParams = new List<AlgoParams>(); | ||
AlgoParams.Add(new AlgoParams("adaptivePriority", "Normal")); | ||
SetHoldings(_spy, 1, false, "", OrderAlgorithm.AdaptiveAlgo, AlgoParams); | ||
//MarketOrder(_spy, 100, true, "", OrderAlgorithm.AdaptiveAlgo, AlgoParams); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert changes to this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, this wasn't supposed to be committed.
Common/Orders/OrderTypes.cs
Outdated
/// <summary> | ||
/// Interactive Brokers algorithm selection | ||
/// </summary> | ||
public enum OrderAlgorithm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are specific to interactive brokers and should be under the QuantConnect.Brokerages.InteractiveBrokers
namespace -- still located in the Common
project -- but we may want a more generalized way of handling brokerage specific order parameters rather than having to define special types for every brokerage -- so not sure how I feel about this yet
I had an idea this morning to pass a single class through the ordering system instead of the two IB specific variables in this pull. Something like OrderExtra contained in it's own file. Inside that would be special parameters for every broker that are individual to that broker. So for example I could set OrderExtra.IB.Algorithm.AdaptiveAlgo and pass the parameters through in the same way. This would be cleaner and broker agnostic, and any extra order options could be added to the OrderExtra class for any broker. Thoughts? |
…ngs(). Setholdings is synchronous by design and may work poorly with IB Algos however." This reverts commit b885c86.
Added a different solution. The new class in OrderExtras.cs is a bit of a mess but the general idea is there. |
@mchandschuh has a good point. After looking at @StefanoRaggi Financial Adviser pull request, I've basically ended up duplicating his work for passing more order properties through. This algorithm selection stuff would fit perfectly into his new OrderProperties class. |
Thank you @sic, tidy PR overall! We'll review and squish this into the FA PR and see if we can add the advanced orders quickly after. @StefanoRaggi - Perhaps the default OrderProperties should be empty & have Brokerage Specific implementations? i.e. "InteractiveBrokersOrderProperties" Then users could set the order default properties for their fav brokerage?
|
This change will make it easier to add other planned brokerage features: for Interactive Brokers, besides Financial Advisor support, we will be adding IB algorithmic orders soon (PR #1203).
This change will make it easier to add other planned brokerage features: for Interactive Brokers, besides Financial Advisor support, we will be adding IB algorithmic orders soon (PR #1203).
@sic8 - We've added a new type,
|
Closing for now but this isn't too far off; lets do a new PR and leverage Stefano's work =) |
I have added optional parameters to the orders to allow setting an IB Algorithm via enum OrderAlgorithm to MarketOrder(), LimitOrder() and SetHoldings(). Settings for the algorithm are stored in class AlgoParams.
The OrderAlgorithm and List[AlgoParams] are passed all the way through to the IB ordering API where the OrderAlgorithm enum is decoded into a string corresponding to the IB Algorithm API requirements, eg. OrderAlgorithm.ArrivalPrice becomes "ArrivalPx". List[AlgoParams] is recast(???) into List[TagValue] and sent off to IB with the order. (I used [ instead of < because it doesn't seem to work here)
SetHoldings() functions by design as synchronous, so allowing IB algos to be used might be a bad idea, as the IB algos can often take a lot longer than a normal market order to resolve.
Backtest results are not changed by setting an IB algo, a market order is a market order IB algo or not.
I'm very new to C#, a novice at programming and this is my first time on GitHub so I hope I haven't made too many mistakes.