Skip to content

Commit efcb657

Browse files
committed
Optimized average price & last trade timestamp calculation
1 parent faebd5d commit efcb657

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

routes.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ function routes.get_trades_by_num(orderNumber)
196196
end
197197

198198
function routes.fill_order_with_trades_data(order)
199+
if order.qty == order.balance then
200+
return order
201+
end
199202
local qty_of_trades = 0
200203
local price_qty = 0
201204
for i = 0, getNumberOf("trades") - 1 do
@@ -205,6 +208,9 @@ function routes.fill_order_with_trades_data(order)
205208
qty_of_trades = qty_of_trades + trade.qty
206209
order.last_trade_datetime_ex = trade.datetime
207210
end
211+
if qty_of_trades == order.qty then
212+
break
213+
end
208214
end
209215
if qty_of_trades > 0 then
210216
order.average_price_ex = price_qty / qty_of_trades

0 commit comments

Comments
 (0)