Show HN: A free, lightweight static page to get stock quotes using the IEX API
github.com
github.com
For example I didn't even realise JS supported string interpolation
https://github.com/toddwschneider/stocks/blob/master/index.h...
There’s still a lot of “pain” left in the build processes, transpiling, etc, but they’re less painful than they were half a decade ago. Those are also less specific to issues with the language, and more with how we need to use the language.
While not plain JS, I’d strongly recommend trying Vue if you’re getting back into JS. Is a true pleasure to use on a daily basis, and I never find myself fighting it. It makes writing non static sites with interactivity a breeze, and even when I’m building near static pages, I like how it helps me to organize my code (from a structure standpoint, it isn’t opinionated on this stuff).
Another really awesome new feature which I can't remember if it's in that course or not, is fetch - super simple AJAX API using promises. It's also used in this app: https://github.com/toddwschneider/stocks/blob/master/index.h...
index.html#L111
in https://github.com/toddwschneider/stocks/blob/master/index.html#L111It let you pick the stocks yourself, and showed you historical graphs too. It was a bit more complex than this, but still only took an hour.
https://support.robinhood.com/hc/en-us/articles/210216823-Ro...
Why would you? Their volume is likely a fraction of IEX's:
https://markets.cboe.com/us/equities/market_share/
Worse all their stuff is effectively darkpooled. You'd be hard-pressed to find a worse source of market data.
Also:
https://medium.com/@Gangal/robinhood-robbing-from-the-poor-g...
Hence when they launched the terrible execution - not enough internal counterparties.
A static page means no processing is done on a web server to serve you the rendered content. This saves you time and money, and ensures scalability for any amount of traffic.
A few notes from taking a look at the code:
* I've very much started doing the same thing in my projects of just using modern JavaScript constructs like fetch and arrow functions without a transpiler. IE is never going to support any of them, but I've accepted that. Caniuse.com ranks most of them at 85%+ supported.
* It's neat to see that the IEX API supports batch requests (as opposed to having to pull one stock at a time) in its API which makes it possible to implement the project efficiently and in a way that doesn't have to store state.
* Nice work building it to support large users as well. A lot of installations probably won't have more than 100 stocks, but it'll break up requests into multiple batches of <= 100 if they do.
I have now transitioned to my own Google Sheet with the "=GOOGLEFINANCE()" function for getting the stock data. Works pretty well.
As everything is done client side how about adding some parsing of the URL #hash/?query to encode data of a portfolio? That way you could have a single statically hosted version serving multiple people. Could even have a portfolio builder page that generates the encoded URL.
https://samdobson.github.io/stocks/?Banks=GS,MS,JPM&Tech=AAP...
Here is the code author uses to get data:
const BASE_URL = 'https://api.iextrading.com/1.0/stock/market/batch';
let url = `${BASE_URL}?types=quote&symbols=${symbols.join(',')}&filter=${filters.join(',')}`;As for an alternative, and I don't know the options here, but maybe a plugin could be made that pulls the data into Calc itself.