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.
BTW, I love working on this stuff and swapping notes with other people. Drop me a line (email in profile) if you want to talk anything related to FIX!
Whilst there will be differences, you can rely on a surprising amount being uniform. The general session/authentication flow and serialisation mechanisms will be largely the same. Or the use of standard fields ClOrdID, or OrderQty. Or the "general" meaning of the messages NewOrderSingle or ExecutionReport.
It's somewhat predictable where the differences are going to be: identifying securities (different codes, etc), expressing order types and algo parameters, and subtle differences to order lifecycles.
Again this is a gut feel, but I doubt that if you take 2 proprietary APIs, you'll get that level of uniformity.
The use case would be to have only one application to watch/place orders simultanously on 2-3(...multiple) broker accounts. To spread risk of losing funds in case a broker goes bankrupt (or whatever reason).
Unfortunately I wasn’t allowed to open source it, and it’s now lost in the void after a takeover. :(
Good luck to you. It’s not an impossible project. :)
It's a shame that you couldn't open source it. If you're open to it, I'd appreciate any feedback, thoughts or code review you could offer. You can get to it (and my email) with the second link in my profile.
Edit: typo, and point about Java/C++ dominance.
Dutch source, do use a translator https://www.tijd.be/markten-live/nieuws/algemeen/nieuwe-eige....
"Is it easier for a pan European company to keep big US competition like Robin Hood and Ameritrade out?
Niehage: 'The companies you name are very badly positioned for Europe. Their economic model is based on two pillars. Firstly, they want to offer everything for free. But if you offer all services for free, you have to earn money with the capital in the investors' accounts. That is possible in the US, where you can still get 2% of interest. In Europe, with zero interest rates, that's very different.'
And the second pillar of their economic model?
Niehage: 'That's the high frequency traders. As far as I know, Robin Hood sells its customer orders to this kind of parties. They are prepared to pay good money for that. According to the European MiFID II-regulation, that is illegal. Those two examples show that the US and EU markets are totally different. That's why American brokers have difficulties breaking into the EU market.' "
Broker offerings here seem a few "paradigm shifts" behind the US. Zero commissions are unheard of last I checked. Also, if you approach some brokers here and ask for an API or a FIX endpoint, you're either told to go away, or you're effectively ushered into a luxurious room, poured some exquisite scotch, and asked about how many millions of AUD you're looking to trade per month. And _then_ told to go away.
Edit: disambiguate "Aus" :-)
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%3...
I used it a bit for fun, seemed legit and worked fine.
There are plenty of successful quantitative algorithms that are in use by non HFT firms
> so basically anything with a proprietary API
If you’re not a direct market participant, colocated in the exchange, you’re not in a position to be talking about speed at all. Also most exchanges optimising for speed are not using FIX.
> is solely for amateurs
You’re not necessarily an amateur, you’re just leaving money on the table for someone else as you’ve not optimised that area of your trading infra yet.
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.
There’s a process where you certify that you are a non-professional trader and they give you access to the data feeds for a reasonable price.
I’m working on a similar project, in case you’re interested in swapping notes (contact info in profile)
The code is just Go, using the cobra library.
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.
You specify pies of funds with weights.
They automatically allocate funds and dividends to the underweight entries, and have 1 click for rebalancing.
It's not made for single-real time trading, there's one trading window each day.
Sure beats the spreadsheet and whole-share issues when I did it for free with Robinhood.
I feel like their UX priorities are screwed up big time. But as a platform, they're my favorite as far as concept/functionality.
They list several ways in which they "will" make money. My (possibly unkind) reading is that currently they're burning investor money.
https://www.cnbc.com/2019/04/18/a-controversial-part-of-robi...
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.
Or through what mechanism do commissioned trades get lower prices?
https://www.cnbc.com/2020/03/09/robinhood-app-down-again-dur...
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-arb...
algo guys take https://www.reddit.com/r/algotrading/comments/gkrb6f/generat...
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?
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).
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_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).
Freetrade, 212 Trading and soon Robinhood offer commission free traedes in the UK but no API
https://news.ycombinator.com/item?id=23210385
Different market and laws.
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.
Interesting timing :-)
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".
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.
Yes...the average retail customer submitting a market order will generally get a better fill with PFOF. This is what most people don't usually mention when talking about those terrible high-frequency trading firms.
E.g. if a stock is trading at 10.00x10.10 and I submit a market buy via Robinhood. Citadel or someone else is going to pick that up and sell it to me for, probably, 10.08 or 10.09. Not the 10.10 I would've paid on the open market hitting the offer. It's in fact illegal for me to get a worse (higher) fill than 10.10.
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-p...
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...
https://alpaca.markets/docs/api-documentation/api-v2/market-...
>Trades, quotes and minute bars are supported.
IBS does live tick data for around $10 a month, smaller than 1sec. I hate IBS, but I hate paying $200 a month more, especially when I'm backtesting most months.
https://gitlab.com/aenegri/toro/-/commit/dd3adb3a19bc21966f9...
I feel like a clueless person who lives in the year 2004, wondering why internet services are offered for free.
tl;dr: Interest, payment for order flow, and securities lending (but mostly interest)
[1] https://www.kalzumeus.com/2019/6/26/how-brokerages-make-mone...
As mentioned, Sharesies plan to allow US market access: https://app.sharesies.nz/us-equities-register They do seem to have a private API at least: https://app.sharesies.nz/api/fund/list
https://www.revolut.com/en-NZ have plans to expand to NZ, I don't know much about their services though.
Tradier Brokerage (https://brokerage.tradier.com) can open individual accounts for New Zealand residents and API access comes standard with every account (including market data). You can place orders for US-based equities and options and we offer competitive pricing models for all traders.
If you have any questions, you can email service@tradierbrokerage.com or call 980-272-3880.
Full disclosure, I work at Tradier.