It would be great if we can get APIs to do basic portfolio checks like:
FindPortfolioOpenPosition(string symbol, int quantity, PositionType)
Then we could use it like this:
In backtest mode, the portfolio APIs will have to behave similar to having a theoretical position to allow strategy to execute the same way as if portfolio APIs were not used.
FindPortfolioOpenPosition(string symbol, int quantity, PositionType)
Then we could use it like this:
CODE:
// Cover trade if theoretical short trade exists and actual short position also exists. // If theoretical or actual short position don't exist then don't cover if (FindOpenPosition(PositionType.Short) != null && FindPortfolioOpenPosition(mySymbol, myQuantity, PositionType.Short) != null) { PlaceTrade(bars, TransactionType.Cover, OrderType.Limit, ...); }
In backtest mode, the portfolio APIs will have to behave similar to having a theoretical position to allow strategy to execute the same way as if portfolio APIs were not used.
Rename
Strategies always run in a hypothetical backtest mode. What's not clear is the reason(s) for the request. If your account doesn't have the position, and, you are using the Portfolio Synch options in Trading Preferences, the Order Manager won't submit the order.
Robert, this #FR is suggested by Dion here:
https://www.wealth-lab.com/Discussion/FindOpenPosition-Is-it-based-on-PlaceTrade-or-actual-position-7826
https://www.wealth-lab.com/Discussion/FindOpenPosition-Is-it-based-on-PlaceTrade-or-actual-position-7826
It's still not clear to me what the advantage is, but letting a script know about live positions can't be a bad thing either.
I'm going to close this one as a duplicate request (that no one has voted for) of another that has a few votes -
https://www.wealth-lab.com/Discussion/Access-Accounts-data-from-broker-programmatically-7914
https://www.wealth-lab.com/Discussion/Access-Accounts-data-from-broker-programmatically-7914
Your Response
Post
Edit Post
Login is required