diff --git a/components/trade/RecentTrades.tsx b/components/trade/RecentTrades.tsx index 4206ce3e..eda067f9 100644 --- a/components/trade/RecentTrades.tsx +++ b/components/trade/RecentTrades.tsx @@ -97,9 +97,27 @@ const RecentTrades = () => { actions.loadMarketFills() }, 5000) + const [buyRatio, sellRatio] = useMemo(() => { + if (!fills.length) return [0, 0] + + const vol = fills.reduce( + (a: { buys: number; sells: number }, c: any) => { + if (c.side === 'buy' || c.takerSide === 1) { + a.buys = a.buys + c.size + } else { + a.sells = a.sells + c.size + } + return a + }, + { buys: 0, sells: 0 } + ) + const totalVol = vol.buys + vol.sells + return [vol.buys / totalVol, vol.sells / totalVol] + }, [fills]) + return (
-
+
@@ -118,6 +136,17 @@ const RecentTrades = () => { )} + + {t('trade:buys')}:{' '} + + {(buyRatio * 100).toFixed(1)}% + + | + {t('trade:sells')}:{' '} + + {(sellRatio * 100).toFixed(1)}% + +
diff --git a/public/locales/en/trade.json b/public/locales/en/trade.json index 6ef4efb6..fed60d19 100644 --- a/public/locales/en/trade.json +++ b/public/locales/en/trade.json @@ -2,6 +2,7 @@ "amount": "Amount", "base": "Base", "book": "Book", + "buys": "Buys", "cancel-order-error": "Failed to cancel order", "connect-orders": "Connect to view your open orders", "connect-positions": "Connect to view your perp positions", @@ -32,6 +33,7 @@ "place-order": "Place {{side}} Order", "placing-order": "Placing Order", "quote": "Quote", + "sells": "Sells", "settle-funds": "Settle Funds", "settle-funds-error": "Failed to settle funds", "show-asks": "Show Asks", diff --git a/public/locales/es/trade.json b/public/locales/es/trade.json index 6ef4efb6..fed60d19 100644 --- a/public/locales/es/trade.json +++ b/public/locales/es/trade.json @@ -2,6 +2,7 @@ "amount": "Amount", "base": "Base", "book": "Book", + "buys": "Buys", "cancel-order-error": "Failed to cancel order", "connect-orders": "Connect to view your open orders", "connect-positions": "Connect to view your perp positions", @@ -32,6 +33,7 @@ "place-order": "Place {{side}} Order", "placing-order": "Placing Order", "quote": "Quote", + "sells": "Sells", "settle-funds": "Settle Funds", "settle-funds-error": "Failed to settle funds", "show-asks": "Show Asks", diff --git a/public/locales/ru/trade.json b/public/locales/ru/trade.json index 1cf16796..fed60d19 100644 --- a/public/locales/ru/trade.json +++ b/public/locales/ru/trade.json @@ -2,6 +2,7 @@ "amount": "Amount", "base": "Base", "book": "Book", + "buys": "Buys", "cancel-order-error": "Failed to cancel order", "connect-orders": "Connect to view your open orders", "connect-positions": "Connect to view your perp positions", @@ -21,17 +22,18 @@ "no-orders": "No open orders", "no-positions": "No perp positions", "no-unsettled": "No unsettled funds", + "notional": "Notional", "open-interest": "Open Interest", "oracle-price": "Oracle Price", "order-error": "Failed to place order", "order-type": "Order Type", "order-value": "Order Value", "orders": "Orders", - "notional": "Notional", "post": "Post", "place-order": "Place {{side}} Order", "placing-order": "Placing Order", "quote": "Quote", + "sells": "Sells", "settle-funds": "Settle Funds", "settle-funds-error": "Failed to settle funds", "show-asks": "Show Asks", diff --git a/public/locales/zh/trade.json b/public/locales/zh/trade.json index 6ef4efb6..fed60d19 100644 --- a/public/locales/zh/trade.json +++ b/public/locales/zh/trade.json @@ -2,6 +2,7 @@ "amount": "Amount", "base": "Base", "book": "Book", + "buys": "Buys", "cancel-order-error": "Failed to cancel order", "connect-orders": "Connect to view your open orders", "connect-positions": "Connect to view your perp positions", @@ -32,6 +33,7 @@ "place-order": "Place {{side}} Order", "placing-order": "Placing Order", "quote": "Quote", + "sells": "Sells", "settle-funds": "Settle Funds", "settle-funds-error": "Failed to settle funds", "show-asks": "Show Asks", diff --git a/public/locales/zh_tw/trade.json b/public/locales/zh_tw/trade.json index 6ef4efb6..fed60d19 100644 --- a/public/locales/zh_tw/trade.json +++ b/public/locales/zh_tw/trade.json @@ -2,6 +2,7 @@ "amount": "Amount", "base": "Base", "book": "Book", + "buys": "Buys", "cancel-order-error": "Failed to cancel order", "connect-orders": "Connect to view your open orders", "connect-positions": "Connect to view your perp positions", @@ -32,6 +33,7 @@ "place-order": "Place {{side}} Order", "placing-order": "Placing Order", "quote": "Quote", + "sells": "Sells", "settle-funds": "Settle Funds", "settle-funds-error": "Failed to settle funds", "show-asks": "Show Asks",