@gbozee/ultimate 0.0.2-next.14 → 0.0.2-next.15

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.
@@ -120,7 +120,7 @@ export declare function determineTPSl(payload: {
120
120
  };
121
121
  export interface GetEntriesParams {
122
122
  kind: "long" | "short";
123
- distribution: "arithmetic" | "geometric" | "normal" | "exponential" | "inverse-exponential";
123
+ distribution: "arithmetic" | "geometric" | "normal" | "exponential" | "lognormal" | "inverse-exponential";
124
124
  margin_range: [
125
125
  number,
126
126
  number
@@ -121,12 +121,37 @@ function getEntries(params) {
121
121
  curveFactor: distribution_params?.curveFactor
122
122
  });
123
123
  break;
124
+ case "lognormal":
125
+ entries = generateLognormal({
126
+ margin_range,
127
+ risk_reward,
128
+ kind,
129
+ price_places,
130
+ stdDevFactor: distribution_params?.stdDevFactor
131
+ });
132
+ break;
124
133
  default:
125
134
  throw new Error(`Unknown distribution type: ${distribution}`);
126
135
  }
127
136
  return entries.sort((a, b) => a - b);
128
137
  }
129
138
  var distributions_default = getEntries;
139
+ function generateLognormal(payload) {
140
+ const { margin_range, risk_reward, kind, price_places = "%.1f", stdDevFactor = 6 } = payload;
141
+ const logMin = Math.log(margin_range[0]);
142
+ const logMax = Math.log(margin_range[1]);
143
+ const mean = (logMin + logMax) / 2;
144
+ const stdDev = Math.abs(logMax - logMin) / stdDevFactor;
145
+ const entries = Array.from({ length: risk_reward + 1 }, (_, i) => {
146
+ const p = (i + 0.5) / (risk_reward + 1);
147
+ const z = approximateInverseNormal(p);
148
+ let logPrice = mean + stdDev * z;
149
+ logPrice = Math.max(logMin, Math.min(logMax, logPrice));
150
+ const price = Math.exp(logPrice);
151
+ return to_f(kind === "long" ? Math.min(price, margin_range[1]) : Math.max(price, margin_range[0]), price_places);
152
+ });
153
+ return entries.sort((a, b) => a - b);
154
+ }
130
155
 
131
156
  // src/helpers/optimizations.ts
132
157
  function calculateTheoreticalKelly({
package/dist/index.cjs CHANGED
@@ -51392,12 +51392,37 @@ function getEntries(params) {
51392
51392
  curveFactor: distribution_params?.curveFactor
51393
51393
  });
51394
51394
  break;
51395
+ case "lognormal":
51396
+ entries = generateLognormal({
51397
+ margin_range,
51398
+ risk_reward,
51399
+ kind,
51400
+ price_places,
51401
+ stdDevFactor: distribution_params?.stdDevFactor
51402
+ });
51403
+ break;
51395
51404
  default:
51396
51405
  throw new Error(`Unknown distribution type: ${distribution}`);
51397
51406
  }
51398
51407
  return entries.sort((a, b) => a - b);
51399
51408
  }
51400
51409
  var distributions_default = getEntries;
51410
+ function generateLognormal(payload) {
51411
+ const { margin_range, risk_reward, kind, price_places = "%.1f", stdDevFactor = 6 } = payload;
51412
+ const logMin = Math.log(margin_range[0]);
51413
+ const logMax = Math.log(margin_range[1]);
51414
+ const mean = (logMin + logMax) / 2;
51415
+ const stdDev = Math.abs(logMax - logMin) / stdDevFactor;
51416
+ const entries = Array.from({ length: risk_reward + 1 }, (_, i2) => {
51417
+ const p = (i2 + 0.5) / (risk_reward + 1);
51418
+ const z2 = approximateInverseNormal(p);
51419
+ let logPrice = mean + stdDev * z2;
51420
+ logPrice = Math.max(logMin, Math.min(logMax, logPrice));
51421
+ const price = Math.exp(logPrice);
51422
+ return to_f(kind === "long" ? Math.min(price, margin_range[1]) : Math.max(price, margin_range[0]), price_places);
51423
+ });
51424
+ return entries.sort((a, b) => a - b);
51425
+ }
51401
51426
 
51402
51427
  // src/helpers/optimizations.ts
