@gbozee/ultimate 0.0.2-145 → 0.0.2-147

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.
@@ -304,7 +304,12 @@ export type AppConfig = {
304
304
  last_value?: any;
305
305
  entries?: any[];
306
306
  max_quantity?: number;
307
- use_kelly?: boolean;
307
+ kelly?: {
308
+ use_kelly?: boolean;
309
+ kelly_confidence_factor?: number;
310
+ kelly_minimum_risk?: number;
311
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
312
+ };
308
313
  };
309
314
  export type ExtendConfigType = {
310
315
  take_profit?: number;
@@ -321,8 +326,12 @@ export type ExtendConfigType = {
321
326
  kind?: "long" | "short";
322
327
  gap?: number;
323
328
  rr?: number;
329
+ use_kelly?: boolean;
330
+ kelly_confidence_factor?: number;
331
+ kelly_minimum_risk?: number;
332
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
324
333
  };
325
- export declare function buildConfig(app_config: AppConfig, { take_profit, entry, stop, raw_instance, risk, no_of_trades, min_profit, risk_reward, kind, increase, gap, rr, price_places, decimal_places, }: ExtendConfigType): any[] | Signal;
334
+ export declare function buildConfig(app_config: AppConfig, { take_profit, entry, stop, raw_instance, risk, no_of_trades, min_profit, risk_reward, kind, increase, gap, rr, price_places, decimal_places, use_kelly, kelly_confidence_factor, kelly_minimum_risk, kelly_prediction_model, }: ExtendConfigType): any[] | Signal;
326
335
  export declare function buildAvg({ _trades, kind, }: {
327
336
  _trades: any[];
328
337
  kind: "long" | "short";
@@ -332,6 +341,10 @@ export declare function get_app_config_and_max_size(config: GlobalConfig, payloa
332
341
  entry: number;
333
342
  stop: number;
334
343
  kind: "long" | "short";
344
+ use_kelly?: boolean;
345
+ kelly_confidence_factor?: number;
346
+ kelly_minimum_risk?: number;
347
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
335
348
  }): {
336
349
  app_config: AppConfig;
337
350
  max_size: any;
@@ -351,6 +364,10 @@ export declare function buildAppConfig(config: GlobalConfig, payload: {
351
364
  risk: number;
352
365
  symbol: string;
353
366
  profit?: number;
367
+ use_kelly?: boolean;
368
+ kelly_confidence_factor?: number;
369
+ kelly_minimum_risk?: number;
370
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
354
371
  }): AppConfig;
355
372
  export declare function getOptimumStopAndRisk(app_config: AppConfig, params: {
356
373
  max_size: number;
@@ -823,7 +840,12 @@ export declare class Strategy {
823
840
  rr?: number;
824
841
  max_size?: number;
825
842
  max_quantity?: number;
826
- use_kelly?: boolean;
843
+ kelly?: {
844
+ use_kelly?: boolean;
845
+ kelly_confidence_factor?: number;
846
+ kelly_minimum_risk?: number;
847
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
848
+ };
827
849
  };
828
850
  identifyGapConfig(payload: {
829
851
  factor?: number;
@@ -10,12 +10,12 @@ function calculateTheoreticalKelly({
10
10
  confidence_factor = 0.6,
11
11
  volatility_adjustment = true
12
12
  } = config;
13
- const sorted_prices = kind === "long" ? zone_prices : zone_prices.reverse();
13
+ const sorted_prices = zone_prices;
14
14
  const current_index = sorted_prices.findIndex((price) => price === current_entry);
15
15
  if (current_index === -1)
16
16
  return 0.02;
17
- const win_zones = kind === "long" ? sorted_prices.slice(current_index + 1) : sorted_prices.slice(0, current_index);
18
- const lose_zones = kind === "long" ? sorted_prices.slice(0, current_index) : sorted_prices.slice(current_index + 1);
17
+ const win_zones = kind === "long" ? sorted_prices.filter((price) => price > current_entry) : sorted_prices.filter((price) => price < current_entry);
18
+ const lose_zones = kind === "long" ? sorted_prices.filter((price) => price < current_entry) : sorted_prices.filter((price) => price > current_entry);
19
19
  const { win_probability, avg_win_ratio, avg_loss_ratio } = calculateZoneProbabilities({
20
20
  current_entry,
21
21
  win_zones,
@@ -1338,7 +1338,11 @@ function buildConfig(app_config, {
1338
1338
  gap,
1339
1339
  rr = 1,
1340
1340
  price_places = "%.1f",
1341
- decimal_places = "%.3f"
1341
+ decimal_places = "%.3f",
1342
+ use_kelly = false,
1343
+ kelly_confidence_factor = 0.95,
1344
+ kelly_minimum_risk = 0.2,
1345
+ kelly_prediction_model = "exponential"
1342
1346
  }) {
1343
1347
  let fee = app_config.fee / 100;
1344
1348
  let working_risk = risk || app_config.risk_per_trade;
@@ -1363,7 +1367,10 @@ function buildConfig(app_config, {
1363
1367
  gap,
1364
1368
  min_profit: min_profit || app_config.min_profit,
1365
1369
  rr: rr || 1,
1366
- use_kelly: app_config.use_kelly
1370
+ use_kelly: use_kelly || app_config.kelly?.use_kelly,
1371
+ kelly_confidence_factor: kelly_confidence_factor || app_config.kelly?.kelly_confidence_factor,
1372
+ kelly_minimum_risk: kelly_minimum_risk || app_config.kelly?.kelly_minimum_risk,
1373
+ kelly_prediction_model: kelly_prediction_model || app_config.kelly?.kelly_prediction_model
1367
1374
  };
1368
1375
  const instance = new Signal(config);
1369
1376
  if (raw_instance) {
@@ -1442,7 +1449,11 @@ function get_app_config_and_max_size(config, payload) {
1442
1449
  increase: true,
1443
1450
  gap: app_config.gap,
1444
1451
  price_places: app_config.price_places,
1445
- decimal_places: app_config.decimal_places
1452
+ decimal_places: app_config.decimal_places,
1453
+ use_kelly: payload.use_kelly,
1454
+ kelly_confidence_factor: payload.kelly_confidence_factor,
1455
+ kelly_minimum_risk: payload.kelly_minimum_risk,
1456
+ kelly_prediction_model: payload.kelly_prediction_model
1446
1457
  });
1447
1458
  const max_size = initialResult[0]?.avg_size;
1448
1459
  const last_value = initialResult[0];
@@ -1475,13 +1486,23 @@ function buildAppConfig(config, payload) {
1475
1486
  }, {
1476
1487
  entry: payload.entry,
1477
1488
  stop: payload.stop,
1478
- kind: payload.entry > payload.stop ? "long" : "short"
1489
+ kind: payload.entry > payload.stop ? "long" : "short",
1490
+ use_kelly: payload.use_kelly,
1491
+ kelly_confidence_factor: payload.kelly_confidence_factor,
1492
+ kelly_minimum_risk: payload.kelly_minimum_risk,
1493
+ kelly_prediction_model: payload.kelly_prediction_model
1479
1494
  });
1480
1495
  app_config.max_size = max_size;
1481
1496
  app_config.entry = payload.entry || app_config.entry;
1482
1497
  app_config.stop = payload.stop || app_config.stop;
1483
1498
  app_config.last_value = last_value;
1484
1499
  app_config.entries = entries;
1500
+ app_config.kelly = {
1501
+ use_kelly: payload.use_kelly,
1502
+ kelly_confidence_factor: payload.kelly_confidence_factor,
1503
+ kelly_minimum_risk: payload.kelly_minimum_risk,
1504
+ kelly_prediction_model: payload.kelly_prediction_model
1505
+ };
1485
1506
  return app_config;
1486
1507
  }
1487
1508
  function getOptimumStopAndRisk(app_config, params) {
package/dist/index.cjs CHANGED
@@ -52882,12 +52882,12 @@ function calculateTheoreticalKelly({
52882
52882
  confidence_factor = 0.6,
52883
52883
  volatility_adjustment = true
52884
52884
  } = config2;
52885
- const sorted_prices = kind === "long" ? zone_prices : zone_prices.reverse();
52885
+ const sorted_prices = zone_prices;
52886
52886
  const current_index = sorted_prices.findIndex((price) => price === current_entry);
52887
52887
  if (current_index === -1)
52888
52888
  return 0.02;
52889
- const win_zones = kind === "long" ? sorted_prices.slice(current_index + 1) : sorted_prices.slice(0, current_index);
52890
- const lose_zones = kind === "long" ? sorted_prices.slice(0, current_index) : sorted_prices.slice(current_index + 1);
52889
+ const win_zones = kind === "long" ? sorted_prices.filter((price) => price > current_entry) : sorted_prices.filter((price) => price < current_entry);
52890
+ const lose_zones = kind === "long" ? sorted_prices.filter((price) => price < current_entry) : sorted_prices.filter((price) => price > current_entry);
52891
52891
  const { win_probability, avg_win_ratio, avg_loss_ratio } = calculateZoneProbabilities({
52892
52892
  current_entry,
52893
52893
  win_zones,
@@ -53736,7 +53736,11 @@ function buildConfig(app_config, {
53736
53736
  gap,
53737
53737
  rr = 1,
53738
53738
  price_places = "%.1f",
53739
- decimal_places = "%.3f"
53739
+ decimal_places = "%.3f",
53740
+ use_kelly = false,
53741
+ kelly_confidence_factor = 0.95,
53742
+ kelly_minimum_risk = 0.2,
53743
+ kelly_prediction_model = "exponential"
53740
53744
  }) {
53741
53745
  let fee = app_config.fee / 100;
53742
53746
  let working_risk = risk || app_config.risk_per_trade;
@@ -53761,7 +53765,10 @@ function buildConfig(app_config, {
53761
53765
  gap,
53762
53766
  min_profit: min_profit || app_config.min_profit,
53763
53767
  rr: rr || 1,
53764
- use_kelly: app_config.use_kelly
53768
+ use_kelly: use_kelly || app_config.kelly?.use_kelly,
53769
+ kelly_confidence_factor: kelly_confidence_factor || app_config.kelly?.kelly_confidence_factor,
53770
+ kelly_minimum_risk: kelly_minimum_risk || app_config.kelly?.kelly_minimum_risk,
53771
+ kelly_prediction_model: kelly_prediction_model || app_config.kelly?.kelly_prediction_model
53765
53772
  };
53766
53773
  const instance = new Signal(config2);
53767
53774
  if (raw_instance) {
@@ -53840,7 +53847,11 @@ function get_app_config_and_max_size(config2, payload) {
53840
53847
  increase: true,
53841
53848
  gap: app_config.gap,
53842
53849
  price_places: app_config.price_places,
53843
- decimal_places: app_config.decimal_places
53850
+ decimal_places: app_config.decimal_places,
53851
+ use_kelly: payload.use_kelly,
53852
+ kelly_confidence_factor: payload.kelly_confidence_factor,
53853
+ kelly_minimum_risk: payload.kelly_minimum_risk,
53854
+ kelly_prediction_model: payload.kelly_prediction_model
53844
53855
  });
53845
53856
  const max_size = initialResult[0]?.avg_size;
53846
53857
  const last_value = initialResult[0];
@@ -53873,13 +53884,23 @@ function buildAppConfig(config2, payload) {
53873
53884
  }, {
53874
53885
  entry: payload.entry,
53875
53886
  stop: payload.stop,
53876
- kind: payload.entry > payload.stop ? "long" : "short"
53887
+ kind: payload.entry > payload.stop ? "long" : "short",
53888
+ use_kelly: payload.use_kelly,
53889
+ kelly_confidence_factor: payload.kelly_confidence_factor,
53890
+ kelly_minimum_risk: payload.kelly_minimum_risk,
53891
+ kelly_prediction_model: payload.kelly_prediction_model
53877
53892
  });
53878
53893
  app_config.max_size = max_size;
53879
53894
  app_config.entry = payload.entry || app_config.entry;
53880
53895
  app_config.stop = payload.stop || app_config.stop;
53881
53896
  app_config.last_value = last_value;
53882
53897
  app_config.entries = entries;
53898
+ app_config.kelly = {
53899
+ use_kelly: payload.use_kelly,
53900
+ kelly_confidence_factor: payload.kelly_confidence_factor,
53901
+ kelly_minimum_risk: payload.kelly_minimum_risk,
53902
+ kelly_prediction_model: payload.kelly_prediction_model
53903
+ };
53883
53904
  return app_config;
53884
53905
  }
53885
53906
  function getOptimumStopAndRisk(app_config, params) {
@@ -58250,7 +58271,7 @@ class ExchangeAccount {
58250
58271
  return app_config;
58251
58272
  }
58252
58273
  async tradeConfig(payload) {
58253
- const { symbol, kind } = payload;
58274
+ const { symbol, kind, override = {} } = payload;
58254
58275
  const config2 = await this.getPositionConfig({
58255
58276
  symbol,
58256
58277
  kind
@@ -58260,7 +58281,12 @@ class ExchangeAccount {
58260
58281
  stop: config2.stop,
58261
58282
  risk_reward: config2.risk_reward,
58262
58283
  risk: config2.risk,
58263
- symbol
58284
+ symbol,
58285
+ use_kelly: config2.kelly?.use_kelly,
58286
+ kelly_confidence_factor: config2.kelly?.kelly_confidence_factor,
58287
+ kelly_minimum_risk: config2.kelly?.kelly_minimum_risk,
58288
+ kelly_prediction_model: config2.kelly?.kelly_prediction_model,
58289
+ ...override
58264
58290
  });
58265
58291
  return app_config;
58266
58292
  }
package/dist/index.d.ts CHANGED
@@ -72,6 +72,12 @@ export interface ScheduledTrade extends BaseSystemFields {
72
72
  threshold_qty?: number;
73
73
  pause_tp?: boolean;
74
74
  stop_percent?: number;
75
+ kelly?: {
76
+ use_kelly?: boolean;
77
+ kelly_confidence_factor?: number;
78
+ kelly_minimum_risk?: number;
79
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
80
+ };
75
81
  }
76
82
  export interface AccountStrategy extends BaseSystemFields {
77
83
  account: string;
@@ -1016,7 +1022,12 @@ export declare class Strategy {
1016
1022
  rr?: number;
1017
1023
  max_size?: number;
1018
1024
  max_quantity?: number;
1019
- use_kelly?: boolean;
1025
+ kelly?: {
1026
+ use_kelly?: boolean;
1027
+ kelly_confidence_factor?: number;
1028
+ kelly_minimum_risk?: number;
1029
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1030
+ };
1020
1031
  };
1021
1032
  identifyGapConfig(payload: {
1022
1033
  factor?: number;
@@ -1283,7 +1294,12 @@ export type AppConfig = {
1283
1294
  last_value?: any;
1284
1295
  entries?: any[];
1285
1296
  max_quantity?: number;
1286
- use_kelly?: boolean;
1297
+ kelly?: {
1298
+ use_kelly?: boolean;
1299
+ kelly_confidence_factor?: number;
1300
+ kelly_minimum_risk?: number;
1301
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1302
+ };
1287
1303
  };
1288
1304
  export type ExtendConfigType = {
1289
1305
  take_profit?: number;
@@ -1300,8 +1316,12 @@ export type ExtendConfigType = {
1300
1316
  kind?: "long" | "short";
1301
1317
  gap?: number;
1302
1318
  rr?: number;
1319
+ use_kelly?: boolean;
1320
+ kelly_confidence_factor?: number;
1321
+ kelly_minimum_risk?: number;
1322
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1303
1323
  };
1304
- export declare function buildConfig(app_config: AppConfig, { take_profit, entry, stop, raw_instance, risk, no_of_trades, min_profit, risk_reward, kind, increase, gap, rr, price_places, decimal_places, }: ExtendConfigType): any[] | Signal;
1324
+ export declare function buildConfig(app_config: AppConfig, { take_profit, entry, stop, raw_instance, risk, no_of_trades, min_profit, risk_reward, kind, increase, gap, rr, price_places, decimal_places, use_kelly, kelly_confidence_factor, kelly_minimum_risk, kelly_prediction_model, }: ExtendConfigType): any[] | Signal;
1305
1325
  export declare function buildAvg({ _trades, kind, }: {
1306
1326
  _trades: any[];
1307
1327
  kind: "long" | "short";
@@ -1311,6 +1331,10 @@ export declare function get_app_config_and_max_size(config: GlobalConfig, payloa
1311
1331
  entry: number;
1312
1332
  stop: number;
1313
1333
  kind: "long" | "short";
1334
+ use_kelly?: boolean;
1335
+ kelly_confidence_factor?: number;
1336
+ kelly_minimum_risk?: number;
1337
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1314
1338
  }): {
1315
1339
  app_config: AppConfig;
1316
1340
  max_size: any;
@@ -1330,6 +1354,10 @@ export declare function buildAppConfig(config: GlobalConfig, payload: {
1330
1354
  risk: number;
1331
1355
  symbol: string;
1332
1356
  profit?: number;
1357
+ use_kelly?: boolean;
1358
+ kelly_confidence_factor?: number;
1359
+ kelly_minimum_risk?: number;
1360
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1333
1361
  }): AppConfig;
1334
1362
  export declare function getOptimumStopAndRisk(app_config: AppConfig, params: {
1335
1363
  max_size: number;
@@ -1864,10 +1892,15 @@ declare class ExchangeAccount$1 {
1864
1892
  profit?: number;
1865
1893
  update_db?: boolean;
1866
1894
  profit_percent?: number;
1895
+ use_kelly?: boolean;
1896
+ kelly_confidence_factor?: number;
1897
+ kelly_minimum_risk?: number;
1898
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1867
1899
  }): Promise<AppConfig>;
1868
1900
  tradeConfig(payload: {
1869
1901
  symbol: string;
1870
1902
  kind: "long" | "short";
1903
+ override?: any;
1871
1904
  }): Promise<AppConfig>;
1872
1905
  justInTimeProfit(payload: {
1873
1906
  symbol: string;
@@ -2211,7 +2244,12 @@ declare class ExchangeAccount$1 {
2211
2244
  rr?: number;
2212
2245
  max_size?: number;
2213
2246
  max_quantity?: number;
2214
- use_kelly?: boolean;
2247
+ kelly?: {
2248
+ use_kelly?: boolean;
2249
+ kelly_confidence_factor?: number;
2250
+ kelly_minimum_risk?: number;
2251
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2252
+ };
2215
2253
  }>;
2216
2254
  runSimulation(payload: {
2217
2255
  symbol: string;
@@ -2392,7 +2430,12 @@ declare class ExchangeAccount$1 {
2392
2430
  rr?: number;
2393
2431
  max_size?: number;
2394
2432
  max_quantity?: number;
2395
- use_kelly?: boolean;
2433
+ kelly?: {
2434
+ use_kelly?: boolean;
2435
+ kelly_confidence_factor?: number;
2436
+ kelly_minimum_risk?: number;
2437
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2438
+ };
2396
2439
  };
2397
2440
  last_value: any;
2398
2441
  config: {
@@ -2660,7 +2703,12 @@ declare class App {
2660
2703
  rr?: number;
2661
2704
  max_size?: number;
2662
2705
  max_quantity?: number;
2663
- use_kelly?: boolean;
2706
+ kelly?: {
2707
+ use_kelly?: boolean;
2708
+ kelly_confidence_factor?: number;
2709
+ kelly_minimum_risk?: number;
2710
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2711
+ };
2664
2712
  };
2665
2713
  last_value: any;
2666
2714
  config: {
package/dist/index.js CHANGED
@@ -52830,12 +52830,12 @@ function calculateTheoreticalKelly({
52830
52830
  confidence_factor = 0.6,
52831
52831
  volatility_adjustment = true
52832
52832
  } = config2;
52833
- const sorted_prices = kind === "long" ? zone_prices : zone_prices.reverse();
52833
+ const sorted_prices = zone_prices;
52834
52834
  const current_index = sorted_prices.findIndex((price) => price === current_entry);
52835
52835
  if (current_index === -1)
52836
52836
  return 0.02;
52837
- const win_zones = kind === "long" ? sorted_prices.slice(current_index + 1) : sorted_prices.slice(0, current_index);
52838
- const lose_zones = kind === "long" ? sorted_prices.slice(0, current_index) : sorted_prices.slice(current_index + 1);
52837
+ const win_zones = kind === "long" ? sorted_prices.filter((price) => price > current_entry) : sorted_prices.filter((price) => price < current_entry);
52838
+ const lose_zones = kind === "long" ? sorted_prices.filter((price) => price < current_entry) : sorted_prices.filter((price) => price > current_entry);
52839
52839
  const { win_probability, avg_win_ratio, avg_loss_ratio } = calculateZoneProbabilities({
52840
52840
  current_entry,
52841
52841
  win_zones,
@@ -53684,7 +53684,11 @@ function buildConfig(app_config, {
53684
53684
  gap,
53685
53685
  rr = 1,
53686
53686
  price_places = "%.1f",
53687
- decimal_places = "%.3f"
53687
+ decimal_places = "%.3f",
53688
+ use_kelly = false,
53689
+ kelly_confidence_factor = 0.95,
53690
+ kelly_minimum_risk = 0.2,
53691
+ kelly_prediction_model = "exponential"
53688
53692
  }) {
53689
53693
  let fee = app_config.fee / 100;
53690
53694
  let working_risk = risk || app_config.risk_per_trade;
@@ -53709,7 +53713,10 @@ function buildConfig(app_config, {
53709
53713
  gap,
53710
53714
  min_profit: min_profit || app_config.min_profit,
53711
53715
  rr: rr || 1,
53712
- use_kelly: app_config.use_kelly
53716
+ use_kelly: use_kelly || app_config.kelly?.use_kelly,
53717
+ kelly_confidence_factor: kelly_confidence_factor || app_config.kelly?.kelly_confidence_factor,
53718
+ kelly_minimum_risk: kelly_minimum_risk || app_config.kelly?.kelly_minimum_risk,
53719
+ kelly_prediction_model: kelly_prediction_model || app_config.kelly?.kelly_prediction_model
53713
53720
  };
53714
53721
  const instance = new Signal(config2);
53715
53722
  if (raw_instance) {
@@ -53788,7 +53795,11 @@ function get_app_config_and_max_size(config2, payload) {
53788
53795
  increase: true,
53789
53796
  gap: app_config.gap,
53790
53797
  price_places: app_config.price_places,
53791
- decimal_places: app_config.decimal_places
53798
+ decimal_places: app_config.decimal_places,
53799
+ use_kelly: payload.use_kelly,
53800
+ kelly_confidence_factor: payload.kelly_confidence_factor,
53801
+ kelly_minimum_risk: payload.kelly_minimum_risk,
53802
+ kelly_prediction_model: payload.kelly_prediction_model
53792
53803
  });
53793
53804
  const max_size = initialResult[0]?.avg_size;
53794
53805
  const last_value = initialResult[0];
@@ -53821,13 +53832,23 @@ function buildAppConfig(config2, payload) {
53821
53832
  }, {
53822
53833
  entry: payload.entry,
53823
53834
  stop: payload.stop,
53824
- kind: payload.entry > payload.stop ? "long" : "short"
53835
+ kind: payload.entry > payload.stop ? "long" : "short",
53836
+ use_kelly: payload.use_kelly,
53837
+ kelly_confidence_factor: payload.kelly_confidence_factor,
53838
+ kelly_minimum_risk: payload.kelly_minimum_risk,
53839
+ kelly_prediction_model: payload.kelly_prediction_model
53825
53840
  });
53826
53841
  app_config.max_size = max_size;
53827
53842
  app_config.entry = payload.entry || app_config.entry;
53828
53843
  app_config.stop = payload.stop || app_config.stop;
53829
53844
  app_config.last_value = last_value;
53830
53845
  app_config.entries = entries;
53846
+ app_config.kelly = {
53847
+ use_kelly: payload.use_kelly,
53848
+ kelly_confidence_factor: payload.kelly_confidence_factor,
53849
+ kelly_minimum_risk: payload.kelly_minimum_risk,
53850
+ kelly_prediction_model: payload.kelly_prediction_model
53851
+ };
53831
53852
  return app_config;
53832
53853
  }
53833
53854
  function getOptimumStopAndRisk(app_config, params) {
@@ -58198,7 +58219,7 @@ class ExchangeAccount {
58198
58219
  return app_config;
58199
58220
  }
58200
58221
  async tradeConfig(payload) {
58201
- const { symbol, kind } = payload;
58222
+ const { symbol, kind, override = {} } = payload;
58202
58223
  const config2 = await this.getPositionConfig({
58203
58224
  symbol,
58204
58225
  kind
@@ -58208,7 +58229,12 @@ class ExchangeAccount {
58208
58229
  stop: config2.stop,
58209
58230
  risk_reward: config2.risk_reward,
58210
58231
  risk: config2.risk,
58211
- symbol
58232
+ symbol,
58233
+ use_kelly: config2.kelly?.use_kelly,
58234
+ kelly_confidence_factor: config2.kelly?.kelly_confidence_factor,
58235
+ kelly_minimum_risk: config2.kelly?.kelly_minimum_risk,
58236
+ kelly_prediction_model: config2.kelly?.kelly_prediction_model,
58237
+ ...override
58212
58238
  });
58213
58239
  return app_config;
58214
58240
  }
@@ -59577,12 +59577,12 @@ function calculateTheoreticalKelly({
59577
59577
  confidence_factor = 0.6,
59578
59578
  volatility_adjustment = true
59579
59579
  } = config2;
59580
- const sorted_prices = kind === "long" ? zone_prices : zone_prices.reverse();
59580
+ const sorted_prices = zone_prices;
59581
59581
  const current_index = sorted_prices.findIndex((price) => price === current_entry);
59582
59582
  if (current_index === -1)
59583
59583
  return 0.02;
59584
- const win_zones = kind === "long" ? sorted_prices.slice(current_index + 1) : sorted_prices.slice(0, current_index);
59585
- const lose_zones = kind === "long" ? sorted_prices.slice(0, current_index) : sorted_prices.slice(current_index + 1);
59584
+ const win_zones = kind === "long" ? sorted_prices.filter((price) => price > current_entry) : sorted_prices.filter((price) => price < current_entry);
59585
+ const lose_zones = kind === "long" ? sorted_prices.filter((price) => price < current_entry) : sorted_prices.filter((price) => price > current_entry);
59586
59586
  const { win_probability, avg_win_ratio, avg_loss_ratio } = calculateZoneProbabilities({
59587
59587
  current_entry,
59588
59588
  win_zones,
@@ -60431,7 +60431,11 @@ function buildConfig(app_config, {
60431
60431
  gap,
60432
60432
  rr = 1,
60433
60433
  price_places = "%.1f",
60434
- decimal_places = "%.3f"
60434
+ decimal_places = "%.3f",
60435
+ use_kelly = false,
60436
+ kelly_confidence_factor = 0.95,
60437
+ kelly_minimum_risk = 0.2,
60438
+ kelly_prediction_model = "exponential"
60435
60439
  }) {
60436
60440
  let fee = app_config.fee / 100;
60437
60441
  let working_risk = risk || app_config.risk_per_trade;
@@ -60456,7 +60460,10 @@ function buildConfig(app_config, {
60456
60460
  gap,
60457
60461
  min_profit: min_profit || app_config.min_profit,
60458
60462
  rr: rr || 1,
60459
- use_kelly: app_config.use_kelly
60463
+ use_kelly: use_kelly || app_config.kelly?.use_kelly,
60464
+ kelly_confidence_factor: kelly_confidence_factor || app_config.kelly?.kelly_confidence_factor,
60465
+ kelly_minimum_risk: kelly_minimum_risk || app_config.kelly?.kelly_minimum_risk,
60466
+ kelly_prediction_model: kelly_prediction_model || app_config.kelly?.kelly_prediction_model
60460
60467
  };
60461
60468
  const instance = new Signal(config2);
60462
60469
  if (raw_instance) {
@@ -60522,7 +60529,11 @@ function get_app_config_and_max_size(config2, payload) {
60522
60529
  increase: true,
60523
60530
  gap: app_config.gap,
60524
60531
  price_places: app_config.price_places,
60525
- decimal_places: app_config.decimal_places
60532
+ decimal_places: app_config.decimal_places,
60533
+ use_kelly: payload.use_kelly,
60534
+ kelly_confidence_factor: payload.kelly_confidence_factor,
60535
+ kelly_minimum_risk: payload.kelly_minimum_risk,
60536
+ kelly_prediction_model: payload.kelly_prediction_model
60526
60537
  });
60527
60538
  const max_size = initialResult[0]?.avg_size;
60528
60539
  const last_value = initialResult[0];
@@ -60555,13 +60566,23 @@ function buildAppConfig(config2, payload) {
60555
60566
  }, {
60556
60567
  entry: payload.entry,
60557
60568
  stop: payload.stop,
60558
- kind: payload.entry > payload.stop ? "long" : "short"
60569
+ kind: payload.entry > payload.stop ? "long" : "short",
60570
+ use_kelly: payload.use_kelly,
60571
+ kelly_confidence_factor: payload.kelly_confidence_factor,
60572
+ kelly_minimum_risk: payload.kelly_minimum_risk,
60573
+ kelly_prediction_model: payload.kelly_prediction_model
60559
60574
  });
60560
60575
  app_config.max_size = max_size;
60561
60576
  app_config.entry = payload.entry || app_config.entry;
60562
60577
  app_config.stop = payload.stop || app_config.stop;
60563
60578
  app_config.last_value = last_value;
60564
60579
  app_config.entries = entries;
60580
+ app_config.kelly = {
60581
+ use_kelly: payload.use_kelly,
60582
+ kelly_confidence_factor: payload.kelly_confidence_factor,
60583
+ kelly_minimum_risk: payload.kelly_minimum_risk,
60584
+ kelly_prediction_model: payload.kelly_prediction_model
60585
+ };
60565
60586
  return app_config;
60566
60587
  }
60567
60588
  function getOptimumStopAndRisk(app_config, params) {
@@ -64926,7 +64947,7 @@ class ExchangeAccount {
64926
64947
  return app_config;
64927
64948
  }
64928
64949
  async tradeConfig(payload) {
64929
- const { symbol, kind } = payload;
64950
+ const { symbol, kind, override = {} } = payload;
64930
64951
  const config2 = await this.getPositionConfig({
64931
64952
  symbol,
64932
64953
  kind
@@ -64936,7 +64957,12 @@ class ExchangeAccount {
64936
64957
  stop: config2.stop,
64937
64958
  risk_reward: config2.risk_reward,
64938
64959
  risk: config2.risk,
64939
- symbol
64960
+ symbol,
64961
+ use_kelly: config2.kelly?.use_kelly,
64962
+ kelly_confidence_factor: config2.kelly?.kelly_confidence_factor,
64963
+ kelly_minimum_risk: config2.kelly?.kelly_minimum_risk,
64964
+ kelly_prediction_model: config2.kelly?.kelly_prediction_model,
64965
+ ...override
64940
64966
  });
64941
64967
  return app_config;
64942
64968
  }
@@ -59554,12 +59554,12 @@ function calculateTheoreticalKelly({
59554
59554
  confidence_factor = 0.6,
59555
59555
  volatility_adjustment = true
59556
59556
  } = config2;
59557
- const sorted_prices = kind === "long" ? zone_prices : zone_prices.reverse();
59557
+ const sorted_prices = zone_prices;
59558
59558
  const current_index = sorted_prices.findIndex((price) => price === current_entry);
59559
59559
  if (current_index === -1)
59560
59560
  return 0.02;
59561
- const win_zones = kind === "long" ? sorted_prices.slice(current_index + 1) : sorted_prices.slice(0, current_index);
59562
- const lose_zones = kind === "long" ? sorted_prices.slice(0, current_index) : sorted_prices.slice(current_index + 1);
59561
+ const win_zones = kind === "long" ? sorted_prices.filter((price) => price > current_entry) : sorted_prices.filter((price) => price < current_entry);
59562
+ const lose_zones = kind === "long" ? sorted_prices.filter((price) => price < current_entry) : sorted_prices.filter((price) => price > current_entry);
59563
59563
  const { win_probability, avg_win_ratio, avg_loss_ratio } = calculateZoneProbabilities({
59564
59564
  current_entry,
59565
59565
  win_zones,
@@ -60408,7 +60408,11 @@ function buildConfig(app_config, {
60408
60408
  gap,
60409
60409
  rr = 1,
60410
60410
  price_places = "%.1f",
60411
- decimal_places = "%.3f"
60411
+ decimal_places = "%.3f",
60412
+ use_kelly = false,
60413
+ kelly_confidence_factor = 0.95,
60414
+ kelly_minimum_risk = 0.2,
60415
+ kelly_prediction_model = "exponential"
60412
60416
  }) {
60413
60417
  let fee = app_config.fee / 100;
60414
60418
  let working_risk = risk || app_config.risk_per_trade;
@@ -60433,7 +60437,10 @@ function buildConfig(app_config, {
60433
60437
  gap,
60434
60438
  min_profit: min_profit || app_config.min_profit,
60435
60439
  rr: rr || 1,
60436
- use_kelly: app_config.use_kelly
60440
+ use_kelly: use_kelly || app_config.kelly?.use_kelly,
60441
+ kelly_confidence_factor: kelly_confidence_factor || app_config.kelly?.kelly_confidence_factor,
60442
+ kelly_minimum_risk: kelly_minimum_risk || app_config.kelly?.kelly_minimum_risk,
60443
+ kelly_prediction_model: kelly_prediction_model || app_config.kelly?.kelly_prediction_model
60437
60444
  };
60438
60445
  const instance = new Signal(config2);
60439
60446
  if (raw_instance) {
@@ -60499,7 +60506,11 @@ function get_app_config_and_max_size(config2, payload) {
60499
60506
  increase: true,
60500
60507
  gap: app_config.gap,
60501
60508
  price_places: app_config.price_places,
60502
- decimal_places: app_config.decimal_places
60509
+ decimal_places: app_config.decimal_places,
60510
+ use_kelly: payload.use_kelly,
60511
+ kelly_confidence_factor: payload.kelly_confidence_factor,
60512
+ kelly_minimum_risk: payload.kelly_minimum_risk,
60513
+ kelly_prediction_model: payload.kelly_prediction_model
60503
60514
  });
60504
60515
  const max_size = initialResult[0]?.avg_size;
60505
60516
  const last_value = initialResult[0];
@@ -60532,13 +60543,23 @@ function buildAppConfig(config2, payload) {
60532
60543
  }, {
60533
60544
  entry: payload.entry,
60534
60545
  stop: payload.stop,
60535
- kind: payload.entry > payload.stop ? "long" : "short"
60546
+ kind: payload.entry > payload.stop ? "long" : "short",
60547
+ use_kelly: payload.use_kelly,
60548
+ kelly_confidence_factor: payload.kelly_confidence_factor,
60549
+ kelly_minimum_risk: payload.kelly_minimum_risk,
60550
+ kelly_prediction_model: payload.kelly_prediction_model
60536
60551
  });
60537
60552
  app_config.max_size = max_size;
60538
60553
  app_config.entry = payload.entry || app_config.entry;
60539
60554
  app_config.stop = payload.stop || app_config.stop;
60540
60555
  app_config.last_value = last_value;
60541
60556
  app_config.entries = entries;
60557
+ app_config.kelly = {
60558
+ use_kelly: payload.use_kelly,
60559
+ kelly_confidence_factor: payload.kelly_confidence_factor,
60560
+ kelly_minimum_risk: payload.kelly_minimum_risk,
60561
+ kelly_prediction_model: payload.kelly_prediction_model
60562
+ };
60542
60563
  return app_config;
60543
60564
  }
60544
60565
  function getOptimumStopAndRisk(app_config, params) {
@@ -64903,7 +64924,7 @@ class ExchangeAccount {
64903
64924
  return app_config;
64904
64925
  }
64905
64926
  async tradeConfig(payload) {
64906
- const { symbol, kind } = payload;
64927
+ const { symbol, kind, override = {} } = payload;
64907
64928
  const config2 = await this.getPositionConfig({
64908
64929
  symbol,
64909
64930
  kind
@@ -64913,7 +64934,12 @@ class ExchangeAccount {
64913
64934
  stop: config2.stop,
64914
64935
  risk_reward: config2.risk_reward,
64915
64936
  risk: config2.risk,
64916
- symbol
64937
+ symbol,
64938
+ use_kelly: config2.kelly?.use_kelly,
64939
+ kelly_confidence_factor: config2.kelly?.kelly_confidence_factor,
64940
+ kelly_minimum_risk: config2.kelly?.kelly_minimum_risk,
64941
+ kelly_prediction_model: config2.kelly?.kelly_prediction_model,
64942
+ ...override
64917
64943
  });
64918
64944
  return app_config;
64919
64945
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-145",
4
+ "version": "0.0.2-147",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",