@gbozee/ultimate 0.0.2-169 → 0.0.2-170

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
@@ -61436,9 +61436,14 @@ class ExchangePosition {
61436
61436
  const price_places = symbol_config.price_places;
61437
61437
  const decimal_places = symbol_config.decimal_places;
61438
61438
  if (place) {
61439
- await this.cancelOrders({
61440
- limit: true
61439
+ await this.cancelExchangeOrder({
61440
+ type: "stop"
61441
61441
  });
61442
+ if (increase) {
61443
+ await this.cancelOrders({
61444
+ limit: true
61445
+ });
61446
+ }
61442
61447
  }
61443
61448
  return await this.exchange.customStopLoss({
61444
61449
  symbol: this.symbol,
@@ -61804,6 +61809,32 @@ class ExchangePosition {
61804
61809
  }
61805
61810
  });
61806
61811
  }
61812
+ async followStop(payload) {
61813
+ const { focus_position, fee_percent = 0.05, place } = payload;
61814
+ const entry = focus_position.instance.entry;
61815
+ if (this.kind !== focus_position.kind) {
61816
+ return;
61817
+ }
61818
+ if (this.kind === focus_position.kind) {
61819
+ if (this.kind === "long" && entry < this.instance.entry) {
61820
+ return;
61821
+ }
61822
+ if (this.kind === "short" && entry > this.instance.entry) {
61823
+ return;
61824
+ }
61825
+ }
61826
+ const target_pnl = Math.abs(entry - this.instance.entry) * this.instance.quantity;
61827
+ const fee = entry * this.instance.quantity * fee_percent / 100;
61828
+ const total_pnl = target_pnl + fee;
61829
+ const sell_diff = total_pnl / this.instance.quantity;
61830
+ const stop = this.kind === "long" ? this.instance.entry + sell_diff : this.instance.entry - sell_diff;
61831
+ return this.increasePositionAtStop({
61832
+ place,
61833
+ price: stop,
61834
+ quantity: this.instance.quantity,
61835
+ increase: false
61836
+ });
61837
+ }
61807
61838
  }
61808
61839
  function convert_to_exchange_order(order) {
61809
61840
  return {
@@ -62420,6 +62451,17 @@ class ExchangeAccount {
62420
62451
  short_position
62421
62452
  });
62422
62453
  }
62454
+ async followStop(payload) {
62455
+ const { symbol, kind, fee_percent, focus_position } = payload;
62456
+ const main_position = await this.getFocusPosition({
62457
+ symbol,
62458
+ kind
62459
+ });
62460
+ return await main_position.followStop({
62461
+ focus_position,
62462
+ fee_percent
62463
+ });
62464
+ }
62423
62465
  async increasePositionAtStop(payload) {
62424
62466
  const focus_position = await this.getFocusPosition(payload);
62425
62467
  return await focus_position.increasePositionAtStop(payload);
package/dist/index.d.ts CHANGED
@@ -2110,6 +2110,11 @@ export declare class ExchangePosition {
2110
2110
  entry: any;
2111
2111
  };
2112
2112
  };
2113
+ followStop(payload: {
2114
+ focus_position: ExchangePosition;
2115
+ fee_percent?: number;
2116
+ place?: boolean;
2117
+ }): Promise<any>;
2113
2118
  }
