- ago
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:
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.
0
1,426
Solved
4 Replies

Reply

Bookmark

Sort
Cone8
 ( 6.17% )
- ago
#1
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.
0
- ago
#2
Robert, this #FR is suggested by Dion here:

https://www.wealth-lab.com/Discussion/FindOpenPosition-Is-it-based-on-PlaceTrade-or-actual-position-7826
0
Cone8
 ( 6.17% )
- ago
#3
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.
0
Cone8
 ( 6.17% )
- ago
#4
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
0
Best Answer

Reply

Bookmark

Sort