Get access to TheRockTrading real-time market data via Pusher websocket service provider.
Websocket documentation will cover simple javascript client implementations based on Pusher library.
Start including pusher library inside your project:
<script src="https://js.pusher.com/5.0/pusher.min.js" type="text/javascript"></script>
Then configure it with TheRockTrading websocket authentication parameters to establish an authenticated connection. Despite all events are public, we encourage to establish an authenticated connection in order to avoid to get disconnected just after 30 seconds of activity.
This security measure has been introduced in order to offer a better service to our customers, discouraging any attempt of abuse toward our platform.
var pusher = new Pusher('f6cab614ad01473962d2', {
cluster: 'eu',
authEndpoint: 'https://api.therocktrading.com/ws/auth/pusher',
auth: {
headers: {
'X-AUTH-Token': 'authentication-token'
}
}
});
pusher.subscribe('private-auth'); // requests pusher to subscribe to an authenticated channel validated by therocktrading.com authentication endpoint.
Replace "authentication-token" string with your personal code that you can get by logging into www.therocktrading.com site under "my personal data" menu, websocket section.
Now you can proceed subscribing websocket events you are interested in as described in the following sections.
Generic events
Generic "currency" channel includes global trading platform related events.
NEW OFFER
Get the best offer (bid or ask) per fund symbol.
CHANNEL: currency EVENT: new_offer
{
"symbol": "BTCEUR",
"value": 277.45,
"type": "ask"
}
var trades_channel = pusher.subscribe('currency');
trades_channel.bind('new_offer', function(data) {
console.log(data);
});
LAST TRADE
Get last trades information.
CHANNEL: currency EVENT: last_trade
{
"symbol": "LTCEUR",
"quantity": 0.2,
"value": 3.05,
"volume": 0.61,
"time": "2015-07-20T10:23:19+02:00",
"diff": 0,
"dark": false,
"side": "sell"
}
var trades_channel = pusher.subscribe('currency');
trades_channel.bind('last_trade', function(data) {
console.log(data);
});
See a complete code example here.
LAST VOLUME
Get last volume information.
CHANNEL: currency EVENT: last_volume
{
"dayv_base_currency": {
"value": 366526.05,
"currency": "EUR"
},
"dayv_trade_currency": {
"value": 5745.74,
"currency": "ETH"
}
}
var trades_channel = pusher.subscribe('currency');
trades_channel.bind('last_volume', function(data) {
console.log(data);
});
Fund related events
Per fund events on orderbook changes
ORDERBOOK_DIFF
Get orderbook differences only. A zero amount value indicates all orders placed at a specific price have been deleted.
CHANNEL: fund symbol EVENT: orderbook_diff
{
"side": "ask",
"price": 277.35,
"amount": 0.67
}
var order_book_channel = pusher.subscribe('BTCEUR');
order_book_channel.bind('orderbook_diff', function(data) {
console.log("price: " + data['price']);
console.log("amount: " + data['amount']);
});
order deleted if amount == 0
See a complete code example here.
ORDERBOOK
Get first 20 orderbook rows on order book changes.
CHANNEL: fund symbol EVENT: orderbook
{
"asks": [
{
"price": 277.36,
"amount": 0.82
}
],
"bids": [
{
"price": 263.14,
"amount": 0.08
}
]
}
var order_book_channel = pusher.subscribe('BTCEUR');
order_book_channel.bind('orderbook', function(data) {
console.log("bids: " + data['bids']);
console.log("asks: " + data['asks']);
});
See a complete code example here.