@gbozee/ultimate 0.0.2-167 → 0.0.2-168

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
@@ -61796,14 +61796,29 @@ class ExchangePosition {
61796
61796
  });
61797
61797
  }
61798
61798
  const last_order = focus_position.instance.last_order;
61799
- const take_profit = this.instance.take_profit;
61800
- if (this.kind === "short" && last_order && take_profit) {
61801
- const reduce_ratio = take_profit < last_order ? 1 : 0;
61802
- await this.getConfig({
61803
- params: {
61804
- reduce_ratio
61799
+ let take_profit;
61800
+ if (this.instance.take_profit) {
61801
+ take_profit = to_f(this.instance.take_profit, this.symbol_config.price_places);
61802
+ if (this.kind === "short" && last_order && take_profit) {
61803
+ const reduce_ratio = take_profit < last_order ? 1 : 0;
61804
+ await this.getConfig({
61805
+ params: {
61806
+ reduce_ratio
61807
+ }
61808
+ });
61809
+ }
61810
+ if (this.instance.quantity > 0) {
61811
+ if (focus_position.kind === "long" && focus_position.instance.stop_loss && take_profit > focus_position.appConfig.stop && focus_position.instance.stop_loss?.price < take_profit) {
61812
+ await focus_position.cancelExchangeOrder({
61813
+ type: "stop"
61814
+ });
61805
61815
  }
61806
- });
61816
+ if (focus_position.kind === "short" && focus_position.instance.stop_loss && take_profit < focus_position.appConfig.stop && focus_position.instance.stop_loss?.price > take_profit) {
61817
+ await focus_position.cancelExchangeOrder({
61818
+ type: "stop"
61819
+ });
61820
+ }
61821
+ }
61807
61822
  }
61808
61823
  return { profit_percent, take_profit, last_order };
61809
61824
  }
@@ -61896,8 +61911,7 @@ class ExchangeAccount {
61896
61911
  async initializePositions(payload) {
61897
61912
  const raw_positions = await this.syncAccount({
61898
61913
  update: payload.update,
61899
- symbol: payload.symbol,
61900
- live_refresh: payload.update
61914
+ symbol: payload.symbol
61901
61915
  });
61902
61916
  const positions = await this.syncAccount({
61903
61917
  symbol: payload.symbol,
@@ -63314,6 +63328,7 @@ class ExchangeAccount {
63314
63328
  const opposite_config = focus_position.getOppositeConfig({
63315
63329
  ratio: reward_factor
63316
63330
  });
63331
+ console.log("opposite_config", opposite_config);
63317
63332
  const reverse_config = await reversePosition.getConfig();
63318
63333
  if ((reverse_config.entry !== opposite_config.entry || reverse_config.stop !== opposite_config.stop || reverse_config.risk !== opposite_config.risk || reverse_config.risk_reward !== opposite_config.risk_reward) && focus_position.getInstance().quantity > 0) {
63319
63334
  console.log("Updating reverse config for ", symbol, kind, "with opposite config", opposite_config);
package/dist/index.d.ts CHANGED
@@ -2049,7 +2049,7 @@ export declare class ExchangePosition {
2049
2049
  focus_position: ExchangePosition;
2050
2050
  }): Promise<{
2051
2051
  profit_percent: number;
2052
- take_profit: any;
2052
+ take_profit: number;
2053
2053
  last_order: number;
2054
2054
  }>;
2055
2055
  getOrders(payload: {
package/dist/index.js CHANGED
@@ -61741,14 +61741,29 @@ class ExchangePosition {
61741
61741
  });
61742
61742
  }
61743
61743
  const last_order = focus_position.instance.last_order;
61744
- const take_profit = this.instance.take_profit;
61745
- if (this.kind === "short" && last_order && take_profit) {
61746
- const reduce_ratio = take_profit < last_order ? 1 : 0;
61747
- await this.getConfig({
61748
- params: {
61749
- reduce_ratio
61744
+ let take_profit;
61745
+ if (this.instance.take_profit) {
61746
+ take_profit = to_f(this.instance.take_profit, this.symbol_config.price_places);
61747
+ if (this.kind === "short" && last_order && take_profit) {
61748
+ const reduce_ratio = take_profit < last_order ? 1 : 0;
61749
+ await this.getConfig({
61750
+ params: {
61751
+ reduce_ratio
61752
+ }
61753
+ });
61754
+ }
61755
+ if (this.instance.quantity > 0) {
61756
+ if (focus_position.kind === "long" && focus_position.instance.stop_loss && take_profit > focus_position.appConfig.stop && focus_position.instance.stop_loss?.price < take_profit) {
61757
+ await focus_position.cancelExchangeOrder({
61758
+ type: "stop"
61759
+ });
61750
61760
  }
61751
- });
61761
+ if (focus_position.kind === "short" && focus_position.instance.stop_loss && take_profit < focus_position.appConfig.stop && focus_position.instance.stop_loss?.price > take_profit) {
61762
+ await focus_position.cancelExchangeOrder({
61763
+ type: "stop"
61764
+ });
61765
+ }
61766
+ }
61752
61767
  }
61753
61768
  return { profit_percent, take_profit, last_order };
61754
61769
  }
@@ -61841,8 +61856,7 @@ class ExchangeAccount {
61841
61856
  async initializePositions(payload) {
61842
61857
  const raw_positions = await this.syncAccount({
61843
61858
  update: payload.update,
61844
- symbol: payload.symbol,
61845
- live_refresh: payload.update
61859
+ symbol: payload.symbol
61846
61860
  });
61847
61861
  const positions = await this.syncAccount({
61848
61862
  symbol: payload.symbol,
@@ -63259,6 +63273,7 @@ class ExchangeAccount {
63259
63273
  const opposite_config = focus_position.getOppositeConfig({
63260
63274
  ratio: reward_factor
63261
63275
  });
63276
+ console.log("opposite_config", opposite_config);
63262
63277
  const reverse_config = await reversePosition.getConfig();
63263
63278
  if ((reverse_config.entry !== opposite_config.entry || reverse_config.stop !== opposite_config.stop || reverse_config.risk !== opposite_config.risk || reverse_config.risk_reward !== opposite_config.risk_reward) && focus_position.getInstance().quantity > 0) {
63264
63279
  console.log("Updating reverse config for ", symbol, kind, "with opposite config", opposite_config);
@@ -68469,14 +68469,29 @@ class ExchangePosition {
68469
68469
  });
68470
68470
  }
68471
68471
  const last_order = focus_position.instance.last_order;
68472
- const take_profit = this.instance.take_profit;
68473
- if (this.kind === "short" && last_order && take_profit) {
68474
- const reduce_ratio = take_profit < last_order ? 1 : 0;
68475
- await this.getConfig({
68476
- params: {
68477
- reduce_ratio
68472
+ let take_profit;
68473
+ if (this.instance.take_profit) {
68474
+ take_profit = to_f(this.instance.take_profit, this.symbol_config.price_places);
68475
+ if (this.kind === "short" && last_order && take_profit) {
68476
+ const reduce_ratio = take_profit < last_order ? 1 : 0;
68477
+ await this.getConfig({
68478
+ params: {
68479
+ reduce_ratio
68480
+ }
68481
+ });
68482
+ }
68483
+ if (this.instance.quantity > 0) {
68484
+ if (focus_position.kind === "long" && focus_position.instance.stop_loss && take_profit > focus_position.appConfig.stop && focus_position.instance.stop_loss?.price < take_profit) {
68485
+ await focus_position.cancelExchangeOrder({
68486
+ type: "stop"
68487
+ });
68478
68488
  }
68479
- });
68489
+ if (focus_position.kind === "short" && focus_position.instance.stop_loss && take_profit < focus_position.appConfig.stop && focus_position.instance.stop_loss?.price > take_profit) {
68490
+ await focus_position.cancelExchangeOrder({
68491
+ type: "stop"
68492
+ });
68493
+ }
68494
+ }
68480
68495
  }
68481
68496
  return { profit_percent, take_profit, last_order };
68482
68497
  }
@@ -68569,8 +68584,7 @@ class ExchangeAccount {
68569
68584
  async initializePositions(payload) {
68570
68585
  const raw_positions = await this.syncAccount({
68571
68586
  update: payload.update,
68572
- symbol: payload.symbol,
68573
- live_refresh: payload.update
68587
+ symbol: payload.symbol
68574
68588
  });
68575
68589
  const positions = await this.syncAccount({
68576
68590
  symbol: payload.symbol,
@@ -69987,6 +70001,7 @@ class ExchangeAccount {
69987
70001
  const opposite_config = focus_position.getOppositeConfig({
69988
70002
  ratio: reward_factor
69989
70003
  });
70004
+ console.log("opposite_config", opposite_config);
69990
70005
  const reverse_config = await reversePosition.getConfig();
69991
70006
  if ((reverse_config.entry !== opposite_config.entry || reverse_config.stop !== opposite_config.stop || reverse_config.risk !== opposite_config.risk || reverse_config.risk_reward !== opposite_config.risk_reward) && focus_position.getInstance().quantity > 0) {
69992
70007
  console.log("Updating reverse config for ", symbol, kind, "with opposite config", opposite_config);
@@ -68446,14 +68446,29 @@ class ExchangePosition {
68446
68446
  });
68447
68447
  }
68448
68448
  const last_order = focus_position.instance.last_order;
68449
- const take_profit = this.instance.take_profit;
68450
- if (this.kind === "short" && last_order && take_profit) {
68451
- const reduce_ratio = take_profit < last_order ? 1 : 0;
68452
- await this.getConfig({
68453
- params: {
68454
- reduce_ratio
68449
+ let take_profit;
68450
+ if (this.instance.take_profit) {
68451
+ take_profit = to_f(this.instance.take_profit, this.symbol_config.price_places);
68452
+ if (this.kind === "short" && last_order && take_profit) {
68453
+ const reduce_ratio = take_profit < last_order ? 1 : 0;
68454
+ await this.getConfig({
68455
+ params: {
68456
+ reduce_ratio
68457
+ }
68458
+ });
68459
+ }
68460
+ if (this.instance.quantity > 0) {
68461
+ if (focus_position.kind === "long" && focus_position.instance.stop_loss && take_profit > focus_position.appConfig.stop && focus_position.instance.stop_loss?.price < take_profit) {
68462
+ await focus_position.cancelExchangeOrder({
68463
+ type: "stop"
68464
+ });
68455
68465
  }
68456
- });
68466
+ if (focus_position.kind === "short" && focus_position.instance.stop_loss && take_profit < focus_position.appConfig.stop && focus_position.instance.stop_loss?.price > take_profit) {
68467
+ await focus_position.cancelExchangeOrder({
68468
+ type: "stop"
68469
+ });
68470
+ }
68471
+ }
68457
68472
  }
68458
68473
  return { profit_percent, take_profit, last_order };
68459
68474
  }
@@ -68546,8 +68561,7 @@ class ExchangeAccount {
68546
68561
  async initializePositions(payload) {
68547
68562
  const raw_positions = await this.syncAccount({
68548
68563
  update: payload.update,
68549
- symbol: payload.symbol,
68550
- live_refresh: payload.update
68564
+ symbol: payload.symbol
68551
68565
  });
68552
68566
  const positions = await this.syncAccount({
68553
68567
  symbol: payload.symbol,
@@ -69964,6 +69978,7 @@ class ExchangeAccount {
69964
69978
  const opposite_config = focus_position.getOppositeConfig({
69965
69979
  ratio: reward_factor
69966
69980
  });
69981
+ console.log("opposite_config", opposite_config);
69967
69982
  const reverse_config = await reversePosition.getConfig();
69968
69983
  if ((reverse_config.entry !== opposite_config.entry || reverse_config.stop !== opposite_config.stop || reverse_config.risk !== opposite_config.risk || reverse_config.risk_reward !== opposite_config.risk_reward) && focus_position.getInstance().quantity > 0) {
69969
69984
  console.log("Updating reverse config for ", symbol, kind, "with opposite config", opposite_config);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-167",
4
+ "version": "0.0.2-168",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",