@gbozee/ultimate 0.0.2-next.68 → 0.0.2-next.69

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.
package/dist/index.cjs CHANGED
@@ -76903,6 +76903,19 @@ async function fetchDBExchangeData(client, symbol, options) {
76903
76903
  short: short_result.trades
76904
76904
  };
76905
76905
  }
76906
+ const stop_losses_by_kind = {
76907
+ long: [],
76908
+ short: []
76909
+ };
76910
+ for (const o of orders) {
76911
+ const k = o.positionSide?.toLowerCase();
76912
+ if (k && (o.isStop || o.stopPrice > 0)) {
76913
+ stop_losses_by_kind[k].push({
76914
+ price: o.stopPrice || o.stop || o.price,
76915
+ quantity: o.origQty || o.quantity
76916
+ });
76917
+ }
76918
+ }
76906
76919
  return {
76907
76920
  orders,
76908
76921
  symbol_config,
@@ -76912,11 +76925,12 @@ async function fetchDBExchangeData(client, symbol, options) {
76912
76925
  trades,
76913
76926
  drift,
76914
76927
  priceChanged,
76928
+ stop_losses_by_kind,
76915
76929
  raw_data: live_exchange_details?.data
76916
76930
  };
76917
76931
  }
76918
76932
  async function reconcileEngineState(client, symbol, options) {
76919
- const { positions, symbol_config, current_price, raw_data, trades, drift, priceChanged } = await fetchDBExchangeData(client, symbol, options);
76933
+ const { positions, symbol_config, current_price, raw_data, trades, drift, priceChanged, stop_losses_by_kind } = await fetchDBExchangeData(client, symbol, options);
76920
76934
  const long_generator = new TradeEngine({
76921
76935
  position: {
76922
76936
  kind: "long",
@@ -76961,7 +76975,13 @@ async function reconcileEngineState(client, symbol, options) {
76961
76975
  state.position.quantity = 0;
76962
76976
  tp = { price: 0, quantity: 0 };
76963
76977
  }
76964
- await updateDbDetails(client, { kind, symbol }, raw_data, { take_profit: tp, position: _position, orders: state_trades });
76978
+ const kind_stops = stop_losses_by_kind[kind];
76979
+ await updateDbDetails(client, { kind, symbol }, raw_data, {
76980
+ take_profit: tp,
76981
+ position: _position,
76982
+ orders: state_trades,
76983
+ stop_losses: kind_stops.length > 0 ? kind_stops : undefined
76984
+ });
76965
76985
  changed = true;
76966
76986
  }
76967
76987
  }
package/dist/index.js CHANGED
@@ -76801,6 +76801,19 @@ async function fetchDBExchangeData(client, symbol, options) {
76801
76801
  short: short_result.trades
76802
76802
  };
76803
76803
  }
76804
+ const stop_losses_by_kind = {
76805
+ long: [],
76806
+ short: []
76807
+ };
76808
+ for (const o of orders) {
76809
+ const k = o.positionSide?.toLowerCase();
76810
+ if (k && (o.isStop || o.stopPrice > 0)) {
76811
+ stop_losses_by_kind[k].push({
76812
+ price: o.stopPrice || o.stop || o.price,
76813
+ quantity: o.origQty || o.quantity
76814
+ });
76815
+ }
76816
+ }
76804
76817
  return {
76805
76818
  orders,
76806
76819
  symbol_config,
@@ -76810,11 +76823,12 @@ async function fetchDBExchangeData(client, symbol, options) {
76810
76823
  trades,
76811
76824
  drift,
76812
76825
  priceChanged,
76826
+ stop_losses_by_kind,
76813
76827
  raw_data: live_exchange_details?.data
76814
76828
  };
76815
76829
  }
76816
76830
  async function reconcileEngineState(client, symbol, options) {
76817
- const { positions, symbol_config, current_price, raw_data, trades, drift, priceChanged } = await fetchDBExchangeData(client, symbol, options);
76831
+ const { positions, symbol_config, current_price, raw_data, trades, drift, priceChanged, stop_losses_by_kind } = await fetchDBExchangeData(client, symbol, options);
76818
76832
  const long_generator = new TradeEngine({
76819
76833
  position: {
76820
76834
  kind: "long",
@@ -76859,7 +76873,13 @@ async function reconcileEngineState(client, symbol, options) {
76859
76873
  state.position.quantity = 0;
76860
76874
  tp = { price: 0, quantity: 0 };
76861
76875
  }
76862
- await updateDbDetails(client, { kind, symbol }, raw_data, { take_profit: tp, position: _position, orders: state_trades });
76876
+ const kind_stops = stop_losses_by_kind[kind];
76877
+ await updateDbDetails(client, { kind, symbol }, raw_data, {
76878
+ take_profit: tp,
76879
+ position: _position,
76880
+ orders: state_trades,
76881
+ stop_losses: kind_stops.length > 0 ? kind_stops : undefined
76882
+ });
76863
76883
  changed = true;
76864
76884
  }
76865
76885
  }
@@ -80625,6 +80625,19 @@ async function fetchDBExchangeData(client, symbol, options) {
80625
80625
  short: short_result.trades
80626
80626
  };
80627
80627
  }
80628
+ const stop_losses_by_kind = {
80629
+ long: [],
80630
+ short: []
80631
+ };
80632
+ for (const o of orders) {
80633
+ const k = o.positionSide?.toLowerCase();
80634
+ if (k && (o.isStop || o.stopPrice > 0)) {
80635
+ stop_losses_by_kind[k].push({
80636
+ price: o.stopPrice || o.stop || o.price,
80637
+ quantity: o.origQty || o.quantity
80638
+ });
80639
+ }
80640
+ }
80628
80641
  return {
80629
80642
  orders,
80630
80643
  symbol_config,
@@ -80634,11 +80647,12 @@ async function fetchDBExchangeData(client, symbol, options) {
80634
80647
  trades,
80635
80648
  drift,
80636
80649
  priceChanged,
80650
+ stop_losses_by_kind,
80637
80651
  raw_data: live_exchange_details?.data
80638
80652
  };
80639
80653
  }
80640
80654
  async function reconcileEngineState(client, symbol, options) {
80641
- const { positions, symbol_config, current_price, raw_data, trades, drift, priceChanged } = await fetchDBExchangeData(client, symbol, options);
80655
+ const { positions, symbol_config, current_price, raw_data, trades, drift, priceChanged, stop_losses_by_kind } = await fetchDBExchangeData(client, symbol, options);
80642
80656
  const long_generator = new TradeEngine({
80643
80657
  position: {
80644
80658
  kind: "long",
@@ -80683,7 +80697,13 @@ async function reconcileEngineState(client, symbol, options) {
80683
80697
  state.position.quantity = 0;
80684
80698
  tp = { price: 0, quantity: 0 };
80685
80699
  }
80686
- await updateDbDetails(client, { kind, symbol }, raw_data, { take_profit: tp, position: _position, orders: state_trades });
80700
+ const kind_stops = stop_losses_by_kind[kind];
80701
+ await updateDbDetails(client, { kind, symbol }, raw_data, {
80702
+ take_profit: tp,
80703
+ position: _position,
80704
+ orders: state_trades,
80705
+ stop_losses: kind_stops.length > 0 ? kind_stops : undefined
80706
+ });
80687
80707
  changed = true;
80688
80708
  }
80689
80709
  }
@@ -80584,6 +80584,19 @@ async function fetchDBExchangeData(client, symbol, options) {
80584
80584
  short: short_result.trades
80585
80585
  };
80586
80586
  }
80587
+ const stop_losses_by_kind = {
80588
+ long: [],
80589
+ short: []
80590
+ };
80591
+ for (const o of orders) {
80592
+ const k = o.positionSide?.toLowerCase();
80593
+ if (k && (o.isStop || o.stopPrice > 0)) {
80594
+ stop_losses_by_kind[k].push({
80595
+ price: o.stopPrice || o.stop || o.price,
80596
+ quantity: o.origQty || o.quantity
80597
+ });
80598
+ }
80599
+ }
80587
80600
  return {
80588
80601
  orders,
80589
80602
  symbol_config,
@@ -80593,11 +80606,12 @@ async function fetchDBExchangeData(client, symbol, options) {
80593
80606
  trades,
80594
80607
  drift,
80595
80608
  priceChanged,
80609
+ stop_losses_by_kind,
80596
80610
  raw_data: live_exchange_details?.data
80597
80611
  };
80598
80612
  }
80599
80613
  async function reconcileEngineState(client, symbol, options) {
80600
- const { positions, symbol_config, current_price, raw_data, trades, drift, priceChanged } = await fetchDBExchangeData(client, symbol, options);
80614
+ const { positions, symbol_config, current_price, raw_data, trades, drift, priceChanged, stop_losses_by_kind } = await fetchDBExchangeData(client, symbol, options);
80601
80615
  const long_generator = new TradeEngine({
80602
80616
  position: {
80603
80617
  kind: "long",
@@ -80642,7 +80656,13 @@ async function reconcileEngineState(client, symbol, options) {
80642
80656
  state.position.quantity = 0;
80643
80657
  tp = { price: 0, quantity: 0 };
80644
80658
  }
80645
- await updateDbDetails(client, { kind, symbol }, raw_data, { take_profit: tp, position: _position, orders: state_trades });
80659
+ const kind_stops = stop_losses_by_kind[kind];
80660
+ await updateDbDetails(client, { kind, symbol }, raw_data, {
80661
+ take_profit: tp,
80662
+ position: _position,
80663
+ orders: state_trades,
80664
+ stop_losses: kind_stops.length > 0 ? kind_stops : undefined
80665
+ });
80646
80666
  changed = true;
80647
80667
  }
80648
80668
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-next.68",
4
+ "version": "0.0.2-next.69",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",