@gbozee/ultimate 0.0.2-77 → 0.0.2-78

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
@@ -58001,8 +58001,42 @@ class ExchangeAccount {
58001
58001
  }
58002
58002
  return 0;
58003
58003
  }
58004
+ async placeOppositeTradeAction(payload) {
58005
+ const { symbol, kind, data } = payload;
58006
+ const position2 = await this.syncAccount({
58007
+ symbol,
58008
+ kind,
58009
+ as_view: true
58010
+ });
58011
+ if (position2.avg_qty !== data.avg.quantity) {
58012
+ const config2 = await this.getPositionConfig({
58013
+ symbol,
58014
+ kind
58015
+ });
58016
+ await this.app_db.updateScheduledTrade(config2.id, {
58017
+ entry: data.entry,
58018
+ stop: data.stop,
58019
+ risk: data.risk_per_trade,
58020
+ profit_percent: data.profit_percent,
58021
+ risk_reward: data.risk_reward
58022
+ });
58023
+ await this.placeTrade({
58024
+ symbol,
58025
+ kind,
58026
+ place: true,
58027
+ ignore_config: true
58028
+ });
58029
+ await this.placeTrade({
58030
+ symbol,
58031
+ kind,
58032
+ place: true,
58033
+ stop: true,
58034
+ ignore_config: true
58035
+ });
58036
+ }
58037
+ }
58004
58038
  async buildOppositeTrades(payload) {
58005
- const { symbol, kind, place } = payload;
58039
+ const { symbol, kind, place, place_symbol } = payload;
58006
58040
  const strategy = await this.runSimulation({
58007
58041
  symbol,
58008
58042
  kind,
@@ -58013,37 +58047,12 @@ class ExchangeAccount {
58013
58047
  avg_entry: strategy.position[kind].avg_price
58014
58048
  });
58015
58049
  if (place && result?.kind) {
58016
- const position2 = await this.syncAccount({
58017
- symbol,
58050
+ const _symbol = place_symbol || symbol;
58051
+ await this.placeOppositeTradeAction({
58052
+ symbol: _symbol,
58018
58053
  kind: result.kind,
58019
- as_view: true
58054
+ data: result
58020
58055
  });
58021
- if (position2.avg_qty !== result.avg.quantity) {
58022
- const config2 = await this.getPositionConfig({
58023
- symbol,
58024
- kind: result.kind
58025
- });
58026
- await this.app_db.updateScheduledTrade(config2.id, {
58027
- entry: result.entry,
58028
- stop: result.stop,
58029
- risk: result.risk_per_trade,
58030
- profit_percent: result.profit_percent,
58031
- risk_reward: result.risk_reward
58032
- });
58033
- await this.placeTrade({
58034
- symbol,
58035
- kind: result.kind,
58036
- place: true,
58037
- ignore_config: true
58038
- });
58039
- await this.placeTrade({
58040
- symbol,
58041
- kind: result.kind,
58042
- place: true,
58043
- stop: true,
58044
- ignore_config: true
58045
- });
58046
- }
58047
58056
  }
58048
58057
  return result;
58049
58058
  }
package/dist/index.d.ts CHANGED
@@ -1494,10 +1494,26 @@ declare class ExchangeAccount$1 {
1494
1494
  symbol: string;
1495
1495
  kind: "long" | "short";
1496
1496
  }): Promise<number>;
1497
+ placeOppositeTradeAction(payload: {
1498
+ symbol: string;
1499
+ kind: "long" | "short";
1500
+ data: {
1501
+ avg: {
1502
+ quantity: number;
1503
+ price: number;
1504
+ };
1505
+ entry: number;
1506
+ stop: number;
1507
+ risk_per_trade: number;
1508
+ profit_percent: number;
1509
+ risk_reward: number;
1510
+ };
1511
+ }): Promise<void>;
1497
1512
  buildOppositeTrades(payload: {
1498
1513
  symbol: string;
1499
1514
  kind: "long" | "short";
1500
1515
  place?: boolean;
1516
+ place_symbol?: string;
1501
1517
  }): Promise<{
1502
1518
  avg: {
1503
1519
  entry: number;
package/dist/index.js CHANGED
@@ -57956,8 +57956,42 @@ class ExchangeAccount {
57956
57956
  }
57957
57957
  return 0;
57958
57958
  }
57959
+ async placeOppositeTradeAction(payload) {
57960
+ const { symbol, kind, data } = payload;
57961
+ const position2 = await this.syncAccount({
57962
+ symbol,
57963
+ kind,
57964
+ as_view: true
57965
+ });
57966
+ if (position2.avg_qty !== data.avg.quantity) {
57967
+ const config2 = await this.getPositionConfig({
57968
+ symbol,
57969
+ kind
57970
+ });
57971
+ await this.app_db.updateScheduledTrade(config2.id, {
57972
+ entry: data.entry,
57973
+ stop: data.stop,
57974
+ risk: data.risk_per_trade,
57975
+ profit_percent: data.profit_percent,
57976
+ risk_reward: data.risk_reward
57977
+ });
57978
+ await this.placeTrade({
57979
+ symbol,
57980
+ kind,
57981
+ place: true,
57982
+ ignore_config: true
57983
+ });
57984
+ await this.placeTrade({
57985
+ symbol,
57986
+ kind,
57987
+ place: true,
57988
+ stop: true,
57989
+ ignore_config: true
57990
+ });
57991
+ }
57992
+ }
57959
57993
  async buildOppositeTrades(payload) {
57960
- const { symbol, kind, place } = payload;
57994
+ const { symbol, kind, place, place_symbol } = payload;
57961
57995
  const strategy = await this.runSimulation({
57962
57996
  symbol,
57963
57997
  kind,
@@ -57968,37 +58002,12 @@ class ExchangeAccount {
57968
58002
  avg_entry: strategy.position[kind].avg_price
57969
58003
  });
57970
58004
  if (place && result?.kind) {
57971
- const position2 = await this.syncAccount({
57972
- symbol,
58005
+ const _symbol = place_symbol || symbol;
58006
+ await this.placeOppositeTradeAction({
58007
+ symbol: _symbol,
57973
58008
  kind: result.kind,
57974
- as_view: true
58009
+ data: result
57975
58010
  });
57976
- if (position2.avg_qty !== result.avg.quantity) {
57977
- const config2 = await this.getPositionConfig({
57978
- symbol,
57979
- kind: result.kind
57980
- });
57981
- await this.app_db.updateScheduledTrade(config2.id, {
57982
- entry: result.entry,
57983
- stop: result.stop,
57984
- risk: result.risk_per_trade,
57985
- profit_percent: result.profit_percent,
57986
- risk_reward: result.risk_reward
57987
- });
57988
- await this.placeTrade({
57989
- symbol,
57990
- kind: result.kind,
57991
- place: true,
57992
- ignore_config: true
57993
- });
57994
- await this.placeTrade({
57995
- symbol,
57996
- kind: result.kind,
57997
- place: true,
57998
- stop: true,
57999
- ignore_config: true
58000
- });
58001
- }
58002
58011
  }
58003
58012
  return result;
58004
58013
  }
@@ -64692,8 +64692,42 @@ class ExchangeAccount {
64692
64692
  }
64693
64693
  return 0;
64694
64694
  }
64695
+ async placeOppositeTradeAction(payload) {
64696
+ const { symbol, kind, data } = payload;
64697
+ const position2 = await this.syncAccount({
64698
+ symbol,
64699
+ kind,
64700
+ as_view: true
64701
+ });
64702
+ if (position2.avg_qty !== data.avg.quantity) {
64703
+ const config2 = await this.getPositionConfig({
64704
+ symbol,
64705
+ kind
64706
+ });
64707
+ await this.app_db.updateScheduledTrade(config2.id, {
64708
+ entry: data.entry,
64709
+ stop: data.stop,
64710
+ risk: data.risk_per_trade,
64711
+ profit_percent: data.profit_percent,
64712
+ risk_reward: data.risk_reward
64713
+ });
64714
+ await this.placeTrade({
64715
+ symbol,
64716
+ kind,
64717
+ place: true,
64718
+ ignore_config: true
64719
+ });
64720
+ await this.placeTrade({
64721
+ symbol,
64722
+ kind,
64723
+ place: true,
64724
+ stop: true,
64725
+ ignore_config: true
64726
+ });
64727
+ }
64728
+ }
64695
64729
  async buildOppositeTrades(payload) {
64696
- const { symbol, kind, place } = payload;
64730
+ const { symbol, kind, place, place_symbol } = payload;
64697
64731
  const strategy = await this.runSimulation({
64698
64732
  symbol,
64699
64733
  kind,
@@ -64704,37 +64738,12 @@ class ExchangeAccount {
64704
64738
  avg_entry: strategy.position[kind].avg_price
64705
64739
  });
64706
64740
  if (place && result?.kind) {
64707
- const position2 = await this.syncAccount({
64708
- symbol,
64741
+ const _symbol = place_symbol || symbol;
64742
+ await this.placeOppositeTradeAction({
64743
+ symbol: _symbol,
64709
64744
  kind: result.kind,
64710
- as_view: true
64745
+ data: result
64711
64746
  });
64712
- if (position2.avg_qty !== result.avg.quantity) {
64713
- const config2 = await this.getPositionConfig({
64714
- symbol,
64715
- kind: result.kind
64716
- });
64717
- await this.app_db.updateScheduledTrade(config2.id, {
64718
- entry: result.entry,
64719
- stop: result.stop,
64720
- risk: result.risk_per_trade,
64721
- profit_percent: result.profit_percent,
64722
- risk_reward: result.risk_reward
64723
- });
64724
- await this.placeTrade({
64725
- symbol,
64726
- kind: result.kind,
64727
- place: true,
64728
- ignore_config: true
64729
- });
64730
- await this.placeTrade({
64731
- symbol,
64732
- kind: result.kind,
64733
- place: true,
64734
- stop: true,
64735
- ignore_config: true
64736
- });
64737
- }
64738
64747
  }
64739
64748
  return result;
64740
64749
  }
@@ -64669,8 +64669,42 @@ class ExchangeAccount {
64669
64669
  }
64670
64670
  return 0;
64671
64671
  }
64672
+ async placeOppositeTradeAction(payload) {
64673
+ const { symbol, kind, data } = payload;
64674
+ const position2 = await this.syncAccount({
64675
+ symbol,
64676
+ kind,
64677
+ as_view: true
64678
+ });
64679
+ if (position2.avg_qty !== data.avg.quantity) {
64680
+ const config2 = await this.getPositionConfig({
64681
+ symbol,
64682
+ kind
64683
+ });
64684
+ await this.app_db.updateScheduledTrade(config2.id, {
64685
+ entry: data.entry,
64686
+ stop: data.stop,
64687
+ risk: data.risk_per_trade,
64688
+ profit_percent: data.profit_percent,
64689
+ risk_reward: data.risk_reward
64690
+ });
64691
+ await this.placeTrade({
64692
+ symbol,
64693
+ kind,
64694
+ place: true,
64695
+ ignore_config: true
64696
+ });
64697
+ await this.placeTrade({
64698
+ symbol,
64699
+ kind,
64700
+ place: true,
64701
+ stop: true,
64702
+ ignore_config: true
64703
+ });
64704
+ }
64705
+ }
64672
64706
  async buildOppositeTrades(payload) {
64673
- const { symbol, kind, place } = payload;
64707
+ const { symbol, kind, place, place_symbol } = payload;
64674
64708
  const strategy = await this.runSimulation({
64675
64709
  symbol,
64676
64710
  kind,
@@ -64681,37 +64715,12 @@ class ExchangeAccount {
64681
64715
  avg_entry: strategy.position[kind].avg_price
64682
64716
  });
64683
64717
  if (place && result?.kind) {
64684
- const position2 = await this.syncAccount({
64685
- symbol,
64718
+ const _symbol = place_symbol || symbol;
64719
+ await this.placeOppositeTradeAction({
64720
+ symbol: _symbol,
64686
64721
  kind: result.kind,
64687
- as_view: true
64722
+ data: result
64688
64723
  });
64689
- if (position2.avg_qty !== result.avg.quantity) {
64690
- const config2 = await this.getPositionConfig({
64691
- symbol,
64692
- kind: result.kind
64693
- });
64694
- await this.app_db.updateScheduledTrade(config2.id, {
64695
- entry: result.entry,
64696
- stop: result.stop,
64697
- risk: result.risk_per_trade,
64698
- profit_percent: result.profit_percent,
64699
- risk_reward: result.risk_reward
64700
- });
64701
- await this.placeTrade({
64702
- symbol,
64703
- kind: result.kind,
64704
- place: true,
64705
- ignore_config: true
64706
- });
64707
- await this.placeTrade({
64708
- symbol,
64709
- kind: result.kind,
64710
- place: true,
64711
- stop: true,
64712
- ignore_config: true
64713
- });
64714
- }
64715
64724
  }
64716
64725
  return result;
64717
64726
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-77",
4
+ "version": "0.0.2-78",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",