Questions about Alpaca API and trading at Alpaca


We wrote an algo that we are looking to deploy at a broker for equities such as TSLA. The algo is for day trading, has an average hold time of 1 min 23 sec, and an average profit of $0.009 per position. Given this, it is super important for us to get good fills. Our methodology is to use a limit order, and if it doesn’t fill and the market moves against us by more than .001 of the price we take a loss on that and convert the limit to a market. Also, the algo flips from long/short.

We are at tradestation now, and I am disappointed by their API. Here are my issues with tradestation:

  1. I cannot flip long/short. For example, if I’m long 100, to flip to short 100 I need to submit to orders, a sell order followed by a sell short order that executes on the initial sell order executing. The fact that I’m forced to use this two order methodology is giving us worse fills.

I want to be able to just send a sell 200 order - and that just sells 200, regardless of what my current position is. So if I’m long 100, and I sell a sell limit order for 200 shares, it’ll be a single order that will flip me to short 100. Can I do this with Alpaca?

  1. If I don’t get a fill, and I need to send a market order to fill, can I sent the market order before canceclling any exiting orders? Tradesation forces me to cancel open orders before I can send another order in certain instances - losing precious time. I want to send the order, get my fill, and then send the command to close the old orders. Will Alpacca just accept orders without any “safeties” I guess you could call it?

  2. Does Alpacca also have a desktop program where I can monitor to make sure that my trading code is working correctly?

  3. Does Alpacca have a full sim environment where I can do dev for the API?

  4. All Alpacca API trades are commission free correct?

@sawtooth500 First, thank you for your interest in Alpaca. You asked a few question which i’ll try to answer.

Can a position be ‘flipped’ from long to short (or vice versa) in a single order?
No, Alpaca requires to first close the position then open a position with the opposite ‘side’. This would be two orders.

Can I send a market order before cancelling any exiting orders?
If it is a ‘sell’ order, you cannot sell more shares than you own. If you have an existing open order to sell all your shares, a second order will be blocked. If you want to increase a position, you can always do that as long as you have buying power for the second order (canceling the initial order will free up buying power). The best way to handle this situation is to not cancel, but rather replace an order. That may work for you and only requires a single call.

Does Alpaca have a full sim environment where I can do dev for the API?
Yes, the paper trade environment simulates live trading quite well and is designed primarily for development.

Are Alpaca API trades commission free?
Yes. Alpaca doesn’t charge commissions on trades. However there are regulatory fees which all brokers are subject to. These fees are outlined here. While these are typically small, they can add up quickly if day trading with a lot of ‘round trips’.

I would like to make a clarification on fills. You stated "the fact that I’m forced to use this two order methodology is giving us worse fills." Not sure why this would be the case. orders will almost always fill at the current quote. A buy order will fill at the current ask and a sell at the current bid. Unless the quote changes, it makes no difference if one or two orders were executed. One should be able to place a close order, check that it filled, and place a second open order in under 500ms. Unless the quote changes within that time there will be no difference in fill prices.

I did a quick check of TSLA quotes from about 10:00-11:00 ET on 2024-06-05. Specifically the delta time between a $.02 change to the ask price. Below are the results (bid prices are similar).

count                         1408
mean     0 days 00:00:02.181675550
std      0 days 00:00:03.653694832
min                0 days 00:00:00
25%         0 days 00:00:00.005635
50%         0 days 00:00:00.616798
75%         0 days 00:00:02.806640
max         0 days 00:00:36.011814

Notice the median time between change is about 616ms. That should be enough time to submit a buy and sell and get in on the same quote especially if your average hold time is over 1 minute.

Unfortunately the reality of needing to send a sell followed by sell short order to flip long to short does give worse fills. The problem is with a touch fill. If I’m long 100 TSLA, and I can just sent a sell 200 order that is accepted, that’s sell 200 that is already sitting on the order book at the exchange - otherwise if I need to sell 100, when that’s filled then I need to send another sellshort 100 order, that second sellshort 100 order may not get filled if the price move - the median between change time is 616 ms, that is more than half a second that the order gets delayed - where I would have gotten a fill, I could lose that fill to someone else in that half second. I’m currently at tradestation and that is what we are experiencing. I can use the DAS Trader API which just has sell and buy orders and doesn’t differentiate between shorting/covering, however there are no commission free brokers that use DAS to my knowledge… however paying commission may be worth it for us if we can get the fills.