@gbozee/ultimate 0.0.2-131 → 0.0.2-134

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.
@@ -491,11 +491,13 @@ export declare function computeProfitDetail(payload: {
491
491
  quantity: number;
492
492
  };
493
493
  };
494
+ full_ratio?: number;
494
495
  price_places?: string;
495
496
  decimal_places?: string;
496
497
  }): {
497
498
  pnl: number;
498
499
  loss: number;
500
+ full_loss: number;
499
501
  original_pnl: number;
500
502
  reward_factor: number;
501
503
  profit_percent: number;
@@ -854,6 +856,7 @@ export declare class Strategy {
854
856
  }): {
855
857
  pnl: number;
856
858
  loss: number;
859
+ full_loss: number;
857
860
  original_pnl: number;
858
861
  reward_factor: number;
859
862
  profit_percent: number;
@@ -1895,13 +1895,15 @@ function computeProfitDetail(payload) {
1895
1895
  price_places = "%.1f",
1896
1896
  reduce_position,
1897
1897
  decimal_places,
1898
- reverse_position
1898
+ reverse_position,
1899
+ full_ratio = 1
1899
1900
  } = payload;
1900
1901
  let reward_factor = strategy.reward_factor;
1901
1902
  const profit_percent = to_f(pnl * 100 / (focus_position.avg_price * focus_position.avg_qty), "%.4f");
1902
1903
  const diff = pnl / focus_position.quantity;
1903
1904
  const sell_price = to_f(focus_position.kind === "long" ? focus_position.entry + diff : focus_position.entry - diff, price_places);
1904
1905
  let loss = 0;
1906
+ let full_loss = 0;
1905
1907
  let expected_loss = 0;
1906
1908
  let quantity = 0;
1907
1909
  let new_pnl = pnl;
@@ -1910,6 +1912,7 @@ function computeProfitDetail(payload) {
1910
1912
  const ratio = pnl / loss;
1911
1913
  quantity = to_f(reduce_position.quantity * ratio, decimal_places);
1912
1914
  expected_loss = to_f(Math.abs(reduce_position.entry - sell_price) * quantity, "%.2f");
1915
+ full_loss = Math.abs(reduce_position.avg_price - sell_price) * reduce_position.avg_qty * full_ratio;
1913
1916
  }
1914
1917
  if (reverse_position) {
1915
1918
  expected_loss = Math.abs(reverse_position.avg_price - sell_price) * reverse_position.avg_qty;
@@ -1918,6 +1921,7 @@ function computeProfitDetail(payload) {
1918
1921
  return {
1919
1922
  pnl: new_pnl,
1920
1923
  loss: to_f(expected_loss, "%.2f"),
1924
+ full_loss: to_f(full_loss, "%.2f"),
1921
1925
  original_pnl: pnl,
1922
1926
  reward_factor,
1923
1927
  profit_percent,
@@ -2150,8 +2154,10 @@ function determineCompoundLongTrade(payload) {
2150
2154
  const short_max_size = short_app_config.last_value.avg_size;
2151
2155
  const start_risk = Math.abs(short_app_config.last_value.neg_pnl) * rr;
2152
2156
  const short_profit = short_app_config.last_value.avg_size * short_app_config.last_value.avg_entry * shortConfig.profit_percent / 100;
2153
- const support = Math.abs(short_app_config.last_value.avg_entry - short_profit) * rr;
2157
+ const diff = short_profit * rr / short_app_config.last_value.avg_size;
2158
+ const support = Math.abs(short_app_config.last_value.avg_entry - diff);
2154
2159
  const resistance = focus_short_position.next_order || focus_long_position.take_profit;
2160
+ console.log({ support, resistance, short_profit });
2155
2161
  const result = getRiskReward({
2156
2162
  entry: resistance,
2157
2163
  stop: support,
package/dist/index.cjs CHANGED
@@ -54232,13 +54232,15 @@ function computeProfitDetail(payload) {
54232
54232
  price_places = "%.1f",
54233
54233
  reduce_position,
54234
54234
  decimal_places,
54235
- reverse_position
54235
+ reverse_position,
54236
+ full_ratio = 1
54236
54237
  } = payload;
54237
54238
  let reward_factor = strategy.reward_factor;
54238
54239
  const profit_percent = to_f2(pnl * 100 / (focus_position.avg_price * focus_position.avg_qty), "%.4f");
54239
54240
  const diff = pnl / focus_position.quantity;
54240
54241
  const sell_price = to_f2(focus_position.kind === "long" ? focus_position.entry + diff : focus_position.entry - diff, price_places);
54241
54242
  let loss = 0;
54243
+ let full_loss = 0;
54242
54244
  let expected_loss = 0;
54243
54245
  let quantity = 0;
54244
54246
  let new_pnl = pnl;
@@ -54247,6 +54249,7 @@ function computeProfitDetail(payload) {
54247
54249
  const ratio = pnl / loss;
54248
54250
  quantity = to_f2(reduce_position.quantity * ratio, decimal_places);
54249
54251
  expected_loss = to_f2(Math.abs(reduce_position.entry - sell_price) * quantity, "%.2f");
54252
+ full_loss = Math.abs(reduce_position.avg_price - sell_price) * reduce_position.avg_qty * full_ratio;
54250
54253
  }
54251
54254
  if (reverse_position) {
54252
54255
  expected_loss = Math.abs(reverse_position.avg_price - sell_price) * reverse_position.avg_qty;
@@ -54255,6 +54258,7 @@ function computeProfitDetail(payload) {
54255
54258
  return {
54256
54259
  pnl: new_pnl,
54257
54260
  loss: to_f2(expected_loss, "%.2f"),
54261
+ full_loss: to_f2(full_loss, "%.2f"),
54258
54262
  original_pnl: pnl,
54259
54263
  reward_factor,
54260
54264
  profit_percent,
@@ -54487,8 +54491,10 @@ function determineCompoundLongTrade(payload) {
54487
54491
  const short_max_size = short_app_config.last_value.avg_size;
54488
54492
  const start_risk = Math.abs(short_app_config.last_value.neg_pnl) * rr;
54489
54493
  const short_profit = short_app_config.last_value.avg_size * short_app_config.last_value.avg_entry * shortConfig.profit_percent / 100;
54490
- const support = Math.abs(short_app_config.last_value.avg_entry - short_profit) * rr;
54494
+ const diff = short_profit * rr / short_app_config.last_value.avg_size;
54495
+ const support = Math.abs(short_app_config.last_value.avg_entry - diff);
54491
54496
  const resistance = focus_short_position.next_order || focus_long_position.take_profit;
54497
+ console.log({ support, resistance, short_profit });
54492
54498
  const result = getRiskReward({
54493
54499
  entry: resistance,
54494
54500
  stop: support,
@@ -60142,7 +60148,7 @@ class ExchangeAccount {
60142
60148
  });
60143
60149
  }
60144
60150
  async getSellPriceFromStrategy(payload) {
60145
- const { symbol, reduce_position, kind } = payload;
60151
+ const { symbol, reduce_position, kind, full_ratio = 1 } = payload;
60146
60152
  const symbol_config = await this.recomputeSymbolConfig({
60147
60153
  symbol
60148
60154
  });
@@ -60192,7 +60198,8 @@ class ExchangeAccount {
60192
60198
  stop_loss: reverse_position.stop_loss
60193
60199
  },
60194
60200
  price_places: symbol_config.price_places,
60195
- decimal_places: symbol_config.decimal_places
60201
+ decimal_places: symbol_config.decimal_places,
60202
+ full_ratio
60196
60203
  });
60197
60204
  }
60198
60205
  async placeCompoundShortTrade(payload) {
@@ -60611,6 +60618,7 @@ class App {
60611
60618
  kind,
60612
60619
  place,
60613
60620
  increase,
60621
+ full_ratio = 1,
60614
60622
  cancel_limit = true
60615
60623
  } = payload;
60616
60624
  const main_exchange_account = await this.getExchangeAccount(main_account);
@@ -60624,7 +60632,8 @@ class App {
60624
60632
  const result = await main_exchange_account.getSellPriceFromStrategy({
60625
60633
  symbol: main_account.symbol,
60626
60634
  reduce_position,
60627
- kind: main_account.kind || reverse_kind
60635
+ kind: main_account.kind || reverse_kind,
60636
+ full_ratio
60628
60637
  });
60629
60638
  if (place) {
60630
60639
  if (cancel_limit) {
package/dist/index.d.ts CHANGED
@@ -1017,6 +1017,7 @@ export declare class Strategy {
1017
1017
  }): {
1018
1018
  pnl: number;
1019
1019
  loss: number;
1020
+ full_loss: number;
1020
1021
  original_pnl: number;
1021
1022
  reward_factor: number;
1022
1023
  profit_percent: number;
@@ -1427,11 +1428,13 @@ export declare function computeProfitDetail(payload: {
1427
1428
  quantity: number;
1428
1429
  };
1429
1430
  };
1431
+ full_ratio?: number;
1430
1432
  price_places?: string;
1431
1433
  decimal_places?: string;
1432
1434
  }): {
1433
1435
  pnl: number;
1434
1436
  loss: number;
1437
+ full_loss: number;
1435
1438
  original_pnl: number;
1436
1439
  reward_factor: number;
1437
1440
  profit_percent: number;
@@ -2384,9 +2387,11 @@ declare class ExchangeAccount$1 {
2384
2387
  symbol: string;
2385
2388
  reduce_position: PositionsView;
2386
2389
  kind?: "long" | "short";
2390
+ full_ratio?: number;
2387
2391
  }): Promise<{
2388
2392
  pnl: number;
2389
2393
  loss: number;
2394
+ full_loss: number;
2390
2395
  original_pnl: number;
2391
2396
  reward_factor: number;
2392
2397
  profit_percent: number;
@@ -2632,6 +2637,7 @@ declare class App {
2632
2637
  kind: "long" | "short";
2633
2638
  place?: boolean;
2634
2639
  increase?: boolean;
2640
+ full_ratio?: number;
2635
2641
  cancel_limit?: boolean;
2636
2642
  }): Promise<any>;
2637
2643
  }
package/dist/index.js CHANGED
@@ -54180,13 +54180,15 @@ function computeProfitDetail(payload) {
54180
54180
  price_places = "%.1f",
54181
54181
  reduce_position,
54182
54182
  decimal_places,
54183
- reverse_position
54183
+ reverse_position,
54184
+ full_ratio = 1
54184
54185
  } = payload;
54185
54186
  let reward_factor = strategy.reward_factor;
54186
54187
  const profit_percent = to_f2(pnl * 100 / (focus_position.avg_price * focus_position.avg_qty), "%.4f");
54187
54188
  const diff = pnl / focus_position.quantity;
54188
54189
  const sell_price = to_f2(focus_position.kind === "long" ? focus_position.entry + diff : focus_position.entry - diff, price_places);
54189
54190
  let loss = 0;
54191
+ let full_loss = 0;
54190
54192
  let expected_loss = 0;
54191
54193
  let quantity = 0;
54192
54194
  let new_pnl = pnl;
@@ -54195,6 +54197,7 @@ function computeProfitDetail(payload) {
54195
54197
  const ratio = pnl / loss;
54196
54198
  quantity = to_f2(reduce_position.quantity * ratio, decimal_places);
54197
54199
  expected_loss = to_f2(Math.abs(reduce_position.entry - sell_price) * quantity, "%.2f");
54200
+ full_loss = Math.abs(reduce_position.avg_price - sell_price) * reduce_position.avg_qty * full_ratio;
54198
54201
  }
54199
54202
  if (reverse_position) {
54200
54203
  expected_loss = Math.abs(reverse_position.avg_price - sell_price) * reverse_position.avg_qty;
@@ -54203,6 +54206,7 @@ function computeProfitDetail(payload) {
54203
54206
  return {
54204
54207
  pnl: new_pnl,
54205
54208
  loss: to_f2(expected_loss, "%.2f"),
54209
+ full_loss: to_f2(full_loss, "%.2f"),
54206
54210
  original_pnl: pnl,
54207
54211
  reward_factor,
54208
54212
  profit_percent,
@@ -54435,8 +54439,10 @@ function determineCompoundLongTrade(payload) {
54435
54439
  const short_max_size = short_app_config.last_value.avg_size;
54436
54440
  const start_risk = Math.abs(short_app_config.last_value.neg_pnl) * rr;
54437
54441
  const short_profit = short_app_config.last_value.avg_size * short_app_config.last_value.avg_entry * shortConfig.profit_percent / 100;
54438
- const support = Math.abs(short_app_config.last_value.avg_entry - short_profit) * rr;
54442
+ const diff = short_profit * rr / short_app_config.last_value.avg_size;
54443
+ const support = Math.abs(short_app_config.last_value.avg_entry - diff);
54439
54444
  const resistance = focus_short_position.next_order || focus_long_position.take_profit;
54445
+ console.log({ support, resistance, short_profit });
54440
54446
  const result = getRiskReward({
54441
54447
  entry: resistance,
54442
54448
  stop: support,
@@ -60090,7 +60096,7 @@ class ExchangeAccount {
60090
60096
  });
60091
60097
  }
60092
60098
  async getSellPriceFromStrategy(payload) {
60093
- const { symbol, reduce_position, kind } = payload;
60099
+ const { symbol, reduce_position, kind, full_ratio = 1 } = payload;
60094
60100
  const symbol_config = await this.recomputeSymbolConfig({
60095
60101
  symbol
60096
60102
  });
@@ -60140,7 +60146,8 @@ class ExchangeAccount {
60140
60146
  stop_loss: reverse_position.stop_loss
60141
60147
  },
60142
60148
  price_places: symbol_config.price_places,
60143
- decimal_places: symbol_config.decimal_places
60149
+ decimal_places: symbol_config.decimal_places,
60150
+ full_ratio
60144
60151
  });
60145
60152
  }
60146
60153
  async placeCompoundShortTrade(payload) {
@@ -60559,6 +60566,7 @@ class App {
60559
60566
  kind,
60560
60567
  place,
60561
60568
  increase,
60569
+ full_ratio = 1,
60562
60570
  cancel_limit = true
60563
60571
  } = payload;
60564
60572
  const main_exchange_account = await this.getExchangeAccount(main_account);
@@ -60572,7 +60580,8 @@ class App {
60572
60580
  const result = await main_exchange_account.getSellPriceFromStrategy({
60573
60581
  symbol: main_account.symbol,
60574
60582
  reduce_position,
60575
- kind: main_account.kind || reverse_kind
60583
+ kind: main_account.kind || reverse_kind,
60584
+ full_ratio
60576
60585
  });
60577
60586
  if (place) {
60578
60587
  if (cancel_limit) {
@@ -60914,13 +60914,15 @@ function computeProfitDetail(payload) {
60914
60914
  price_places = "%.1f",
60915
60915
  reduce_position,
60916
60916
  decimal_places,
60917
- reverse_position
60917
+ reverse_position,
60918
+ full_ratio = 1
60918
60919
  } = payload;
60919
60920
  let reward_factor = strategy.reward_factor;
60920
60921
  const profit_percent = to_f2(pnl * 100 / (focus_position.avg_price * focus_position.avg_qty), "%.4f");
60921
60922
  const diff = pnl / focus_position.quantity;
60922
60923
  const sell_price = to_f2(focus_position.kind === "long" ? focus_position.entry + diff : focus_position.entry - diff, price_places);
60923
60924
  let loss = 0;
60925
+ let full_loss = 0;
60924
60926
  let expected_loss = 0;
60925
60927
  let quantity = 0;
60926
60928
  let new_pnl = pnl;
@@ -60929,6 +60931,7 @@ function computeProfitDetail(payload) {
60929
60931
  const ratio = pnl / loss;
60930
60932
  quantity = to_f2(reduce_position.quantity * ratio, decimal_places);
60931
60933
  expected_loss = to_f2(Math.abs(reduce_position.entry - sell_price) * quantity, "%.2f");
60934
+ full_loss = Math.abs(reduce_position.avg_price - sell_price) * reduce_position.avg_qty * full_ratio;
60932
60935
  }
60933
60936
  if (reverse_position) {
60934
60937
  expected_loss = Math.abs(reverse_position.avg_price - sell_price) * reverse_position.avg_qty;
@@ -60937,6 +60940,7 @@ function computeProfitDetail(payload) {
60937
60940
  return {
60938
60941
  pnl: new_pnl,
60939
60942
  loss: to_f2(expected_loss, "%.2f"),
60943
+ full_loss: to_f2(full_loss, "%.2f"),
60940
60944
  original_pnl: pnl,
60941
60945
  reward_factor,
60942
60946
  profit_percent,
@@ -61163,8 +61167,10 @@ function determineCompoundLongTrade(payload) {
61163
61167
  const short_max_size = short_app_config.last_value.avg_size;
61164
61168
  const start_risk = Math.abs(short_app_config.last_value.neg_pnl) * rr;
61165
61169
  const short_profit = short_app_config.last_value.avg_size * short_app_config.last_value.avg_entry * shortConfig.profit_percent / 100;
61166
- const support = Math.abs(short_app_config.last_value.avg_entry - short_profit) * rr;
61170
+ const diff = short_profit * rr / short_app_config.last_value.avg_size;
61171
+ const support = Math.abs(short_app_config.last_value.avg_entry - diff);
61167
61172
  const resistance = focus_short_position.next_order || focus_long_position.take_profit;
61173
+ console.log({ support, resistance, short_profit });
61168
61174
  const result = getRiskReward({
61169
61175
  entry: resistance,
61170
61176
  stop: support,
@@ -66818,7 +66824,7 @@ class ExchangeAccount {
66818
66824
  });
66819
66825
  }
66820
66826
  async getSellPriceFromStrategy(payload) {
66821
- const { symbol, reduce_position, kind } = payload;
66827
+ const { symbol, reduce_position, kind, full_ratio = 1 } = payload;
66822
66828
  const symbol_config = await this.recomputeSymbolConfig({
66823
66829
  symbol
66824
66830
  });
@@ -66868,7 +66874,8 @@ class ExchangeAccount {
66868
66874
  stop_loss: reverse_position.stop_loss
66869
66875
  },
66870
66876
  price_places: symbol_config.price_places,
66871
- decimal_places: symbol_config.decimal_places
66877
+ decimal_places: symbol_config.decimal_places,
66878
+ full_ratio
66872
66879
  });
66873
66880
  }
66874
66881
  async placeCompoundShortTrade(payload) {
@@ -67287,6 +67294,7 @@ class App {
67287
67294
  kind,
67288
67295
  place,
67289
67296
  increase,
67297
+ full_ratio = 1,
67290
67298
  cancel_limit = true
67291
67299
  } = payload;
67292
67300
  const main_exchange_account = await this.getExchangeAccount(main_account);
@@ -67300,7 +67308,8 @@ class App {
67300
67308
  const result = await main_exchange_account.getSellPriceFromStrategy({
67301
67309
  symbol: main_account.symbol,
67302
67310
  reduce_position,
67303
- kind: main_account.kind || reverse_kind
67311
+ kind: main_account.kind || reverse_kind,
67312
+ full_ratio
67304
67313
  });
67305
67314
  if (place) {
67306
67315
  if (cancel_limit) {
@@ -60891,13 +60891,15 @@ function computeProfitDetail(payload) {
60891
60891
  price_places = "%.1f",
60892
60892
  reduce_position,
60893
60893
  decimal_places,
60894
- reverse_position
60894
+ reverse_position,
60895
+ full_ratio = 1
60895
60896
  } = payload;
60896
60897
  let reward_factor = strategy.reward_factor;
60897
60898
  const profit_percent = to_f2(pnl * 100 / (focus_position.avg_price * focus_position.avg_qty), "%.4f");
60898
60899
  const diff = pnl / focus_position.quantity;
60899
60900
  const sell_price = to_f2(focus_position.kind === "long" ? focus_position.entry + diff : focus_position.entry - diff, price_places);
60900
60901
  let loss = 0;
60902
+ let full_loss = 0;
60901
60903
  let expected_loss = 0;
60902
60904
  let quantity = 0;
60903
60905
  let new_pnl = pnl;
@@ -60906,6 +60908,7 @@ function computeProfitDetail(payload) {
60906
60908
  const ratio = pnl / loss;
60907
60909
  quantity = to_f2(reduce_position.quantity * ratio, decimal_places);
60908
60910
  expected_loss = to_f2(Math.abs(reduce_position.entry - sell_price) * quantity, "%.2f");
60911
+ full_loss = Math.abs(reduce_position.avg_price - sell_price) * reduce_position.avg_qty * full_ratio;
60909
60912
  }
60910
60913
  if (reverse_position) {
60911
60914
  expected_loss = Math.abs(reverse_position.avg_price - sell_price) * reverse_position.avg_qty;
@@ -60914,6 +60917,7 @@ function computeProfitDetail(payload) {
60914
60917
  return {
60915
60918
  pnl: new_pnl,
60916
60919
  loss: to_f2(expected_loss, "%.2f"),
60920
+ full_loss: to_f2(full_loss, "%.2f"),
60917
60921
  original_pnl: pnl,
60918
60922
  reward_factor,
60919
60923
  profit_percent,
@@ -61140,8 +61144,10 @@ function determineCompoundLongTrade(payload) {
61140
61144
  const short_max_size = short_app_config.last_value.avg_size;
61141
61145
  const start_risk = Math.abs(short_app_config.last_value.neg_pnl) * rr;
61142
61146
  const short_profit = short_app_config.last_value.avg_size * short_app_config.last_value.avg_entry * shortConfig.profit_percent / 100;
61143
- const support = Math.abs(short_app_config.last_value.avg_entry - short_profit) * rr;
61147
+ const diff = short_profit * rr / short_app_config.last_value.avg_size;
61148
+ const support = Math.abs(short_app_config.last_value.avg_entry - diff);
61144
61149
  const resistance = focus_short_position.next_order || focus_long_position.take_profit;
61150
+ console.log({ support, resistance, short_profit });
61145
61151
  const result = getRiskReward({
61146
61152
  entry: resistance,
61147
61153
  stop: support,
@@ -66795,7 +66801,7 @@ class ExchangeAccount {
66795
66801
  });
66796
66802
  }
66797
66803
  async getSellPriceFromStrategy(payload) {
66798
- const { symbol, reduce_position, kind } = payload;
66804
+ const { symbol, reduce_position, kind, full_ratio = 1 } = payload;
66799
66805
  const symbol_config = await this.recomputeSymbolConfig({
66800
66806
  symbol
66801
66807
  });
@@ -66845,7 +66851,8 @@ class ExchangeAccount {
66845
66851
  stop_loss: reverse_position.stop_loss
66846
66852
  },
66847
66853
  price_places: symbol_config.price_places,
66848
- decimal_places: symbol_config.decimal_places
66854
+ decimal_places: symbol_config.decimal_places,
66855
+ full_ratio
66849
66856
  });
66850
66857
  }
66851
66858
  async placeCompoundShortTrade(payload) {
@@ -67264,6 +67271,7 @@ class App {
67264
67271
  kind,
67265
67272
  place,
67266
67273
  increase,
67274
+ full_ratio = 1,
67267
67275
  cancel_limit = true
67268
67276
  } = payload;
67269
67277
  const main_exchange_account = await this.getExchangeAccount(main_account);
@@ -67277,7 +67285,8 @@ class App {
67277
67285
  const result = await main_exchange_account.getSellPriceFromStrategy({
67278
67286
  symbol: main_account.symbol,
67279
67287
  reduce_position,
67280
- kind: main_account.kind || reverse_kind
67288
+ kind: main_account.kind || reverse_kind,
67289
+ full_ratio
67281
67290
  });
67282
67291
  if (place) {
67283
67292
  if (cancel_limit) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-131",
4
+ "version": "0.0.2-134",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",