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