Add flipped orderbook to getOrderBook response

This commit is contained in:
Chris Clark
2015-06-30 15:43:30 -07:00
parent 99e076b7dd
commit d5f3d90486
2 changed files with 102 additions and 4 deletions

View File

@@ -40,9 +40,13 @@ function formatBidsAndAsks(orderbook, offers) {
// for both bids and asks, lowest quality is closest to mid-market
// we sort the orders so that earlier orders are closer to mid-market
const orders = _.sortBy(offers, 'quality').map(parseOrderbookOrder);
const bids = orders.filter(_.partial(orderFilter, orderbook.base, 'buy'));
const asks = orders.filter(_.partial(orderFilter, orderbook.base, 'sell'));
return {bids, asks};
const {base, counter} = orderbook;
const bids = orders.filter(_.partial(orderFilter, base, 'buy'));
const asks = orders.filter(_.partial(orderFilter, base, 'sell'));
const flippedBids = orders.filter(_.partial(orderFilter, counter, 'buy'));
const flippedAsks = orders.filter(_.partial(orderFilter, counter, 'sell'));
const flipped = {bids: flippedBids, asks: flippedAsks};
return {bids, asks, flipped};
}
function getOrderBook(account, orderbook, options, callback) {

View File

@@ -366,5 +366,99 @@
"sequence": 35789
}
}
]
],
"flipped": {
"bids": [
{
"specification": {
"direction": "buy",
"quantity": {
"currency": "BTC",
"value": "93.030522464522",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
},
"totalPrice": {
"currency": "USD",
"value": "0.2849323720855092",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"properties": {
"maker": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
"sequence": 386940
}
},
{
"specification": {
"direction": "buy",
"quantity": {
"currency": "BTC",
"value": "1",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
},
"totalPrice": {
"currency": "USD",
"value": "0.00302447007930511",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"properties": {
"maker": "rwjsRktX1eguUr1pHTffyHnC4uyrvX58V1",
"sequence": 207855
}
},
{
"specification": {
"direction": "buy",
"quantity": {
"currency": "BTC",
"value": "182.9814890090516",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
},
"totalPrice": {
"currency": "USD",
"value": "0.5",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"properties": {
"maker": "rUeCeioKJkbYhv4mRGuAbZpPcqkMCoYq6N",
"sequence": 5255
},
"state": {
"availableQuantity": {
"currency": "BTC",
"value": "82.50309772176658",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
},
"priceOfAvailableQuantity": {
"currency": "USD",
"value": "0.2254411038203033",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
}
}
],
"asks": [
{
"specification": {
"direction": "sell",
"quantity": {
"currency": "BTC",
"value": "1.24252537879871",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
},
"totalPrice": {
"currency": "USD",
"value": "0.003967400879423823",
"counterparty": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
}
},
"properties": {
"maker": "rDbsCJr5m8gHDCNEHCZtFxcXHsD4S9jH83",
"sequence": 110099
}
}
]
}
}