@orderly.network/hooks 2.7.0 → 2.7.1
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/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -33,7 +33,7 @@ declare global {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
declare const _default: "2.7.
|
|
36
|
+
declare const _default: "2.7.1";
|
|
37
37
|
|
|
38
38
|
declare const fetcher: (url: string, init: RequestInit | undefined, queryOptions: useQueryOptions<any>) => Promise<any>;
|
|
39
39
|
type useQueryOptions<T> = SWRConfiguration & {
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ declare global {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
declare const _default: "2.7.
|
|
36
|
+
declare const _default: "2.7.1";
|
|
37
37
|
|
|
38
38
|
declare const fetcher: (url: string, init: RequestInit | undefined, queryOptions: useQueryOptions<any>) => Promise<any>;
|
|
39
39
|
type useQueryOptions<T> = SWRConfiguration & {
|
package/dist/index.js
CHANGED
|
@@ -61,9 +61,9 @@ var __export = (target, all) => {
|
|
|
61
61
|
// src/version.ts
|
|
62
62
|
if (typeof window !== "undefined") {
|
|
63
63
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
64
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.7.
|
|
64
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.7.1";
|
|
65
65
|
}
|
|
66
|
-
var version_default = "2.7.
|
|
66
|
+
var version_default = "2.7.1";
|
|
67
67
|
var fetcher = (url, init2 = {}, queryOptions) => net.get(url, init2, queryOptions?.formatter);
|
|
68
68
|
var noCacheConfig = {
|
|
69
69
|
dedupingInterval: 0,
|
|
@@ -1127,21 +1127,27 @@ function offsetPercentageToPrice(inputs) {
|
|
|
1127
1127
|
}
|
|
1128
1128
|
function priceToOffsetPercentage(inputs) {
|
|
1129
1129
|
const { price, entryPrice, orderType, orderSide } = inputs;
|
|
1130
|
+
const direction = utils.getTPSLDirection({
|
|
1131
|
+
side: orderSide,
|
|
1132
|
+
type: orderType === types.AlgoOrderType.TAKE_PROFIT ? "tp" : "sl",
|
|
1133
|
+
closePrice: price,
|
|
1134
|
+
orderPrice: entryPrice
|
|
1135
|
+
});
|
|
1130
1136
|
if (orderSide === types.OrderSide.BUY) {
|
|
1131
1137
|
if (entryPrice === 0)
|
|
1132
1138
|
return 0;
|
|
1133
1139
|
if (orderType === types.AlgoOrderType.TAKE_PROFIT) {
|
|
1134
|
-
return new utils.Decimal(price).div(new utils.Decimal(entryPrice)).minus(1).toDecimalPlaces(4, utils.Decimal.ROUND_DOWN).toNumber();
|
|
1140
|
+
return new utils.Decimal(price).div(new utils.Decimal(entryPrice)).minus(1).abs().mul(direction).toDecimalPlaces(4, utils.Decimal.ROUND_DOWN).toNumber();
|
|
1135
1141
|
}
|
|
1136
|
-
return new utils.Decimal(1).minus(new utils.Decimal(price).div(new utils.Decimal(entryPrice))).toDecimalPlaces(4, utils.Decimal.ROUND_DOWN).toNumber();
|
|
1142
|
+
return new utils.Decimal(1).minus(new utils.Decimal(price).div(new utils.Decimal(entryPrice))).abs().mul(direction).toDecimalPlaces(4, utils.Decimal.ROUND_DOWN).toNumber();
|
|
1137
1143
|
}
|
|
1138
1144
|
if (orderSide === types.OrderSide.SELL) {
|
|
1139
1145
|
if (entryPrice === 0)
|
|
1140
1146
|
return 0;
|
|
1141
1147
|
if (orderType === types.AlgoOrderType.TAKE_PROFIT) {
|
|
1142
|
-
return new utils.Decimal(1).minus(new utils.Decimal(price).div(new utils.Decimal(entryPrice))).abs().toDecimalPlaces(4, utils.Decimal.ROUND_DOWN).toNumber();
|
|
1148
|
+
return new utils.Decimal(1).minus(new utils.Decimal(price).div(new utils.Decimal(entryPrice))).abs().mul(direction).toDecimalPlaces(4, utils.Decimal.ROUND_DOWN).toNumber();
|
|
1143
1149
|
}
|
|
1144
|
-
return new utils.Decimal(price).div(new utils.Decimal(entryPrice)).minus(1).toDecimalPlaces(4, utils.Decimal.ROUND_DOWN).toNumber();
|
|
1150
|
+
return new utils.Decimal(price).div(new utils.Decimal(entryPrice)).minus(1).abs().mul(direction).toDecimalPlaces(4, utils.Decimal.ROUND_DOWN).toNumber();
|
|
1145
1151
|
}
|
|
1146
1152
|
}
|
|
1147
1153
|
function pnlToPrice(inputs) {
|
|
@@ -8222,7 +8228,7 @@ var BaseAlgoOrderCreator = class {
|
|
|
8222
8228
|
formatPrice2(quote_min, quote_dp)
|
|
8223
8229
|
);
|
|
8224
8230
|
}
|
|
8225
|
-
if (!!sl_trigger_price && Number(sl_trigger_price)
|
|
8231
|
+
if (!!sl_trigger_price && Number(sl_trigger_price) >= mark_price) {
|
|
8226
8232
|
result.sl_trigger_price = OrderValidation.max(
|
|
8227
8233
|
"sl_trigger_price",
|
|
8228
8234
|
formatPrice2(mark_price, quote_dp)
|
|
@@ -8292,7 +8298,7 @@ var BaseAlgoOrderCreator = class {
|
|
|
8292
8298
|
formatPrice2(quote_max, quote_dp)
|
|
8293
8299
|
);
|
|
8294
8300
|
}
|
|
8295
|
-
if (!!sl_trigger_price && Number(sl_trigger_price)
|
|
8301
|
+
if (!!sl_trigger_price && Number(sl_trigger_price) <= mark_price) {
|
|
8296
8302
|
result.sl_trigger_price = OrderValidation.min(
|
|
8297
8303
|
"sl_trigger_price",
|
|
8298
8304
|
formatPrice2(mark_price, quote_dp)
|