@gbozee/ultimate 0.0.2-107 → 0.0.2-108

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.
@@ -82,7 +82,7 @@ export type RawPosition = {
82
82
  entry: number;
83
83
  quantity: number;
84
84
  price_places: string;
85
- decimal_places: string;
85
+ decimal_places?: string;
86
86
  };
87
87
  export type ConfigOptionType = {
88
88
  reduce_ratio: number | string;
@@ -451,6 +451,7 @@ export declare function computeProfitDetail(payload: {
451
451
  max_reward_factor: number;
452
452
  risk: number;
453
453
  };
454
+ pnl: number;
454
455
  reduce_position?: {
455
456
  kind: "long" | "short";
456
457
  entry: number;
@@ -152,8 +152,7 @@ class Signal {
152
152
  support: kind === "long" ? _stop_loss : this.support
153
153
  };
154
154
  const instance = new Signal(derivedConfig);
155
- if (kind === "short") {
156
- }
155
+ if (kind === "short") {}
157
156
  let result = instance.get_bulk_trade_zones({ current_price, kind });
158
157
  return result;
159
158
  return result?.filter((x) => {
@@ -371,8 +370,7 @@ class Signal {
371
370
  kind = "long",
372
371
  raw
373
372
  }) {
374
- if (raw) {
375
- }
373
+ if (raw) {}
376
374
  const margin_range = this.get_margin_range(current_price, kind);
377
375
  let margin_zones = this.get_margin_zones({ current_price });
378
376
  let remaining_zones = margin_zones.filter((x) => JSON.stringify(x) != JSON.stringify(margin_range));
@@ -583,8 +581,7 @@ class Signal {
583
581
  return true;
584
582
  });
585
583
  let total_orders = limit_trades.concat(market_trades);
586
- if (kind === "short") {
587
- }
584
+ if (kind === "short") {}
588
585
  if (this.minimum_size && total_orders.length > 0) {
589
586
  let payload = total_orders;
590
587
  let greater_than_min_size = total_orders.filter((o) => o ? o.quantity >= this.minimum_size : true);
@@ -670,8 +667,7 @@ class Signal {
670
667
  });
671
668
  const multiplier = start - index;
672
669
  const incurred_fees = fees.reduce((a, b) => a + b, 0) + previous_risks.reduce((a, b) => a + b, 0);
673
- if (index === 0) {
674
- }
670
+ if (index === 0) {}
675
671
  let quantity = determine_position_size({
676
672
  entry,
677
673
  stop,
@@ -837,8 +833,7 @@ function extractValue(_param, condition) {
837
833
  try {
838
834
  let value2 = JSON.parse(_param || "[]");
839
835
  param = value2.map((o) => parseFloat(o));
840
- } catch (error) {
841
- }
836
+ } catch (error) {}
842
837
  } else {
843
838
  param = parseFloat(_param);
844
839
  }
@@ -853,8 +848,7 @@ function asCoins(symbol) {
853
848
  if (symbol.toLowerCase().includes("-")) {
854
849
  result = result.split("-")[0];
855
850
  }
856
- if (symbol.toLowerCase() == "usdt-usd") {
857
- }
851
+ if (symbol.toLowerCase() == "usdt-usd") {}
858
852
  let result2 = _type == "usdt" ? symbol.split(result)[0] : result;
859
853
  if (result.includes("-")) {
860
854
  result2 = result;
@@ -1243,8 +1237,7 @@ function buildConfig(app_config, {
1243
1237
  return [];
1244
1238
  }
1245
1239
  const condition = (kind === "long" ? entry > app_config.support : entry >= app_config.support) && stop >= app_config.support * 0.999;
1246
- if (kind === "short") {
1247
- }
1240
+ if (kind === "short") {}
1248
1241
  const result = entry === stop ? [] : condition ? instance.build_entry({
1249
1242
  current_price: entry,
1250
1243
  stop_loss: stop,
@@ -1807,24 +1800,14 @@ function computeProfitDetail(payload) {
1807
1800
  const {
1808
1801
  focus_position,
1809
1802
  strategy,
1803
+ pnl,
1810
1804
  price_places = "%.1f",
1811
1805
  reduce_position,
1812
1806
  decimal_places,
1813
1807
  reverse_position
1814
1808
  } = payload;
1815
1809
  let reward_factor = strategy.reward_factor;
1816
- let risk = strategy.risk;
1817
- if (strategy.max_reward_factor === 0) {
1818
- reward_factor = strategy.reward_factor;
1819
- }
1820
- if (focus_position.avg_qty >= focus_position.quantity && strategy.max_reward_factor) {
1821
- reward_factor = to_f(focus_position.quantity * strategy.max_reward_factor / focus_position.avg_qty, "%.4f");
1822
- } else {
1823
- reward_factor = strategy.reward_factor;
1824
- }
1825
- const full_pnl = reward_factor * risk;
1826
- const profit_percent = to_f(full_pnl * 100 / (focus_position.avg_price * focus_position.avg_qty), "%.4f");
1827
- const pnl = to_f(focus_position.entry * focus_position.quantity * profit_percent / 100, "%.2f");
1810
+ const profit_percent = to_f(pnl * 100 / (focus_position.avg_price * focus_position.avg_qty), "%.4f");
1828
1811
  const diff = pnl / focus_position.quantity;
1829
1812
  const sell_price = to_f(focus_position.kind === "long" ? focus_position.entry + diff : focus_position.entry - diff, price_places);
1830
1813
  let loss = 0;
@@ -2381,6 +2364,7 @@ class Strategy {
2381
2364
  avg_price: focus_position.avg_price,
2382
2365
  avg_qty: focus_position.avg_qty
2383
2366
  },
2367
+ pnl: this.pnl(kind),
2384
2368
  strategy: {
2385
2369
  reward_factor,
2386
2370
  max_reward_factor,