Skip to content

Commit

Permalink
Sum order amounts in the orderbook when clicking on an order, fix an …
Browse files Browse the repository at this point in the history
…issue in MarketsActions
  • Loading branch information
svk31 committed Sep 18, 2015
1 parent e3c22ec commit eb98d6c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dl/src/actions/MarketsActions.js
Expand Up @@ -228,7 +228,7 @@ class MarketsActions {
"amount": buyAmount,
"asset_id": buyAssetID
},
"expiration": uniqueExpiration,
"expiration": expiration,
"fill_or_kill": isFillOrKill
});
return WalletDb.process_transaction(tr, null, true).then(result => {
Expand Down
12 changes: 3 additions & 9 deletions web/app/components/Exchange/Exchange.jsx
Expand Up @@ -5,22 +5,16 @@ import {MyOpenOrders} from "./MyOpenOrders";
import OrderBook from "./OrderBook";
import MarketHistory from "./MarketHistory";
import BuySell from "./BuySell";
// import Margin from "./Margin";
import utils from "common/utils";
import PriceChart from "./PriceChart";
import DepthHighChart from "./DepthHighChart";
// import Tabs from "react-foundation-apps/src/tabs";
import {debounce} from "lodash";
import BorrowModal from "../Modal/BorrowModal";
import Translate from "react-translate-component";
import counterpart from "counterpart";
import notify from "actions/NotificationActions";
import {Link} from "react-router";
import AccountNotifications from "../Notifier/NotifierContainer";
// import Wallet from "transitionTo";
// import BlockchainStore from "stores/BlockchainStore";
// import FormattedAsset from "../Utility/FormattedAsset";
// import WalletDb from "stores/WalletDb";
import Ps from "perfect-scrollbar";
import ChainTypes from "../Utility/ChainTypes";
import BindToChainState from "../Utility/BindToChainState";
Expand Down Expand Up @@ -112,15 +106,16 @@ class Exchange extends React.Component {
_createLimitOrder(buyAsset, sellAsset, buyAssetAmount, sellAssetAmount) {
console.log("createLimitOrder:", buyAssetAmount, sellAssetAmount);
let expiration = new Date();
// TODO: Add selector for expiry
expiration.setYear(expiration.getFullYear() + 5);
MarketsActions.createLimitOrder(
this.props.account.get("id"),
parseInt(sellAssetAmount * utils.get_asset_precision(sellAsset.precision), 10),
sellAsset.id,
parseInt(buyAssetAmount * utils.get_asset_precision(buyAsset.precision), 10),
buyAsset.id,
expiration.toISOString().slice(0, -7), // the seconds will be added in the actionCreator to set a unique identifer for this user and order
false // fill or kill
expiration,
false // fill or kill TODO: add fill or kill switch
).then(result => {
if (!result) {
notify.addNotification({
Expand Down Expand Up @@ -295,7 +290,6 @@ class Exchange extends React.Component {
}

_orderbookClick(base, quote, price, amount, type) {
console.log("price:", price, "amount:", amount, "type:", type);
if (type === "bid") {

let value = amount.toString();
Expand Down
13 changes: 9 additions & 4 deletions web/app/components/Exchange/OrderBook.jsx
Expand Up @@ -60,9 +60,12 @@ class OrderBook extends React.Component {

high = bids.length > 0 ? bids[bids.length - 1].price_full : 0;

bidRows = bids.map(order => {
let totalBidAmount = 0;

bidRows = bids.reverse().map(order => {
totalBidAmount += order.amount;
return (
<tr key={order.price_full} onClick={this.props.onClick.bind(this, order.price_full, order.amount, "bid")}>
<tr key={order.price_full} onClick={this.props.onClick.bind(this, order.price_full, totalBidAmount, "bid")}>
<td className="show-for-medium">{utils.format_number(order.value, base.precision)}</td>
<td>{utils.format_number(order.amount, quote.precision)}</td>
<td className="orderHistoryBid">
Expand All @@ -72,17 +75,19 @@ class OrderBook extends React.Component {
</td>
</tr>
);
});
}).reverse();

// console.log("time to process bids in orderbook:", new Date() - start, "ms");

// start = new Date();

low = asks.length > 0 ? asks[0].price_full : 0;

let totalAskAmount = 0;
askRows = asks.map(order => {
totalAskAmount += order.amount;
return (
<tr key={order.price_full} onClick={this.props.onClick.bind(this, order.price_full, order.amount, "ask")}>
<tr key={order.price_full} onClick={this.props.onClick.bind(this, order.price_full, totalAskAmount, "ask")}>
<td className="show-for-medium">{utils.format_number(order.value, base.precision)}</td>
<td >{utils.format_number(order.amount, quote.precision)}</td>
<td className="orderHistoryAsk">
Expand Down

0 comments on commit eb98d6c

Please sign in to comment.