@gbozee/ultimate 0.0.2-53 → 0.0.2-55

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.
@@ -371,6 +371,7 @@ export type Config = {
371
371
  short_tp_factor: number;
372
372
  fee_percent?: number;
373
373
  budget: number;
374
+ risk_reward: number;
374
375
  global_config: GlobalConfig;
375
376
  };
376
377
  export declare class Strategy {
@@ -398,10 +399,10 @@ export declare class Strategy {
398
399
  get short_tp(): number;
399
400
  generateGapClosingAlgorithm(payload: {
400
401
  kind: "long" | "short";
401
- risk_reward?: number;
402
402
  }): {
403
403
  [x: string]: any;
404
404
  risk: number;
405
+ risk_reward: number;
405
406
  last_entry: any;
406
407
  first_entry: any;
407
408
  threshold: any;
@@ -413,6 +414,7 @@ export declare class Strategy {
413
414
  }): {
414
415
  [x: string]: any;
415
416
  risk: number;
417
+ risk_reward: number;
416
418
  last_entry: any;
417
419
  first_entry: any;
418
420
  threshold: any;
@@ -1693,15 +1693,20 @@ class Strategy {
1693
1693
  return this.tp("short");
1694
1694
  }
1695
1695
  generateGapClosingAlgorithm(payload) {
1696
- const { kind, risk_reward = 199 } = payload;
1696
+ const { kind } = payload;
1697
1697
  const { entry, quantity } = this.position[kind];
1698
1698
  const focus_position = this.position[kind];
1699
1699
  const reverse_kind = kind == "long" ? "short" : "long";
1700
1700
  const reverse_position = this.position[reverse_kind];
1701
+ let _entry = this.tp(kind);
1702
+ let _stop = this.tp(reverse_kind);
1703
+ if (!_entry && !_stop) {
1704
+ return null;
1705
+ }
1701
1706
  const second_payload = {
1702
- entry: this.tp(kind),
1703
- stop: this.tp(reverse_kind),
1704
- risk_reward,
1707
+ entry: _entry,
1708
+ stop: _stop,
1709
+ risk_reward: this.config.risk_reward,
1705
1710
  start_risk: this.pnl(reverse_kind),
1706
1711
  max_risk: this.config.budget
1707
1712
  };
@@ -1778,6 +1783,7 @@ class Strategy {
1778
1783
  const remaining_quantity = this.to_df(avg.quantity - quantity_to_sell);
1779
1784
  return {
1780
1785
  risk,
1786
+ risk_reward: this.config.risk_reward,
1781
1787
  [kind]: {
1782
1788
  avg_entry: avg.entry,
1783
1789
  avg_size: avg.quantity,
@@ -1802,7 +1808,7 @@ class Strategy {
1802
1808
  };
1803
1809
  }
1804
1810
  runIterations(payload) {
1805
- const { kind, iterations, risk_reward = 199 } = payload;
1811
+ const { kind, iterations } = payload;
1806
1812
  const reverse_kind = kind == "long" ? "short" : "long";
1807
1813
  const result = [];
1808
1814
  let position2 = {
@@ -1819,8 +1825,7 @@ class Strategy {
1819
1825
  }
1820
1826
  });
1821
1827
  const algorithm = instance.generateGapClosingAlgorithm({
1822
- kind,
1823
- risk_reward
1828
+ kind
1824
1829
  });
1825
1830
  if (!algorithm) {
1826
1831
  console.log("No algorithm found");