Settings

Theme

Show HN: Stock Trading with Insomnia REST Client and Alpaca API

71 points by shift8 7 years ago · 39 comments · 1 min read


I've created an Insomnia workspace to make it easier to debug your stock trading code and learn the Alpaca API. You can read about how here: https://medium.com/automation-generation/using-alpacas-stock...

The actual workspace JSON for you to import into Insomnia can be found here: https://github.com/alpacahq/insomnia-workspace

nodesocket 7 years ago

I've been playing with the Alpaca streaming API's in Node to get quotes. I have it working, the next step is figure out a trading algorithm.

I am a pretty traditional long term investor, $AAPL, Berkshire, Bank of America, Ford, Amazon, AMD, $SPY, with 10+ years in the market. However with the crazy volatility, I have been toying with the idea of buying ProShares UltraPro Short $SQQQ to hedge my losses on big pre-market open down days. Today for example would have been a good day to own $SQQQ for the day (up 7.3%). Any insight on how to go about this hedge strategy using Alpaca? Can I get pre-market quotes for the Nasdaq?

9712263 7 years ago

Seems inherit the same limitation of RobinHood: you can't do short selling. Not sure how actually they could do a free commission order, so not sure why short selling is not supported, but it limits the use of long only strategy.

  • anonu 7 years ago

    Interesting. I suppose it's a much more involved process where you need to locate shares to borrow. You need to maintain a list of easy to borrow and hard to borrow names. ETFs by definition are hard to borrow.

    I used to work next to the stock loan desk at a bank. The equity markets are generally pretty tech driven these days but stock loan is still operating in a 1980s mentality.

ta1234567890 7 years ago

Open question: If, for one stock, you could predict tomorrow's closing price today (with 80% accuracy within 2% of the actual price), how would you trade that stock?

  • kgwgk 7 years ago

    It's easy to predict tomorrow's closing price with that accuracy: it will be the same as today's closing price.

    For a large majority of S&P 500 stocks this prediction will be within 2% of the actual price very often (more than 80% of the days). In aggregate, the hit rate is over 80% as well.

    • ta1234567890 7 years ago

      Great, so how do you use that for a trading strategy?

      • hartator 7 years ago

        You can't. What parent tries to explain is your predictions is no different than regular fluctuations, so you can't use it to get an edge.

      • toomuchtodo 7 years ago

        Weekly out of the money options trades with short expires. It’s more gambling than anything else fwiw.

  • hueving 7 years ago

    How far will it move if it doesn't land within the "80% accuracy"?

  • 18nleung 7 years ago

    Try an iron condor - you’ll profit if the price of the underlying asset stays between two points

  • pmalynin 7 years ago

    Buy call / puts (depending on the current price) near the target price, with very close expiry dates. This would maximize your convexity.

  • thisisit 7 years ago

    The bigger question is - what happens if you get the price 20% wrong? This might look like a winning strategy in a normal and calm market. But, it'll take only one day to wipe out all the gains.

    • ta1234567890 7 years ago

      That's an excellent question. It all depends on the strategy. How would you address that scenario?

  • hartator 7 years ago

    More than 80% of stocks will close within 2% of previous day closing price.

rpedela 7 years ago

Alpaca looks awesome, but doesn't support after hours trading. Does anyone know of a good API that does?

  • malhotra_chetan 7 years ago

    Yes. Narwhal. Narwhal provides commission free flat rate brokerage trading via tradier and you can trade both in pre and post market hours.

hellofunk 7 years ago

How is the access to historical data with these services?

kaycebasques 7 years ago

A commission-free trading API? How does Alpaca make money?

  • gschier 7 years ago

    Likely the same as similar services like RobinHood. A quick Google suggests they make most of their money on interest from cash sitting around in user's accounts that has not been invested yet.

    • JonasJSchreiber 7 years ago

      And by selling info about customer orders to front runners. IIUC, these are high frequency traders who may place similar orders milliseconds in advance of yours then profit from the fact that you have to pay a bit more to fill your order. Full disclosure, I continue to use Robinhood despite this.

    • gammateam 7 years ago

      And selling order flow

      • dplgk 7 years ago

        What is order flow?

        • gschier 7 years ago

          I'm not familiar with it either, but this seems to provide a description https://en.wikipedia.org/wiki/Payment_for_order_flow

        • vostok 7 years ago

          Seeing/selling order flow is a term of art in finance. Seeing order flow refers to the ability to trade against customer orders. Selling order flow is getting paid by someone else for the ability to trade against customer orders.

          Imagine that a stock is bid at $100.00 and offered at $100.01. Assume that market makers estimate the fair price to be $100.005 unconditionally.

          A customer sends a marketable buy limit order at $100.01.

          If this hits the exchange then the person who's offering at $100.01 will make $0.005.

          If the order flow gets sold (i.e. someone gets to see the flow before it hits the exchange) then the internalizer can fill it at $100.01 and make the $0.005 themselves instead of letting someone else on the exchange do it. It has nothing to do with front running or even information.

          This is really valuable because you're not competing for speed with other market participants and you expect the customer flow to be uninformed so the trade is less likely to move against you before you trade out.

          This is a problem for market structure because it discourages people from quoting on the exchange.

          • gbrits 7 years ago

            So the market maker who pays for order flow data takes the spread. But how are they able to trade with the buyer at $100.01 when there are limit asks on the book already at that price? Seems they need to cut the line?

            • vostok 7 years ago

              That's part of thr reason that they pay for the flow. They're able to sell at $100.01 off exchange even if there was someone else who was willing to sell at $100.01 on the exchange first.

              This also why I think payment for order flow is bad even if the first order effects are not bad for Robinhood customers under reasonable assumptions.

          • dplgk 7 years ago

            Why is this not just a spread and does RH not just have spreads to make money?

        • gammateam 7 years ago

          User data on what stocks they buy and sell

          Except between the time the user clicks buy and when it the buy actually happens. Basically hedge funds are able to receive and parse this data, and change their orders to an advantage before the users order hits the actual exchange

          Its analogous to a MITM attack

          Despite my wording its not necessarily bad, but I think users should have a better understanding of it.

  • brian_herman 7 years ago

    They probably use the algorithms implemented on their platform to make better ones.

  • shift8OP 7 years ago

    services

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection