@gbozee/ultimate 0.0.2-122 → 0.0.2-124
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 +2 -0
- package/dist/frontend-index.js +17 -7
- package/dist/index.cjs +36 -13
- package/dist/index.d.ts +11 -4
- package/dist/index.js +36 -13
- package/dist/mcp-server.cjs +36 -13
- package/dist/mcp-server.js +36 -13
- package/package.json +1 -1
package/dist/frontend-index.d.ts
CHANGED
|
@@ -295,6 +295,7 @@ export type AppConfig = {
|
|
|
295
295
|
max_size?: number;
|
|
296
296
|
last_value?: any;
|
|
297
297
|
entries?: any[];
|
|
298
|
+
max_quantity?: number;
|
|
298
299
|
};
|
|
299
300
|
export type ExtendConfigType = {
|
|
300
301
|
take_profit?: number;
|
|
@@ -761,6 +762,7 @@ export declare class Strategy {
|
|
|
761
762
|
gap?: number;
|
|
762
763
|
rr?: number;
|
|
763
764
|
max_size?: number;
|
|
765
|
+
max_quantity?: number;
|
|
764
766
|
};
|
|
765
767
|
identifyGapConfig(payload: {
|
|
766
768
|
factor?: number;
|
package/dist/frontend-index.js
CHANGED
|
@@ -1195,6 +1195,22 @@ function determineTPSl(payload) {
|
|
|
1195
1195
|
};
|
|
1196
1196
|
}
|
|
1197
1197
|
// src/helpers/shared.ts
|
|
1198
|
+
function getMaxQuantity(x, app_config) {
|
|
1199
|
+
let max_quantity = app_config.max_quantity;
|
|
1200
|
+
if (max_quantity) {
|
|
1201
|
+
return x <= max_quantity;
|
|
1202
|
+
}
|
|
1203
|
+
if (app_config.symbol === "BTCUSDT") {
|
|
1204
|
+
max_quantity = 0.03;
|
|
1205
|
+
}
|
|
1206
|
+
if (app_config.symbol?.toLowerCase().startsWith("sol")) {
|
|
1207
|
+
max_quantity = 2;
|
|
1208
|
+
}
|
|
1209
|
+
if (!max_quantity) {
|
|
1210
|
+
return true;
|
|
1211
|
+
}
|
|
1212
|
+
return x <= max_quantity;
|
|
1213
|
+
}
|
|
1198
1214
|
function buildConfig(app_config, {
|
|
1199
1215
|
take_profit,
|
|
1200
1216
|
entry,
|
|
@@ -1269,13 +1285,7 @@ function buildAvg({
|
|
|
1269
1285
|
}
|
|
1270
1286
|
function sortedBuildConfig(app_config, options) {
|
|
1271
1287
|
const sorted = buildConfig(app_config, options).sort((a, b) => app_config.kind === "long" ? a.entry - b.entry : b.entry - b.entry).filter((x) => {
|
|
1272
|
-
|
|
1273
|
-
return x.quantity <= 0.03;
|
|
1274
|
-
}
|
|
1275
|
-
if (app_config.symbol?.toLowerCase().startsWith("sol")) {
|
|
1276
|
-
return x.quantity <= 2;
|
|
1277
|
-
}
|
|
1278
|
-
return true;
|
|
1288
|
+
return getMaxQuantity(x.quantity, app_config);
|
|
1279
1289
|
});
|
|
1280
1290
|
return sorted.map((k, i) => {
|
|
1281
1291
|
const arrSet = sorted.slice(0, i + 1);
|
package/dist/index.cjs
CHANGED
|
@@ -51971,7 +51971,7 @@ class AppDatabase {
|
|
|
51971
51971
|
}
|
|
51972
51972
|
}
|
|
51973
51973
|
async cancelLimitOrders(payload) {
|
|
51974
|
-
const { symbol, kind, account, cancelExchangeOrders } = payload;
|
|
51974
|
+
const { symbol, kind, account, cancelExchangeOrders, raw } = payload;
|
|
51975
51975
|
const side = kind === "long" ? "buy" : "sell";
|
|
51976
51976
|
const orders = await this.pb.collection("orders").getFullList({
|
|
51977
51977
|
filter: `symbol:lower="${symbol.toLowerCase()}" && account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}" && kind="${kind}" && side:lower="${side}" && stop = 0`
|
|
@@ -51981,6 +51981,9 @@ class AppDatabase {
|
|
|
51981
51981
|
filter: `symbol:lower="${symbol.toLowerCase()}" && account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}" && kind="${kind}" && side:lower="${stop_side}" && stop > 0`
|
|
51982
51982
|
});
|
|
51983
51983
|
const exchange_order_ids = orders.concat(existing_stop_orders).map((o) => account.exchange === "bybit" ? o.order_id : parseInt(o.order_id, 10));
|
|
51984
|
+
if (raw) {
|
|
51985
|
+
return exchange_order_ids;
|
|
51986
|
+
}
|
|
51984
51987
|
try {
|
|
51985
51988
|
console.log(`Attempting to cancel ${exchange_order_ids.length} orders on ${account.exchange} for ${account.owner}...`);
|
|
51986
51989
|
const cancel_result = await cancelExchangeOrders({
|
|
@@ -53496,6 +53499,22 @@ class Signal {
|
|
|
53496
53499
|
}
|
|
53497
53500
|
|
|
53498
53501
|
// src/helpers/shared.ts
|
|
53502
|
+
function getMaxQuantity(x, app_config) {
|
|
53503
|
+
let max_quantity = app_config.max_quantity;
|
|
53504
|
+
if (max_quantity) {
|
|
53505
|
+
return x <= max_quantity;
|
|
53506
|
+
}
|
|
53507
|
+
if (app_config.symbol === "BTCUSDT") {
|
|
53508
|
+
max_quantity = 0.03;
|
|
53509
|
+
}
|
|
53510
|
+
if (app_config.symbol?.toLowerCase().startsWith("sol")) {
|
|
53511
|
+
max_quantity = 2;
|
|
53512
|
+
}
|
|
53513
|
+
if (!max_quantity) {
|
|
53514
|
+
return true;
|
|
53515
|
+
}
|
|
53516
|
+
return x <= max_quantity;
|
|
53517
|
+
}
|
|
53499
53518
|
function buildConfig(app_config, {
|
|
53500
53519
|
take_profit,
|
|
53501
53520
|
entry,
|
|
@@ -53570,13 +53589,7 @@ function buildAvg({
|
|
|
53570
53589
|
}
|
|
53571
53590
|
function sortedBuildConfig(app_config, options) {
|
|
53572
53591
|
const sorted = buildConfig(app_config, options).sort((a, b) => app_config.kind === "long" ? a.entry - b.entry : b.entry - b.entry).filter((x) => {
|
|
53573
|
-
|
|
53574
|
-
return x.quantity <= 0.03;
|
|
53575
|
-
}
|
|
53576
|
-
if (app_config.symbol?.toLowerCase().startsWith("sol")) {
|
|
53577
|
-
return x.quantity <= 2;
|
|
53578
|
-
}
|
|
53579
|
-
return true;
|
|
53592
|
+
return getMaxQuantity(x.quantity, app_config);
|
|
53580
53593
|
});
|
|
53581
53594
|
return sorted.map((k, i2) => {
|
|
53582
53595
|
const arrSet = sorted.slice(0, i2 + 1);
|
|
@@ -56279,6 +56292,7 @@ async function cancelOrdersParallel(payload) {
|
|
|
56279
56292
|
|
|
56280
56293
|
// src/exchanges/bybit.ts
|
|
56281
56294
|
var import_bybit_api = __toESM(require_lib3());
|
|
56295
|
+
var import_p_limit2 = __toESM(require_p_limit());
|
|
56282
56296
|
async function initClient2(credentials, options) {
|
|
56283
56297
|
const { proxyAgent } = options;
|
|
56284
56298
|
try {
|
|
@@ -56385,14 +56399,22 @@ async function getPositionInfo2(client, symbol) {
|
|
|
56385
56399
|
const short = result.find((x) => x.side.toLowerCase() === "sell");
|
|
56386
56400
|
return { long, short };
|
|
56387
56401
|
}
|
|
56402
|
+
var ORDERS_PER_SECONDS = 10;
|
|
56403
|
+
var BATCH_SIZE2 = 10;
|
|
56388
56404
|
async function cancelOrders2(payload) {
|
|
56389
56405
|
const client = payload.custom_client;
|
|
56390
56406
|
const results = [];
|
|
56391
|
-
|
|
56392
|
-
|
|
56393
|
-
|
|
56407
|
+
const batches = [];
|
|
56408
|
+
for (let i2 = 0;i2 < payload.orders.length; i2 += BATCH_SIZE2) {
|
|
56409
|
+
batches.push(payload.orders.slice(i2, i2 + BATCH_SIZE2));
|
|
56410
|
+
}
|
|
56411
|
+
const limit = import_p_limit2.default(ORDERS_PER_SECONDS);
|
|
56412
|
+
for (let i2 = 0;i2 < batches.length; i2++) {
|
|
56413
|
+
const batch2 = batches[i2];
|
|
56414
|
+
let rr = await limit(async () => {
|
|
56415
|
+
return await client.batchCancelOrders("linear", batch2.map((x) => ({ orderId: x.orderId, symbol: payload.symbol })));
|
|
56416
|
+
});
|
|
56394
56417
|
results.push(rr);
|
|
56395
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
56396
56418
|
}
|
|
56397
56419
|
return results;
|
|
56398
56420
|
}
|
|
@@ -57808,7 +57830,7 @@ class ExchangeAccount {
|
|
|
57808
57830
|
}
|
|
57809
57831
|
}
|
|
57810
57832
|
async cancelOrders(payload) {
|
|
57811
|
-
const { symbol, kind, price: _price, all, stop, limit } = payload;
|
|
57833
|
+
const { symbol, kind, price: _price, all, stop, limit, raw } = payload;
|
|
57812
57834
|
let price = _price || 0;
|
|
57813
57835
|
await this.syncAccount({
|
|
57814
57836
|
symbol,
|
|
@@ -57817,6 +57839,7 @@ class ExchangeAccount {
|
|
|
57817
57839
|
});
|
|
57818
57840
|
if (limit) {
|
|
57819
57841
|
return await this.app_db.cancelLimitOrders({
|
|
57842
|
+
raw,
|
|
57820
57843
|
symbol,
|
|
57821
57844
|
kind,
|
|
57822
57845
|
account: this.instance,
|
package/dist/index.d.ts
CHANGED
|
@@ -656,11 +656,12 @@ export declare class AppDatabase {
|
|
|
656
656
|
symbol: string;
|
|
657
657
|
kind: "long" | "short";
|
|
658
658
|
account: ExchangeType;
|
|
659
|
+
raw?: boolean;
|
|
659
660
|
cancelExchangeOrders: (payload: {
|
|
660
661
|
symbol: string;
|
|
661
662
|
orders: number[];
|
|
662
663
|
}) => Promise<any>;
|
|
663
|
-
}): Promise<
|
|
664
|
+
}): Promise<any[]>;
|
|
664
665
|
cancelOrders(payload: {
|
|
665
666
|
cancelExchangeOrders: (payload: {
|
|
666
667
|
symbol: string;
|
|
@@ -961,6 +962,7 @@ export declare class Strategy {
|
|
|
961
962
|
gap?: number;
|
|
962
963
|
rr?: number;
|
|
963
964
|
max_size?: number;
|
|
965
|
+
max_quantity?: number;
|
|
964
966
|
};
|
|
965
967
|
identifyGapConfig(payload: {
|
|
966
968
|
factor?: number;
|
|
@@ -1217,6 +1219,7 @@ export type AppConfig = {
|
|
|
1217
1219
|
max_size?: number;
|
|
1218
1220
|
last_value?: any;
|
|
1219
1221
|
entries?: any[];
|
|
1222
|
+
max_quantity?: number;
|
|
1220
1223
|
};
|
|
1221
1224
|
export type ExtendConfigType = {
|
|
1222
1225
|
take_profit?: number;
|
|
@@ -1516,7 +1519,7 @@ declare class ExchangePosition {
|
|
|
1516
1519
|
cancelOrders(payload: {
|
|
1517
1520
|
limit?: boolean;
|
|
1518
1521
|
price?: number;
|
|
1519
|
-
}): Promise<
|
|
1522
|
+
}): Promise<any[] | {
|
|
1520
1523
|
success: boolean;
|
|
1521
1524
|
message: string;
|
|
1522
1525
|
exchange_result?: undefined;
|
|
@@ -1710,7 +1713,8 @@ declare class ExchangeAccount$1 {
|
|
|
1710
1713
|
all?: boolean;
|
|
1711
1714
|
stop?: boolean;
|
|
1712
1715
|
limit?: boolean;
|
|
1713
|
-
|
|
1716
|
+
raw?: boolean;
|
|
1717
|
+
}): Promise<any[] | {
|
|
1714
1718
|
success: boolean;
|
|
1715
1719
|
message: string;
|
|
1716
1720
|
exchange_result?: undefined;
|
|
@@ -2052,6 +2056,7 @@ declare class ExchangeAccount$1 {
|
|
|
2052
2056
|
gap?: number;
|
|
2053
2057
|
rr?: number;
|
|
2054
2058
|
max_size?: number;
|
|
2059
|
+
max_quantity?: number;
|
|
2055
2060
|
}>;
|
|
2056
2061
|
runSimulation(payload: {
|
|
2057
2062
|
symbol: string;
|
|
@@ -2230,6 +2235,7 @@ declare class ExchangeAccount$1 {
|
|
|
2230
2235
|
gap?: number;
|
|
2231
2236
|
rr?: number;
|
|
2232
2237
|
max_size?: number;
|
|
2238
|
+
max_quantity?: number;
|
|
2233
2239
|
};
|
|
2234
2240
|
last_value: any;
|
|
2235
2241
|
config: {
|
|
@@ -2362,7 +2368,7 @@ declare class App {
|
|
|
2362
2368
|
price?: number;
|
|
2363
2369
|
all?: boolean;
|
|
2364
2370
|
stop?: boolean;
|
|
2365
|
-
}): Promise<
|
|
2371
|
+
}): Promise<any[] | {
|
|
2366
2372
|
success: boolean;
|
|
2367
2373
|
message: string;
|
|
2368
2374
|
exchange_result?: undefined;
|
|
@@ -2470,6 +2476,7 @@ declare class App {
|
|
|
2470
2476
|
gap?: number;
|
|
2471
2477
|
rr?: number;
|
|
2472
2478
|
max_size?: number;
|
|
2479
|
+
max_quantity?: number;
|
|
2473
2480
|
};
|
|
2474
2481
|
last_value: any;
|
|
2475
2482
|
config: {
|
package/dist/index.js
CHANGED
|
@@ -51921,7 +51921,7 @@ class AppDatabase {
|
|
|
51921
51921
|
}
|
|
51922
51922
|
}
|
|
51923
51923
|
async cancelLimitOrders(payload) {
|
|
51924
|
-
const { symbol, kind, account, cancelExchangeOrders } = payload;
|
|
51924
|
+
const { symbol, kind, account, cancelExchangeOrders, raw } = payload;
|
|
51925
51925
|
const side = kind === "long" ? "buy" : "sell";
|
|
51926
51926
|
const orders = await this.pb.collection("orders").getFullList({
|
|
51927
51927
|
filter: `symbol:lower="${symbol.toLowerCase()}" && account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}" && kind="${kind}" && side:lower="${side}" && stop = 0`
|
|
@@ -51931,6 +51931,9 @@ class AppDatabase {
|
|
|
51931
51931
|
filter: `symbol:lower="${symbol.toLowerCase()}" && account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}" && kind="${kind}" && side:lower="${stop_side}" && stop > 0`
|
|
51932
51932
|
});
|
|
51933
51933
|
const exchange_order_ids = orders.concat(existing_stop_orders).map((o) => account.exchange === "bybit" ? o.order_id : parseInt(o.order_id, 10));
|
|
51934
|
+
if (raw) {
|
|
51935
|
+
return exchange_order_ids;
|
|
51936
|
+
}
|
|
51934
51937
|
try {
|
|
51935
51938
|
console.log(`Attempting to cancel ${exchange_order_ids.length} orders on ${account.exchange} for ${account.owner}...`);
|
|
51936
51939
|
const cancel_result = await cancelExchangeOrders({
|
|
@@ -53446,6 +53449,22 @@ class Signal {
|
|
|
53446
53449
|
}
|
|
53447
53450
|
|
|
53448
53451
|
// src/helpers/shared.ts
|
|
53452
|
+
function getMaxQuantity(x, app_config) {
|
|
53453
|
+
let max_quantity = app_config.max_quantity;
|
|
53454
|
+
if (max_quantity) {
|
|
53455
|
+
return x <= max_quantity;
|
|
53456
|
+
}
|
|
53457
|
+
if (app_config.symbol === "BTCUSDT") {
|
|
53458
|
+
max_quantity = 0.03;
|
|
53459
|
+
}
|
|
53460
|
+
if (app_config.symbol?.toLowerCase().startsWith("sol")) {
|
|
53461
|
+
max_quantity = 2;
|
|
53462
|
+
}
|
|
53463
|
+
if (!max_quantity) {
|
|
53464
|
+
return true;
|
|
53465
|
+
}
|
|
53466
|
+
return x <= max_quantity;
|
|
53467
|
+
}
|
|
53449
53468
|
function buildConfig(app_config, {
|
|
53450
53469
|
take_profit,
|
|
53451
53470
|
entry,
|
|
@@ -53520,13 +53539,7 @@ function buildAvg({
|
|
|
53520
53539
|
}
|
|
53521
53540
|
function sortedBuildConfig(app_config, options) {
|
|
53522
53541
|
const sorted = buildConfig(app_config, options).sort((a, b) => app_config.kind === "long" ? a.entry - b.entry : b.entry - b.entry).filter((x) => {
|
|
53523
|
-
|
|
53524
|
-
return x.quantity <= 0.03;
|
|
53525
|
-
}
|
|
53526
|
-
if (app_config.symbol?.toLowerCase().startsWith("sol")) {
|
|
53527
|
-
return x.quantity <= 2;
|
|
53528
|
-
}
|
|
53529
|
-
return true;
|
|
53542
|
+
return getMaxQuantity(x.quantity, app_config);
|
|
53530
53543
|
});
|
|
53531
53544
|
return sorted.map((k, i2) => {
|
|
53532
53545
|
const arrSet = sorted.slice(0, i2 + 1);
|
|
@@ -56229,6 +56242,7 @@ async function cancelOrdersParallel(payload) {
|
|
|
56229
56242
|
|
|
56230
56243
|
// src/exchanges/bybit.ts
|
|
56231
56244
|
var import_bybit_api = __toESM(require_lib3(), 1);
|
|
56245
|
+
var import_p_limit2 = __toESM(require_p_limit(), 1);
|
|
56232
56246
|
async function initClient2(credentials, options) {
|
|
56233
56247
|
const { proxyAgent } = options;
|
|
56234
56248
|
try {
|
|
@@ -56335,14 +56349,22 @@ async function getPositionInfo2(client, symbol) {
|
|
|
56335
56349
|
const short = result.find((x) => x.side.toLowerCase() === "sell");
|
|
56336
56350
|
return { long, short };
|
|
56337
56351
|
}
|
|
56352
|
+
var ORDERS_PER_SECONDS = 10;
|
|
56353
|
+
var BATCH_SIZE2 = 10;
|
|
56338
56354
|
async function cancelOrders2(payload) {
|
|
56339
56355
|
const client = payload.custom_client;
|
|
56340
56356
|
const results = [];
|
|
56341
|
-
|
|
56342
|
-
|
|
56343
|
-
|
|
56357
|
+
const batches = [];
|
|
56358
|
+
for (let i2 = 0;i2 < payload.orders.length; i2 += BATCH_SIZE2) {
|
|
56359
|
+
batches.push(payload.orders.slice(i2, i2 + BATCH_SIZE2));
|
|
56360
|
+
}
|
|
56361
|
+
const limit = import_p_limit2.default(ORDERS_PER_SECONDS);
|
|
56362
|
+
for (let i2 = 0;i2 < batches.length; i2++) {
|
|
56363
|
+
const batch2 = batches[i2];
|
|
56364
|
+
let rr = await limit(async () => {
|
|
56365
|
+
return await client.batchCancelOrders("linear", batch2.map((x) => ({ orderId: x.orderId, symbol: payload.symbol })));
|
|
56366
|
+
});
|
|
56344
56367
|
results.push(rr);
|
|
56345
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
56346
56368
|
}
|
|
56347
56369
|
return results;
|
|
56348
56370
|
}
|
|
@@ -57758,7 +57780,7 @@ class ExchangeAccount {
|
|
|
57758
57780
|
}
|
|
57759
57781
|
}
|
|
57760
57782
|
async cancelOrders(payload) {
|
|
57761
|
-
const { symbol, kind, price: _price, all, stop, limit } = payload;
|
|
57783
|
+
const { symbol, kind, price: _price, all, stop, limit, raw } = payload;
|
|
57762
57784
|
let price = _price || 0;
|
|
57763
57785
|
await this.syncAccount({
|
|
57764
57786
|
symbol,
|
|
@@ -57767,6 +57789,7 @@ class ExchangeAccount {
|
|
|
57767
57789
|
});
|
|
57768
57790
|
if (limit) {
|
|
57769
57791
|
return await this.app_db.cancelLimitOrders({
|
|
57792
|
+
raw,
|
|
57770
57793
|
symbol,
|
|
57771
57794
|
kind,
|
|
57772
57795
|
account: this.instance,
|
package/dist/mcp-server.cjs
CHANGED
|
@@ -58675,7 +58675,7 @@ class AppDatabase {
|
|
|
58675
58675
|
}
|
|
58676
58676
|
}
|
|
58677
58677
|
async cancelLimitOrders(payload) {
|
|
58678
|
-
const { symbol, kind, account, cancelExchangeOrders } = payload;
|
|
58678
|
+
const { symbol, kind, account, cancelExchangeOrders, raw } = payload;
|
|
58679
58679
|
const side = kind === "long" ? "buy" : "sell";
|
|
58680
58680
|
const orders = await this.pb.collection("orders").getFullList({
|
|
58681
58681
|
filter: `symbol:lower="${symbol.toLowerCase()}" && account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}" && kind="${kind}" && side:lower="${side}" && stop = 0`
|
|
@@ -58685,6 +58685,9 @@ class AppDatabase {
|
|
|
58685
58685
|
filter: `symbol:lower="${symbol.toLowerCase()}" && account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}" && kind="${kind}" && side:lower="${stop_side}" && stop > 0`
|
|
58686
58686
|
});
|
|
58687
58687
|
const exchange_order_ids = orders.concat(existing_stop_orders).map((o) => account.exchange === "bybit" ? o.order_id : parseInt(o.order_id, 10));
|
|
58688
|
+
if (raw) {
|
|
58689
|
+
return exchange_order_ids;
|
|
58690
|
+
}
|
|
58688
58691
|
try {
|
|
58689
58692
|
console.log(`Attempting to cancel ${exchange_order_ids.length} orders on ${account.exchange} for ${account.owner}...`);
|
|
58690
58693
|
const cancel_result = await cancelExchangeOrders({
|
|
@@ -60193,6 +60196,22 @@ class Signal {
|
|
|
60193
60196
|
}
|
|
60194
60197
|
|
|
60195
60198
|
// src/helpers/shared.ts
|
|
60199
|
+
function getMaxQuantity(x, app_config) {
|
|
60200
|
+
let max_quantity = app_config.max_quantity;
|
|
60201
|
+
if (max_quantity) {
|
|
60202
|
+
return x <= max_quantity;
|
|
60203
|
+
}
|
|
60204
|
+
if (app_config.symbol === "BTCUSDT") {
|
|
60205
|
+
max_quantity = 0.03;
|
|
60206
|
+
}
|
|
60207
|
+
if (app_config.symbol?.toLowerCase().startsWith("sol")) {
|
|
60208
|
+
max_quantity = 2;
|
|
60209
|
+
}
|
|
60210
|
+
if (!max_quantity) {
|
|
60211
|
+
return true;
|
|
60212
|
+
}
|
|
60213
|
+
return x <= max_quantity;
|
|
60214
|
+
}
|
|
60196
60215
|
function buildConfig(app_config, {
|
|
60197
60216
|
take_profit,
|
|
60198
60217
|
entry,
|
|
@@ -60254,13 +60273,7 @@ function buildConfig(app_config, {
|
|
|
60254
60273
|
}
|
|
60255
60274
|
function sortedBuildConfig(app_config, options) {
|
|
60256
60275
|
const sorted = buildConfig(app_config, options).sort((a, b) => app_config.kind === "long" ? a.entry - b.entry : b.entry - b.entry).filter((x) => {
|
|
60257
|
-
|
|
60258
|
-
return x.quantity <= 0.03;
|
|
60259
|
-
}
|
|
60260
|
-
if (app_config.symbol?.toLowerCase().startsWith("sol")) {
|
|
60261
|
-
return x.quantity <= 2;
|
|
60262
|
-
}
|
|
60263
|
-
return true;
|
|
60276
|
+
return getMaxQuantity(x.quantity, app_config);
|
|
60264
60277
|
});
|
|
60265
60278
|
return sorted.map((k, i2) => {
|
|
60266
60279
|
const arrSet = sorted.slice(0, i2 + 1);
|
|
@@ -62957,6 +62970,7 @@ async function cancelOrdersParallel(payload) {
|
|
|
62957
62970
|
|
|
62958
62971
|
// src/exchanges/bybit.ts
|
|
62959
62972
|
var import_bybit_api = __toESM(require_lib3());
|
|
62973
|
+
var import_p_limit2 = __toESM(require_p_limit());
|
|
62960
62974
|
async function initClient2(credentials, options) {
|
|
62961
62975
|
const { proxyAgent } = options;
|
|
62962
62976
|
try {
|
|
@@ -63063,14 +63077,22 @@ async function getPositionInfo2(client, symbol) {
|
|
|
63063
63077
|
const short = result.find((x) => x.side.toLowerCase() === "sell");
|
|
63064
63078
|
return { long, short };
|
|
63065
63079
|
}
|
|
63080
|
+
var ORDERS_PER_SECONDS = 10;
|
|
63081
|
+
var BATCH_SIZE2 = 10;
|
|
63066
63082
|
async function cancelOrders2(payload) {
|
|
63067
63083
|
const client = payload.custom_client;
|
|
63068
63084
|
const results = [];
|
|
63069
|
-
|
|
63070
|
-
|
|
63071
|
-
|
|
63085
|
+
const batches = [];
|
|
63086
|
+
for (let i2 = 0;i2 < payload.orders.length; i2 += BATCH_SIZE2) {
|
|
63087
|
+
batches.push(payload.orders.slice(i2, i2 + BATCH_SIZE2));
|
|
63088
|
+
}
|
|
63089
|
+
const limit = import_p_limit2.default(ORDERS_PER_SECONDS);
|
|
63090
|
+
for (let i2 = 0;i2 < batches.length; i2++) {
|
|
63091
|
+
const batch2 = batches[i2];
|
|
63092
|
+
let rr = await limit(async () => {
|
|
63093
|
+
return await client.batchCancelOrders("linear", batch2.map((x) => ({ orderId: x.orderId, symbol: payload.symbol })));
|
|
63094
|
+
});
|
|
63072
63095
|
results.push(rr);
|
|
63073
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
63074
63096
|
}
|
|
63075
63097
|
return results;
|
|
63076
63098
|
}
|
|
@@ -64486,7 +64508,7 @@ class ExchangeAccount {
|
|
|
64486
64508
|
}
|
|
64487
64509
|
}
|
|
64488
64510
|
async cancelOrders(payload) {
|
|
64489
|
-
const { symbol, kind, price: _price, all, stop, limit } = payload;
|
|
64511
|
+
const { symbol, kind, price: _price, all, stop, limit, raw } = payload;
|
|
64490
64512
|
let price = _price || 0;
|
|
64491
64513
|
await this.syncAccount({
|
|
64492
64514
|
symbol,
|
|
@@ -64495,6 +64517,7 @@ class ExchangeAccount {
|
|
|
64495
64517
|
});
|
|
64496
64518
|
if (limit) {
|
|
64497
64519
|
return await this.app_db.cancelLimitOrders({
|
|
64520
|
+
raw,
|
|
64498
64521
|
symbol,
|
|
64499
64522
|
kind,
|
|
64500
64523
|
account: this.instance,
|
package/dist/mcp-server.js
CHANGED
|
@@ -58652,7 +58652,7 @@ class AppDatabase {
|
|
|
58652
58652
|
}
|
|
58653
58653
|
}
|
|
58654
58654
|
async cancelLimitOrders(payload) {
|
|
58655
|
-
const { symbol, kind, account, cancelExchangeOrders } = payload;
|
|
58655
|
+
const { symbol, kind, account, cancelExchangeOrders, raw } = payload;
|
|
58656
58656
|
const side = kind === "long" ? "buy" : "sell";
|
|
58657
58657
|
const orders = await this.pb.collection("orders").getFullList({
|
|
58658
58658
|
filter: `symbol:lower="${symbol.toLowerCase()}" && account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}" && kind="${kind}" && side:lower="${side}" && stop = 0`
|
|
@@ -58662,6 +58662,9 @@ class AppDatabase {
|
|
|
58662
58662
|
filter: `symbol:lower="${symbol.toLowerCase()}" && account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}" && kind="${kind}" && side:lower="${stop_side}" && stop > 0`
|
|
58663
58663
|
});
|
|
58664
58664
|
const exchange_order_ids = orders.concat(existing_stop_orders).map((o) => account.exchange === "bybit" ? o.order_id : parseInt(o.order_id, 10));
|
|
58665
|
+
if (raw) {
|
|
58666
|
+
return exchange_order_ids;
|
|
58667
|
+
}
|
|
58665
58668
|
try {
|
|
58666
58669
|
console.log(`Attempting to cancel ${exchange_order_ids.length} orders on ${account.exchange} for ${account.owner}...`);
|
|
58667
58670
|
const cancel_result = await cancelExchangeOrders({
|
|
@@ -60170,6 +60173,22 @@ class Signal {
|
|
|
60170
60173
|
}
|
|
60171
60174
|
|
|
60172
60175
|
// src/helpers/shared.ts
|
|
60176
|
+
function getMaxQuantity(x, app_config) {
|
|
60177
|
+
let max_quantity = app_config.max_quantity;
|
|
60178
|
+
if (max_quantity) {
|
|
60179
|
+
return x <= max_quantity;
|
|
60180
|
+
}
|
|
60181
|
+
if (app_config.symbol === "BTCUSDT") {
|
|
60182
|
+
max_quantity = 0.03;
|
|
60183
|
+
}
|
|
60184
|
+
if (app_config.symbol?.toLowerCase().startsWith("sol")) {
|
|
60185
|
+
max_quantity = 2;
|
|
60186
|
+
}
|
|
60187
|
+
if (!max_quantity) {
|
|
60188
|
+
return true;
|
|
60189
|
+
}
|
|
60190
|
+
return x <= max_quantity;
|
|
60191
|
+
}
|
|
60173
60192
|
function buildConfig(app_config, {
|
|
60174
60193
|
take_profit,
|
|
60175
60194
|
entry,
|
|
@@ -60231,13 +60250,7 @@ function buildConfig(app_config, {
|
|
|
60231
60250
|
}
|
|
60232
60251
|
function sortedBuildConfig(app_config, options) {
|
|
60233
60252
|
const sorted = buildConfig(app_config, options).sort((a, b) => app_config.kind === "long" ? a.entry - b.entry : b.entry - b.entry).filter((x) => {
|
|
60234
|
-
|
|
60235
|
-
return x.quantity <= 0.03;
|
|
60236
|
-
}
|
|
60237
|
-
if (app_config.symbol?.toLowerCase().startsWith("sol")) {
|
|
60238
|
-
return x.quantity <= 2;
|
|
60239
|
-
}
|
|
60240
|
-
return true;
|
|
60253
|
+
return getMaxQuantity(x.quantity, app_config);
|
|
60241
60254
|
});
|
|
60242
60255
|
return sorted.map((k, i2) => {
|
|
60243
60256
|
const arrSet = sorted.slice(0, i2 + 1);
|
|
@@ -62934,6 +62947,7 @@ async function cancelOrdersParallel(payload) {
|
|
|
62934
62947
|
|
|
62935
62948
|
// src/exchanges/bybit.ts
|
|
62936
62949
|
var import_bybit_api = __toESM(require_lib3(), 1);
|
|
62950
|
+
var import_p_limit2 = __toESM(require_p_limit(), 1);
|
|
62937
62951
|
async function initClient2(credentials, options) {
|
|
62938
62952
|
const { proxyAgent } = options;
|
|
62939
62953
|
try {
|
|
@@ -63040,14 +63054,22 @@ async function getPositionInfo2(client, symbol) {
|
|
|
63040
63054
|
const short = result.find((x) => x.side.toLowerCase() === "sell");
|
|
63041
63055
|
return { long, short };
|
|
63042
63056
|
}
|
|
63057
|
+
var ORDERS_PER_SECONDS = 10;
|
|
63058
|
+
var BATCH_SIZE2 = 10;
|
|
63043
63059
|
async function cancelOrders2(payload) {
|
|
63044
63060
|
const client = payload.custom_client;
|
|
63045
63061
|
const results = [];
|
|
63046
|
-
|
|
63047
|
-
|
|
63048
|
-
|
|
63062
|
+
const batches = [];
|
|
63063
|
+
for (let i2 = 0;i2 < payload.orders.length; i2 += BATCH_SIZE2) {
|
|
63064
|
+
batches.push(payload.orders.slice(i2, i2 + BATCH_SIZE2));
|
|
63065
|
+
}
|
|
63066
|
+
const limit = import_p_limit2.default(ORDERS_PER_SECONDS);
|
|
63067
|
+
for (let i2 = 0;i2 < batches.length; i2++) {
|
|
63068
|
+
const batch2 = batches[i2];
|
|
63069
|
+
let rr = await limit(async () => {
|
|
63070
|
+
return await client.batchCancelOrders("linear", batch2.map((x) => ({ orderId: x.orderId, symbol: payload.symbol })));
|
|
63071
|
+
});
|
|
63049
63072
|
results.push(rr);
|
|
63050
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
63051
63073
|
}
|
|
63052
63074
|
return results;
|
|
63053
63075
|
}
|
|
@@ -64463,7 +64485,7 @@ class ExchangeAccount {
|
|
|
64463
64485
|
}
|
|
64464
64486
|
}
|
|
64465
64487
|
async cancelOrders(payload) {
|
|
64466
|
-
const { symbol, kind, price: _price, all, stop, limit } = payload;
|
|
64488
|
+
const { symbol, kind, price: _price, all, stop, limit, raw } = payload;
|
|
64467
64489
|
let price = _price || 0;
|
|
64468
64490
|
await this.syncAccount({
|
|
64469
64491
|
symbol,
|
|
@@ -64472,6 +64494,7 @@ class ExchangeAccount {
|
|
|
64472
64494
|
});
|
|
64473
64495
|
if (limit) {
|
|
64474
64496
|
return await this.app_db.cancelLimitOrders({
|
|
64497
|
+
raw,
|
|
64475
64498
|
symbol,
|
|
64476
64499
|
kind,
|
|
64477
64500
|
account: this.instance,
|