@gbozee/ultimate 0.0.2-102 → 0.0.2-103

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.
@@ -484,6 +484,12 @@ export declare function generateGapTp(payload: {
484
484
  gap: number;
485
485
  gap_loss: number;
486
486
  };
487
+ export declare function determineRewardFactor(payload: {
488
+ quantity: number;
489
+ avg_qty: number;
490
+ minimum_pnl: number;
491
+ risk: number;
492
+ }): number;
487
493
  export type StrategyPosition = {
488
494
  entry: number;
489
495
  quantity: number;
@@ -152,7 +152,8 @@ class Signal {
152
152
  support: kind === "long" ? _stop_loss : this.support
153
153
  };
154
154
  const instance = new Signal(derivedConfig);
155
- if (kind === "short") {}
155
+ if (kind === "short") {
156
+ }
156
157
  let result = instance.get_bulk_trade_zones({ current_price, kind });
157
158
  return result;
158
159
  return result?.filter((x) => {
@@ -370,7 +371,8 @@ class Signal {
370
371
  kind = "long",
371
372
  raw
372
373
  }) {
373
- if (raw) {}
374
+ if (raw) {
375
+ }
374
376
  const margin_range = this.get_margin_range(current_price, kind);
375
377
  let margin_zones = this.get_margin_zones({ current_price });
376
378
  let remaining_zones = margin_zones.filter((x) => JSON.stringify(x) != JSON.stringify(margin_range));
@@ -581,7 +583,8 @@ class Signal {
581
583
  return true;
582
584
  });
583
585
  let total_orders = limit_trades.concat(market_trades);
584
- if (kind === "short") {}
586
+ if (kind === "short") {
587
+ }
585
588
  if (this.minimum_size && total_orders.length > 0) {
586
589
  let payload = total_orders;
587
590
  let greater_than_min_size = total_orders.filter((o) => o ? o.quantity >= this.minimum_size : true);
@@ -667,7 +670,8 @@ class Signal {
667
670
  });
668
671
  const multiplier = start - index;
669
672
  const incurred_fees = fees.reduce((a, b) => a + b, 0) + previous_risks.reduce((a, b) => a + b, 0);
670
- if (index === 0) {}
673
+ if (index === 0) {
674
+ }
671
675
  let quantity = determine_position_size({
672
676
  entry,
673
677
  stop,
@@ -833,7 +837,8 @@ function extractValue(_param, condition) {
833
837
  try {
834
838
  let value2 = JSON.parse(_param || "[]");
835
839
  param = value2.map((o) => parseFloat(o));
836
- } catch (error) {}
840
+ } catch (error) {
841
+ }
837
842
  } else {
838
843
  param = parseFloat(_param);
839
844
  }
@@ -848,7 +853,8 @@ function asCoins(symbol) {
848
853
  if (symbol.toLowerCase().includes("-")) {
849
854
  result = result.split("-")[0];
850
855
  }
851
- if (symbol.toLowerCase() == "usdt-usd") {}
856
+ if (symbol.toLowerCase() == "usdt-usd") {
857
+ }
852
858
  let result2 = _type == "usdt" ? symbol.split(result)[0] : result;
853
859
  if (result.includes("-")) {
854
860
  result2 = result;
@@ -1196,7 +1202,8 @@ function buildConfig(app_config, {
1196
1202
  return [];
1197
1203
  }
1198
1204
  const condition = (kind === "long" ? entry > app_config.support : entry >= app_config.support) && stop >= app_config.support * 0.999;
1199
- if (kind === "short") {}
1205
+ if (kind === "short") {
1206
+ }
1200
1207
  const result = entry === stop ? [] : condition ? instance.build_entry({
1201
1208
  current_price: entry,
1202
1209
  stop_loss: stop,
@@ -1901,6 +1908,12 @@ function calculate_factor(payload) {
1901
1908
  calculated_factor = to_f(calculated_factor, places);
1902
1909
  return calculated_factor;
1903
1910
  }
1911
+ function determineRewardFactor(payload) {
1912
+ const { quantity, avg_qty, minimum_pnl, risk } = payload;
1913
+ const reward_factor = minimum_pnl / risk;
1914
+ const quantity_ratio = quantity / avg_qty;
1915
+ return to_f(reward_factor / quantity_ratio, "%.4f");
1916
+ }
1904
1917
  // src/helpers/strategy.ts
1905
1918
  class Strategy {
1906
1919
  position;
@@ -2374,8 +2387,11 @@ class Strategy {
2374
2387
  }
2375
2388
  }
2376
2389
  };
2377
- results.push(to_add);
2378
2390
  const sell_kind = direction == "long" ? "short" : "long";
2391
+ if (sell_quantity[sell_kind] <= 0) {
2392
+ break;
2393
+ }
2394
+ results.push(to_add);
2379
2395
  const remaining = this.to_df(params[sell_kind].quantity - sell_quantity[sell_kind]);
2380
2396
  if (remaining <= 0) {
2381
2397
  break;
@@ -2424,6 +2440,7 @@ export {
2424
2440
  determine_average_entry_and_size,
2425
2441
  determine_amount_to_sell2 as determine_amount_to_sell,
2426
2442
  determine_amount_to_buy,
2443
+ determineRewardFactor,
2427
2444
  determineOptimumReward,
2428
2445
  createGapPairs,
2429
2446
  createArray,