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.
Requires Node.js v4.0 or higher.
$ npm install libbux
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);
}
});
});
TODO
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
TODO
TODO
BUX.api
options:
server
(string) - BUX API server address (default: "https://api.bux.com"
)no_symbols
(boolean) - Dont resolve Products Symbols (default: false
)access_token
(string) - Access TokenTODO
BUX
methods and constantsBUX.api
instance methods(account, callback)
- Login(callback)
- Basic info about account(callback)
- Lock sensitive operations (seriousBUX only)(callback)
- Get lock status (seriousBUX only)(callback)
- Reset your pincode via email (seriousBUX only)(pincode, callback)
- Unlock with pincode (seriousBUX only)(callback)
- Cash balance(callback)
- Cash transactions(callback)
- Your profile(callback)
- Friends list(query, callback)
- Search user(userId, callback)
- User profile(callback)
- List of pending notifications(callback)
- News articles(callback)
- Social feed(callback)
- Products list(productId, callback)
- Product detail(query, callback)
- Product search(productId, amount, callback)
- Set product alert(productId, callback)
- Remove product alert(productId, callback)
- Set product as favorite(productId, callback)
- Remove product from favorites(callback)
- Trading fees(callback)
- Opened positions(positionId, callback)
- Position detail(positionId, options, callback)
- Set position alert(positionId, callback)
- Remove alert from position(positionId, options, callback)
- Set position autoclose(positionId, callback)
- Remove autoclose from position(callback)
- Basic performance info(callback)
- Trading history(tradeId, callback)
- Detailed info about trade from history(trade, callback)
- Open position(positionId, callback)
- Close position(eventsArray, callback, [onReady])
- Subscribe for Realtime data(productsArray, callback, [onReady])
- Subscribe for Product price changes(eventsArray, callback)
- Unsubscribe(callback)
- Your following/participating groups(callback)
- Get number of allowed groups(groupId, callback)
- Group details(groupId, callback)
- Follow group(groupId, callback)
- Un-Follow group(groupId, callback)
- Group feed items(groupId, callback)
- Group feed cursor(groupId, lastReadFeedItemId, callback)
- Set last read feed item(groupId, message, callback)
- Post message to group(groupId, messageId, callback)
- Delete message(groupId, callback)
- User group role(groupId, memberId, callback)
- Group member portfolio(groupId, callback)
- Group followers overview (only public groups)(groupId, settings, callback)
- Update group settings (notifications)(callback)
- List of your battles(callback)
- Get number of allowed battles(battleId, callback)
- Battle info(options, callback)
- Create new battle(battleId, callback)
- Battle feed(battleId, message, callback)
- Post message to battle(battleId, settings, callback)
- Group settings(callback)
- Battle templates(callback)
- Get global activities(callback)
- Get your activities(callback)
- Info about seriousBUX status(method, endpoint, data, callback)
- Execute BUX API call()
(symbolsObject)
(productId)
(endpoint)
Login to BUX, get your access_token.
account object properties:
{
email: 'your_email@example.org',
password: 'your_bux_password'
}
options object properties:
{
"upperLimit": 0.8, // 8%
"lowerLimit": -0.10, // -10%
}
trade object properties:
{
product: '@DAX', // productId or symbol
direction: 'BUY', // BUY or SELL
size: 1000, // Trade amount
multiplier: 5
}
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 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:
performance
product.{securityId}
- (for example product.sb33927
)position.opened
battle.created
battle.finished
group.followed
notification
settings object properties:
{
"muteUntil": 31536000000000
}
options object properties:
{
"battleName": "Battle name",
"orientation": "LOCAL",
"templateId": "2"
}
Jan Stránský <jan.stransky@arnal.cz>
If you make profits and this work make you happy, you can donate any amount to my Bitcoin address:
1P1swvi7Y6tTYBgxBszr71CG3fc67C2oBD
MIT