15 ms·
Show HN: Trade stocks from the command line with no commission
- deleted 6y ago[deleted]
- sdan 6y ago*using a service called Alpaca
- ilrwbwrkhv 6y agoIs that service available outside USA?
- smabie 6y agoNo.
- ISL 6y agoIs there a reason that the repo size should be 10 MB? Seems odd.
- axaxs 6y agoAuthor committed the binary, then just removed it in a separate commit. Ouch.
- j4ah4n 6y agoIt seems a binary got into the git history. https://gitlab.com/aenegri/toro/-/commit/dd3adb3a19bc21966f909e2096300058a749c937 https://gitlab.com/aenegri/toro/-/commit/dd3adb3a19bc21966f9...
- anegri 6y agoOh didn't realize that! Thanks for pointing that out
- badrabbit 6y agoThanks for sharing. Didn't know alpacca was a thing.
- proverbialbunny 6y agoA problem I've bumped into with Alpaca compared to other services is my bot needs 1 second bars, and I believe Alpaca goes down to 1min bars and nothing smaller.
- anegri 6y agoYeah there are definitely a number of limitations if you are using just alpaca (which I limited myself to for this), which is why this project is intended for just a few basic use cases.
- larrykubin 6y agoDid you try the Alpaca Market Data (streaming) they just released? You should be able to get real-time data now that is aggregated from multiple exchanges.
- proverbialbunny 6y agoThat's the 1 min bars I was talking about. https://alpaca.markets/docs/api-documentation/api-v2/market-data/streaming/ https://alpaca.markets/docs/api-documentation/api-v2/market-... >Trades, quotes and minute bars are supported.
- Vindicis 6y agoCouldn't you just make your own off the tick data you're streaming?
- proverbialbunny 6y agoAlpaca streams bars not ticks.
- nemothekid 6y agoPolygon offers 1 second bars (https://polygon.io/sockets https://polygon.io/sockets) for $200/mo.
- 6y ago
- encyclopedia 6y agoWould be interesting to tie it into what Elastic published about trading baskets of pharma companies related to drug development (COVID-19 included): Generating and visualizing alpha with Vectorspace AI datasets and Canvas https://www.elastic.co/blog/generating-and-visualizing-alpha-with-vectorspace-ai-datasets-and-canvas https://www.elastic.co/blog/generating-and-visualizing-alpha... Generating Alpha from Information Arbitrage in the Financial Markets with NLP Datasets: 水涨船高 https://medium.com/hackernoon/profiting-from-information-arbitrage-in-the-financial-markets-3abfca9806d8 https://medium.com/hackernoon/profiting-from-information-arb... algo guys take https://www.reddit.com/r/algotrading/comments/gkrb6f/generating_alpha_in_a_down_market_with_nlp/ https://www.reddit.com/r/algotrading/comments/gkrb6f/generat...
- larrykubin 6y agoShameless plug: I started a YouTube channel on this topic that covers a lot of commission free trading API's, including Alpaca (got featured in their docs), Robinhood Private API, TD Ameritrade, Tradier, and more. I'm seeing a huge growth in interest in developing automated trading bots and algos. With commissions dropping to zero, there is a huge wave of day/swing traders that want to learn Python, so am creating as many tutorials as possible. https://youtube.com/parttimelarry https://youtube.com/parttimelarry
- melvinroest 6y agoWhat's the revenue model if commissions have dropped to zero? In other words, how can this be free? Are they making money via worse bid-ask spreads? I feel like a clueless person who lives in the year 2004, wondering why internet services are offered for free.
- alteria 6y agoExcellent explainer that's worth a read [1] and it's HN thread [2] tl;dr: Interest, payment for order flow, and securities lending (but mostly interest) [1] https://www.kalzumeus.com/2019/6/26/how-brokerages-make-money/ https://www.kalzumeus.com/2019/6/26/how-brokerages-make-mone... [2] https://news.ycombinator.com/item?id=20276551 https://news.ycombinator.com/item?id=20276551
- nimchimpsky 6y agoI'd imagine if you specify a limit or market price they just get a better price, and pocket the difference.
- teruakohatu 6y agoI have subscribed to your channel. Do you know of any services that allow non US residents to join? I am in New Zealand.
- phyalow 6y agoNZ doesnt have much going for it in terms of access to international equities. If you have over $10k USD, you can get an interactive brokers account, their API is a bit rubbish and commissions are normally around $6.00 USD flat. Otherwise Direct Broking via Jardens, commissions are c. $30 NZD per trade. Sharesies are apparently launching international equities later in the year, but they dont offer API access.
- anegri 6y agoHeard about alpaca a while back, so I made this as a small fun side project. The main features are buying, selling, and viewing stocks. In the future I may add additional features if I find something I want to add (or others want to add). The code is just Go, using the cobra library.
- axaxs 6y agoFYI - You're supposed to fill out the license info. I see empties in at least two files in the main repo.
- smabie 6y agoWhat's really cool about Alpaca is the integration with zipline via pylivetrader. This means that you can take your backtested factor models and easily convert them to live trading. Also, they have pretty lax margin requirements. You can borrow 2x the cash you have, 4x for intraday if you're a pattern day trader, and the maintenance requirement is only 25%. And with zero commissions, suddenly it's possible for the average joe retail investor to actually run a legit factor strat. If you're only trading highly liquid securities, it could even make sense to run a intraday only strat at 4x leverage. Lets say you're trading stuff that has spreads around 4 bips, your lost returns are going to be around 10% per year from trading costs. That's certainly a lot and you'll need a kick-ass strategy, but that 4x leverage might let you get there.
- tosylate 6y agoDo you have any reference on `legit factor stats`? I do not understand how leverage will be beneficial. Leverage will also multiply the potential downside risk after all? I would like to understand more how the trading cost would make up for it on average.
- pedrosorio 6y ago> I do not understand how leverage will be beneficial. Same here, if I understood the grandparent they were saying you lose 0.04% on every trade (from spread) and "in a year" that is 10% (250 trades?). If you have a strategy that has expected returns of x bips per trade then you make an expected x-4 and with leverage 4 * (x - 4). Both have the same "sign", so if x-4 is expected positive, leverage just makes it higher risk-reward. In fact with leverage you also have to pay interest on the loan, which seems to be at least ~18 bips (or 3/4 of that since the returns are on 4 * cash and interest is on 3 * cash) for a single day loan (far exceeding the "spread cost"): https://www.schwab.com/public/schwab/investing/accounts_products/investment/margin_accounts https://www.schwab.com/public/schwab/investing/accounts_prod... It seems the only way leverage would help is if there were fixed costs to trading (which I assume there are but the GP does not mention).
- 6y ago
- optymizer 6y agoBeginner question on a related topic for those of you more knowledgeable than me: Is there a way to get access to the order books on Nasdaq or other exchanges? I'm working on a script that can run stock trading algorithms (and hopefully see some profit). My first trading experience was with crypto on GDAX (now Coinbase Pro). The order book on GDAX is basically available via their API. I've been looking at various stock trading APIs (Alpaca looks interesting as well) and it seems like the only thing that's available are broker APIs that don't share the order book. Is the order book on Nasdaq and other exchanges unavailable to regular folks like me? Is it hidden, available to institutions only, or to some sort of registered brokers? Having first dealt with GDAX and now looking at stocks, it all seems so ambiguous and hidden behind 3rd parties, unclear order execution, etc. (not that gdax was perfect - it has its issues), so I'm just generally confused as to how things work.
- hendzen 6y agoYou have to buy the feed, the market data isn’t free. Depending on your usage the fees can get fairly steep [0]. And that’s just the market data, you need to pay for colocation, cross connects, and order entry sessions. Of course Nasdaq is only one US equity market - there are 14+ with more coming online in recent years. [0] - http://www.nasdaqtrader.com/Trader.aspx?id=DPUSdata http://www.nasdaqtrader.com/Trader.aspx?id=DPUSdata
- optymizer 6y agoThis is great. Thanks for the info - it does look expensive. I might have to investigate other exchanges.
- speedgoose 6y agoI need to create and operate a market place.
- totalZero 6y agoSure, you can see market depth as long as you pay for the data. Check out Interactive Brokers.
- noloblo 6y agogo install doesn't work @anegri # github.com/keybase/go-keychain cgo-gcc-prolog:203:11: warning: 'SecTrustedApplicationCreateFromPath' is deprecated: first deprecated in macOS 10.15 - No longer supported [-Wdeprecated-declarations] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrustedApplication.h:59:10: note: 'SecTrustedApplicationCreateFromPath' has been explicitly marked deprecated here
- anegri 6y agoWhat os and version are you running? I have been having trouble with Mac because of one of my dependencies
- bwood 6y agoAlpaca is great! As far as brokerage APIs go, theirs is top notch and a breeze to code for. The founders are also really responsive and helpful. I know this because I wrote an app that connects to Alpaca accounts (as well as other brokerages) to help people build their own custom index funds [0]. It only took a few weeks to build our Alpaca integration, whereas other brokerages often take months/years just to get access to their APIs. [0] https://getpassiv.com/ https://getpassiv.com/
- KeithBrink 6y agoNice to see you on here, big fan of Passiv!
- giorgioz 6y agohow does Alpaca make money?
- throwaway888abc 6y agoGuesing, they are selling order flow. Same like Robin Hood https://www.cnbc.com/2019/04/18/a-controversial-part-of-robinhoods-business-tripled-in-sales-thanks-to-high-frequency-trading-firms.html https://www.cnbc.com/2019/04/18/a-controversial-part-of-robi...
- TeMPOraL 6y agoSo Robin Hood is taking from the rich, giving to the poor, and then turning around and selling the poor out?
- psanford 6y agoSelling order flow isn't "selling the poor out". Reg NMS literally requires brokerages to route your orders to where they will get the best execution price. In general you as a retail investor get better execution prices because of how this works (why? because retail investors generally don't have new information that will move the price so they are "safe" trades for liquidity providers). Now robin hood _did_ get fined for "not perform[ing] systematic best execution reviews of several order types". If that's what you were referring to then fine. But if your complaint is just about selling order flow you should better understand what that means. Maybe start with patio11's How Brokerages Make Money[0]. [0]: https://www.kalzumeus.com/2019/6/26/how-brokerages-make-money/ https://www.kalzumeus.com/2019/6/26/how-brokerages-make-mone...
- lawrenceyan 6y agoOk, but what's going to be your business model if you don't charge commission?
- pmorici 6y agoSell order flow to HFT?
- lawrenceyan 6y agoExactly.
- sitzkrieg 6y agowhich is fine for retail traders, often resulting in execution improvements in dark pools etc. its amazing to me no one questions no commissions but trading equities is decentralized garbage anyway
- ciarannolan 6y agoWho is this question directed at? OP is linking free software. If you mean brokerages that advertise no fees to trade, they make money by loaning the cash in customers' accounts. https://www.bloomberg.com/news/articles/2019-10-10/brokers-profit-from-you-even-if-they-don-t-charge-for-trading https://www.bloomberg.com/news/articles/2019-10-10/brokers-p...
- toohotatopic 6y agoAnd by loaning out shares to short sellers [1] Which to me begs the question: do you actually own the shares when you buy them with those brokers? What happens if supply is limited and the loaned shares actually have to be sold? [1] https://www.investopedia.com/ask/answers/05/shortsalebenefit.asp https://www.investopedia.com/ask/answers/05/shortsalebenefit...
- ciarannolan 6y ago
- kyriakos 6y agoAlpaca is US-residents only unfortunately
- LethargicStud 6y agoMy main FUD with alpaca.markets is the ability to transfer assets in/out. It doesn't look like they offer ACATS transfers (although there's not much info on this!). Using them for anything beyond entertainment budget is very scary - you may incur substantial tax liability if e.g. they ever go out of business or you choose to use a different brokerage. Any insight here? Am I missing something? Is there any way to transfer holdings out without incurring the cap gains?
- whb07 6y agoas far as i know the "actual" backend data is standardized, ie same instrument names and dates etc. Adding to that, by playing in the US markets the SEC and FINRA, have that stipulation of being able to move between institutions in a standardized and regulated way. long story short, they all have to implement a system to move out and in (well they all want your assets so this part is obvious).
- srazzaque 6y ago(Disclaimer that I'm working on an open source FIX engine in Lisp.) This is a really cool project! But alas I couldn't use it as I'm not in the US, and I don't trade with Alpaca. And I feel like this plays into a negative trend I'm seeing. The retail brokerage market right now is treading on similar 'mistakes' in institutional markets 15ish years ago. Proprietary APIs were prolific, and therefore increased switching costs and lock-in (looking at you, Reuters and Bloomberg). On the one hand, retail brokers need to support popular programming languages and paradigms to gain traction. So, they are releasing http-based APIs, or popular language-specific libraries/bindings for their proprietary APIs. But, they are doing this instead of pushing well-publicised battle-tested standards such as FIX[1], that would normalise the playing field across brokers. So my gut feel is that they are banking on users coding against their APIs and having some lock-in effects. Notable exception is that any broker that supports cTrader will have a FIX API, because cTrader provides that for them. The problem is: if I write a bunch of code to work against Alpaca, TD Ameritrade, or whoever, that code will likely need to be revisited for some other broker like Robinhood. Granted, market connectivity code _should_ be well abstracted from my model if I'm following good design principles. But at least with FIX, the core concepts, fields, and messages remain the same across most FIX endpoints (NOS, ExecRpt, etc), allowing for a more uniform code holistically. [1] https://www.fixtrading.org https://www.fixtrading.org
- Random_ernest 6y agoProbably not the question you had in mind, but what Lisp and what made you choose it?
- srazzaque 6y agoCommon Lisp on SBCL. I lived on the JVM for quite some time (and still do), and I wanted to explore other ecosystems out of sheer curiosity. Got to playing with Lisp/SBCL, some initial tests showed it was pretty quick, and was impressed that I could disassemble functions in the REPL and iterate rapidly. Then a while later... I noticed there wasn't a FIX library at around the same time I was exploring creating my own trading models. So I can't say there was a lot of analysis across the different Lisps, etc. Had the coin flipped a little differently a while back this might have been in Racket. Also the choice of language in the book Professional Automated Trading[1] did influence me somewhat. [1] https://www.wiley.com/en-us/Professional+Automated+Trading%3A+Theory+and+Practice-p-9781118129852 https://www.wiley.com/en-us/Professional+Automated+Trading%3...
- xvilka 6y agoWould be nice if the author will add more popular Interactive Brokers[1] support. Alpaca is US bounded and seems not going to change this. [1] https://www.interactivebrokers.com/ https://www.interactivebrokers.com/
- moneywoes 6y agoHow is the alpaca API, are there any limits? Is it fast?
- BenderV 6y agoDoes anyone know why they are US only? Is it because the market is different abroad, because there are no European/Worldwide legal framework or simply because it's easier to start with?
- asmosoinio 6y agoLooks like this is the answer: https://news.ycombinator.com/item?id=23210385 https://news.ycombinator.com/item?id=23210385 Different market and laws.
- tutfbhuf 6y agoYou may also like https://github.com/madnight/wallstreet https://github.com/madnight/wallstreet just to get the charts and quotes
- supernova87a 6y agoYou should know in general, though, that no one trades "for free" despite what brokerages say. Your order gets routed, delayed, placed differently, and while you may not immediately see it, your trades are getting a different result than if you explicitly paid a brokerage who charges a commission on it. Learn about "payment for order flow".
- tom_mellior 6y agoI don't know why others downvoted you, I didn't. But as general feedback: "learn about X" without linking to some resource about X is really lazy soapboxing.
- loceng 6y agoMaybe, and it'd be nice if people cited all their knowledge with sources, otherwise it's possible to simply ask - or do a quick Google search to research yourself; of course if someone's explanation and understanding sounds good, though out, then they are more likely have access to good sources to save you a bit of time not having to research..
- kasey_junk 6y agoI downvoted it because it’s mostly factually wrong. First paying a commission is not correlated with participation in order flow payment. Commissioned brokers also get paid for order flow. Second if you interact with an internalizer your order will execute faster not slower. And you will usually be getting better price execution than if you try to route manually. Third all brokerages have routing tiers that involve self matching/dark pools/contractual discounts etc. Most of them will let you pay for the privilege of using the same router the non-premium orders go through. At the end of the day if your trade is that sensitive to execution you are not a retail customer and should not be using a retail brokerage.
- CallMeMarc 6y agoFor everyone wondering: https://www.investopedia.com/terms/p/paymentoforderflow.asp https://www.investopedia.com/terms/p/paymentoforderflow.asp
- posedge 6y agoI don't get it. How does Alpaca offer free broker services?
- smabie 6y agoProbably payment for order flow and earning interest on cash, like everyone else. Or maybe they don't make any money, I dunno.
- shoo 6y agohttps://www.bloomberg.com/opinion/articles/2019-10-02/the-trades-will-be-free-now https://www.bloomberg.com/opinion/articles/2019-10-02/the-tr... https://www.kalzumeus.com/2019/6/26/how-brokerages-make-money/ https://www.kalzumeus.com/2019/6/26/how-brokerages-make-mone...
- adamsvystun 6y agoFrom official site: https://support.alpaca.markets/hc/en-us/articles/360011047171-Business-Model https://support.alpaca.markets/hc/en-us/articles/36001104717...
- jb775 6y agoThese "free" stock trading companies cut deals with high-frequency trading firms that buy order flow. The more order flow they buy the more money they make (essentially risk free to them), which is why they are willing to send boatloads of money to companies like Alpaca/Robinhood. High-frequency trading firms aren't in the business of stocks, they are in the business of building the fastest tech on the planet to connect buyers with sellers, therefore making markets more efficient.
- monkeydust 6y agoWhat's closest to Alpaca for UK based traders?
- CallMeMarc 6y agoTrading212 is afaik UK based and also has no comissions on stocks/ETFs with okay-ish spreads
- dharma1 6y agoNot seen anything with both free trades and an API in the UK. I would like to do this to implement simple strategies - for instance mirror indices but with user defined filters (S&P500 minus hospitality, airlines and oil, as an example). Freetrade, 212 Trading and soon Robinhood offer commission free traedes in the UK but no API
- deleted 6y ago[deleted]
- xwdv 6y agoCan this do OCO orders and sequences? If it can’t then it’s kind of useless.
- mylons 6y agowith a record number of investors in the stock market and tools like this, i’m happy to be in all cash.
- matiasb 6y agoAlpaca is very interesting, I've been following them since the beginning. The sad thing is that I'm not from the US and it's still not available for residents of my country (Paraguay in South America).
- vijucat 6y agoFYI: "With no commission" is a bug, not a feature. Typically, when you pay commission, you get better prices. Let's say you buy 100 shares of SPY at Interactive Brokers. You pay $1 commission and get it for 268.28. At a free-of-commissions broker, you might get your 100 shares for 268.30. That's $1 more than the trade at IB. TNSTAAFL. It's exactly like how duck typing took over programming in the last decade or so with, "Whee, see, less typing!!", and we lost the value of having static types ("strong typing"). Why are we tempted so easily? Now we have the horror of Javascript everywhere. Even the Node.js founders recoil from their own creation and are going a step in the right direction with Deno.
- admax88q 6y agoAre you saying that alpaca charges a commission on trades by inflating the price and taking a cut? Or through what mechanism do commissioned trades get lower prices?
- selectodude 6y agoFree brokerages generally don’t execute orders as quickly in order to sell order flow which allows HFT firms to front-run your trade. If you’re a buy and hold investor, the fractions of a cent you’re losing don’t matter much over the long run but the issue is still there. Generally when you pay for something, it means that somebody is beholden to you if there’s issues. Robinhood et. al. are free because they suck. https://www.cnbc.com/2020/03/09/robinhood-app-down-again-during-another-historic-trading-day.html https://www.cnbc.com/2020/03/09/robinhood-app-down-again-dur...
- mrep 6y agoNo, they sell order flow because market makers know discount brokerage users are uninformed and thus less risky to buy and sell from. However, they actually give you better prices than the public market offers and they have to or else the SEC would fine them [0]. Your link is just about robinhoods shitty infra that couldn't handle their user load and has nothing to do with order flow. [0]: https://www.kalzumeus.com/2019/6/26/how-brokerages-make-money/ https://www.kalzumeus.com/2019/6/26/how-brokerages-make-mone...
- vfg1234 6y agoThis is a terrible use-case for the command-line.
- anegri 6y agoCould you elaborate? I understand it's pretty niche, but not sure why it is terrible to have a cli for it?
- vfg1234 6y agoThis is a terrible use-case for the command-line. One of the worst ideas I have come across.
- m3kw9 6y agoFile it under:New ways to lose money
- dose 6y agoCoincidentally I've also just released a command line client for Alpaca [0] written in Rust along with a library backing it [1]. Interesting timing :-) [0] https://github.com/d-e-s-o/apcacli https://github.com/d-e-s-o/apcacli [1] https://github.com/d-e-s-o/apca https://github.com/d-e-s-o/apca
- totetsu 6y agoThis makes me wonder if there are any old school, ASCII or DOS era stock trading games out there..
- anthony_r 6y agoWhat are you folks using this kind of stuff for? The best I can come up with is carefully studying issuers' financial reports and reaching some not very good but close enough conclusion about the state of businesses. At which point paying a few $$ or even $100 in commissions is really irrelevant given how much effort I had to put in ...