Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bfx-hf-data-server

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bfx-hf-data-server

HF data server module

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by500%
Maintainers
1
Weekly downloads
 
Created
Source

HF Data Server

Build Status

The HF data server exposes a websocket interface for querying trade/candle data from Bitfinex, and syncronizes that data in a local DB.

To run, use npm start

Initialization

Start a data server instance using lib/start:

const { RESTv2 } = require('bfx-api-node-rest')
const { logDataDBInfo, startDataServer } = require('bfx-hf-data-server')

const run = async () => {
  const rest = new RESTv2(...) // create a REST API interface for fetching data
  const ds = startDataServer({
    port: 8899, // command port number
    rest
  })

  await logDataDBInfo()
}

try {
  run()
} catch (e) {
  debug(e.stack)
}

Then connect to the command port number (8899 in the above example) and request a backtest by sending an 'exec.bt' command:

['exec.bt', [
  from,      // start timestamp
  to,        // end timestamp
  symbol,    // i.e. 'tBTCUSD'
  timeFrame, // i.e. '1m'
  candles,   // true or false
  trades,    // true or false
  candleFields, // '*' (which candle data fields to return)
  tradeFields,  // '*' (see above)
  sync       // true or false, whether to sync missing data
]]

If not all requested data is available locally, the server will first syncronize it before initiating the backtest data stream. In all, the server will reply with any of the following packets:

  • ['bt.sync.start', symbol, timeFrame, from, to] - when a sync process starts
  • ['bt.sync.end', symbol, timeFrame, from, to] - when a sync process end
  • ['bt.start', null, null, from, to, null, nTrades, nCandles] - before the backtest data stream
  • ['bt.end', null, null, from, to] - after the backtest data stream
  • ['bt.candle', null, null, candle] - individual BT candle
  • ['bt.trade', null, trade] - individual BT trade

Candles are of the form { symbol, open, high, low, close, mts }, and trades { id, symbol, amount, price }.

Keywords

FAQs

Package last updated on 16 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc