Last active
April 10, 2021 11:15
-
-
Save vnegi10/890a06e3be6fe5693194691c1012e80a to your computer and use it in GitHub Desktop.
This file contains 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
function get_price_data_single(currency::String) | |
df_out_price = DataFrame() | |
df_out_vol = DataFrame() | |
df_out_candle = DataFrame() | |
date = Dates.today() | |
main_dir = pwd() | |
cd("data") | |
# Look for present day's CSV file, if not found, download and save data to a new file | |
if isfile("$(currency)_EUR_data_$(date).csv") | |
@info "Reading $(currency) data from CSV file on disk" | |
global raw_df = CSV.File("$(currency)_EUR_data_$(date).csv") |> DataFrame | |
else | |
try | |
@info "Fetching $(currency) data from Alpha Vantage" | |
raw = AlphaVantage.digital_currency_daily(currency, "EUR", datatype="csv") | |
global raw_df = raw_to_df(raw) | |
s2 = "$(currency)_EUR_data_$(date).csv" | |
CSV.write(s2, raw_df) | |
catch | |
println("Could not fetch data, try again later!") | |
cd(main_dir) | |
end | |
end | |
cd(main_dir) | |
average_price_df(currency, raw_df, df_out_price, df_out_candle) | |
vol_df(currency, raw_df, df_out_vol) | |
return df_out_price, df_out_candle, df_out_vol | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment