@gbozee/ultimate 0.0.2-180 → 0.0.2-182

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.
@@ -335,6 +335,20 @@ export interface ExchangeAccount extends BaseSystemFields {
335
335
  };
336
336
  include_delisted?: boolean;
337
337
  }
338
+ export interface SymbolConfig extends BaseSystemFields {
339
+ symbol: string;
340
+ support?: number;
341
+ resistance?: number;
342
+ stop_percent?: number;
343
+ price_places?: string;
344
+ decimal_places?: string;
345
+ min_size?: number;
346
+ weight?: number;
347
+ leverage?: number;
348
+ candle_count?: number;
349
+ interval?: any;
350
+ fee_percent?: number;
351
+ }
338
352
  export interface ScheduledTrade extends BaseSystemFields {
339
353
  symbol: string;
340
354
  account: string;
@@ -420,6 +434,7 @@ export interface PositionsView {
420
434
  account_strategy?: AccountStrategy;
421
435
  compound_instance?: CompoundInstance;
422
436
  support?: SupportTable;
437
+ symbol_config: SymbolConfig;
423
438
  };
424
439
  pnl?: number;
425
440
  support_price?: number;
package/dist/index.cjs CHANGED
@@ -54702,7 +54702,7 @@ class AppDatabase {
54702
54702
  return result;
54703
54703
  }
54704
54704
  get positionExpand() {
54705
- return "b_config, account_strategy, p_account, proxy, compound_instance.ref,support";
54705
+ return "b_config, account_strategy, p_account, proxy, compound_instance.ref,support,symbol_config";
54706
54706
  }
54707
54707
  async fetchCentralPositions(payload) {
54708
54708
  const { asset: assetName, symbol, customFilter = "" } = payload;
@@ -61115,13 +61115,11 @@ var import_https_proxy_agent2 = __toESM(require_dist2());
61115
61115
  var import_socks_proxy_agent2 = __toESM(require_dist3());
61116
61116
  class ExchangePosition {
61117
61117
  exchange;
61118
- symbol_config;
61119
61118
  exchange_account;
61120
61119
  app_db;
61121
61120
  instance;
61122
61121
  orders;
61123
61122
  constructor(payload) {
61124
- this.symbol_config = payload.symbol_config;
61125
61123
  this.exchange = payload.exchange;
61126
61124
  this.app_db = payload.app_db;
61127
61125
  this.instance = payload.instance;
@@ -61132,6 +61130,10 @@ class ExchangePosition {
61132
61130
  tp_orders: []
61133
61131
  };
61134
61132
  }
61133
+ get symbol_config() {
61134
+ const { symbol_config } = this.instance.expand;
61135
+ return symbol_config;
61136
+ }
61135
61137
  async initialize() {
61136
61138
  const proxy = await this.getProxyForAccount();
61137
61139
  if (proxy) {
@@ -61758,7 +61760,12 @@ class ExchangePosition {
61758
61760
  };
61759
61761
  }
61760
61762
  async increasePositionAtStop(payload) {
61761
- const { place = false, increase = true } = payload;
61763
+ const {
61764
+ place = false,
61765
+ increase = true,
61766
+ ratio_to_loose = 0,
61767
+ reverse_position
61768
+ } = payload;
61762
61769
  const position2 = this.instance;
61763
61770
  console.log(position2);
61764
61771
  let price_params = {
@@ -61786,6 +61793,10 @@ class ExchangePosition {
61786
61793
  });
61787
61794
  }
61788
61795
  }
61796
+ const _pnl = determine_pnl(position2.entry, price_params.price, price_params.quantity, this.kind);
61797
+ if (_pnl > 0 && ratio_to_loose) {
61798
+ await reverse_position.lockReduction({ pnl: _pnl * ratio_to_loose });
61799
+ }
61789
61800
  return await this.exchange.customStopLoss({
61790
61801
  symbol: this.symbol,
61791
61802
  kind: this.kind,
@@ -61798,6 +61809,24 @@ class ExchangePosition {
61798
61809
  });
61799
61810
  }
61800
61811
  }
61812
+ async lockReduction({
61813
+ pnl,
61814
+ place = true,
61815
+ pause_tp = true
61816
+ }) {
61817
+ if (pnl > 0 && this.instance.quantity > 0) {
61818
+ const diff = pnl / this.instance.quantity;
61819
+ const tp_price = this.kind === "long" ? diff + this.instance.entry : this.instance.entry - diff;
61820
+ return this.exchange_account.justInTimeProfit({
61821
+ symbol: this.symbol,
61822
+ kind: this.kind,
61823
+ take_profit: tp_price,
61824
+ target_pnl: pnl,
61825
+ place,
61826
+ pause_tp
61827
+ });
61828
+ }
61829
+ }
61801
61830
  async placeSingleOrder(payload) {
61802
61831
  const { long_position, short_position } = payload;
61803
61832
  const kind = this.kind;
@@ -62290,9 +62319,6 @@ class ExchangeAccount {
62290
62319
  symbol: payload.symbol,
62291
62320
  as_view: true
62292
62321
  });
62293
- const symbol_config = await this.recomputeSymbolConfig({
62294
- symbol: payload.symbol
62295
- });
62296
62322
  const active_account = await this.getActiveAccount({
62297
62323
  symbol: payload.symbol
62298
62324
  });
@@ -62300,7 +62326,6 @@ class ExchangeAccount {
62300
62326
  const long_position = positions.find((x) => x.kind === "long");
62301
62327
  const short_position = positions.find((x) => x.kind === "short");
62302
62328
  this.long_position = new ExchangePosition({
62303
- symbol_config,
62304
62329
  exchange: this.exchange,
62305
62330
  exchange_account: this,
62306
62331
  instance: long_position,
@@ -62310,7 +62335,6 @@ class ExchangeAccount {
62310
62335
  });
62311
62336
  await this.long_position.initialize();
62312
62337
  this.short_position = new ExchangePosition({
62313
- symbol_config,
62314
62338
  exchange: this.exchange,
62315
62339
  exchange_account: this,
62316
62340
  instance: short_position,
@@ -62849,8 +62873,16 @@ class ExchangeAccount {
62849
62873
  });
62850
62874
  }
62851
62875
  async increasePositionAtStop(payload) {
62876
+ const { symbol, kind } = payload;
62877
+ const reverse_position = await this.getFocusPosition({
62878
+ symbol,
62879
+ kind: kind === "long" ? "short" : "long"
62880
+ });
62852
62881
  const focus_position = await this.getFocusPosition(payload);
62853
- return await focus_position.increasePositionAtStop(payload);
62882
+ return await focus_position.increasePositionAtStop({
62883
+ ...payload,
62884
+ reverse_position
62885
+ });
62854
62886
  }
62855
62887
  async triggerTradeFromConfig(payload) {
62856
62888
  const focus_position = await this.getFocusPosition(payload);
package/dist/index.d.ts CHANGED
@@ -160,6 +160,7 @@ export interface PositionsView {
160
160
  account_strategy?: AccountStrategy;
161
161
  compound_instance?: CompoundInstance;
162
162
  support?: SupportTable;
163
+ symbol_config: SymbolConfig;
163
164
  };
164
165
  pnl?: number;
165
166
  support_price?: number;
@@ -1892,7 +1893,6 @@ export type ExchangeOrder = {
1892
1893
  };
1893
1894
  export declare class ExchangePosition {
1894
1895
  exchange: BaseExchange;
1895
- symbol_config: SymbolConfig;
1896
1896
  exchange_account: ExchangeAccount$1;
1897
1897
  private app_db;
1898
1898
  private instance;
@@ -1904,7 +1904,6 @@ export declare class ExchangePosition {
1904
1904
  constructor(payload: {
1905
1905
  exchange: BaseExchange;
1906
1906
  app_db: AppDatabase;
1907
- symbol_config: SymbolConfig;
1908
1907
  instance: PositionsView;
1909
1908
  exchange_account: ExchangeAccount$1;
1910
1909
  without_view?: PositionsView;
@@ -1914,6 +1913,7 @@ export declare class ExchangePosition {
1914
1913
  tp_orders: any[];
1915
1914
  };
1916
1915
  });
1916
+ get symbol_config(): SymbolConfig;
1917
1917
  initialize(): Promise<void>;
1918
1918
  getInstance(): PositionsView;
1919
1919
  get symbol(): any;
@@ -2149,7 +2149,20 @@ export declare class ExchangePosition {
2149
2149
  price?: number;
2150
2150
  quantity?: number;
2151
2151
  increase?: boolean;
2152
+ ratio_to_loose?: number;
2153
+ reverse_position?: ExchangePosition;
2152
2154
  }): Promise<any>;
2155
+ lockReduction({ pnl, place, pause_tp, }: {
2156
+ pnl: number;
2157
+ place?: boolean;
2158
+ pause_tp?: boolean;
2159
+ }): Promise<{
2160
+ sell_ratio: number;
2161
+ current_pnl: number;
2162
+ profit_percent: number;
2163
+ current_price: number;
2164
+ notional_value: number;
2165
+ }>;
2153
2166
  placeSingleOrder(payload: {
2154
2167
  long_position: ExchangePosition;
2155
2168
  short_position: ExchangePosition;
@@ -2621,6 +2634,7 @@ declare class ExchangeAccount$1 {
2621
2634
  price?: number;
2622
2635
  quantity?: number;
2623
2636
  increase?: boolean;
2637
+ ratio_to_loose?: number;
2624
2638
  }): Promise<any>;
2625
2639
  triggerTradeFromConfig(payload: {
2626
2640
  symbol: string;
package/dist/index.js CHANGED
@@ -54640,7 +54640,7 @@ class AppDatabase {
54640
54640
  return result;
54641
54641
  }
54642
54642
  get positionExpand() {
54643
- return "b_config, account_strategy, p_account, proxy, compound_instance.ref,support";
54643
+ return "b_config, account_strategy, p_account, proxy, compound_instance.ref,support,symbol_config";
54644
54644
  }
54645
54645
  async fetchCentralPositions(payload) {
54646
54646
  const { asset: assetName, symbol, customFilter = "" } = payload;
@@ -61053,13 +61053,11 @@ var import_https_proxy_agent2 = __toESM(require_dist2(), 1);
61053
61053
  var import_socks_proxy_agent2 = __toESM(require_dist3(), 1);
61054
61054
  class ExchangePosition {
61055
61055
  exchange;
61056
- symbol_config;
61057
61056
  exchange_account;
61058
61057
  app_db;
61059
61058
  instance;
61060
61059
  orders;
61061
61060
  constructor(payload) {
61062
- this.symbol_config = payload.symbol_config;
61063
61061
  this.exchange = payload.exchange;
61064
61062
  this.app_db = payload.app_db;
61065
61063
  this.instance = payload.instance;
@@ -61070,6 +61068,10 @@ class ExchangePosition {
61070
61068
  tp_orders: []
61071
61069
  };
61072
61070
  }
61071
+ get symbol_config() {
61072
+ const { symbol_config } = this.instance.expand;
61073
+ return symbol_config;
61074
+ }
61073
61075
  async initialize() {
61074
61076
  const proxy = await this.getProxyForAccount();
61075
61077
  if (proxy) {
@@ -61696,7 +61698,12 @@ class ExchangePosition {
61696
61698
  };
61697
61699
  }
61698
61700
  async increasePositionAtStop(payload) {
61699
- const { place = false, increase = true } = payload;
61701
+ const {
61702
+ place = false,
61703
+ increase = true,
61704
+ ratio_to_loose = 0,
61705
+ reverse_position
61706
+ } = payload;
61700
61707
  const position2 = this.instance;
61701
61708
  console.log(position2);
61702
61709
  let price_params = {
@@ -61724,6 +61731,10 @@ class ExchangePosition {
61724
61731
  });
61725
61732
  }
61726
61733
  }
61734
+ const _pnl = determine_pnl(position2.entry, price_params.price, price_params.quantity, this.kind);
61735
+ if (_pnl > 0 && ratio_to_loose) {
61736
+ await reverse_position.lockReduction({ pnl: _pnl * ratio_to_loose });
61737
+ }
61727
61738
  return await this.exchange.customStopLoss({
61728
61739
  symbol: this.symbol,
61729
61740
  kind: this.kind,
@@ -61736,6 +61747,24 @@ class ExchangePosition {
61736
61747
  });
61737
61748
  }
61738
61749
  }
61750
+ async lockReduction({
61751
+ pnl,
61752
+ place = true,
61753
+ pause_tp = true
61754
+ }) {
61755
+ if (pnl > 0 && this.instance.quantity > 0) {
61756
+ const diff = pnl / this.instance.quantity;
61757
+ const tp_price = this.kind === "long" ? diff + this.instance.entry : this.instance.entry - diff;
61758
+ return this.exchange_account.justInTimeProfit({
61759
+ symbol: this.symbol,
61760
+ kind: this.kind,
61761
+ take_profit: tp_price,
61762
+ target_pnl: pnl,
61763
+ place,
61764
+ pause_tp
61765
+ });
61766
+ }
61767
+ }
61739
61768
  async placeSingleOrder(payload) {
61740
61769
  const { long_position, short_position } = payload;
61741
61770
  const kind = this.kind;
@@ -62228,9 +62257,6 @@ class ExchangeAccount {
62228
62257
  symbol: payload.symbol,
62229
62258
  as_view: true
62230
62259
  });
62231
- const symbol_config = await this.recomputeSymbolConfig({
62232
- symbol: payload.symbol
62233
- });
62234
62260
  const active_account = await this.getActiveAccount({
62235
62261
  symbol: payload.symbol
62236
62262
  });
@@ -62238,7 +62264,6 @@ class ExchangeAccount {
62238
62264
  const long_position = positions.find((x) => x.kind === "long");
62239
62265
  const short_position = positions.find((x) => x.kind === "short");
62240
62266
  this.long_position = new ExchangePosition({
62241
- symbol_config,
62242
62267
  exchange: this.exchange,
62243
62268
  exchange_account: this,
62244
62269
  instance: long_position,
@@ -62248,7 +62273,6 @@ class ExchangeAccount {
62248
62273
  });
62249
62274
  await this.long_position.initialize();
62250
62275
  this.short_position = new ExchangePosition({
62251
- symbol_config,
62252
62276
  exchange: this.exchange,
62253
62277
  exchange_account: this,
62254
62278
  instance: short_position,
@@ -62787,8 +62811,16 @@ class ExchangeAccount {
62787
62811
  });
62788
62812
  }
62789
62813
  async increasePositionAtStop(payload) {
62814
+ const { symbol, kind } = payload;
62815
+ const reverse_position = await this.getFocusPosition({
62816
+ symbol,
62817
+ kind: kind === "long" ? "short" : "long"
62818
+ });
62790
62819
  const focus_position = await this.getFocusPosition(payload);
62791
- return await focus_position.increasePositionAtStop(payload);
62820
+ return await focus_position.increasePositionAtStop({
62821
+ ...payload,
62822
+ reverse_position
62823
+ });
62792
62824
  }
62793
62825
  async triggerTradeFromConfig(payload) {
62794
62826
  const focus_position = await this.getFocusPosition(payload);
@@ -61396,7 +61396,7 @@ class AppDatabase {
61396
61396
  return result;
61397
61397
  }
61398
61398
  get positionExpand() {
61399
- return "b_config, account_strategy, p_account, proxy, compound_instance.ref,support";
61399
+ return "b_config, account_strategy, p_account, proxy, compound_instance.ref,support,symbol_config";
61400
61400
  }
61401
61401
  async fetchCentralPositions(payload) {
61402
61402
  const { asset: assetName, symbol, customFilter = "" } = payload;
@@ -67691,13 +67691,11 @@ var import_https_proxy_agent2 = __toESM(require_dist2());
67691
67691
  var import_socks_proxy_agent2 = __toESM(require_dist3());
67692
67692
  class ExchangePosition {
67693
67693
  exchange;
67694
- symbol_config;
67695
67694
  exchange_account;
67696
67695
  app_db;
67697
67696
  instance;
67698
67697
  orders;
67699
67698
  constructor(payload) {
67700
- this.symbol_config = payload.symbol_config;
67701
67699
  this.exchange = payload.exchange;
67702
67700
  this.app_db = payload.app_db;
67703
67701
  this.instance = payload.instance;
@@ -67708,6 +67706,10 @@ class ExchangePosition {
67708
67706
  tp_orders: []
67709
67707
  };
67710
67708
  }
67709
+ get symbol_config() {
67710
+ const { symbol_config } = this.instance.expand;
67711
+ return symbol_config;
67712
+ }
67711
67713
  async initialize() {
67712
67714
  const proxy = await this.getProxyForAccount();
67713
67715
  if (proxy) {
@@ -68334,7 +68336,12 @@ class ExchangePosition {
68334
68336
  };
68335
68337
  }
68336
68338
  async increasePositionAtStop(payload) {
68337
- const { place = false, increase = true } = payload;
68339
+ const {
68340
+ place = false,
68341
+ increase = true,
68342
+ ratio_to_loose = 0,
68343
+ reverse_position
68344
+ } = payload;
68338
68345
  const position2 = this.instance;
68339
68346
  console.log(position2);
68340
68347
  let price_params = {
@@ -68362,6 +68369,10 @@ class ExchangePosition {
68362
68369
  });
68363
68370
  }
68364
68371
  }
68372
+ const _pnl = determine_pnl(position2.entry, price_params.price, price_params.quantity, this.kind);
68373
+ if (_pnl > 0 && ratio_to_loose) {
68374
+ await reverse_position.lockReduction({ pnl: _pnl * ratio_to_loose });
68375
+ }
68365
68376
  return await this.exchange.customStopLoss({
68366
68377
  symbol: this.symbol,
68367
68378
  kind: this.kind,
@@ -68374,6 +68385,24 @@ class ExchangePosition {
68374
68385
  });
68375
68386
  }
68376
68387
  }
68388
+ async lockReduction({
68389
+ pnl,
68390
+ place = true,
68391
+ pause_tp = true
68392
+ }) {
68393
+ if (pnl > 0 && this.instance.quantity > 0) {
68394
+ const diff = pnl / this.instance.quantity;
68395
+ const tp_price = this.kind === "long" ? diff + this.instance.entry : this.instance.entry - diff;
68396
+ return this.exchange_account.justInTimeProfit({
68397
+ symbol: this.symbol,
68398
+ kind: this.kind,
68399
+ take_profit: tp_price,
68400
+ target_pnl: pnl,
68401
+ place,
68402
+ pause_tp
68403
+ });
68404
+ }
68405
+ }
68377
68406
  async placeSingleOrder(payload) {
68378
68407
  const { long_position, short_position } = payload;
68379
68408
  const kind = this.kind;
@@ -68866,9 +68895,6 @@ class ExchangeAccount {
68866
68895
  symbol: payload.symbol,
68867
68896
  as_view: true
68868
68897
  });
68869
- const symbol_config = await this.recomputeSymbolConfig({
68870
- symbol: payload.symbol
68871
- });
68872
68898
  const active_account = await this.getActiveAccount({
68873
68899
  symbol: payload.symbol
68874
68900
  });
@@ -68876,7 +68902,6 @@ class ExchangeAccount {
68876
68902
  const long_position = positions.find((x) => x.kind === "long");
68877
68903
  const short_position = positions.find((x) => x.kind === "short");
68878
68904
  this.long_position = new ExchangePosition({
68879
- symbol_config,
68880
68905
  exchange: this.exchange,
68881
68906
  exchange_account: this,
68882
68907
  instance: long_position,
@@ -68886,7 +68911,6 @@ class ExchangeAccount {
68886
68911
  });
68887
68912
  await this.long_position.initialize();
68888
68913
  this.short_position = new ExchangePosition({
68889
- symbol_config,
68890
68914
  exchange: this.exchange,
68891
68915
  exchange_account: this,
68892
68916
  instance: short_position,
@@ -69425,8 +69449,16 @@ class ExchangeAccount {
69425
69449
  });
69426
69450
  }
69427
69451
  async increasePositionAtStop(payload) {
69452
+ const { symbol, kind } = payload;
69453
+ const reverse_position = await this.getFocusPosition({
69454
+ symbol,
69455
+ kind: kind === "long" ? "short" : "long"
69456
+ });
69428
69457
  const focus_position = await this.getFocusPosition(payload);
69429
- return await focus_position.increasePositionAtStop(payload);
69458
+ return await focus_position.increasePositionAtStop({
69459
+ ...payload,
69460
+ reverse_position
69461
+ });
69430
69462
  }
69431
69463
  async triggerTradeFromConfig(payload) {
69432
69464
  const focus_position = await this.getFocusPosition(payload);
@@ -61369,7 +61369,7 @@ class AppDatabase {
61369
61369
  return result;
61370
61370
  }
61371
61371
  get positionExpand() {
61372
- return "b_config, account_strategy, p_account, proxy, compound_instance.ref,support";
61372
+ return "b_config, account_strategy, p_account, proxy, compound_instance.ref,support,symbol_config";
61373
61373
  }
61374
61374
  async fetchCentralPositions(payload) {
61375
61375
  const { asset: assetName, symbol, customFilter = "" } = payload;
@@ -67664,13 +67664,11 @@ var import_https_proxy_agent2 = __toESM(require_dist2(), 1);
67664
67664
  var import_socks_proxy_agent2 = __toESM(require_dist3(), 1);
67665
67665
  class ExchangePosition {
67666
67666
  exchange;
67667
- symbol_config;
67668
67667
  exchange_account;
67669
67668
  app_db;
67670
67669
  instance;
67671
67670
  orders;
67672
67671
  constructor(payload) {
67673
- this.symbol_config = payload.symbol_config;
67674
67672
  this.exchange = payload.exchange;
67675
67673
  this.app_db = payload.app_db;
67676
67674
  this.instance = payload.instance;
@@ -67681,6 +67679,10 @@ class ExchangePosition {
67681
67679
  tp_orders: []
67682
67680
  };
67683
67681
  }
67682
+ get symbol_config() {
67683
+ const { symbol_config } = this.instance.expand;
67684
+ return symbol_config;
67685
+ }
67684
67686
  async initialize() {
67685
67687
  const proxy = await this.getProxyForAccount();
67686
67688
  if (proxy) {
@@ -68307,7 +68309,12 @@ class ExchangePosition {
68307
68309
  };
68308
68310
  }
68309
68311
  async increasePositionAtStop(payload) {
68310
- const { place = false, increase = true } = payload;
68312
+ const {
68313
+ place = false,
68314
+ increase = true,
68315
+ ratio_to_loose = 0,
68316
+ reverse_position
68317
+ } = payload;
68311
68318
  const position2 = this.instance;
68312
68319
  console.log(position2);
68313
68320
  let price_params = {
@@ -68335,6 +68342,10 @@ class ExchangePosition {
68335
68342
  });
68336
68343
  }
68337
68344
  }
68345
+ const _pnl = determine_pnl(position2.entry, price_params.price, price_params.quantity, this.kind);
68346
+ if (_pnl > 0 && ratio_to_loose) {
68347
+ await reverse_position.lockReduction({ pnl: _pnl * ratio_to_loose });
68348
+ }
68338
68349
  return await this.exchange.customStopLoss({
68339
68350
  symbol: this.symbol,
68340
68351
  kind: this.kind,
@@ -68347,6 +68358,24 @@ class ExchangePosition {
68347
68358
  });
68348
68359
  }
68349
68360
  }
68361
+ async lockReduction({
68362
+ pnl,
68363
+ place = true,
68364
+ pause_tp = true
68365
+ }) {
68366
+ if (pnl > 0 && this.instance.quantity > 0) {
68367
+ const diff = pnl / this.instance.quantity;
68368
+ const tp_price = this.kind === "long" ? diff + this.instance.entry : this.instance.entry - diff;
68369
+ return this.exchange_account.justInTimeProfit({
68370
+ symbol: this.symbol,
68371
+ kind: this.kind,
68372
+ take_profit: tp_price,
68373
+ target_pnl: pnl,
68374
+ place,
68375
+ pause_tp
68376
+ });
68377
+ }
68378
+ }
68350
68379
  async placeSingleOrder(payload) {
68351
68380
  const { long_position, short_position } = payload;
68352
68381
  const kind = this.kind;
@@ -68839,9 +68868,6 @@ class ExchangeAccount {
68839
68868
  symbol: payload.symbol,
68840
68869
  as_view: true
68841
68870
  });
68842
- const symbol_config = await this.recomputeSymbolConfig({
68843
- symbol: payload.symbol
68844
- });
68845
68871
  const active_account = await this.getActiveAccount({
68846
68872
  symbol: payload.symbol
68847
68873
  });
@@ -68849,7 +68875,6 @@ class ExchangeAccount {
68849
68875
  const long_position = positions.find((x) => x.kind === "long");
68850
68876
  const short_position = positions.find((x) => x.kind === "short");
68851
68877
  this.long_position = new ExchangePosition({
68852
- symbol_config,
68853
68878
  exchange: this.exchange,
68854
68879
  exchange_account: this,
68855
68880
  instance: long_position,
@@ -68859,7 +68884,6 @@ class ExchangeAccount {
68859
68884
  });
68860
68885
  await this.long_position.initialize();
68861
68886
  this.short_position = new ExchangePosition({
68862
- symbol_config,
68863
68887
  exchange: this.exchange,
68864
68888
  exchange_account: this,
68865
68889
  instance: short_position,
@@ -69398,8 +69422,16 @@ class ExchangeAccount {
69398
69422
  });
69399
69423
  }
69400
69424
  async increasePositionAtStop(payload) {
69425
+ const { symbol, kind } = payload;
69426
+ const reverse_position = await this.getFocusPosition({
69427
+ symbol,
69428
+ kind: kind === "long" ? "short" : "long"
69429
+ });
69401
69430
  const focus_position = await this.getFocusPosition(payload);
69402
- return await focus_position.increasePositionAtStop(payload);
69431
+ return await focus_position.increasePositionAtStop({
69432
+ ...payload,
69433
+ reverse_position
69434
+ });
69403
69435
  }
69404
69436
  async triggerTradeFromConfig(payload) {
69405
69437
  const focus_position = await this.getFocusPosition(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-180",
4
+ "version": "0.0.2-182",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",