@gbozee/ultimate 0.0.2-110 → 0.0.2-111
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 +33 -8
- package/dist/frontend-index.js +64 -0
- package/dist/index.cjs +64 -0
- package/dist/index.d.ts +36 -8
- package/dist/index.js +64 -0
- package/package.json +1 -1
package/dist/frontend-index.d.ts
CHANGED
|
@@ -531,17 +531,18 @@ export declare function determineRewardFactor(payload: {
|
|
|
531
531
|
minimum_pnl: number;
|
|
532
532
|
risk: number;
|
|
533
533
|
}): number;
|
|
534
|
+
export type BotPosition = {
|
|
535
|
+
kind: "long" | "short";
|
|
536
|
+
entry: number;
|
|
537
|
+
quantity: number;
|
|
538
|
+
tp: {
|
|
539
|
+
price: number;
|
|
540
|
+
};
|
|
541
|
+
};
|
|
534
542
|
export declare function getHedgeZone(payload: {
|
|
535
543
|
symbol_config: GlobalConfig;
|
|
536
544
|
risk: number;
|
|
537
|
-
position:
|
|
538
|
-
kind: "long" | "short";
|
|
539
|
-
entry: number;
|
|
540
|
-
quantity: number;
|
|
541
|
-
tp: {
|
|
542
|
-
price: number;
|
|
543
|
-
};
|
|
544
|
-
};
|
|
545
|
+
position: BotPosition;
|
|
545
546
|
reward_factor: number;
|
|
546
547
|
risk_factor?: number;
|
|
547
548
|
}): {
|
|
@@ -550,6 +551,30 @@ export declare function getHedgeZone(payload: {
|
|
|
550
551
|
risk: number;
|
|
551
552
|
profit_percent: number;
|
|
552
553
|
};
|
|
554
|
+
export declare function getOptimumHedgeFactor(payload: {
|
|
555
|
+
target_support: number;
|
|
556
|
+
tolerance?: number;
|
|
557
|
+
max_iterations?: number;
|
|
558
|
+
min_factor?: number;
|
|
559
|
+
max_factor?: number;
|
|
560
|
+
symbol_config: GlobalConfig;
|
|
561
|
+
risk: number;
|
|
562
|
+
position: BotPosition;
|
|
563
|
+
}): {
|
|
564
|
+
reward_factor: number;
|
|
565
|
+
achieved_support: number;
|
|
566
|
+
target_support: number;
|
|
567
|
+
difference: number;
|
|
568
|
+
iterations: number;
|
|
569
|
+
converged?: undefined;
|
|
570
|
+
} | {
|
|
571
|
+
reward_factor: number;
|
|
572
|
+
achieved_support: number;
|
|
573
|
+
target_support: number;
|
|
574
|
+
difference: number;
|
|
575
|
+
iterations: number;
|
|
576
|
+
converged: boolean;
|
|
577
|
+
};
|
|
553
578
|
export type StrategyPosition = {
|
|
554
579
|
entry: number;
|
|
555
580
|
quantity: number;
|
package/dist/frontend-index.js
CHANGED
|
@@ -1974,6 +1974,69 @@ function getHedgeZone(payload) {
|
|
|
1974
1974
|
profit_percent: to_f(profit_percent, "%.2f")
|
|
1975
1975
|
};
|
|
1976
1976
|
}
|
|
1977
|
+
function getOptimumHedgeFactor(payload) {
|
|
1978
|
+
const {
|
|
1979
|
+
target_support,
|
|
1980
|
+
max_iterations = 50,
|
|
1981
|
+
min_factor = 0.1,
|
|
1982
|
+
max_factor = 20,
|
|
1983
|
+
symbol_config,
|
|
1984
|
+
risk,
|
|
1985
|
+
position: position2
|
|
1986
|
+
} = payload;
|
|
1987
|
+
const current_price = position2.entry;
|
|
1988
|
+
const tolerance = current_price > 100 ? 0.5 : current_price > 1 ? 0.01 : 0.001;
|
|
1989
|
+
let low = min_factor;
|
|
1990
|
+
let high = max_factor;
|
|
1991
|
+
let best_factor = low;
|
|
1992
|
+
let best_diff = Infinity;
|
|
1993
|
+
for (let iteration = 0;iteration < max_iterations; iteration++) {
|
|
1994
|
+
const mid_factor = (low + high) / 2;
|
|
1995
|
+
const hedge_zone = getHedgeZone({
|
|
1996
|
+
reward_factor: mid_factor,
|
|
1997
|
+
symbol_config,
|
|
1998
|
+
risk,
|
|
1999
|
+
position: position2
|
|
2000
|
+
});
|
|
2001
|
+
const current_support = hedge_zone.support;
|
|
2002
|
+
const diff = Math.abs(current_support - target_support);
|
|
2003
|
+
if (diff < best_diff) {
|
|
2004
|
+
best_diff = diff;
|
|
2005
|
+
best_factor = mid_factor;
|
|
2006
|
+
}
|
|
2007
|
+
if (diff <= tolerance) {
|
|
2008
|
+
return {
|
|
2009
|
+
reward_factor: to_f(mid_factor, "%.4f"),
|
|
2010
|
+
achieved_support: to_f(current_support, symbol_config.price_places),
|
|
2011
|
+
target_support: to_f(target_support, symbol_config.price_places),
|
|
2012
|
+
difference: to_f(diff, symbol_config.price_places),
|
|
2013
|
+
iterations: iteration + 1
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
if (current_support > target_support) {
|
|
2017
|
+
low = mid_factor;
|
|
2018
|
+
} else {
|
|
2019
|
+
high = mid_factor;
|
|
2020
|
+
}
|
|
2021
|
+
if (Math.abs(high - low) < 0.0001) {
|
|
2022
|
+
break;
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
const final_hedge_zone = getHedgeZone({
|
|
2026
|
+
symbol_config,
|
|
2027
|
+
risk,
|
|
2028
|
+
position: position2,
|
|
2029
|
+
reward_factor: best_factor
|
|
2030
|
+
});
|
|
2031
|
+
return {
|
|
2032
|
+
reward_factor: to_f(best_factor, "%.4f"),
|
|
2033
|
+
achieved_support: to_f(final_hedge_zone.support, symbol_config.price_places),
|
|
2034
|
+
target_support: to_f(target_support, symbol_config.price_places),
|
|
2035
|
+
difference: to_f(best_diff, symbol_config.price_places),
|
|
2036
|
+
iterations: max_iterations,
|
|
2037
|
+
converged: best_diff <= tolerance
|
|
2038
|
+
};
|
|
2039
|
+
}
|
|
1977
2040
|
// src/helpers/strategy.ts
|
|
1978
2041
|
class Strategy {
|
|
1979
2042
|
position;
|
|
@@ -2487,6 +2550,7 @@ export {
|
|
|
2487
2550
|
getRiskReward,
|
|
2488
2551
|
getParamForField,
|
|
2489
2552
|
getOptimumStopAndRisk,
|
|
2553
|
+
getOptimumHedgeFactor,
|
|
2490
2554
|
getHedgeZone,
|
|
2491
2555
|
getDecimalPlaces,
|
|
2492
2556
|
generate_config_params,
|
package/dist/index.cjs
CHANGED
|
@@ -41894,6 +41894,7 @@ __export(exports_src, {
|
|
|
41894
41894
|
get_app_config_and_max_size: () => get_app_config_and_max_size,
|
|
41895
41895
|
getRiskReward: () => getRiskReward,
|
|
41896
41896
|
getOptimumStopAndRisk: () => getOptimumStopAndRisk,
|
|
41897
|
+
getOptimumHedgeFactor: () => getOptimumHedgeFactor,
|
|
41897
41898
|
getHedgeZone: () => getHedgeZone,
|
|
41898
41899
|
generate_config_params: () => generate_config_params,
|
|
41899
41900
|
generateOptimumAppConfig: () => generateOptimumAppConfig,
|
|
@@ -54195,6 +54196,69 @@ function getHedgeZone(payload) {
|
|
|
54195
54196
|
profit_percent: to_f2(profit_percent, "%.2f")
|
|
54196
54197
|
};
|
|
54197
54198
|
}
|
|
54199
|
+
function getOptimumHedgeFactor(payload) {
|
|
54200
|
+
const {
|
|
54201
|
+
target_support,
|
|
54202
|
+
max_iterations = 50,
|
|
54203
|
+
min_factor = 0.1,
|
|
54204
|
+
max_factor = 20,
|
|
54205
|
+
symbol_config,
|
|
54206
|
+
risk,
|
|
54207
|
+
position: position2
|
|
54208
|
+
} = payload;
|
|
54209
|
+
const current_price = position2.entry;
|
|
54210
|
+
const tolerance = current_price > 100 ? 0.5 : current_price > 1 ? 0.01 : 0.001;
|
|
54211
|
+
let low = min_factor;
|
|
54212
|
+
let high = max_factor;
|
|
54213
|
+
let best_factor = low;
|
|
54214
|
+
let best_diff = Infinity;
|
|
54215
|
+
for (let iteration = 0;iteration < max_iterations; iteration++) {
|
|
54216
|
+
const mid_factor = (low + high) / 2;
|
|
54217
|
+
const hedge_zone = getHedgeZone({
|
|
54218
|
+
reward_factor: mid_factor,
|
|
54219
|
+
symbol_config,
|
|
54220
|
+
risk,
|
|
54221
|
+
position: position2
|
|
54222
|
+
});
|
|
54223
|
+
const current_support = hedge_zone.support;
|
|
54224
|
+
const diff = Math.abs(current_support - target_support);
|
|
54225
|
+
if (diff < best_diff) {
|
|
54226
|
+
best_diff = diff;
|
|
54227
|
+
best_factor = mid_factor;
|
|
54228
|
+
}
|
|
54229
|
+
if (diff <= tolerance) {
|
|
54230
|
+
return {
|
|
54231
|
+
reward_factor: to_f2(mid_factor, "%.4f"),
|
|
54232
|
+
achieved_support: to_f2(current_support, symbol_config.price_places),
|
|
54233
|
+
target_support: to_f2(target_support, symbol_config.price_places),
|
|
54234
|
+
difference: to_f2(diff, symbol_config.price_places),
|
|
54235
|
+
iterations: iteration + 1
|
|
54236
|
+
};
|
|
54237
|
+
}
|
|
54238
|
+
if (current_support > target_support) {
|
|
54239
|
+
low = mid_factor;
|
|
54240
|
+
} else {
|
|
54241
|
+
high = mid_factor;
|
|
54242
|
+
}
|
|
54243
|
+
if (Math.abs(high - low) < 0.0001) {
|
|
54244
|
+
break;
|
|
54245
|
+
}
|
|
54246
|
+
}
|
|
54247
|
+
const final_hedge_zone = getHedgeZone({
|
|
54248
|
+
symbol_config,
|
|
54249
|
+
risk,
|
|
54250
|
+
position: position2,
|
|
54251
|
+
reward_factor: best_factor
|
|
54252
|
+
});
|
|
54253
|
+
return {
|
|
54254
|
+
reward_factor: to_f2(best_factor, "%.4f"),
|
|
54255
|
+
achieved_support: to_f2(final_hedge_zone.support, symbol_config.price_places),
|
|
54256
|
+
target_support: to_f2(target_support, symbol_config.price_places),
|
|
54257
|
+
difference: to_f2(best_diff, symbol_config.price_places),
|
|
54258
|
+
iterations: max_iterations,
|
|
54259
|
+
converged: best_diff <= tolerance
|
|
54260
|
+
};
|
|
54261
|
+
}
|
|
54198
54262
|
|
|
54199
54263
|
// src/helpers/strategy.ts
|
|
54200
54264
|
class Strategy {
|
package/dist/index.d.ts
CHANGED
|
@@ -1369,17 +1369,18 @@ export declare function determineRewardFactor(payload: {
|
|
|
1369
1369
|
minimum_pnl: number;
|
|
1370
1370
|
risk: number;
|
|
1371
1371
|
}): number;
|
|
1372
|
+
export type BotPosition = {
|
|
1373
|
+
kind: "long" | "short";
|
|
1374
|
+
entry: number;
|
|
1375
|
+
quantity: number;
|
|
1376
|
+
tp: {
|
|
1377
|
+
price: number;
|
|
1378
|
+
};
|
|
1379
|
+
};
|
|
1372
1380
|
export declare function getHedgeZone(payload: {
|
|
1373
1381
|
symbol_config: GlobalConfig;
|
|
1374
1382
|
risk: number;
|
|
1375
|
-
position:
|
|
1376
|
-
kind: "long" | "short";
|
|
1377
|
-
entry: number;
|
|
1378
|
-
quantity: number;
|
|
1379
|
-
tp: {
|
|
1380
|
-
price: number;
|
|
1381
|
-
};
|
|
1382
|
-
};
|
|
1383
|
+
position: BotPosition;
|
|
1383
1384
|
reward_factor: number;
|
|
1384
1385
|
risk_factor?: number;
|
|
1385
1386
|
}): {
|
|
@@ -1388,6 +1389,30 @@ export declare function getHedgeZone(payload: {
|
|
|
1388
1389
|
risk: number;
|
|
1389
1390
|
profit_percent: number;
|
|
1390
1391
|
};
|
|
1392
|
+
export declare function getOptimumHedgeFactor(payload: {
|
|
1393
|
+
target_support: number;
|
|
1394
|
+
tolerance?: number;
|
|
1395
|
+
max_iterations?: number;
|
|
1396
|
+
min_factor?: number;
|
|
1397
|
+
max_factor?: number;
|
|
1398
|
+
symbol_config: GlobalConfig;
|
|
1399
|
+
risk: number;
|
|
1400
|
+
position: BotPosition;
|
|
1401
|
+
}): {
|
|
1402
|
+
reward_factor: number;
|
|
1403
|
+
achieved_support: number;
|
|
1404
|
+
target_support: number;
|
|
1405
|
+
difference: number;
|
|
1406
|
+
iterations: number;
|
|
1407
|
+
converged?: undefined;
|
|
1408
|
+
} | {
|
|
1409
|
+
reward_factor: number;
|
|
1410
|
+
achieved_support: number;
|
|
1411
|
+
target_support: number;
|
|
1412
|
+
difference: number;
|
|
1413
|
+
iterations: number;
|
|
1414
|
+
converged: boolean;
|
|
1415
|
+
};
|
|
1391
1416
|
declare class ExchangePosition {
|
|
1392
1417
|
exchange: BaseExchange;
|
|
1393
1418
|
exchange_account: ExchangeAccount$1;
|
|
@@ -1866,6 +1891,9 @@ declare class ExchangeAccount$1 {
|
|
|
1866
1891
|
symbol: string;
|
|
1867
1892
|
kind: "long" | "short";
|
|
1868
1893
|
}): Promise<number>;
|
|
1894
|
+
/**
|
|
1895
|
+
* This method is used to place the opposite trade action
|
|
1896
|
+
*/
|
|
1869
1897
|
placeOppositeTradeAction(payload: {
|
|
1870
1898
|
symbol: string;
|
|
1871
1899
|
kind: "long" | "short";
|
package/dist/index.js
CHANGED
|
@@ -54146,6 +54146,69 @@ function getHedgeZone(payload) {
|
|
|
54146
54146
|
profit_percent: to_f2(profit_percent, "%.2f")
|
|
54147
54147
|
};
|
|
54148
54148
|
}
|
|
54149
|
+
function getOptimumHedgeFactor(payload) {
|
|
54150
|
+
const {
|
|
54151
|
+
target_support,
|
|
54152
|
+
max_iterations = 50,
|
|
54153
|
+
min_factor = 0.1,
|
|
54154
|
+
max_factor = 20,
|
|
54155
|
+
symbol_config,
|
|
54156
|
+
risk,
|
|
54157
|
+
position: position2
|
|
54158
|
+
} = payload;
|
|
54159
|
+
const current_price = position2.entry;
|
|
54160
|
+
const tolerance = current_price > 100 ? 0.5 : current_price > 1 ? 0.01 : 0.001;
|
|
54161
|
+
let low = min_factor;
|
|
54162
|
+
let high = max_factor;
|
|
54163
|
+
let best_factor = low;
|
|
54164
|
+
let best_diff = Infinity;
|
|
54165
|
+
for (let iteration = 0;iteration < max_iterations; iteration++) {
|
|
54166
|
+
const mid_factor = (low + high) / 2;
|
|
54167
|
+
const hedge_zone = getHedgeZone({
|
|
54168
|
+
reward_factor: mid_factor,
|
|
54169
|
+
symbol_config,
|
|
54170
|
+
risk,
|
|
54171
|
+
position: position2
|
|
54172
|
+
});
|
|
54173
|
+
const current_support = hedge_zone.support;
|
|
54174
|
+
const diff = Math.abs(current_support - target_support);
|
|
54175
|
+
if (diff < best_diff) {
|
|
54176
|
+
best_diff = diff;
|
|
54177
|
+
best_factor = mid_factor;
|
|
54178
|
+
}
|
|
54179
|
+
if (diff <= tolerance) {
|
|
54180
|
+
return {
|
|
54181
|
+
reward_factor: to_f2(mid_factor, "%.4f"),
|
|
54182
|
+
achieved_support: to_f2(current_support, symbol_config.price_places),
|
|
54183
|
+
target_support: to_f2(target_support, symbol_config.price_places),
|
|
54184
|
+
difference: to_f2(diff, symbol_config.price_places),
|
|
54185
|
+
iterations: iteration + 1
|
|
54186
|
+
};
|
|
54187
|
+
}
|
|
54188
|
+
if (current_support > target_support) {
|
|
54189
|
+
low = mid_factor;
|
|
54190
|
+
} else {
|
|
54191
|
+
high = mid_factor;
|
|
54192
|
+
}
|
|
54193
|
+
if (Math.abs(high - low) < 0.0001) {
|
|
54194
|
+
break;
|
|
54195
|
+
}
|
|
54196
|
+
}
|
|
54197
|
+
const final_hedge_zone = getHedgeZone({
|
|
54198
|
+
symbol_config,
|
|
54199
|
+
risk,
|
|
54200
|
+
position: position2,
|
|
54201
|
+
reward_factor: best_factor
|
|
54202
|
+
});
|
|
54203
|
+
return {
|
|
54204
|
+
reward_factor: to_f2(best_factor, "%.4f"),
|
|
54205
|
+
achieved_support: to_f2(final_hedge_zone.support, symbol_config.price_places),
|
|
54206
|
+
target_support: to_f2(target_support, symbol_config.price_places),
|
|
54207
|
+
difference: to_f2(best_diff, symbol_config.price_places),
|
|
54208
|
+
iterations: max_iterations,
|
|
54209
|
+
converged: best_diff <= tolerance
|
|
54210
|
+
};
|
|
54211
|
+
}
|
|
54149
54212
|
|
|
54150
54213
|
// src/helpers/strategy.ts
|
|
54151
54214
|
class Strategy {
|
|
@@ -60115,6 +60178,7 @@ export {
|
|
|
60115
60178
|
get_app_config_and_max_size,
|
|
60116
60179
|
getRiskReward,
|
|
60117
60180
|
getOptimumStopAndRisk,
|
|
60181
|
+
getOptimumHedgeFactor,
|
|
60118
60182
|
getHedgeZone,
|
|
60119
60183
|
generate_config_params,
|
|
60120
60184
|
generateOptimumAppConfig,
|