Lurker News
Here's a little side project I’ve been working on: https://totalrealreturns.com/ The Total Real Returns chart demonstrates the preservation or growth of real wealth more clearly than conventional (nominal-dollar, price-only) stock charts, because: (1) we include the effects of inflation-diminished purchasing power, and (2) we include the effects of reinvesting dividends from the initial investment.

I found it harder to explain the y-axis in words than it was to do the math, so please let me know if you think the "baguettes" explanation on the homepage helps.
I was up until 4am ET finishing some features on this, and then at 8:30am ET the BLS released the new CPI numbers through their API: https://download.bls.gov/pub/time.series/cu/ and I was able to manually re-run my daily cronjob with the new numbers, so it's up to date! If you catch any bugs, please let me know via the “Report a bug” link in the footer of every page.
Some FAANG examples: https://totalrealreturns.com/s/META
https://totalrealreturns.com/s/GOOGL
https://totalrealreturns.com/s/AMZN
https://totalrealreturns.com/s/AAPL
https://totalrealreturns.com/s/NFLX
Comparing three Vanguard treasury funds, showing vividly the impact of bond duration (short-term, intermediate-term, long-term) on both risk and reward: https://totalrealreturns.com/s/VFISX,VFITX,VUSTX

Comments (272) 48 threads

Show all comments

Showing thread 19 of 48

rrevi1 reply#
Thanks for sharing compumike! Very cool!!

If you don’t mind me asking, why did you choose the Crystal programming language for this project?

compumike#
Crystal https://crystal-lang.org/ is beautiful, highly performant, concise, powerful, well documented. It has a solid standard library and plenty of "shards" (packages) too. It's really the elegance of writing it that I appreciate the most -- perhaps even more than I get that elegant feeling from Ruby. The code for the standard library is highly readable and well documented, which is awesome.

In working on this project, I discovered two "superpowers" of Crystal:
The first was macros https://crystal-lang.org/reference/1.5/syntax_and_semantics/... which I used sparingly, but to great effect, when an ordinary method call wouldn't do.
The second was monkeypatching: specifically, it's super easy to reopen existing standard library classes and add a field I need, for example:

    # BEGIN MONKEYPATCH
    class HTTP::Server::Context
      property response_body_cache_key : String? = nil
    end
    # END MONKEYPATCH
This adds a new field the standard library HTTP::Server::Context https://github.com/crystal-lang/crystal/blob/1.5.0/src/http/... / https://crystal-lang.org/api/1.5.0/HTTP/Server/Context.html so I can specify a cache key near the beginning of a request handler, and later my response middleware picks it up to store the response body.