GithubHelp home page GithubHelp logo

joemccann / api-long-short-ratio Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 23 KB

☁️ REST-ful API for fetching the Bitfinex Long vs Short ratio for BTC, ETH, LTC and XRP via Google Cloud Functions.

JavaScript 100.00%
bitfinex gcp gcp-cloud-functions cloud-functions trading-bot trading-algorithms

api-long-short-ratio's Introduction

SYNOPSIS

☁️ REST-ful API for fetching the Bitfinex Long vs Short ratio for BTC, ETH, LTC and XRP via Google Cloud Functions.

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-long-short-ratio?asset=BTC

Or, if you prefer a POST:

curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-long-short-ratio --data '{"asset": "BTC"}' -H "Content-Type: application/json"

The expected response:

{
  "data": {
    "long": 301751.81084729,
    "short": 146453.13477503,
    "timestamp": 1555083480000,
    "ratio": 2.0603984428931335,
    "date": "Fri Apr 12 2019 15:38:54 GMT+0000 (Coordinated Universal Time)"
  }
}

Or in the case there is a failure:

{
  "err": "Request failed: response body was null."
}

API

curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-long-short-ratio?asset=BTC
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-long-short-ratio?asset=ETH
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-long-short-ratio?asset=LTC
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-long-short-ratio?asset=XRP

DEPLOY

First, fork or clone this repo, then:

npm i

Now, deploy it GCP, run the following command in the root of this repository:

gcloud functions deploy api-long-short-ratio --runtime nodejs10 --trigger-http --memory 128MB

You should receive a YAML like response in your terminal including the URL for the Cloud Function.

TESTS

npm i -D
npm test

AUTHORS

LICENSE

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.