Skip to content

Instantly share code, notes, and snippets.

@evanaze
Last active October 12, 2021 07:31
Show Gist options
  • Save evanaze/9e9c012d157e974d55be24320b59feea to your computer and use it in GitHub Desktop.
Save evanaze/9e9c012d157e974d55be24320b59feea to your computer and use it in GitHub Desktop.
Using Amberdata to get the daily Sharpe Ratio of BTC
# our first token to try out
token = "btc"
# the url for our token
url = f"https://web3api.io/api/v2/market/metrics/{token}/historical/sharpe"
# our API key
headers = {'x-api-key': api_key["AMBERDATA_API_KEY"]}
# the start and end of the period
end = dt.datetime.today().isoformat()
start = (dt.datetime.today() + dt.timedelta(-365)).isoformat()
print("Start:", start, "\n", "End:", end)
# a querystring, indicating the time period
querystring = {
"startDate": start,
"endDate": end,
"timeFrame": "1d"
}
# get the response
response = get_response(url, headers)
print("\nFirst five lines of the result:")
for i in range(5):
print(response["data"][i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment