diff --git a/packages/bot/src/processing/bot/normalizer.ts b/packages/bot/src/processing/bot/normalizer.ts index c54ca940..dfdb403b 100644 --- a/packages/bot/src/processing/bot/normalizer.ts +++ b/packages/bot/src/processing/bot/normalizer.ts @@ -21,7 +21,7 @@ import { nullToUndefined, required } from "../utils/index.js"; export class OrderNormalizer { static normalize(order: Order): StrategyOrder { const quantityExecuted = order.status === XOrderStatus.Filled ? order.quantity : 0; - const filledOrLimitPrice = order.filledPrice || order.price || 0; + const filledOrLimitPrice = Number(order.filledPrice || order.price || 0); const volume = order.quantity * filledOrLimitPrice; const volumeExecuted = order.status === XOrderStatus.Filled ? volume : 0; diff --git a/packages/bot/src/processing/exchange-account/exchange-account.processor.ts b/packages/bot/src/processing/exchange-account/exchange-account.processor.ts index 47bbe19a..dd0d9d91 100644 --- a/packages/bot/src/processing/exchange-account/exchange-account.processor.ts +++ b/packages/bot/src/processing/exchange-account/exchange-account.processor.ts @@ -112,7 +112,7 @@ export class ExchangeAccountProcessor { orderId: order.id, filledPrice: exchangeOrder.filledPrice, filledAt: new Date(exchangeOrder.lastTradeTimestamp), - fee: exchangeOrder.fee, + fee: Number(exchangeOrder.fee), }); logger.info(` -> Filled with price ${exchangeOrder.filledPrice} and fee ${exchangeOrder.fee}`); diff --git a/packages/bot/src/processing/smart-trade/smart-trade.synchronizer.ts b/packages/bot/src/processing/smart-trade/smart-trade.synchronizer.ts index c67565f3..727c9ad0 100644 --- a/packages/bot/src/processing/smart-trade/smart-trade.synchronizer.ts +++ b/packages/bot/src/processing/smart-trade/smart-trade.synchronizer.ts @@ -102,7 +102,7 @@ export class SmartTradeSynchronizer { orderId: order.id, filledPrice: exchangeOrder.filledPrice, filledAt: new Date(exchangeOrder.lastTradeTimestamp), - fee: exchangeOrder.fee, + fee: Number(exchangeOrder.fee), }); console.log(` -> Filled with price ${exchangeOrder.filledPrice} and fee ${exchangeOrder.fee}`); diff --git a/packages/bot/src/streams/orders.stream.ts b/packages/bot/src/streams/orders.stream.ts index 4c6c3e5e..0ea76cd6 100644 --- a/packages/bot/src/streams/orders.stream.ts +++ b/packages/bot/src/streams/orders.stream.ts @@ -98,7 +98,7 @@ export class OrdersStream extends EventEmitter { orderId: order.id, filledPrice: exchangeOrder.filledPrice, filledAt: new Date(exchangeOrder.lastTradeTimestamp || Date.now()), - fee: exchangeOrder.fee, + fee: Number(exchangeOrder.fee), }); this.emit("order", { diff --git a/packages/exchanges/src/exchanges/ccxt/normalize.ts b/packages/exchanges/src/exchanges/ccxt/normalize.ts index 545c57ef..e9a51ebd 100644 --- a/packages/exchanges/src/exchanges/ccxt/normalize.ts +++ b/packages/exchanges/src/exchanges/ccxt/normalize.ts @@ -35,7 +35,7 @@ const getLimitOrder: Normalize["getLimitOrder"] = { price: order.price, // could be undefined for market order, in case not filled yet? filledPrice: order.average || null, status: normalizeOrderStatus(order), - fee: order.fee?.cost || 0, + fee: Number(order.fee?.cost) || 0, createdAt: order.timestamp, lastTradeTimestamp: order.lastTradeTimestamp, }), @@ -116,7 +116,7 @@ const getOpenOrders: Normalize["getOpenOrders"] = { price: order.price, filledPrice: null, status: normalizeOrderStatus(order) as "open", - fee: order.fee?.cost || 0, + fee: Number(order.fee?.cost) || 0, createdAt: order.timestamp, lastTradeTimestamp: order.lastTradeTimestamp, })), @@ -137,7 +137,7 @@ const getClosedOrders: Normalize["getClosedOrders"] = { price: order.price, filledPrice: order.average || order.price, // assume that filled order must always contain `order.average` status: normalizeOrderStatus(order) as "filled" | "canceled", - fee: order.fee?.cost || 0, + fee: Number(order.fee?.cost) || 0, createdAt: order.timestamp, lastTradeTimestamp: order.lastTradeTimestamp, })), @@ -223,7 +223,7 @@ const watchOrders: Normalize["watchOrders"] = { price: order.price, filledPrice: order.average || null, status: normalizeOrderStatus(order), - fee: order.fee?.cost || 0, + fee: Number(order.fee?.cost) || 0, createdAt: order.timestamp, lastTradeTimestamp: order.lastTradeTimestamp, })),