2114
2119
  declare class ExchangeAccount$1 {
2115
2120
  instance: {
@@ -2394,6 +2399,12 @@ declare class ExchangeAccount$1 {
2394
2399
  symbol: string;
2395
2400
  kind: "long" | "short";
2396
2401
  }): Promise<string>;
2402
+ followStop(payload: {
2403
+ symbol: string;
2404
+ kind: "long" | "short";
2405
+ fee_percent?: number;
2406
+ focus_position: ExchangePosition;
2407
+ }): Promise<any>;
2397
2408
  increasePositionAtStop(payload: {
2398
2409
  symbol: string;
2399
2410
  kind: "long" | "short";
package/dist/index.js CHANGED
@@ -61376,9 +61376,14 @@ class ExchangePosition {
61376
61376
  const price_places = symbol_config.price_places;
61377
61377
  const decimal_places = symbol_config.decimal_places;
61378
61378
  if (place) {
61379
- await this.cancelOrders({
61380
- limit: true
61379
+ await this.cancelExchangeOrder({
61380
+ type: "stop"
61381
61381
  });
61382
+ if (increase) {
61383
+ await this.cancelOrders({
61384
+ limit: true
61385
+ });
61386
+ }
61382
61387
  }
61383
61388
  return await this.exchange.customStopLoss({
61384
61389
  symbol: this.symbol,
@@ -61744,6 +61749,32 @@ class ExchangePosition {
61744
61749
  }
61745
61750
  });
61746
61751
  }
61752
+ async followStop(payload) {
61753
+ const { focus_position, fee_percent = 0.05, place } = payload;
61754
+ const entry = focus_position.instance.entry;
61755
+ if (this.kind !== focus_position.kind) {
61756
+ return;
61757
+ }
61758
+ if (this.kind === focus_position.kind) {
61759
+ if (this.kind === "long" && entry < this.instance.entry) {
61760
+ return;
61761
+ }
61762
+ if (this.kind === "short" && entry > this.instance.entry) {
61763
+ return;
61764
+ }
61765
+ }
61766
+ const target_pnl = Math.abs(entry - this.instance.entry) * this.instance.quantity;
61767
+ const fee = entry * this.instance.quantity * fee_percent / 100;
61768
+ const total_pnl = target_pnl + fee;
61769
+ const sell_diff = total_pnl / this.instance.quantity;
61770
+ const stop = this.kind === "long" ? this.instance.entry + sell_diff : this.instance.entry - sell_diff;
61771
+ return this.increasePositionAtStop({
61772
+ place,
61773
+ price: stop,
61774
+ quantity: this.instance.quantity,
61775
+ increase: false
61776
+ });
61777
+ }
61747
61778
  }
61748
61779
  function convert_to_exchange_order(order) {
61749
61780
  return {
@@ -62360,6 +62391,17 @@ class ExchangeAccount {
62360
62391
  short_position
62361
62392
  });
62362
62393
  }
62394
+ async followStop(payload) {
62395
+ const { symbol, kind, fee_percent, focus_position } = payload;
62396
+ const main_position = await this.getFocusPosition({
62397
+ symbol,
62398
+ kind
62399
+ });
62400
+ return await main_position.followStop({
62401
+ focus_position,
62402
+ fee_percent
62403
+ });
62404
+ }
62363
62405
  async increasePositionAtStop(payload) {
62364
62406
  const focus_position = await this.getFocusPosition(payload);
62365
62407
  return await focus_position.increasePositionAtStop(payload);
@@ -68106,9 +68106,14 @@ class ExchangePosition {
68106
68106
  const price_places = symbol_config.price_places;
68107
68107
  const decimal_places = symbol_config.decimal_places;
68108
68108
  if (place) {
68109
- await this.cancelOrders({
68110
- limit: true
68109
+ await this.cancelExchangeOrder({
68110
+ type: "stop"
68111
68111
  });
68112
+ if (increase) {
68113
+ await this.cancelOrders({
68114
+ limit: true
68115
+ });
68116
+ }
68112
68117
  }
68113
68118
  return await this.exchange.customStopLoss({
68114
68119
  symbol: this.symbol,
@@ -68474,6 +68479,32 @@ class ExchangePosition {
68474
68479
  }
68475
68480
  });
68476
68481
  }
68482
+ async followStop(payload) {
68483
+ const { focus_position, fee_percent = 0.05, place } = payload;
68484
+ const entry = focus_position.instance.entry;
68485
+ if (this.kind !== focus_position.kind) {
68486
+ return;
68487
+ }
68488
+ if (this.kind === focus_position.kind) {
68489
+ if (this.kind === "long" && entry < this.instance.entry) {
68490
+ return;
68491
+ }
68492
+ if (this.kind === "short" && entry > this.instance.entry) {
68493
+ return;
68494
+ }
68495
+ }
68496
+ const target_pnl = Math.abs(entry - this.instance.entry) * this.instance.quantity;
68497
+ const fee = entry * this.instance.quantity * fee_percent / 100;
68498
+ const total_pnl = target_pnl + fee;
68499
+ const sell_diff = total_pnl / this.instance.quantity;
68500
+ const stop = this.kind === "long" ? this.instance.entry + sell_diff : this.instance.entry - sell_diff;
68501
+ return this.increasePositionAtStop({
68502
+ place,
68503
+ price: stop,
68504
+ quantity: this.instance.quantity,
68505
+ increase: false
68506
+ });
68507
+ }
68477
68508
  }
68478
68509
  function convert_to_exchange_order(order) {
68479
68510
  return {
@@ -69090,6 +69121,17 @@ class ExchangeAccount {
69090
69121
  short_position
69091
69122
  });
69092
69123
  }
69124
+ async followStop(payload) {
69125
+ const { symbol, kind, fee_percent, focus_position } = payload;
69126
+ const main_position = await this.getFocusPosition({
69127
+ symbol,
69128
+ kind
69129
+ });
69130
+ return await main_position.followStop({
69131
+ focus_position,
69132
+ fee_percent
69133
+ });
69134
+ }
69093
69135
  async increasePositionAtStop(payload) {
69094
69136
  const focus_position = await this.getFocusPosition(payload);
69095
69137
  return await focus_position.increasePositionAtStop(payload);
@@ -68079,9 +68079,14 @@ class ExchangePosition {
68079
68079
  const price_places = symbol_config.price_places;
68080
68080
  const decimal_places = symbol_config.decimal_places;
68081
68081
  if (place) {
68082
- await this.cancelOrders({
68083
- limit: true
68082
+ await this.cancelExchangeOrder({
68083
+ type: "stop"
68084
68084
  });
68085
+ if (increase) {
68086
+ await this.cancelOrders({
68087
+ limit: true
68088
+ });
68089
+ }
68085
68090
  }
68086
68091
  return await this.exchange.customStopLoss({
68087
68092
  symbol: this.symbol,
@@ -68447,6 +68452,32 @@ class ExchangePosition {
68447
68452
  }
68448
68453
  });
68449
68454
  }
68455
+ async followStop(payload) {
68456
+ const { focus_position, fee_percent = 0.05, place } = payload;
68457
+ const entry = focus_position.instance.entry;
68458
+ if (this.kind !== focus_position.kind) {
68459
+ return;
68460
+ }
68461
+ if (this.kind === focus_position.kind) {
68462
+ if (this.kind === "long" && entry < this.instance.entry) {
68463
+ return;
68464
+ }
68465
+ if (this.kind === "short" && entry > this.instance.entry) {
68466
+ return;
68467
+ }
68468
+ }
68469
+ const target_pnl = Math.abs(entry - this.instance.entry) * this.instance.quantity;
68470
+ const fee = entry * this.instance.quantity * fee_percent / 100;
68471
+ const total_pnl = target_pnl + fee;
68472
+ const sell_diff = total_pnl / this.instance.quantity;
68473
+ const stop = this.kind === "long" ? this.instance.entry + sell_diff : this.instance.entry - sell_diff;
68474
+ return this.increasePositionAtStop({
68475
+ place,
68476
+ price: stop,
68477
+ quantity: this.instance.quantity,
68478
+ increase: false
68479
+ });
68480
+ }
68450
68481
  }
68451
68482
  function convert_to_exchange_order(order) {
68452
68483
  return {
@@ -69063,6 +69094,17 @@ class ExchangeAccount {
69063
69094
  short_position
69064
69095
  });
69065
69096
  }
69097
+ async followStop(payload) {
69098
+ const { symbol, kind, fee_percent, focus_position } = payload;
69099
+ const main_position = await this.getFocusPosition({
69100
+ symbol,
69101
+ kind
69102
+ });
69103
+ return await main_position.followStop({
69104
+ focus_position,
69105
+ fee_percent
69106
+ });
69107
+ }
69066
69108
  async increasePositionAtStop(payload) {
69067
69109
  const focus_position = await this.getFocusPosition(payload);
69068
69110
  return await focus_position.increasePositionAtStop(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-169",
4
+ "version": "0.0.2-170",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",