Skip to content

Instantly share code, notes, and snippets.

@vnegi10
Created February 14, 2021 22:37
Show Gist options
  • Save vnegi10/de2ec79a19d60b8639ba972f2839eb1d to your computer and use it in GitHub Desktop.
Save vnegi10/de2ec79a19d60b8639ba972f2839eb1d to your computer and use it in GitHub Desktop.
function get_ratings_data(currency::String)
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)_metrics_data_$(date).csv")
metrics_df = CSV.File("$(currency)_metrics_data_$(date).csv") |> DataFrames.DataFrame
else
rating = AlphaVantage.crypto_rating(currency)
scores = try
scores = rating["Crypto Rating (FCAS)"]
catch
cd(main_dir)
end
#s1 = pwd()
s2 = "$(currency)_metrics_data_$(date).csv"
CSV.write(s2, scores)
metrics_df = CSV.File("$(currency)_metrics_data_$(date).csv") |> DataFrames.DataFrame
end
cd(main_dir)
ratings = ["utility", "fcas score", "developer", "market", "fcas rating"]
index = Array{Int64}(undef,0)
# Find the row(index) of a string match
for rating in ratings
i = findall(occursin.(rating, metrics_df[!,1]))
push!(index, i[1])
end
# Variables should be assigned in the same order as the list of ratings above
utility_score, fcas_score, dev_score = metrics_df[!,2][index[1]], metrics_df[!,2][index[2]], metrics_df[!,2][index[3]]
mark_score, fcas_rating = metrics_df[!,2][index[4]], metrics_df[!,2][index[5]]
return utility_score, fcas_score, dev_score, mark_score, fcas_rating
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment