burningtree / libbux

Un-official library for BUX trading platform (Node.js)
28 stars 9 forks source link

libBUX

Build Status Dependency Status

Un-official Javascript/Node.js library for BUX trading platform. Let's rock the world of finance!

It uses official REST & WebSockets APIs which are used for a BUX mobile applications. For these APIs, there is no public documentation and thus no official support from the BUX team. Keep in mind that any change in the interface may (temporarily) break this library.

Current version: 0.2.7
This is EXPERIMENTAL version. Use at your own risk.

Table of contents

Installation

Requires Node.js v4.0 or higher.

$ npm install libbux

Getting Started

Example: Show my profits

Source: examples/minimal.js

// Load library and get api interface
var BUX = require('libbux');
var bux = BUX.api();

// Specify account details
var account = {
  email: 'your_email@example.org',
  password: 'your_bux_password'
};

// Do login
bux.login(account, function(err, data) {
  if (err) throw err;

  // Here is your access_token, you can use it later
  console.log('Your access_token: '+data.access_token);

  // Get your portfolio
  bux.portfolio(function(err, data) {
    if (err) throw err;

    // Traverse portfolio and print your current products and profits
    for (var pos in data.positions) {
      var p = data.positions[pos];
      console.log('%s .. %s', p.product.displayName, p.profitAndLoss.amount);
    }
  });
});

BUX Functionality

Implemented

TODO

User Guide

Why Use It?

TODO

Authentication

var account = {
  email: 'your_email@example.org',
  password: 'your_bux_password'
}

bux.login(function(err, auth) {

  // Grab your token (for store)
  var token = data.access_token;

  // Your authenticated requests
  // ...
});

If you have access_token then you can setup library directly:

// passed as config option
var bux = BUX.api({ access_token: 'MY_TOKEN' });

// or later
// TODO

Understanding Data

TODO

Making Trades

TODO

Configuration

BUX.api options:

Symbols

TODO

API Reference

BUX methods and constants

BUX.api instance methods

Internal methods

login (account, callback)

Login to BUX, get your access_token.

account object properties:

{
  email: 'your_email@example.org',
  password: 'your_bux_password'
}

alert (positionId, options, callback)

autoclose (positionId, options, callback)

options object properties:

{
  "upperLimit": 0.8,     // 8%
  "lowerLimit": -0.10,   // -10%
}

open (trade, callback)

trade object properties:

{
  product: '@DAX',    // productId or symbol
  direction: 'BUY',   // BUY or SELL
  size: 1000,         // Trade amount 
  multiplier: 5
}

exec (method, endpoint, data, callback)

Short version for GET requests: exec (method, endpoint, callback)

Executes all raw BUX API calls. For more informations about BUX API endpoints, see endpoints.yaml file.

bux.exec('get', 'users/me', function(err, me) {
  console.log(me.nickname);
});

subscribe (eventsArray, callback)

Subscribe to Realtime data, for example:

bux.subscribe([ 'portfolio.performance' ], function(res, type, data) {
  console.log('Got message: type=%s, data=%s', type, data);
});

Available events:

groupSettings (groupId, settings, callback)

settings object properties:

{
  "muteUntil": 31536000000000
}

battleCreate (options, callback)

options object properties:

{
  "battleName": "Battle name",
  "orientation": "LOCAL",
  "templateId": "2"
}

Related Projects

TODO

Authors

Jan Stránský <jan.stransky@arnal.cz>

Donate

If you make profits and this work make you happy, you can donate any amount to my Bitcoin address: 1P1swvi7Y6tTYBgxBszr71CG3fc67C2oBD

Licence

MIT