moonmath/README.md

55 lines
1.6 KiB
Markdown
Raw Normal View History

2024-03-17 09:10:05 +00:00
# moonmath
2024-03-22 00:45:27 +00:00
## Bullshit Crypto Price Projections, Now in Your CLI!
2024-03-17 09:10:05 +00:00
![screenshot](./screenshot.png)
This is a re-implementation of [Moon Math][moon] that runs locally as a CLI
program. It's written in Go using the [Bubble Tea][tea] library, and uses
[Coindesk][coin] to source price data.
[moon]: https://www.moonmath.win
[tea]: https://github.com/charmbracelet/bubbletea
[coin]: https://www.coindesk.com
### Configuration
By default, the program will use Bitcoin along with various goals and bases
2024-03-22 00:39:10 +00:00
of comparison. With the `--asset` flag, another asset supported by Coindesk can
be chosen. The [builtin default config](./config/default.yaml) only has special
goals for Ethereum ("ETH"). With the `--config-file` flag, however, one can
specify a YAML file that overrides these defaults and adds goals for other
assets.
2024-03-17 09:10:05 +00:00
### "Theory"
Given a pair of quotes taken at the start and end of some period,
$$ (t_s, p_s), (t_e, p_e) $$
we can derive the total gain for that period, and its length in days.
$$ g = p_e / p_s $$
$$ d = t_e - t_s $$
Combining these, we can calculate the *compounding daily periodic rate* (CDPR).
$$ r = g^{1/d} $$
We can use this rate to project the price $ p_f $ at some $ x $ days in the
future.
$$ p_f = p_e r^x $$
If we instead make $ p_f $ a target price, we can solve this equation for $ x $,
telling us how many days it will take to reach that target.
$$ x = {{log(p_f) - log(p_e)} \over log(r)} $$
### Future Improvements
* Add more default configurations for various assets.
2024-03-17 09:10:05 +00:00
* Allow projection by date, e.g. use the CDPR to calculate what the price
would be on a particular date.
* Log errors to a file.