51403
51428
  function calculateTheoreticalKelly({
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { SocksProxyAgent } from 'socks-proxy-agent';
7
7
 
8
8
  export interface GetEntriesParams {
9
9
  kind: "long" | "short";
10
- distribution: "arithmetic" | "geometric" | "normal" | "exponential" | "inverse-exponential";
10
+ distribution: "arithmetic" | "geometric" | "normal" | "exponential" | "lognormal" | "inverse-exponential";
11
11
  margin_range: [
12
12
  number,
13
13
  number
package/dist/index.js CHANGED
@@ -51329,12 +51329,37 @@ function getEntries(params) {
51329
51329
  curveFactor: distribution_params?.curveFactor
51330
51330
  });
51331
51331
  break;
51332
+ case "lognormal":
51333
+ entries = generateLognormal({
51334
+ margin_range,
51335
+ risk_reward,
51336
+ kind,
51337
+ price_places,
51338
+ stdDevFactor: distribution_params?.stdDevFactor
51339
+ });
51340
+ break;
51332
51341
  default:
51333
51342
  throw new Error(`Unknown distribution type: ${distribution}`);
51334
51343
  }
51335
51344
  return entries.sort((a, b) => a - b);
51336
51345
  }
51337
51346
  var distributions_default = getEntries;
51347
+ function generateLognormal(payload) {
51348
+ const { margin_range, risk_reward, kind, price_places = "%.1f", stdDevFactor = 6 } = payload;
51349
+ const logMin = Math.log(margin_range[0]);
51350
+ const logMax = Math.log(margin_range[1]);
51351
+ const mean = (logMin + logMax) / 2;
51352
+ const stdDev = Math.abs(logMax - logMin) / stdDevFactor;
51353
+ const entries = Array.from({ length: risk_reward + 1 }, (_, i2) => {
51354
+ const p = (i2 + 0.5) / (risk_reward + 1);
51355
+ const z2 = approximateInverseNormal(p);
51356
+ let logPrice = mean + stdDev * z2;
51357
+ logPrice = Math.max(logMin, Math.min(logMax, logPrice));
51358
+ const price = Math.exp(logPrice);
51359
+ return to_f(kind === "long" ? Math.min(price, margin_range[1]) : Math.max(price, margin_range[0]), price_places);
51360
+ });
51361
+ return entries.sort((a, b) => a - b);
51362
+ }
51338
51363
 
51339
51364
  // src/helpers/optimizations.ts
51340
51365
  function calculateTheoreticalKelly({
@@ -64483,12 +64483,37 @@ function getEntries(params) {
64483
64483
  curveFactor: distribution_params?.curveFactor
64484
64484
  });
64485
64485
  break;
64486
+ case "lognormal":
64487
+ entries = generateLognormal({
64488
+ margin_range,
64489
+ risk_reward,
64490
+ kind,
64491
+ price_places,
64492
+ stdDevFactor: distribution_params?.stdDevFactor
64493
+ });
64494
+ break;
64486
64495
  default:
64487
64496
  throw new Error(`Unknown distribution type: ${distribution}`);
64488
64497
  }
64489
64498
  return entries.sort((a, b) => a - b);
64490
64499
  }
64491
64500
  var distributions_default = getEntries;
64501
+ function generateLognormal(payload) {
64502
+ const { margin_range, risk_reward, kind, price_places = "%.1f", stdDevFactor = 6 } = payload;
64503
+ const logMin = Math.log(margin_range[0]);
64504
+ const logMax = Math.log(margin_range[1]);
64505
+ const mean = (logMin + logMax) / 2;
64506
+ const stdDev = Math.abs(logMax - logMin) / stdDevFactor;
64507
+ const entries = Array.from({ length: risk_reward + 1 }, (_, i2) => {
64508
+ const p = (i2 + 0.5) / (risk_reward + 1);
64509
+ const z2 = approximateInverseNormal(p);
64510
+ let logPrice = mean + stdDev * z2;
64511
+ logPrice = Math.max(logMin, Math.min(logMax, logPrice));
64512
+ const price = Math.exp(logPrice);
64513
+ return to_f(kind === "long" ? Math.min(price, margin_range[1]) : Math.max(price, margin_range[0]), price_places);
64514
+ });
64515
+ return entries.sort((a, b) => a - b);
64516
+ }
64492
64517
 
64493
64518
  // src/helpers/optimizations.ts
64494
64519
  function calculateTheoreticalKelly({
@@ -64456,12 +64456,37 @@ function getEntries(params) {
64456
64456
  curveFactor: distribution_params?.curveFactor
64457
64457
  });
64458
64458
  break;
64459
+ case "lognormal":
64460
+ entries = generateLognormal({
64461
+ margin_range,
64462
+ risk_reward,
64463
+ kind,
64464
+ price_places,
64465
+ stdDevFactor: distribution_params?.stdDevFactor
64466
+ });
64467
+ break;
64459
64468
  default:
64460
64469
  throw new Error(`Unknown distribution type: ${distribution}`);
64461
64470
  }
64462
64471
  return entries.sort((a, b) => a - b);
64463
64472
  }
64464
64473
  var distributions_default = getEntries;
64474
+ function generateLognormal(payload) {
64475
+ const { margin_range, risk_reward, kind, price_places = "%.1f", stdDevFactor = 6 } = payload;
64476
+ const logMin = Math.log(margin_range[0]);
64477
+ const logMax = Math.log(margin_range[1]);
64478
+ const mean = (logMin + logMax) / 2;
64479
+ const stdDev = Math.abs(logMax - logMin) / stdDevFactor;
64480
+ const entries = Array.from({ length: risk_reward + 1 }, (_, i2) => {
64481
+ const p = (i2 + 0.5) / (risk_reward + 1);
64482
+ const z2 = approximateInverseNormal(p);
64483
+ let logPrice = mean + stdDev * z2;
64484
+ logPrice = Math.max(logMin, Math.min(logMax, logPrice));
64485
+ const price = Math.exp(logPrice);
64486
+ return to_f(kind === "long" ? Math.min(price, margin_range[1]) : Math.max(price, margin_range[0]), price_places);
64487
+ });
64488
+ return entries.sort((a, b) => a - b);
64489
+ }
64465
64490
 
64466
64491
  // src/helpers/optimizations.ts
64467
64492
  function calculateTheoreticalKelly({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-next.14",
4
+ "version": "0.0.2-next.15",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",