🔮 REST-ful API to evaluate whether a cryptoasset is in backwardation or contango.
- A Google Cloud Account.
- Billing Enabled.
- API Access Enabled.
gcloud
CLI installed and in your$PATH
.- A preferred configuration created (
gcloud init
).
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-backwardango?spot=.BXBT&futures=XBTM19&exchange=Bitmex
Or, if you prefer a POST
:
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-backwardango --data '{"spot": ".BXBT", "futures": "XBTM19", "exchange": "Bitmex"}' -H "Content-Type: application/json"
The expected response:
{
code: 1,
date: 'Mon Apr 15 2019 11:16:00 GMT-0700 (Pacific Daylight Time)',
delta: -23.5,
futures: 5026.5,
spot: 5050,
state: 'backwardation',
timestamp: 1555352160602
}
NOTE: the
code
property has value0
for contango and1
for backwardation.
Or in the case there is a failure:
{
"err": "Exchange, XXX, not supported."
}
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-backwardango?spot=.BXBT&futures=XBTM19&exchange=Bitmex
First, fork or clone this repo, then:
npm i
You need to pass in your environment variables either in a .env.yaml
file or as command line arguements for your exchange clients.
For example, for Bitmex, you need the following in your .env.yaml
file:
BITMEX_API_KEY: XXX
BITMEX_API_SECRET: YYY
Run the following command in the root of this repository, assuming a .env.yaml
file:
gcloud functions deploy api-backwardango --runtime nodejs10 --trigger-http --memory 128MB --env-vars-file .env.yaml
You should receive a YAML like response in your terminal including the URL for the Cloud Function.
npm i -D
BITMEX_API_KEY={YOUR-BITMEX-API-KEY} BITMEX_API_SECRET={YOUR-BITMEX-API-SECRET} npm test
MIT