- ago
I'm seeing that limit price for cover and buy long are getting swapped on TDA side.

Here's the limit price of cover and buy long order shown in order manager:


Cover limit price is 60.67 and buy long limit price is 60.53 at 8:47am today.

But in the TDA side I see the limit prices are getting swapped.


The buy "to close" or cover order limit price is shown as 60.53 and buy "to open" or buy long order limit price is shown as 60.67. It's the other way around.

For sell and short orders there is no issue. I see the same limit price in TDA side. Sell to close limit price is 60.66 and sell "to open" or short is 60.80.



Although WL7 is showing the correct limit price but it looks like somewhere in TD API the limit price is getting swapped for buy to close/to open orders before being transmitted to TD.
0
810
4 Replies

Reply

Bookmark

Sort
Glitch8
 ( 10.62% )
- ago
#1
Hmm I'm checking our extension code and everything is correct there, will run some trials next week when the market is open and see what might be going on here.
0
Cone8
 ( 4.98% )
- ago
#2
Since the TDA API doesn’t differentiate between buy/cover sell/short, probably the buy is received at the broker an instant before the cover, and therefore TDA interprets it as buy to close, i.e., cover.

Understanding that it’s on the same bar, does the strategy logic execute the buy signal statement before the cover?
0
Cone8
 ( 4.98% )
- ago
#3
I stand corrected. TDA does differentiate. Alpaca and IB do not. Glitch found something that could help in the next TDA Provider Build (2).
0
- ago
#4
I have cover first and then buy later.

CODE:
if (FindOpenPosition(PositionType.Short) != null) {    PlaceTrade(bars, TransactionType.Cover, OrderType.Limit, bars.Close[idx] * (1 + exitslippage), "Short Exit Strategy 1"); } if {!eod} {    PlaceTrade(bars, TransactionType.Buy, OrderType.Limit, bars.Close[idx] * (1 + enterslippage), "Long Enter Strategy 1"); }


Here, eod is end of day. I check if time is not 5 minutes before market close. Why in the order manager, buy is shown first and cover is shown later? I guess that's what is causing the limit price to get swapped as TD API doesn't differentiate buy/cover.

On the other hand, I have short first and sell later. But in order manager, it shows sell first and short later.

CODE:
if {!eod} {    PlaceTrade(bars, TransactionType.Short, OrderType.Limit, bars.Close[idx] * (1 - enterslippage), "Short Enter Strategy 1"); } if (FindOpenPosition(PositionType.Long) != null) {    PlaceTrade(bars, TransactionType.Sell, OrderType.Limit, bars.Close[idx] * (1 - exitslippage), "Long Exit Strategy 1"); }
0

Reply

Bookmark

Sort