@icgio/icg-utils 1.9.53 → 1.9.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/utils.js +10 -0
  2. package/package.json +1 -1
package/lib/utils.js CHANGED
@@ -656,6 +656,16 @@ function merge_trades_with_same_id(array) {
656
656
  if (to_compare_trade.order_id === trade.order_id) {
657
657
  trade.amount = trade.amount + to_compare_trade.amount
658
658
  trade.total = trade.total + to_compare_trade.total
659
+ // Merge fees from partial fills (previously only first fill's fees were kept)
660
+ if (trade.fees && to_compare_trade.fees) {
661
+ for (const [cur, amount] of Object.entries(to_compare_trade.fees)) {
662
+ trade.fees[cur] = (trade.fees[cur] || 0) + amount
663
+ }
664
+ }
665
+ // Use earliest close_time so timeframe filters include the merged trade
666
+ if (to_compare_trade.close_time && trade.close_time && to_compare_trade.close_time < trade.close_time) {
667
+ trade.close_time = to_compare_trade.close_time
668
+ }
659
669
  processed_index_set.add(j)
660
670
  }
661
671
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.9.53",
3
+ "version": "1.9.54",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {