Created
March 26, 2024 02:15
-
-
Save JeffBezanson/818cddc8eafc6aab19cc78f188668c8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CSV, DataFrames, Plots, CurveFit, Dates, Statistics | |
btc = CSV.read("/home/jeff/Downloads/bitcoinity_data.csv", DataFrame) | |
mmiddle(x,y) = ismissing(x) ? y : ismissing(y) ? x : middle(x,y) | |
merged = mmiddle.(btc[!,:coinbase], btc[!,:others]) # use both coinbase and "other" (early) data | |
deleteat!(btc, findall(ismissing, merged)) | |
logprice = log10.(mmiddle.(btc[!,:coinbase], btc[!,:others])) | |
logdays = map(x->log10((Date(x[1:10])-Date(2009,1,3)).value-1), btc[!,:Time]) # days since genesis block! | |
plot(logdays, logprice, title="Bitcoin price history log-log", xlabel="log(days)", ylabel="log(dollars)", label=nothing, yformatter=:plain) | |
a, power = linear_fit(logdays, logprice) | |
@show power | |
fitline = a .+ power*logdays | |
plot!(logdays, fitline, label="power law fit") | |
savefig("btcpriceloglog.png") | |
@show cor(fitline, logprice) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment