joemccann / api-backwardango

🔮 REST-ful API to evaluate whether a cryptoasset is in backwardation or contango.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SYNOPSIS

🔮 REST-ful API to evaluate whether a cryptoasset is in backwardation or contango.

REQUIREMENTS

  1. A Google Cloud Account.
  2. Billing Enabled.
  3. API Access Enabled.
  4. gcloud CLI installed and in your $PATH.
  5. A preferred configuration created ( gcloud init ).

USAGE

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 value 0 for contango and 1 for backwardation.

Or in the case there is a failure:

{
  "err": "Exchange, XXX, not supported."
}

API

curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-backwardango?spot=.BXBT&futures=XBTM19&exchange=Bitmex

DEPLOY

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.

TESTS

npm i -D
BITMEX_API_KEY={YOUR-BITMEX-API-KEY} BITMEX_API_SECRET={YOUR-BITMEX-API-SECRET} npm test

AUTHORS

LICENSE

MIT

About

🔮 REST-ful API to evaluate whether a cryptoasset is in backwardation or contango.


Languages

Language:JavaScript 100.0%