Skip to content

Commit

Permalink
Improve order matching when clicking orderbook orders #200
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed Sep 6, 2017
1 parent b87baec commit 41aca40
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions web/app/stores/MarketsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ class MarketsStore {
combinedBids.sort((a, b) => {
return b.getPrice() - a.getPrice();
}).forEach(a => {
totalToReceive.plus(a.amountToReceive(false));
totalToReceive.plus(a.amountToReceive(true));
totalForSale.plus(a.amountForSale());

a.setTotalForSale(totalForSale.clone());
Expand All @@ -804,7 +804,7 @@ class MarketsStore {
return a.getPrice() - b.getPrice();
}).forEach(a => {
totalForSale.plus(a.amountForSale());
totalToReceive.plus(a.amountToReceive(true));
totalToReceive.plus(a.amountToReceive(false));
a.setTotalForSale(totalForSale.clone());
a.setTotalToReceive(totalToReceive.clone());
});
Expand Down
20 changes: 20 additions & 0 deletions web/test/marketTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,24 @@ describe("LimitOrder", function() {
,"deferred_fee":14676
};

const o5 = {
"id":"1.7.69372",
"expiration":"2017-12-13T14:14:09",
"seller":"1.2.132823",
"for_sale":1,
"sell_price": {
"base":{
"amount": 6470,
"asset_id":"1.3.0"
},
"quote": {
"amount":20113,
"asset_id":"1.3.121"
},
}
,"deferred_fee":14676
};

it("Instantiates", function() {
let order = new LimitOrder(o, assets, "1.3.0");
assert(order.id === o.id);
Expand Down Expand Up @@ -663,11 +681,13 @@ describe("LimitOrder", function() {
let order4 = new LimitOrder(o4, assets, "1.3.121");
let order5 = new LimitOrder(o3, assets, "1.3.0");
let order6 = new LimitOrder(o4, assets, "1.3.0");
let order7 = new LimitOrder(o5, assets, "1.3.121");

assert.equal(order3.amountToReceive().getAmount(), 3154, "As an ask, amountToReceive should equal 3154");
assert.equal(order4.amountToReceive().getAmount(), 1, "Order4 should equal 1");
assert.equal(order5.amountToReceive().getAmount(), 3155, "As a bid, amountToReceive should equal 3155");
assert.equal(order6.amountToReceive().getAmount(), 1, "Order6 should equal 1");
assert.equal(order7.amountToReceive().getAmount(), 4, "Order7 should equal 4");

});

Expand Down

0 comments on commit 41aca40

Please sign in to comment.