@gbozee/ultimate 0.0.2-next.14 → 0.0.2-next.17
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.
- package/dist/frontend-index.d.ts +1 -1
- package/dist/frontend-index.js +25 -0
- package/dist/index.cjs +2482 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2482 -3
- package/dist/mcp-server.cjs +2482 -3
- package/dist/mcp-server.js +2482 -3
- package/package.json +3 -6
package/dist/frontend-index.d.ts
CHANGED
|
@@ -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
|
package/dist/frontend-index.js
CHANGED
|
@@ -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({
|