@gbozee/ultimate 0.0.2-next.70 → 0.0.2-next.72
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.cjs +56 -7
- package/dist/index.d.ts +20 -0
- package/dist/index.js +56 -7
- package/dist/mcp-server.cjs +56 -7
- package/dist/mcp-server.js +56 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -72036,14 +72036,13 @@ class BaseExchange {
|
|
|
72036
72036
|
}
|
|
72037
72037
|
}
|
|
72038
72038
|
async placeSpotLimitOrders(_payload) {}
|
|
72039
|
-
async
|
|
72039
|
+
async buildCumulative(payload) {
|
|
72040
72040
|
const {
|
|
72041
72041
|
orders,
|
|
72042
72042
|
kind,
|
|
72043
72043
|
decimal_places = "%.3f",
|
|
72044
|
-
price_places = "%.1f",
|
|
72045
72044
|
symbol,
|
|
72046
|
-
|
|
72045
|
+
is_stop = false
|
|
72047
72046
|
} = payload;
|
|
72048
72047
|
const totalQuantity = orders.reduce((sum, order) => sum + (order.quantity || 0), 0);
|
|
72049
72048
|
let runningTotal = to_f(totalQuantity, decimal_places);
|
|
@@ -72051,6 +72050,9 @@ class BaseExchange {
|
|
|
72051
72050
|
if (kind === "short") {
|
|
72052
72051
|
sortedOrders.reverse();
|
|
72053
72052
|
}
|
|
72053
|
+
if (is_stop) {
|
|
72054
|
+
sortedOrders.reverse();
|
|
72055
|
+
}
|
|
72054
72056
|
const withCumulative = [];
|
|
72055
72057
|
for (const order of sortedOrders) {
|
|
72056
72058
|
withCumulative.push({
|
|
@@ -72073,6 +72075,17 @@ class BaseExchange {
|
|
|
72073
72075
|
kind,
|
|
72074
72076
|
side: kind.toLowerCase() === "long" ? "buy" : "sell"
|
|
72075
72077
|
}));
|
|
72078
|
+
return filteredOrders;
|
|
72079
|
+
}
|
|
72080
|
+
async bulkPlaceLimitOrders(payload) {
|
|
72081
|
+
const {
|
|
72082
|
+
kind,
|
|
72083
|
+
decimal_places = "%.3f",
|
|
72084
|
+
price_places = "%.1f",
|
|
72085
|
+
symbol,
|
|
72086
|
+
place = false
|
|
72087
|
+
} = payload;
|
|
72088
|
+
const filteredOrders = await this.buildCumulative(payload);
|
|
72076
72089
|
if (filteredOrders.length > 0 && place) {
|
|
72077
72090
|
await this.cancelAllOrders(symbol, {
|
|
72078
72091
|
type: "limit",
|
|
@@ -72216,6 +72229,44 @@ class BaseExchange {
|
|
|
72216
72229
|
]
|
|
72217
72230
|
});
|
|
72218
72231
|
}
|
|
72232
|
+
async entryStopLimitOrders(payload) {
|
|
72233
|
+
const { symbol, kind, price_places, decimal_places, place } = payload;
|
|
72234
|
+
const cummulative = await this.buildCumulative({
|
|
72235
|
+
...payload,
|
|
72236
|
+
is_stop: true
|
|
72237
|
+
});
|
|
72238
|
+
const price = await this.get_current_price(symbol);
|
|
72239
|
+
const orders_to_place = cummulative.map((order) => {
|
|
72240
|
+
const { entry } = order;
|
|
72241
|
+
let spread = 0.005;
|
|
72242
|
+
if (price < 5000) {
|
|
72243
|
+
spread = 0.02;
|
|
72244
|
+
}
|
|
72245
|
+
let full_spread = spread / 100 + 1;
|
|
72246
|
+
const stop = kind === "long" ? entry * full_spread ** -1 : entry * full_spread;
|
|
72247
|
+
const side = kind === "long" ? "buy" : "sell";
|
|
72248
|
+
return {
|
|
72249
|
+
price: order.entry,
|
|
72250
|
+
quantity: order.quantity,
|
|
72251
|
+
stop: to_f(stop, price_places || "%.3f"),
|
|
72252
|
+
side,
|
|
72253
|
+
kind,
|
|
72254
|
+
is_market: false
|
|
72255
|
+
};
|
|
72256
|
+
});
|
|
72257
|
+
if (place && orders_to_place.length > 0) {
|
|
72258
|
+
await this.cancelAllOrders(symbol, {
|
|
72259
|
+
kind
|
|
72260
|
+
});
|
|
72261
|
+
return this._createLimitPurchaseOrders({
|
|
72262
|
+
symbol,
|
|
72263
|
+
price_places,
|
|
72264
|
+
decimal_places,
|
|
72265
|
+
orders: orders_to_place
|
|
72266
|
+
});
|
|
72267
|
+
}
|
|
72268
|
+
return orders_to_place;
|
|
72269
|
+
}
|
|
72219
72270
|
async customStopLoss(payload) {
|
|
72220
72271
|
const {
|
|
72221
72272
|
symbol,
|
|
@@ -77153,10 +77204,8 @@ async function placeStopOrder3(client, payload) {
|
|
|
77153
77204
|
validateQuantity: false,
|
|
77154
77205
|
validatePrice: false
|
|
77155
77206
|
});
|
|
77156
|
-
const
|
|
77157
|
-
|
|
77158
|
-
stop_loss
|
|
77159
|
-
];
|
|
77207
|
+
const filtered = (existingStops || []).filter((s2) => s2.price !== stop_loss.price);
|
|
77208
|
+
const all_stop_losses = [...filtered, stop_loss];
|
|
77160
77209
|
return savePaperDetails(client, {
|
|
77161
77210
|
kind: order.kind,
|
|
77162
77211
|
symbol: payload.symbol,
|
package/dist/index.d.ts
CHANGED
|
@@ -373,6 +373,15 @@ declare abstract class BaseExchange {
|
|
|
373
373
|
cancel?: boolean;
|
|
374
374
|
}): Promise<any>;
|
|
375
375
|
placeSpotLimitOrders(_payload: any): Promise<void>;
|
|
376
|
+
buildCumulative(payload: {
|
|
377
|
+
orders: Order$1[];
|
|
378
|
+
kind: "long" | "short";
|
|
379
|
+
decimal_places?: string;
|
|
380
|
+
price_places?: string;
|
|
381
|
+
symbol: string;
|
|
382
|
+
place?: boolean;
|
|
383
|
+
is_stop?: boolean;
|
|
384
|
+
}): Promise<any[]>;
|
|
376
385
|
bulkPlaceLimitOrders(payload: {
|
|
377
386
|
orders: Order$1[];
|
|
378
387
|
kind: "long" | "short";
|
|
@@ -517,6 +526,17 @@ declare abstract class BaseExchange {
|
|
|
517
526
|
decimal_places?: string;
|
|
518
527
|
close?: boolean;
|
|
519
528
|
}): Promise<any>;
|
|
529
|
+
entryStopLimitOrders(payload: {
|
|
530
|
+
symbol: string;
|
|
531
|
+
kind: "long" | "short";
|
|
532
|
+
orders: Array<{
|
|
533
|
+
entry: number;
|
|
534
|
+
quantity: number;
|
|
535
|
+
}>;
|
|
536
|
+
price_places?: string;
|
|
537
|
+
decimal_places?: string;
|
|
538
|
+
place?: boolean;
|
|
539
|
+
}): Promise<any>;
|
|
520
540
|
customStopLoss(payload: {
|
|
521
541
|
price_places: string;
|
|
522
542
|
decimal_places: string;
|
package/dist/index.js
CHANGED
|
@@ -71934,14 +71934,13 @@ class BaseExchange {
|
|
|
71934
71934
|
}
|
|
71935
71935
|
}
|
|
71936
71936
|
async placeSpotLimitOrders(_payload) {}
|
|
71937
|
-
async
|
|
71937
|
+
async buildCumulative(payload) {
|
|
71938
71938
|
const {
|
|
71939
71939
|
orders,
|
|
71940
71940
|
kind,
|
|
71941
71941
|
decimal_places = "%.3f",
|
|
71942
|
-
price_places = "%.1f",
|
|
71943
71942
|
symbol,
|
|
71944
|
-
|
|
71943
|
+
is_stop = false
|
|
71945
71944
|
} = payload;
|
|
71946
71945
|
const totalQuantity = orders.reduce((sum, order) => sum + (order.quantity || 0), 0);
|
|
71947
71946
|
let runningTotal = to_f(totalQuantity, decimal_places);
|
|
@@ -71949,6 +71948,9 @@ class BaseExchange {
|
|
|
71949
71948
|
if (kind === "short") {
|
|
71950
71949
|
sortedOrders.reverse();
|
|
71951
71950
|
}
|
|
71951
|
+
if (is_stop) {
|
|
71952
|
+
sortedOrders.reverse();
|
|
71953
|
+
}
|
|
71952
71954
|
const withCumulative = [];
|
|
71953
71955
|
for (const order of sortedOrders) {
|
|
71954
71956
|
withCumulative.push({
|
|
@@ -71971,6 +71973,17 @@ class BaseExchange {
|
|
|
71971
71973
|
kind,
|
|
71972
71974
|
side: kind.toLowerCase() === "long" ? "buy" : "sell"
|
|
71973
71975
|
}));
|
|
71976
|
+
return filteredOrders;
|
|
71977
|
+
}
|
|
71978
|
+
async bulkPlaceLimitOrders(payload) {
|
|
71979
|
+
const {
|
|
71980
|
+
kind,
|
|
71981
|
+
decimal_places = "%.3f",
|
|
71982
|
+
price_places = "%.1f",
|
|
71983
|
+
symbol,
|
|
71984
|
+
place = false
|
|
71985
|
+
} = payload;
|
|
71986
|
+
const filteredOrders = await this.buildCumulative(payload);
|
|
71974
71987
|
if (filteredOrders.length > 0 && place) {
|
|
71975
71988
|
await this.cancelAllOrders(symbol, {
|
|
71976
71989
|
type: "limit",
|
|
@@ -72114,6 +72127,44 @@ class BaseExchange {
|
|
|
72114
72127
|
]
|
|
72115
72128
|
});
|
|
72116
72129
|
}
|
|
72130
|
+
async entryStopLimitOrders(payload) {
|
|
72131
|
+
const { symbol, kind, price_places, decimal_places, place } = payload;
|
|
72132
|
+
const cummulative = await this.buildCumulative({
|
|
72133
|
+
...payload,
|
|
72134
|
+
is_stop: true
|
|
72135
|
+
});
|
|
72136
|
+
const price = await this.get_current_price(symbol);
|
|
72137
|
+
const orders_to_place = cummulative.map((order) => {
|
|
72138
|
+
const { entry } = order;
|
|
72139
|
+
let spread = 0.005;
|
|
72140
|
+
if (price < 5000) {
|
|
72141
|
+
spread = 0.02;
|
|
72142
|
+
}
|
|
72143
|
+
let full_spread = spread / 100 + 1;
|
|
72144
|
+
const stop = kind === "long" ? entry * full_spread ** -1 : entry * full_spread;
|
|
72145
|
+
const side = kind === "long" ? "buy" : "sell";
|
|
72146
|
+
return {
|
|
72147
|
+
price: order.entry,
|
|
72148
|
+
quantity: order.quantity,
|
|
72149
|
+
stop: to_f(stop, price_places || "%.3f"),
|
|
72150
|
+
side,
|
|
72151
|
+
kind,
|
|
72152
|
+
is_market: false
|
|
72153
|
+
};
|
|
72154
|
+
});
|
|
72155
|
+
if (place && orders_to_place.length > 0) {
|
|
72156
|
+
await this.cancelAllOrders(symbol, {
|
|
72157
|
+
kind
|
|
72158
|
+
});
|
|
72159
|
+
return this._createLimitPurchaseOrders({
|
|
72160
|
+
symbol,
|
|
72161
|
+
price_places,
|
|
72162
|
+
decimal_places,
|
|
72163
|
+
orders: orders_to_place
|
|
72164
|
+
});
|
|
72165
|
+
}
|
|
72166
|
+
return orders_to_place;
|
|
72167
|
+
}
|
|
72117
72168
|
async customStopLoss(payload) {
|
|
72118
72169
|
const {
|
|
72119
72170
|
symbol,
|
|
@@ -77051,10 +77102,8 @@ async function placeStopOrder3(client, payload) {
|
|
|
77051
77102
|
validateQuantity: false,
|
|
77052
77103
|
validatePrice: false
|
|
77053
77104
|
});
|
|
77054
|
-
const
|
|
77055
|
-
|
|
77056
|
-
stop_loss
|
|
77057
|
-
];
|
|
77105
|
+
const filtered = (existingStops || []).filter((s2) => s2.price !== stop_loss.price);
|
|
77106
|
+
const all_stop_losses = [...filtered, stop_loss];
|
|
77058
77107
|
return savePaperDetails(client, {
|
|
77059
77108
|
kind: order.kind,
|
|
77060
77109
|
symbol: payload.symbol,
|
package/dist/mcp-server.cjs
CHANGED
|
@@ -75758,14 +75758,13 @@ class BaseExchange {
|
|
|
75758
75758
|
}
|
|
75759
75759
|
}
|
|
75760
75760
|
async placeSpotLimitOrders(_payload) {}
|
|
75761
|
-
async
|
|
75761
|
+
async buildCumulative(payload) {
|
|
75762
75762
|
const {
|
|
75763
75763
|
orders,
|
|
75764
75764
|
kind,
|
|
75765
75765
|
decimal_places = "%.3f",
|
|
75766
|
-
price_places = "%.1f",
|
|
75767
75766
|
symbol,
|
|
75768
|
-
|
|
75767
|
+
is_stop = false
|
|
75769
75768
|
} = payload;
|
|
75770
75769
|
const totalQuantity = orders.reduce((sum, order) => sum + (order.quantity || 0), 0);
|
|
75771
75770
|
let runningTotal = to_f(totalQuantity, decimal_places);
|
|
@@ -75773,6 +75772,9 @@ class BaseExchange {
|
|
|
75773
75772
|
if (kind === "short") {
|
|
75774
75773
|
sortedOrders.reverse();
|
|
75775
75774
|
}
|
|
75775
|
+
if (is_stop) {
|
|
75776
|
+
sortedOrders.reverse();
|
|
75777
|
+
}
|
|
75776
75778
|
const withCumulative = [];
|
|
75777
75779
|
for (const order of sortedOrders) {
|
|
75778
75780
|
withCumulative.push({
|
|
@@ -75795,6 +75797,17 @@ class BaseExchange {
|
|
|
75795
75797
|
kind,
|
|
75796
75798
|
side: kind.toLowerCase() === "long" ? "buy" : "sell"
|
|
75797
75799
|
}));
|
|
75800
|
+
return filteredOrders;
|
|
75801
|
+
}
|
|
75802
|
+
async bulkPlaceLimitOrders(payload) {
|
|
75803
|
+
const {
|
|
75804
|
+
kind,
|
|
75805
|
+
decimal_places = "%.3f",
|
|
75806
|
+
price_places = "%.1f",
|
|
75807
|
+
symbol,
|
|
75808
|
+
place = false
|
|
75809
|
+
} = payload;
|
|
75810
|
+
const filteredOrders = await this.buildCumulative(payload);
|
|
75798
75811
|
if (filteredOrders.length > 0 && place) {
|
|
75799
75812
|
await this.cancelAllOrders(symbol, {
|
|
75800
75813
|
type: "limit",
|
|
@@ -75938,6 +75951,44 @@ class BaseExchange {
|
|
|
75938
75951
|
]
|
|
75939
75952
|
});
|
|
75940
75953
|
}
|
|
75954
|
+
async entryStopLimitOrders(payload) {
|
|
75955
|
+
const { symbol, kind, price_places, decimal_places, place } = payload;
|
|
75956
|
+
const cummulative = await this.buildCumulative({
|
|
75957
|
+
...payload,
|
|
75958
|
+
is_stop: true
|
|
75959
|
+
});
|
|
75960
|
+
const price = await this.get_current_price(symbol);
|
|
75961
|
+
const orders_to_place = cummulative.map((order) => {
|
|
75962
|
+
const { entry } = order;
|
|
75963
|
+
let spread = 0.005;
|
|
75964
|
+
if (price < 5000) {
|
|
75965
|
+
spread = 0.02;
|
|
75966
|
+
}
|
|
75967
|
+
let full_spread = spread / 100 + 1;
|
|
75968
|
+
const stop = kind === "long" ? entry * full_spread ** -1 : entry * full_spread;
|
|
75969
|
+
const side = kind === "long" ? "buy" : "sell";
|
|
75970
|
+
return {
|
|
75971
|
+
price: order.entry,
|
|
75972
|
+
quantity: order.quantity,
|
|
75973
|
+
stop: to_f(stop, price_places || "%.3f"),
|
|
75974
|
+
side,
|
|
75975
|
+
kind,
|
|
75976
|
+
is_market: false
|
|
75977
|
+
};
|
|
75978
|
+
});
|
|
75979
|
+
if (place && orders_to_place.length > 0) {
|
|
75980
|
+
await this.cancelAllOrders(symbol, {
|
|
75981
|
+
kind
|
|
75982
|
+
});
|
|
75983
|
+
return this._createLimitPurchaseOrders({
|
|
75984
|
+
symbol,
|
|
75985
|
+
price_places,
|
|
75986
|
+
decimal_places,
|
|
75987
|
+
orders: orders_to_place
|
|
75988
|
+
});
|
|
75989
|
+
}
|
|
75990
|
+
return orders_to_place;
|
|
75991
|
+
}
|
|
75941
75992
|
async customStopLoss(payload) {
|
|
75942
75993
|
const {
|
|
75943
75994
|
symbol,
|
|
@@ -80875,10 +80926,8 @@ async function placeStopOrder3(client, payload) {
|
|
|
80875
80926
|
validateQuantity: false,
|
|
80876
80927
|
validatePrice: false
|
|
80877
80928
|
});
|
|
80878
|
-
const
|
|
80879
|
-
|
|
80880
|
-
stop_loss
|
|
80881
|
-
];
|
|
80929
|
+
const filtered = (existingStops || []).filter((s2) => s2.price !== stop_loss.price);
|
|
80930
|
+
const all_stop_losses = [...filtered, stop_loss];
|
|
80882
80931
|
return savePaperDetails(client, {
|
|
80883
80932
|
kind: order.kind,
|
|
80884
80933
|
symbol: payload.symbol,
|
package/dist/mcp-server.js
CHANGED
|
@@ -75717,14 +75717,13 @@ class BaseExchange {
|
|
|
75717
75717
|
}
|
|
75718
75718
|
}
|
|
75719
75719
|
async placeSpotLimitOrders(_payload) {}
|
|
75720
|
-
async
|
|
75720
|
+
async buildCumulative(payload) {
|
|
75721
75721
|
const {
|
|
75722
75722
|
orders,
|
|
75723
75723
|
kind,
|
|
75724
75724
|
decimal_places = "%.3f",
|
|
75725
|
-
price_places = "%.1f",
|
|
75726
75725
|
symbol,
|
|
75727
|
-
|
|
75726
|
+
is_stop = false
|
|
75728
75727
|
} = payload;
|
|
75729
75728
|
const totalQuantity = orders.reduce((sum, order) => sum + (order.quantity || 0), 0);
|
|
75730
75729
|
let runningTotal = to_f(totalQuantity, decimal_places);
|
|
@@ -75732,6 +75731,9 @@ class BaseExchange {
|
|
|
75732
75731
|
if (kind === "short") {
|
|
75733
75732
|
sortedOrders.reverse();
|
|
75734
75733
|
}
|
|
75734
|
+
if (is_stop) {
|
|
75735
|
+
sortedOrders.reverse();
|
|
75736
|
+
}
|
|
75735
75737
|
const withCumulative = [];
|
|
75736
75738
|
for (const order of sortedOrders) {
|
|
75737
75739
|
withCumulative.push({
|
|
@@ -75754,6 +75756,17 @@ class BaseExchange {
|
|
|
75754
75756
|
kind,
|
|
75755
75757
|
side: kind.toLowerCase() === "long" ? "buy" : "sell"
|
|
75756
75758
|
}));
|
|
75759
|
+
return filteredOrders;
|
|
75760
|
+
}
|
|
75761
|
+
async bulkPlaceLimitOrders(payload) {
|
|
75762
|
+
const {
|
|
75763
|
+
kind,
|
|
75764
|
+
decimal_places = "%.3f",
|
|
75765
|
+
price_places = "%.1f",
|
|
75766
|
+
symbol,
|
|
75767
|
+
place = false
|
|
75768
|
+
} = payload;
|
|
75769
|
+
const filteredOrders = await this.buildCumulative(payload);
|
|
75757
75770
|
if (filteredOrders.length > 0 && place) {
|
|
75758
75771
|
await this.cancelAllOrders(symbol, {
|
|
75759
75772
|
type: "limit",
|
|
@@ -75897,6 +75910,44 @@ class BaseExchange {
|
|
|
75897
75910
|
]
|
|
75898
75911
|
});
|
|
75899
75912
|
}
|
|
75913
|
+
async entryStopLimitOrders(payload) {
|
|
75914
|
+
const { symbol, kind, price_places, decimal_places, place } = payload;
|
|
75915
|
+
const cummulative = await this.buildCumulative({
|
|
75916
|
+
...payload,
|
|
75917
|
+
is_stop: true
|
|
75918
|
+
});
|
|
75919
|
+
const price = await this.get_current_price(symbol);
|
|
75920
|
+
const orders_to_place = cummulative.map((order) => {
|
|
75921
|
+
const { entry } = order;
|
|
75922
|
+
let spread = 0.005;
|
|
75923
|
+
if (price < 5000) {
|
|
75924
|
+
spread = 0.02;
|
|
75925
|
+
}
|
|
75926
|
+
let full_spread = spread / 100 + 1;
|
|
75927
|
+
const stop = kind === "long" ? entry * full_spread ** -1 : entry * full_spread;
|
|
75928
|
+
const side = kind === "long" ? "buy" : "sell";
|
|
75929
|
+
return {
|
|
75930
|
+
price: order.entry,
|
|
75931
|
+
quantity: order.quantity,
|
|
75932
|
+
stop: to_f(stop, price_places || "%.3f"),
|
|
75933
|
+
side,
|
|
75934
|
+
kind,
|
|
75935
|
+
is_market: false
|
|
75936
|
+
};
|
|
75937
|
+
});
|
|
75938
|
+
if (place && orders_to_place.length > 0) {
|
|
75939
|
+
await this.cancelAllOrders(symbol, {
|
|
75940
|
+
kind
|
|
75941
|
+
});
|
|
75942
|
+
return this._createLimitPurchaseOrders({
|
|
75943
|
+
symbol,
|
|
75944
|
+
price_places,
|
|
75945
|
+
decimal_places,
|
|
75946
|
+
orders: orders_to_place
|
|
75947
|
+
});
|
|
75948
|
+
}
|
|
75949
|
+
return orders_to_place;
|
|
75950
|
+
}
|
|
75900
75951
|
async customStopLoss(payload) {
|
|
75901
75952
|
const {
|
|
75902
75953
|
symbol,
|
|
@@ -80834,10 +80885,8 @@ async function placeStopOrder3(client, payload) {
|
|
|
80834
80885
|
validateQuantity: false,
|
|
80835
80886
|
validatePrice: false
|
|
80836
80887
|
});
|
|
80837
|
-
const
|
|
80838
|
-
|
|
80839
|
-
stop_loss
|
|
80840
|
-
];
|
|
80888
|
+
const filtered = (existingStops || []).filter((s2) => s2.price !== stop_loss.price);
|
|
80889
|
+
const all_stop_losses = [...filtered, stop_loss];
|
|
80841
80890
|
return savePaperDetails(client, {
|
|
80842
80891
|
kind: order.kind,
|
|
80843
80892
|
symbol: payload.symbol,
|