FRED (Cloud Node-RED) and cryptocurrencies

with No Comments

Accessing Cryptocurrency data via the STS Binance node

We’ve seen a few folks playing around with FRED to access – and in some cases – trade on cryptocurrencies, which we thought was a fun use of Node-RED. Our very own crypto expert, Ted, here at STS decided to jump in and develop a new Node for accessing and using the Binance cryptocurrency platform. For those of you who aren’t familiar, Binance is one of the largest crypto trading platform (perhaps largest by volume), and importantly has a comprehensive and sophisticated API.

The new Binance node that Ted has written is available for NPM download and is also installed on FRED for use.

A couple of caveats:

  1. you’ll need a FRED tall (or higher) account to really use the node – otherwise your ability to track in real-time won’t be great
  2. Use it at your own risk – while you can use it for trading, you do so entirely at your own risk. FRED isn’t a trading platform and we take no responsibility whatsoever for financial losses, security or other issues if you choose to use the node on FRED for any type of trading activity.

 

Tutorials:

  • We’ve written a short tutorial on using the node that shows how a simple Node-RED flow can get a variety of market data.
  • A second tutorial on dashboarding market data from Binance builds on the previous tutorial and adds a basic dashboard that uses Node-RED UI nodes to graph live data.
  • Dashboard DEMO. Ted has also created a very slick dashboard demo which you can see here.
    • A tutorial that explains how this is done is here

Basic capabilities

The node provides an interface to two core sets of API. Those associated with getting market data and those associated with balance and trading. The first group can be accessed without an account at Binance. The functionality associated with balance and trading requires you have an account with Binance and have set up the associated 2 phase security.

Accessing market info

  • getPrice: Gets the latest price of a symbol. Takes a ticker pair as input and returns the current price
  • getAllPrices: Gets the latest price of all symbols. No input and returns an {object} map of all available ticker pairs and their current prices
  • getBookTicker: Gets the bid/ask prices for a symbol. Takes a ticker pair as input and returns an {object} info on latest book price
  • getDayStats: Get the 24hr ticker price change statistics for a symbol. Takes a tickerPair as input and returns the latest 24h stats
  • getCandlesticks: Get Kline/candlestick data for a symbol. Takes a tickerPair, time interval and start/ed times and returns an {array} of candlesticks/kline data specified by parameters

Balance and trading

  • getOrders: Get open orders for a symbol. Takes and API credential and a tickerPair. Returns an {array} of current orders for that tickerPair
  • getBalance:  Get a list of current balances.Takes and API credential and a tickerPair and returns an {object} map of ticker symbols and quantity on the account
  • cancelOrders: Cancel all open orders of a ticker pair. Takes and API credential and a tickerPair and returns an {object} with the binance API response
  • getTradeHistory: Get trade history of a ticker pair.Takes and API credential and a tickerPair and returns an {array} list of previous orders
  • buy: Create a limit or market buy order. USE AT YOUR OWN RISK.
    • Input:
      • API credentials – required
      • tickerPair – required
      • order type (limit/market) – required
      • quantity – required
      • price – required
    • Output:
      • {object} binance API response
  • sell: Create a limit or market sell order. USE AT YOUR OWN RISK
    • Input:
      • API credentials – required
      • tickerPair – required
      • order type (limit/market) – required
      • quantity – required
      • price – required
    • Output:
      • {object} binance API response

Response and error handling

Most responses are directly passed through from the API to the output payload. Errors are directed to the nodes status message as well as the debug console.