@gbozee/ultimate 0.0.2-167 → 0.0.2-169

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.
@@ -813,6 +813,29 @@ export declare function constructAppConfig(payload: {
813
813
  kelly_prediction_model: string;
814
814
  };
815
815
  }): AppConfig;
816
+ export declare function generateDangerousConfig(payload: {
817
+ account: PositionsView;
818
+ global_config: GlobalConfig;
819
+ config: {
820
+ quantity: number;
821
+ stop: number;
822
+ entry: number;
823
+ };
824
+ }): {
825
+ entry: number;
826
+ risk: number;
827
+ stop: number;
828
+ risk_reward: number | {
829
+ result: any[];
830
+ value: number;
831
+ total: number;
832
+ risk_per_trade: number;
833
+ max: number;
834
+ min: number;
835
+ neg_pnl: any;
836
+ entry: any;
837
+ };
838
+ };
816
839
  export type StrategyPosition = {
817
840
  entry: number;
818
841
  quantity: number;
@@ -351,8 +351,7 @@ class Signal {
351
351
  support: kind === "long" ? _stop_loss : this.support
352
352
  };
353
353
  const instance = new Signal(derivedConfig);
354
- if (kind === "short") {
355
- }
354
+ if (kind === "short") {}
356
355
  let result = instance.get_bulk_trade_zones({ current_price, kind });
357
356
  return result;
358
357
  return result?.filter((x) => {
@@ -570,8 +569,7 @@ class Signal {
570
569
  kind = "long",
571
570
  raw
572
571
  }) {
573
- if (raw) {
574
- }
572
+ if (raw) {}
575
573
  const margin_range = this.get_margin_range(current_price, kind);
576
574
  let margin_zones = this.get_margin_zones({ current_price });
577
575
  let remaining_zones = margin_zones.filter((x) => JSON.stringify(x) != JSON.stringify(margin_range));
@@ -798,8 +796,7 @@ class Signal {
798
796
  return true;
799
797
  });
800
798
  let total_orders = limit_trades.concat(market_trades);
801
- if (kind === "short") {
802
- }
799
+ if (kind === "short") {}
803
800
  if (this.minimum_size && total_orders.length > 0) {
804
801
  let payload = total_orders;
805
802
  let greater_than_min_size = total_orders.filter((o) => o ? o.quantity >= this.minimum_size : true);
@@ -885,8 +882,7 @@ class Signal {
885
882
  });
886
883
  const multiplier = start - index;
887
884
  const incurred_fees = fees.reduce((a, b) => a + b, 0) + previous_risks.reduce((a, b) => a + b, 0);
888
- if (index === 0) {
889
- }
885
+ if (index === 0) {}
890
886
  let quantity = determine_position_size({
891
887
  entry,
892
888
  stop,
@@ -1052,8 +1048,7 @@ function extractValue(_param, condition) {
1052
1048
  try {
1053
1049
  let value2 = JSON.parse(_param || "[]");
1054
1050
  param = value2.map((o) => parseFloat(o));
1055
- } catch (error) {
1056
- }
1051
+ } catch (error) {}
1057
1052
  } else {
1058
1053
  param = parseFloat(_param);
1059
1054
  }
@@ -1068,8 +1063,7 @@ function asCoins(symbol) {
1068
1063
  if (symbol.toLowerCase().includes("-")) {
1069
1064
  result = result.split("-")[0];
1070
1065
  }
1071
- if (symbol.toLowerCase() == "usdt-usd") {
1072
- }
1066
+ if (symbol.toLowerCase() == "usdt-usd") {}
1073
1067
  let result2 = _type == "usdt" ? symbol.split(result)[0] : result;
1074
1068
  if (result.includes("-")) {
1075
1069
  result2 = result;
@@ -1485,8 +1479,7 @@ function buildConfig(app_config, {
1485
1479
  return [];
1486
1480
  }
1487
1481
  const condition = (kind === "long" ? entry > app_config.support : entry >= app_config.support) && stop >= app_config.support * 0.999;
1488
- if (kind === "short") {
1489
- }
1482
+ if (kind === "short") {}
1490
1483
  console.log({ entry, stop, condition, working_risk, config });
1491
1484
  const result = entry === stop ? [] : condition ? instance.build_entry({
1492
1485
  current_price: entry,
@@ -2523,6 +2516,31 @@ function constructAppConfig(payload) {
2523
2516
  const appConfig = buildAppConfig(global_config, options);
2524
2517
  return appConfig;
2525
2518
  }
2519
+ function generateDangerousConfig(payload) {
2520
+ const { account, global_config, config } = payload;
2521
+ const app_config = constructAppConfig({
2522
+ account,
2523
+ global_config,
2524
+ kelly_config: {}
2525
+ });
2526
+ const { optimal_risk, optimal_stop } = getOptimumStopAndRisk(app_config, {
2527
+ max_size: config.quantity,
2528
+ target_stop: config.stop
2529
+ });
2530
+ const optimumRiskReward = computeRiskReward({
2531
+ app_config,
2532
+ entry: config.entry,
2533
+ stop: optimal_stop,
2534
+ risk_per_trade: optimal_risk,
2535
+ target_loss: optimal_risk
2536
+ });
2537
+ return {
2538
+ entry: config.entry,
2539
+ risk: optimal_risk,
2540
+ stop: optimal_stop,
2541
+ risk_reward: optimumRiskReward
2542
+ };
2543
+ }
2526
2544
  // src/helpers/strategy.ts
2527
2545
  class Strategy {
2528
2546
  position;
@@ -3043,6 +3061,7 @@ export {
3043
3061
  generateOptimumAppConfig,
3044
3062
  generateOppositeTradeConfig,
3045
3063
  generateGapTp,
3064
+ generateDangerousConfig,
3046
3065
  formatPrice,
3047
3066
  fibonacci_analysis,
3048
3067
  extractValue,