Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
feat(api): add orderbook api
Browse files Browse the repository at this point in the history
 Get order book data.
  • Loading branch information
albertosantini committed Sep 5, 2015
1 parent cb7354a commit cf41662
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/server/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ exports.getOrders = getOrders;
exports.getPositions = getPositions;
exports.getTransactions = getTransactions;
exports.getCalendar = getCalendar;
exports.getOrderbook = getOrderbook;
exports.putOrder = putOrder;
exports.closeOrder = closeOrder;
exports.closeTrade = closeTrade;
Expand Down Expand Up @@ -237,6 +238,32 @@ function getCalendar(req, response) {
});
}

function getOrderbook(req, response) {
var environment,
token;

if (!req.body) {
return response.sendStatus(400);
}

environment = req.body.environment || credentials.environment;
token = req.body.token || credentials.token;

throttledRequest({
"url": config.getUrl(environment, "api")
+ "/labs/v1/orderbook_data",
qs: {
instrument: req.body.instrument || "EUR_USD",
period: req.body.period || 3600
},
"headers": {
"Authorization": "Bearer " + token
}
}, function (err, res, body) {
processApi("getOrderbook", err, body, response);
});
}

function putOrder(req, response) {
var environment,
token,
Expand Down
1 change: 1 addition & 0 deletions src/server/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ router.post("/orders", jsonParser, api.getOrders);
router.post("/positions", jsonParser, api.getPositions);
router.post("/transactions", jsonParser, api.getTransactions);
router.post("/calendar", jsonParser, api.getCalendar);
router.post("/orderbook", jsonParser, api.getOrderbook);
router.post("/order", jsonParser, api.putOrder);
router.post("/closeorder", jsonParser, api.closeOrder);
router.post("/closetrade", jsonParser, api.closeTrade);
Expand Down

0 comments on commit cf41662

Please sign in to comment.