@gbozee/ultimate 0.0.2-113 → 0.0.2-115
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 +335 -350
- package/dist/index.d.ts +91 -16
- package/dist/index.js +335 -350
- package/dist/mcp-server.cjs +335 -350
- package/dist/mcp-server.js +335 -350
- package/package.json +2 -2
package/dist/mcp-server.cjs
CHANGED
|
@@ -58607,7 +58607,7 @@ class AppDatabase {
|
|
|
58607
58607
|
const existing_stop_orders = await this.pb.collection("orders").getFullList({
|
|
58608
58608
|
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`
|
|
58609
58609
|
});
|
|
58610
|
-
const exchange_order_ids = orders.concat(existing_stop_orders).map((o) => parseInt(o.order_id, 10));
|
|
58610
|
+
const exchange_order_ids = orders.concat(existing_stop_orders).map((o) => account.exchange === "bybit" ? o.order_id : parseInt(o.order_id, 10));
|
|
58611
58611
|
try {
|
|
58612
58612
|
console.log(`Attempting to cancel ${exchange_order_ids.length} orders on ${account.exchange} for ${account.owner}...`);
|
|
58613
58613
|
const cancel_result = await cancelExchangeOrders({
|
|
@@ -61453,13 +61453,207 @@ class Strategy {
|
|
|
61453
61453
|
|
|
61454
61454
|
// src/exchanges/binance.ts
|
|
61455
61455
|
var import_binance = __toESM(require_lib2());
|
|
61456
|
-
|
|
61457
61456
|
// src/types/index.ts
|
|
61458
61457
|
class BaseExchange {
|
|
61459
61458
|
client;
|
|
61459
|
+
getCredentials;
|
|
61460
|
+
proxyAgent;
|
|
61460
61461
|
constructor(client) {
|
|
61461
61462
|
this.client = client;
|
|
61462
61463
|
}
|
|
61464
|
+
async rawCreateLimitPurchaseOrders(payload) {
|
|
61465
|
+
const { symbol, orders, price_places, decimal_places } = payload;
|
|
61466
|
+
return this._createLimitPurchaseOrders({
|
|
61467
|
+
symbol,
|
|
61468
|
+
price_places,
|
|
61469
|
+
decimal_places,
|
|
61470
|
+
orders
|
|
61471
|
+
});
|
|
61472
|
+
}
|
|
61473
|
+
async placeStopOrders(payload) {
|
|
61474
|
+
if (payload.place) {
|
|
61475
|
+
const current_price = await this.getCurrentPrice(payload.symbol);
|
|
61476
|
+
return this._placeStopOrder({
|
|
61477
|
+
symbol: payload.symbol,
|
|
61478
|
+
stop: payload.stop,
|
|
61479
|
+
final_stop: payload.stop,
|
|
61480
|
+
quantity: Math.abs(payload.quantity),
|
|
61481
|
+
kind: payload.kind,
|
|
61482
|
+
cancel: true,
|
|
61483
|
+
is_limit: true,
|
|
61484
|
+
price_places: payload.price_places,
|
|
61485
|
+
decimal_places: payload.decimal_places,
|
|
61486
|
+
current_price
|
|
61487
|
+
});
|
|
61488
|
+
}
|
|
61489
|
+
}
|
|
61490
|
+
async bulkPlaceLimitOrders(payload) {
|
|
61491
|
+
const {
|
|
61492
|
+
orders,
|
|
61493
|
+
kind,
|
|
61494
|
+
decimal_places = "%.3f",
|
|
61495
|
+
price_places = "%.1f",
|
|
61496
|
+
symbol,
|
|
61497
|
+
place = false
|
|
61498
|
+
} = payload;
|
|
61499
|
+
const totalQuantity = orders.reduce((sum, order) => sum + (order.quantity || 0), 0);
|
|
61500
|
+
let runningTotal = to_f2(totalQuantity, decimal_places);
|
|
61501
|
+
let sortedOrders = [...orders].sort((a, b) => (a.entry || 0) - (b.entry || 0));
|
|
61502
|
+
if (kind === "short") {
|
|
61503
|
+
sortedOrders.reverse();
|
|
61504
|
+
}
|
|
61505
|
+
const withCumulative = [];
|
|
61506
|
+
for (const order of sortedOrders) {
|
|
61507
|
+
withCumulative.push({
|
|
61508
|
+
...order,
|
|
61509
|
+
cumulative_quantity: runningTotal
|
|
61510
|
+
});
|
|
61511
|
+
runningTotal -= order.quantity;
|
|
61512
|
+
runningTotal = to_f2(runningTotal, decimal_places);
|
|
61513
|
+
}
|
|
61514
|
+
const positions = await this.getPositionInfo(symbol);
|
|
61515
|
+
const position2 = positions[kind] || {
|
|
61516
|
+
kind,
|
|
61517
|
+
size: 0,
|
|
61518
|
+
entryPrice: 0,
|
|
61519
|
+
symbol
|
|
61520
|
+
};
|
|
61521
|
+
const filteredOrders = withCumulative.filter((order) => (order.cumulative_quantity || 0) > position2.size).map((order) => ({
|
|
61522
|
+
...order,
|
|
61523
|
+
price: order.entry,
|
|
61524
|
+
kind,
|
|
61525
|
+
side: kind.toLowerCase() === "long" ? "buy" : "sell"
|
|
61526
|
+
}));
|
|
61527
|
+
if (filteredOrders.length > 0 && place) {
|
|
61528
|
+
await this.cancelAllOrders(symbol, {
|
|
61529
|
+
type: "limit",
|
|
61530
|
+
kind
|
|
61531
|
+
});
|
|
61532
|
+
await this._createLimitPurchaseOrders({
|
|
61533
|
+
symbol,
|
|
61534
|
+
orders: filteredOrders,
|
|
61535
|
+
price_places,
|
|
61536
|
+
decimal_places
|
|
61537
|
+
});
|
|
61538
|
+
}
|
|
61539
|
+
return filteredOrders;
|
|
61540
|
+
}
|
|
61541
|
+
async get_current_price(symbol) {
|
|
61542
|
+
return await this.getCurrentPrice(symbol);
|
|
61543
|
+
}
|
|
61544
|
+
async getExchangeAccountInfo(options) {
|
|
61545
|
+
const {
|
|
61546
|
+
price_places = "%.1f",
|
|
61547
|
+
decimal_places = "%.3f",
|
|
61548
|
+
account,
|
|
61549
|
+
symbol
|
|
61550
|
+
} = options;
|
|
61551
|
+
return await this.getExchangeInfo({
|
|
61552
|
+
price_places,
|
|
61553
|
+
decimal_places,
|
|
61554
|
+
account,
|
|
61555
|
+
symbol
|
|
61556
|
+
});
|
|
61557
|
+
}
|
|
61558
|
+
async cancelOrders(payload) {
|
|
61559
|
+
return await this._cancelOrders({
|
|
61560
|
+
symbol: payload.symbol,
|
|
61561
|
+
orders: payload.orders.map((x) => ({ orderId: x }))
|
|
61562
|
+
});
|
|
61563
|
+
}
|
|
61564
|
+
async placeTpOrder(payload) {
|
|
61565
|
+
return await this._placeTpOrder({
|
|
61566
|
+
symbol: payload.symbol,
|
|
61567
|
+
tp: payload.take_profit,
|
|
61568
|
+
kind: payload.kind,
|
|
61569
|
+
quantity: payload.quantity,
|
|
61570
|
+
cancel: true,
|
|
61571
|
+
price_places: payload.price_places,
|
|
61572
|
+
decimal_places: payload.decimal_places
|
|
61573
|
+
});
|
|
61574
|
+
}
|
|
61575
|
+
async placeLimitOrder(payload) {
|
|
61576
|
+
return await this.placeLimitOrders({
|
|
61577
|
+
symbol: payload.symbol,
|
|
61578
|
+
orders: [
|
|
61579
|
+
{
|
|
61580
|
+
entry: payload.price,
|
|
61581
|
+
quantity: payload.quantity
|
|
61582
|
+
}
|
|
61583
|
+
],
|
|
61584
|
+
kind: payload.kind,
|
|
61585
|
+
price_places: payload.price_places,
|
|
61586
|
+
decimal_places: payload.decimal_places
|
|
61587
|
+
});
|
|
61588
|
+
}
|
|
61589
|
+
async placeStopOrder(payload) {
|
|
61590
|
+
const current_price = await this.getCurrentPrice(payload.symbol);
|
|
61591
|
+
return await this._placeStopOrder({
|
|
61592
|
+
symbol: payload.symbol,
|
|
61593
|
+
stop: payload.stop,
|
|
61594
|
+
final_stop: payload.stop,
|
|
61595
|
+
quantity: Math.abs(payload.quantity),
|
|
61596
|
+
kind: payload.kind,
|
|
61597
|
+
cancel: true,
|
|
61598
|
+
is_limit: true,
|
|
61599
|
+
price_places: payload.price_places,
|
|
61600
|
+
decimal_places: payload.decimal_places,
|
|
61601
|
+
current_price
|
|
61602
|
+
});
|
|
61603
|
+
}
|
|
61604
|
+
async closePosition(payload) {
|
|
61605
|
+
const { symbol, kind, price_places, decimal_places } = payload;
|
|
61606
|
+
const currentPrice = await this.getCurrentPrice(symbol);
|
|
61607
|
+
return this.placeTpOrder({
|
|
61608
|
+
price_places,
|
|
61609
|
+
decimal_places,
|
|
61610
|
+
symbol,
|
|
61611
|
+
take_profit: currentPrice,
|
|
61612
|
+
kind
|
|
61613
|
+
});
|
|
61614
|
+
}
|
|
61615
|
+
async getAllOpenSymbols() {
|
|
61616
|
+
const response = await this.getAllOpenOrders();
|
|
61617
|
+
return Array.from(new Set(response.map((x) => x.symbol)));
|
|
61618
|
+
}
|
|
61619
|
+
async createLimitPurchaseOrders(payload) {
|
|
61620
|
+
const {
|
|
61621
|
+
orders,
|
|
61622
|
+
kind,
|
|
61623
|
+
decimal_places = "%.3f",
|
|
61624
|
+
price_places = "%.1f",
|
|
61625
|
+
symbol
|
|
61626
|
+
} = payload;
|
|
61627
|
+
return await this._createLimitPurchaseOrders({
|
|
61628
|
+
symbol,
|
|
61629
|
+
price_places,
|
|
61630
|
+
decimal_places,
|
|
61631
|
+
orders: orders.map((order) => ({
|
|
61632
|
+
...order,
|
|
61633
|
+
price: order.entry,
|
|
61634
|
+
kind,
|
|
61635
|
+
side: kind.toLowerCase() === "long" ? "buy" : "sell"
|
|
61636
|
+
}))
|
|
61637
|
+
});
|
|
61638
|
+
}
|
|
61639
|
+
async placeMarketOrder(payload) {
|
|
61640
|
+
const { symbol, kind, quantity, price_places, decimal_places } = payload;
|
|
61641
|
+
const currentPrice = await this.get_current_price(symbol);
|
|
61642
|
+
return this._createLimitPurchaseOrders({
|
|
61643
|
+
symbol,
|
|
61644
|
+
price_places,
|
|
61645
|
+
decimal_places,
|
|
61646
|
+
orders: [
|
|
61647
|
+
{
|
|
61648
|
+
force_market: true,
|
|
61649
|
+
side: kind === "long" ? "buy" : "sell",
|
|
61650
|
+
kind,
|
|
61651
|
+
quantity,
|
|
61652
|
+
price: currentPrice
|
|
61653
|
+
}
|
|
61654
|
+
]
|
|
61655
|
+
});
|
|
61656
|
+
}
|
|
61463
61657
|
async customStopLoss(payload) {
|
|
61464
61658
|
const {
|
|
61465
61659
|
symbol,
|
|
@@ -61498,6 +61692,33 @@ class BaseExchange {
|
|
|
61498
61692
|
decimal_places
|
|
61499
61693
|
});
|
|
61500
61694
|
}
|
|
61695
|
+
async placeBadStopEntry(payload) {
|
|
61696
|
+
const { symbol, orders, price_places, decimal_places } = payload;
|
|
61697
|
+
const openOrders = await this.getOpenOrders({ symbol });
|
|
61698
|
+
const existingBadEntry = openOrders.filter((k) => {
|
|
61699
|
+
if (k.stopPrice > 0) {
|
|
61700
|
+
if (k.kind === "long" && k.price > k.stopPrice || k.kind === "short" && k.price < k.stopPrice) {
|
|
61701
|
+
return true;
|
|
61702
|
+
}
|
|
61703
|
+
return false;
|
|
61704
|
+
}
|
|
61705
|
+
return false;
|
|
61706
|
+
});
|
|
61707
|
+
if (existingBadEntry.length > 0) {
|
|
61708
|
+
console.log("Cancelling existing bad entry");
|
|
61709
|
+
await this._cancelOrders({
|
|
61710
|
+
symbol,
|
|
61711
|
+
orders: existingBadEntry.map((x) => ({ orderId: x.orderId }))
|
|
61712
|
+
});
|
|
61713
|
+
}
|
|
61714
|
+
console.log("Placing new order");
|
|
61715
|
+
return this._createLimitPurchaseOrders({
|
|
61716
|
+
symbol,
|
|
61717
|
+
price_places,
|
|
61718
|
+
decimal_places,
|
|
61719
|
+
orders
|
|
61720
|
+
});
|
|
61721
|
+
}
|
|
61501
61722
|
async analyzeCandlesticks(payload) {
|
|
61502
61723
|
const { symbol } = payload;
|
|
61503
61724
|
const arr = [
|
|
@@ -61548,6 +61769,10 @@ class BaseExchange {
|
|
|
61548
61769
|
minimum_weekly: minimumWeekly
|
|
61549
61770
|
};
|
|
61550
61771
|
}
|
|
61772
|
+
setAccountDetails(payload) {
|
|
61773
|
+
this.getCredentials = payload.getCredentials;
|
|
61774
|
+
this.proxyAgent = payload.proxyAgent;
|
|
61775
|
+
}
|
|
61551
61776
|
}
|
|
61552
61777
|
|
|
61553
61778
|
// src/exchanges/binance.ts
|
|
@@ -62333,98 +62558,22 @@ async function getAllOpenOrders(payload) {
|
|
|
62333
62558
|
class BinanceExchange extends BaseExchange {
|
|
62334
62559
|
client;
|
|
62335
62560
|
main_client;
|
|
62336
|
-
getCredentials;
|
|
62337
|
-
proxyAgent;
|
|
62338
62561
|
constructor(client, main_client) {
|
|
62339
62562
|
super(client);
|
|
62340
62563
|
this.client = client;
|
|
62341
62564
|
this.main_client = main_client;
|
|
62342
62565
|
}
|
|
62343
|
-
|
|
62344
|
-
this.
|
|
62345
|
-
this.proxyAgent = payload.proxyAgent;
|
|
62566
|
+
async getPositionInfo(symbol) {
|
|
62567
|
+
return await getPositionInfo(this.client, symbol);
|
|
62346
62568
|
}
|
|
62347
|
-
async
|
|
62348
|
-
|
|
62349
|
-
const current_price = await this.get_current_price(payload.symbol);
|
|
62350
|
-
return placeStopOrder(this.client, {
|
|
62351
|
-
symbol: payload.symbol,
|
|
62352
|
-
stop: payload.stop,
|
|
62353
|
-
final_stop: payload.stop,
|
|
62354
|
-
quantity: Math.abs(payload.quantity),
|
|
62355
|
-
kind: payload.kind,
|
|
62356
|
-
cancel: true,
|
|
62357
|
-
is_limit: true,
|
|
62358
|
-
price_places: payload.price_places,
|
|
62359
|
-
decimal_places: payload.decimal_places,
|
|
62360
|
-
current_price
|
|
62361
|
-
});
|
|
62362
|
-
}
|
|
62569
|
+
async getCurrentPrice(symbol) {
|
|
62570
|
+
return await getCurrentPrice(this.client, symbol);
|
|
62363
62571
|
}
|
|
62364
|
-
async
|
|
62365
|
-
|
|
62366
|
-
orders,
|
|
62367
|
-
kind,
|
|
62368
|
-
decimal_places = "%.3f",
|
|
62369
|
-
price_places = "%.1f",
|
|
62370
|
-
symbol
|
|
62371
|
-
} = payload;
|
|
62372
|
-
const _orders = orders.map((order) => ({
|
|
62373
|
-
...order,
|
|
62374
|
-
price: order.entry,
|
|
62375
|
-
kind,
|
|
62376
|
-
side: kind.toLowerCase() === "long" ? "buy" : "sell"
|
|
62377
|
-
}));
|
|
62378
|
-
return await createLimitPurchaseOrders(this.client, symbol, price_places, decimal_places, _orders);
|
|
62572
|
+
async cancelAllOrders(symbol, payload) {
|
|
62573
|
+
return await cancelAllOrders(this.client, symbol, payload);
|
|
62379
62574
|
}
|
|
62380
|
-
async
|
|
62381
|
-
|
|
62382
|
-
orders,
|
|
62383
|
-
kind,
|
|
62384
|
-
decimal_places = "%.3f",
|
|
62385
|
-
price_places = "%.1f",
|
|
62386
|
-
symbol,
|
|
62387
|
-
place = false
|
|
62388
|
-
} = payload;
|
|
62389
|
-
const totalQuantity = orders.reduce((sum, order) => sum + (order.quantity || 0), 0);
|
|
62390
|
-
let runningTotal = to_f2(totalQuantity, decimal_places);
|
|
62391
|
-
let sortedOrders = [...orders].sort((a, b) => (a.entry || 0) - (b.entry || 0));
|
|
62392
|
-
if (kind === "short") {
|
|
62393
|
-
sortedOrders.reverse();
|
|
62394
|
-
}
|
|
62395
|
-
const withCumulative = [];
|
|
62396
|
-
for (const order of sortedOrders) {
|
|
62397
|
-
withCumulative.push({
|
|
62398
|
-
...order,
|
|
62399
|
-
cumulative_quantity: runningTotal
|
|
62400
|
-
});
|
|
62401
|
-
runningTotal -= order.quantity;
|
|
62402
|
-
runningTotal = to_f2(runningTotal, decimal_places);
|
|
62403
|
-
}
|
|
62404
|
-
const positions = await getPositionInfo(this.client, symbol);
|
|
62405
|
-
const position2 = positions[kind] || {
|
|
62406
|
-
kind,
|
|
62407
|
-
size: 0,
|
|
62408
|
-
entryPrice: 0,
|
|
62409
|
-
symbol
|
|
62410
|
-
};
|
|
62411
|
-
const filteredOrders = withCumulative.filter((order) => (order.cumulative_quantity || 0) > position2.size).map((order) => ({
|
|
62412
|
-
...order,
|
|
62413
|
-
price: order.entry,
|
|
62414
|
-
kind,
|
|
62415
|
-
side: kind.toLowerCase() === "long" ? "buy" : "sell"
|
|
62416
|
-
}));
|
|
62417
|
-
if (filteredOrders.length > 0 && place) {
|
|
62418
|
-
await cancelAllOrders(this.client, symbol, {
|
|
62419
|
-
type: "limit",
|
|
62420
|
-
kind
|
|
62421
|
-
});
|
|
62422
|
-
await createLimitPurchaseOrders(this.client, symbol, price_places, decimal_places, filteredOrders);
|
|
62423
|
-
}
|
|
62424
|
-
return filteredOrders;
|
|
62425
|
-
}
|
|
62426
|
-
async get_current_price(symbol) {
|
|
62427
|
-
return await getCurrentPrice(this.client, symbol);
|
|
62575
|
+
async _createLimitPurchaseOrders(payload) {
|
|
62576
|
+
return await createLimitPurchaseOrders(this.client, payload.symbol, payload.price_places, payload.decimal_places, payload.orders);
|
|
62428
62577
|
}
|
|
62429
62578
|
async analyzeCharts(payload) {
|
|
62430
62579
|
return await analyzeCharts({
|
|
@@ -62435,67 +62584,30 @@ class BinanceExchange extends BaseExchange {
|
|
|
62435
62584
|
raw: payload.raw
|
|
62436
62585
|
});
|
|
62437
62586
|
}
|
|
62438
|
-
async
|
|
62439
|
-
const {
|
|
62440
|
-
price_places = "%.1f",
|
|
62441
|
-
decimal_places = "%.3f",
|
|
62442
|
-
account,
|
|
62443
|
-
symbol
|
|
62444
|
-
} = options;
|
|
62587
|
+
async getExchangeInfo(options) {
|
|
62445
62588
|
return await fetchBinanceAccount(this.client, {
|
|
62446
|
-
owner: account.owner,
|
|
62447
|
-
symbol
|
|
62589
|
+
owner: options.account.owner,
|
|
62590
|
+
symbol: options.symbol
|
|
62448
62591
|
}, {
|
|
62449
|
-
price_places,
|
|
62450
|
-
decimal_places
|
|
62592
|
+
price_places: options.price_places,
|
|
62593
|
+
decimal_places: options.decimal_places
|
|
62451
62594
|
});
|
|
62452
62595
|
}
|
|
62453
|
-
async
|
|
62596
|
+
async _cancelOrders(payload) {
|
|
62454
62597
|
return await cancelOrders({
|
|
62455
62598
|
symbol: payload.symbol,
|
|
62456
|
-
orders: payload.orders
|
|
62599
|
+
orders: payload.orders,
|
|
62457
62600
|
custom_client: this.client
|
|
62458
62601
|
});
|
|
62459
62602
|
}
|
|
62460
|
-
async
|
|
62461
|
-
return await placeTpOrder(this.client,
|
|
62462
|
-
symbol: payload.symbol,
|
|
62463
|
-
tp: payload.take_profit,
|
|
62464
|
-
kind: payload.kind,
|
|
62465
|
-
quantity: payload.quantity,
|
|
62466
|
-
cancel: true,
|
|
62467
|
-
price_places: payload.price_places,
|
|
62468
|
-
decimal_places: payload.decimal_places
|
|
62469
|
-
});
|
|
62603
|
+
async _placeTpOrder(payload) {
|
|
62604
|
+
return await placeTpOrder(this.client, payload);
|
|
62470
62605
|
}
|
|
62471
|
-
async
|
|
62472
|
-
return await placeLimitOrders(this.client,
|
|
62473
|
-
symbol: payload.symbol,
|
|
62474
|
-
orders: [
|
|
62475
|
-
{
|
|
62476
|
-
entry: payload.price,
|
|
62477
|
-
quantity: payload.quantity
|
|
62478
|
-
}
|
|
62479
|
-
],
|
|
62480
|
-
kind: payload.kind,
|
|
62481
|
-
price_places: payload.price_places,
|
|
62482
|
-
decimal_places: payload.decimal_places
|
|
62483
|
-
});
|
|
62606
|
+
async placeLimitOrders(payload) {
|
|
62607
|
+
return await placeLimitOrders(this.client, payload);
|
|
62484
62608
|
}
|
|
62485
|
-
async
|
|
62486
|
-
|
|
62487
|
-
return await placeStopOrder(this.client, {
|
|
62488
|
-
symbol: payload.symbol,
|
|
62489
|
-
stop: payload.stop,
|
|
62490
|
-
final_stop: payload.stop,
|
|
62491
|
-
quantity: Math.abs(payload.quantity),
|
|
62492
|
-
kind: payload.kind,
|
|
62493
|
-
cancel: true,
|
|
62494
|
-
is_limit: true,
|
|
62495
|
-
price_places: payload.price_places,
|
|
62496
|
-
decimal_places: payload.decimal_places,
|
|
62497
|
-
current_price
|
|
62498
|
-
});
|
|
62609
|
+
async _placeStopOrder(payload) {
|
|
62610
|
+
return await placeStopOrder(this.client, payload);
|
|
62499
62611
|
}
|
|
62500
62612
|
async setLeverage(payload) {
|
|
62501
62613
|
let maxLeverage = payload.leverage;
|
|
@@ -62589,20 +62701,8 @@ class BinanceExchange extends BaseExchange {
|
|
|
62589
62701
|
const _movers = activeMovers.filter((m) => !toBeDelisted.includes(m.symbol));
|
|
62590
62702
|
return { movers: _movers, delisted };
|
|
62591
62703
|
}
|
|
62592
|
-
async
|
|
62593
|
-
|
|
62594
|
-
const currentPrice = await this.get_current_price(symbol);
|
|
62595
|
-
return this.placeTpOrder({
|
|
62596
|
-
price_places,
|
|
62597
|
-
decimal_places,
|
|
62598
|
-
symbol,
|
|
62599
|
-
take_profit: currentPrice,
|
|
62600
|
-
kind
|
|
62601
|
-
});
|
|
62602
|
-
}
|
|
62603
|
-
async getAllOpenSymbols() {
|
|
62604
|
-
const response = await getAllOpenOrders({ client: this.client });
|
|
62605
|
-
return Array.from(new Set(response.map((x) => x.symbol)));
|
|
62704
|
+
async getAllOpenOrders() {
|
|
62705
|
+
return await getAllOpenOrders({ client: this.client });
|
|
62606
62706
|
}
|
|
62607
62707
|
async getDelistedSpotSymbols() {
|
|
62608
62708
|
if (this.main_client) {
|
|
@@ -62635,49 +62735,9 @@ class BinanceExchange extends BaseExchange {
|
|
|
62635
62735
|
return result;
|
|
62636
62736
|
}
|
|
62637
62737
|
}
|
|
62638
|
-
async placeMarketOrder(payload) {
|
|
62639
|
-
const { symbol, kind, quantity, price_places, decimal_places } = payload;
|
|
62640
|
-
const currentPrice = await this.get_current_price(symbol);
|
|
62641
|
-
return createLimitPurchaseOrders(this.client, symbol, price_places, decimal_places, [
|
|
62642
|
-
{
|
|
62643
|
-
force_market: true,
|
|
62644
|
-
side: kind === "long" ? "buy" : "sell",
|
|
62645
|
-
kind,
|
|
62646
|
-
quantity,
|
|
62647
|
-
price: currentPrice
|
|
62648
|
-
}
|
|
62649
|
-
]);
|
|
62650
|
-
}
|
|
62651
|
-
async rawCreateLimitPurchaseOrders(payload) {
|
|
62652
|
-
const { symbol, orders, price_places, decimal_places } = payload;
|
|
62653
|
-
return createLimitPurchaseOrders(this.client, symbol, price_places, decimal_places, orders);
|
|
62654
|
-
}
|
|
62655
62738
|
async getOpenOrders(payload) {
|
|
62656
62739
|
return await getOpenOrders(this.client, payload.symbol);
|
|
62657
62740
|
}
|
|
62658
|
-
async placeBadStopEntry(payload) {
|
|
62659
|
-
const { symbol, orders, price_places, decimal_places } = payload;
|
|
62660
|
-
const openOrders = await this.getOpenOrders({ symbol });
|
|
62661
|
-
const existingBadEntry = openOrders.filter((k) => {
|
|
62662
|
-
if (k.stopPrice > 0) {
|
|
62663
|
-
if (k.kind === "long" && k.price > k.stopPrice || k.kind === "short" && k.price < k.stopPrice) {
|
|
62664
|
-
return true;
|
|
62665
|
-
}
|
|
62666
|
-
return false;
|
|
62667
|
-
}
|
|
62668
|
-
return false;
|
|
62669
|
-
});
|
|
62670
|
-
if (existingBadEntry.length > 0) {
|
|
62671
|
-
console.log("Cancelling existing bad entry");
|
|
62672
|
-
await cancelOrders({
|
|
62673
|
-
symbol,
|
|
62674
|
-
orders: existingBadEntry.map((x) => ({ orderId: x.orderId })),
|
|
62675
|
-
custom_client: this.client
|
|
62676
|
-
});
|
|
62677
|
-
}
|
|
62678
|
-
console.log("Placing new order");
|
|
62679
|
-
return createLimitPurchaseOrders(this.client, symbol, price_places, decimal_places, orders);
|
|
62680
|
-
}
|
|
62681
62741
|
}
|
|
62682
62742
|
function getPricePlaces(target) {
|
|
62683
62743
|
const numStr = target.toString();
|
|
@@ -62875,10 +62935,11 @@ async function placeStopOrder2(client, payload) {
|
|
|
62875
62935
|
kind: payload.kind
|
|
62876
62936
|
});
|
|
62877
62937
|
}
|
|
62938
|
+
const spread = 1.00005;
|
|
62878
62939
|
const order = {
|
|
62879
62940
|
kind: payload.kind,
|
|
62880
62941
|
side: payload.kind === "long" ? "sell" : "buy",
|
|
62881
|
-
price: payload.stop,
|
|
62942
|
+
price: payload.kind === "long" ? payload.stop * spread ** -1 : payload.stop * spread,
|
|
62882
62943
|
quantity: payload.quantity,
|
|
62883
62944
|
stop: payload.final_stop,
|
|
62884
62945
|
is_market: !payload.is_limit
|
|
@@ -63174,6 +63235,28 @@ async function analyzeCharts2(params) {
|
|
|
63174
63235
|
}
|
|
63175
63236
|
return finalPairs;
|
|
63176
63237
|
}
|
|
63238
|
+
async function getAllOpenOrders2(payload) {
|
|
63239
|
+
const { client, currency = "USDT" } = payload;
|
|
63240
|
+
const response = await client.getActiveOrders({
|
|
63241
|
+
category: "linear",
|
|
63242
|
+
openOnly: 0,
|
|
63243
|
+
settleCoin: currency
|
|
63244
|
+
});
|
|
63245
|
+
let cursor = response.result.nextPageCursor;
|
|
63246
|
+
const orders = response.result.list || [];
|
|
63247
|
+
while (Boolean(cursor)) {
|
|
63248
|
+
const nextResponse = await client.getActiveOrders({
|
|
63249
|
+
category: "linear",
|
|
63250
|
+
openOnly: 0,
|
|
63251
|
+
settleCoin: currency,
|
|
63252
|
+
cursor
|
|
63253
|
+
});
|
|
63254
|
+
orders.push(...nextResponse.result.list);
|
|
63255
|
+
cursor = nextResponse.result.nextPageCursor;
|
|
63256
|
+
console.log("getAllOpenOrders cursor", cursor);
|
|
63257
|
+
}
|
|
63258
|
+
return orders;
|
|
63259
|
+
}
|
|
63177
63260
|
|
|
63178
63261
|
class BybitExchange extends BaseExchange {
|
|
63179
63262
|
client;
|
|
@@ -63183,68 +63266,16 @@ class BybitExchange extends BaseExchange {
|
|
|
63183
63266
|
this.client = client;
|
|
63184
63267
|
this.main_client = main_client;
|
|
63185
63268
|
}
|
|
63186
|
-
async
|
|
63187
|
-
|
|
63188
|
-
return placeStopOrder2(this.client, {
|
|
63189
|
-
symbol: payload.symbol,
|
|
63190
|
-
stop: payload.stop,
|
|
63191
|
-
final_stop: payload.stop,
|
|
63192
|
-
quantity: Math.abs(payload.quantity),
|
|
63193
|
-
kind: payload.kind,
|
|
63194
|
-
cancel: true,
|
|
63195
|
-
is_limit: true,
|
|
63196
|
-
price_places: payload.price_places,
|
|
63197
|
-
decimal_places: payload.decimal_places
|
|
63198
|
-
});
|
|
63199
|
-
}
|
|
63269
|
+
async getPositionInfo(symbol) {
|
|
63270
|
+
return await getPositionInfo2(this.client, symbol);
|
|
63200
63271
|
}
|
|
63201
|
-
async
|
|
63202
|
-
|
|
63203
|
-
orders,
|
|
63204
|
-
kind,
|
|
63205
|
-
decimal_places = "%.3f",
|
|
63206
|
-
price_places = "%.1f",
|
|
63207
|
-
symbol,
|
|
63208
|
-
place = false
|
|
63209
|
-
} = payload;
|
|
63210
|
-
const totalQuantity = orders.reduce((sum, order) => sum + (order.quantity || 0), 0);
|
|
63211
|
-
let runningTotal = to_f2(totalQuantity, decimal_places);
|
|
63212
|
-
let sortedOrders = [...orders].sort((a, b) => (a.entry || 0) - (b.entry || 0));
|
|
63213
|
-
if (kind === "short") {
|
|
63214
|
-
sortedOrders.reverse();
|
|
63215
|
-
}
|
|
63216
|
-
const withCumulative = [];
|
|
63217
|
-
for (const order of sortedOrders) {
|
|
63218
|
-
withCumulative.push({
|
|
63219
|
-
...order,
|
|
63220
|
-
cumulative_quantity: runningTotal
|
|
63221
|
-
});
|
|
63222
|
-
runningTotal -= order.quantity;
|
|
63223
|
-
runningTotal = to_f2(runningTotal, decimal_places);
|
|
63224
|
-
}
|
|
63225
|
-
const positions = await getPositionInfo2(this.client, symbol);
|
|
63226
|
-
const position2 = positions[kind] || {
|
|
63227
|
-
kind,
|
|
63228
|
-
size: 0,
|
|
63229
|
-
entryPrice: 0,
|
|
63230
|
-
symbol
|
|
63231
|
-
};
|
|
63232
|
-
const filteredOrders = withCumulative.filter((order) => (order.cumulative_quantity || 0) > position2.size).map((order) => ({
|
|
63233
|
-
...order,
|
|
63234
|
-
price: order.entry,
|
|
63235
|
-
kind,
|
|
63236
|
-
side: kind.toLowerCase() === "long" ? "buy" : "sell"
|
|
63237
|
-
}));
|
|
63238
|
-
if (filteredOrders.length > 0 && place) {
|
|
63239
|
-
await cancelAllOrders2(this.client, symbol, {
|
|
63240
|
-
type: "limit",
|
|
63241
|
-
kind
|
|
63242
|
-
});
|
|
63243
|
-
await createLimitPurchaseOrders2(this.client, symbol, price_places, decimal_places, filteredOrders);
|
|
63244
|
-
}
|
|
63245
|
-
return filteredOrders;
|
|
63272
|
+
async cancelAllOrders(symbol, payload) {
|
|
63273
|
+
return await cancelAllOrders2(this.client, symbol, payload);
|
|
63246
63274
|
}
|
|
63247
|
-
async
|
|
63275
|
+
async _createLimitPurchaseOrders(payload) {
|
|
63276
|
+
return await createLimitPurchaseOrders2(this.client, payload.symbol, payload.price_places, payload.decimal_places, payload.orders);
|
|
63277
|
+
}
|
|
63278
|
+
async getCurrentPrice(symbol) {
|
|
63248
63279
|
return await getCurrentPrice2(this.client, symbol);
|
|
63249
63280
|
}
|
|
63250
63281
|
async analyzeCharts(payload) {
|
|
@@ -63256,60 +63287,30 @@ class BybitExchange extends BaseExchange {
|
|
|
63256
63287
|
raw: payload.raw || false
|
|
63257
63288
|
});
|
|
63258
63289
|
}
|
|
63259
|
-
async
|
|
63260
|
-
const {
|
|
63261
|
-
price_places = "%.1f",
|
|
63262
|
-
decimal_places = "%.3f",
|
|
63263
|
-
account,
|
|
63264
|
-
symbol
|
|
63265
|
-
} = options;
|
|
63290
|
+
async getExchangeInfo(options) {
|
|
63266
63291
|
return await fetchBybitAccount(this.client, {
|
|
63267
|
-
owner: account.owner,
|
|
63268
|
-
symbol
|
|
63292
|
+
owner: options.account.owner,
|
|
63293
|
+
symbol: options.symbol
|
|
63269
63294
|
}, {
|
|
63270
|
-
price_places,
|
|
63271
|
-
decimal_places
|
|
63295
|
+
price_places: options.price_places,
|
|
63296
|
+
decimal_places: options.decimal_places
|
|
63272
63297
|
});
|
|
63273
63298
|
}
|
|
63274
|
-
async
|
|
63299
|
+
async _cancelOrders(payload) {
|
|
63275
63300
|
return await cancelOrders2({
|
|
63276
63301
|
symbol: payload.symbol,
|
|
63277
|
-
orders: payload.orders
|
|
63302
|
+
orders: payload.orders,
|
|
63278
63303
|
custom_client: this.client
|
|
63279
63304
|
});
|
|
63280
63305
|
}
|
|
63281
|
-
async
|
|
63282
|
-
return await placeTpOrder2(this.client,
|
|
63283
|
-
symbol: payload.symbol,
|
|
63284
|
-
tp: payload.take_profit,
|
|
63285
|
-
kind: payload.kind,
|
|
63286
|
-
cancel: true
|
|
63287
|
-
});
|
|
63306
|
+
async _placeTpOrder(payload) {
|
|
63307
|
+
return await placeTpOrder2(this.client, payload);
|
|
63288
63308
|
}
|
|
63289
|
-
async
|
|
63290
|
-
return await placeLimitOrders2(this.client,
|
|
63291
|
-
symbol: payload.symbol,
|
|
63292
|
-
orders: [
|
|
63293
|
-
{
|
|
63294
|
-
entry: payload.price,
|
|
63295
|
-
quantity: payload.quantity
|
|
63296
|
-
}
|
|
63297
|
-
],
|
|
63298
|
-
kind: payload.kind
|
|
63299
|
-
});
|
|
63309
|
+
async placeLimitOrders(payload) {
|
|
63310
|
+
return await placeLimitOrders2(this.client, payload);
|
|
63300
63311
|
}
|
|
63301
|
-
async
|
|
63302
|
-
return await placeStopOrder2(this.client,
|
|
63303
|
-
symbol: payload.symbol,
|
|
63304
|
-
stop: payload.stop,
|
|
63305
|
-
final_stop: payload.stop,
|
|
63306
|
-
quantity: Math.abs(payload.quantity),
|
|
63307
|
-
kind: payload.kind,
|
|
63308
|
-
cancel: true,
|
|
63309
|
-
is_limit: true,
|
|
63310
|
-
price_places: payload.price_places,
|
|
63311
|
-
decimal_places: payload.decimal_places
|
|
63312
|
-
});
|
|
63312
|
+
async _placeStopOrder(payload) {
|
|
63313
|
+
return await placeStopOrder2(this.client, payload);
|
|
63313
63314
|
}
|
|
63314
63315
|
async setLeverage(payload) {
|
|
63315
63316
|
return await this.client.setLeverage({
|
|
@@ -63323,40 +63324,18 @@ class BybitExchange extends BaseExchange {
|
|
|
63323
63324
|
}
|
|
63324
63325
|
async checkDelistedMovers(payload) {
|
|
63325
63326
|
}
|
|
63326
|
-
async
|
|
63327
|
-
|
|
63328
|
-
|
|
63329
|
-
return [];
|
|
63327
|
+
async getAllOpenOrders() {
|
|
63328
|
+
const result = await getAllOpenOrders2({ client: this.client });
|
|
63329
|
+
return result;
|
|
63330
63330
|
}
|
|
63331
63331
|
async getOpenPositions() {
|
|
63332
63332
|
return [];
|
|
63333
63333
|
}
|
|
63334
|
-
async createLimitPurchaseOrders(payload) {
|
|
63335
|
-
const {
|
|
63336
|
-
orders,
|
|
63337
|
-
kind,
|
|
63338
|
-
decimal_places = "%.3f",
|
|
63339
|
-
price_places = "%.1f",
|
|
63340
|
-
symbol
|
|
63341
|
-
} = payload;
|
|
63342
|
-
return await createLimitPurchaseOrders2(this.client, symbol, price_places, decimal_places, orders.map((order) => ({
|
|
63343
|
-
...order,
|
|
63344
|
-
price: order.entry,
|
|
63345
|
-
kind,
|
|
63346
|
-
side: kind.toLowerCase() === "long" ? "buy" : "sell"
|
|
63347
|
-
})));
|
|
63348
|
-
}
|
|
63349
63334
|
async getDelistedSpotSymbols() {
|
|
63350
63335
|
return [];
|
|
63351
63336
|
}
|
|
63352
63337
|
async crossAccountTransfer(payload) {
|
|
63353
63338
|
}
|
|
63354
|
-
async placeMarketOrder(payload) {
|
|
63355
|
-
}
|
|
63356
|
-
async rawCreateLimitPurchaseOrders(payload) {
|
|
63357
|
-
const { symbol, orders, price_places, decimal_places } = payload;
|
|
63358
|
-
return createLimitPurchaseOrders2(this.client, symbol, price_places, decimal_places, orders);
|
|
63359
|
-
}
|
|
63360
63339
|
getOpenOrders(payload) {
|
|
63361
63340
|
return getOpenOrders2(this.client, payload.symbol);
|
|
63362
63341
|
}
|
|
@@ -64792,6 +64771,9 @@ class ExchangeAccount {
|
|
|
64792
64771
|
long_config,
|
|
64793
64772
|
short_config
|
|
64794
64773
|
});
|
|
64774
|
+
if (!long_config || !short_config) {
|
|
64775
|
+
return null;
|
|
64776
|
+
}
|
|
64795
64777
|
let long_target_pnl = payload.kind == "long" ? payload.target_pnl : 0;
|
|
64796
64778
|
let short_target_pnl = payload.kind == "short" ? payload.target_pnl : 0;
|
|
64797
64779
|
const long_sell_ratio = long_config.sell_ratio || long_position?.sell_ratio;
|
|
@@ -64916,7 +64898,7 @@ class ExchangeAccount {
|
|
|
64916
64898
|
});
|
|
64917
64899
|
const long_pause_tp = long_config?.pause_tp;
|
|
64918
64900
|
const short_pause_tp = short_config?.pause_tp;
|
|
64919
|
-
if (payload.trigger && !long_pause_tp && !short_pause_tp) {
|
|
64901
|
+
if (payload.trigger && !long_pause_tp && !short_pause_tp && config2) {
|
|
64920
64902
|
return await this.reduceMajorPositionEntry({
|
|
64921
64903
|
symbol,
|
|
64922
64904
|
long: config2.long,
|
|
@@ -65480,15 +65462,15 @@ class ExchangeAccount {
|
|
|
65480
65462
|
}
|
|
65481
65463
|
async buildOppositeTrades(payload) {
|
|
65482
65464
|
const { symbol, kind, place, place_symbol } = payload;
|
|
65483
|
-
const
|
|
65465
|
+
const strategy2 = await this.runSimulation({
|
|
65484
65466
|
symbol,
|
|
65485
65467
|
kind,
|
|
65486
65468
|
raw: true
|
|
65487
65469
|
});
|
|
65488
65470
|
try {
|
|
65489
|
-
const result =
|
|
65471
|
+
const result = strategy2.generateOppositeTrades({
|
|
65490
65472
|
kind,
|
|
65491
|
-
avg_entry:
|
|
65473
|
+
avg_entry: strategy2.position[kind].avg_price
|
|
65492
65474
|
});
|
|
65493
65475
|
if (place && result?.kind) {
|
|
65494
65476
|
const _symbol = place_symbol || symbol;
|
|
@@ -65539,7 +65521,7 @@ class ExchangeAccount {
|
|
|
65539
65521
|
reduce_ratio,
|
|
65540
65522
|
global_config: symbol_config
|
|
65541
65523
|
};
|
|
65542
|
-
const
|
|
65524
|
+
const strategy2 = new Strategy({
|
|
65543
65525
|
long: {
|
|
65544
65526
|
entry: long_position.entry,
|
|
65545
65527
|
quantity: long_position.quantity,
|
|
@@ -65555,9 +65537,9 @@ class ExchangeAccount {
|
|
|
65555
65537
|
config: strategy_config
|
|
65556
65538
|
});
|
|
65557
65539
|
if (raw) {
|
|
65558
|
-
return
|
|
65540
|
+
return strategy2;
|
|
65559
65541
|
}
|
|
65560
|
-
return
|
|
65542
|
+
return strategy2.runIterations({
|
|
65561
65543
|
iterations,
|
|
65562
65544
|
kind
|
|
65563
65545
|
});
|
|
@@ -66246,31 +66228,31 @@ class ExchangeAccount {
|
|
|
66246
66228
|
if (!focus_position) {
|
|
66247
66229
|
return;
|
|
66248
66230
|
}
|
|
66249
|
-
const
|
|
66250
|
-
if (!
|
|
66231
|
+
const strategy2 = focus_position?.expand?.account_strategy;
|
|
66232
|
+
if (!strategy2) {
|
|
66251
66233
|
return;
|
|
66252
66234
|
}
|
|
66253
|
-
const risk =
|
|
66254
|
-
const kind =
|
|
66255
|
-
const support =
|
|
66256
|
-
const resistance =
|
|
66235
|
+
const risk = strategy2.risk;
|
|
66236
|
+
const kind = strategy2.kind;
|
|
66237
|
+
const support = strategy2.support;
|
|
66238
|
+
const resistance = strategy2.resistance;
|
|
66257
66239
|
console.log("Getting long and short positions for ", symbol);
|
|
66258
66240
|
const long_position = positions.find((k) => k.kind === "long");
|
|
66259
66241
|
const short_position = positions.find((k) => k.kind === "short");
|
|
66260
66242
|
console.log("Getting focus position for ", symbol, kind);
|
|
66261
66243
|
const reverse_position = kind === "long" ? short_position : long_position;
|
|
66262
|
-
if (
|
|
66263
|
-
reward_factor =
|
|
66244
|
+
if (strategy2.max_reward_factor === 0) {
|
|
66245
|
+
reward_factor = strategy2.reward_factor;
|
|
66264
66246
|
}
|
|
66265
|
-
if (focus_position.avg_qty >= focus_position.quantity &&
|
|
66266
|
-
if (
|
|
66247
|
+
if (focus_position.avg_qty >= focus_position.quantity && strategy2.max_reward_factor) {
|
|
66248
|
+
if (strategy2.dynamic) {
|
|
66267
66249
|
const quantity_ratio = focus_position.quantity / focus_position.avg_qty;
|
|
66268
|
-
reward_factor = to_f2(quantity_ratio ** 2 *
|
|
66250
|
+
reward_factor = to_f2(quantity_ratio ** 2 * strategy2.max_reward_factor, "%.2f");
|
|
66269
66251
|
} else {
|
|
66270
|
-
reward_factor = to_f2(focus_position.quantity *
|
|
66252
|
+
reward_factor = to_f2(focus_position.quantity * strategy2.max_reward_factor / focus_position.avg_qty, "%.4f");
|
|
66271
66253
|
}
|
|
66272
66254
|
} else {
|
|
66273
|
-
reward_factor =
|
|
66255
|
+
reward_factor = strategy2.reward_factor;
|
|
66274
66256
|
}
|
|
66275
66257
|
console.log("Getting entry and stop for ", symbol, kind);
|
|
66276
66258
|
const entry = kind === "long" ? resistance : support;
|
|
@@ -66284,7 +66266,7 @@ class ExchangeAccount {
|
|
|
66284
66266
|
symbol
|
|
66285
66267
|
});
|
|
66286
66268
|
console.log("Computing risk reward for ", symbol, kind);
|
|
66287
|
-
const risk_reward =
|
|
66269
|
+
const risk_reward = strategy2.risk_reward || computeRiskReward({
|
|
66288
66270
|
app_config: initial_app_config,
|
|
66289
66271
|
entry: initial_app_config.entry,
|
|
66290
66272
|
stop: initial_app_config.stop,
|
|
@@ -66417,7 +66399,7 @@ class ExchangeAccount {
|
|
|
66417
66399
|
const max_size = app_config.max_size * 0.98;
|
|
66418
66400
|
if (reverse_config.threshold_qty !== max_size) {
|
|
66419
66401
|
await this.app_db.updateScheduledTrade(reverse_config.id, {
|
|
66420
|
-
follow:
|
|
66402
|
+
follow: strategy2.follow,
|
|
66421
66403
|
threshold_qty: max_size
|
|
66422
66404
|
});
|
|
66423
66405
|
}
|
|
@@ -66491,8 +66473,8 @@ class ExchangeAccount {
|
|
|
66491
66473
|
}
|
|
66492
66474
|
const reverse_kind = focus_position.kind === "long" ? "short" : "long";
|
|
66493
66475
|
const reverse_position = positions.find((k) => k.kind === reverse_kind);
|
|
66494
|
-
const
|
|
66495
|
-
if (!
|
|
66476
|
+
const strategy2 = focus_position?.expand?.account_strategy;
|
|
66477
|
+
if (!strategy2) {
|
|
66496
66478
|
return;
|
|
66497
66479
|
}
|
|
66498
66480
|
return computeProfitDetail({
|
|
@@ -66505,9 +66487,9 @@ class ExchangeAccount {
|
|
|
66505
66487
|
},
|
|
66506
66488
|
pnl: focus_position.target_pnl,
|
|
66507
66489
|
strategy: {
|
|
66508
|
-
reward_factor:
|
|
66509
|
-
risk:
|
|
66510
|
-
max_reward_factor:
|
|
66490
|
+
reward_factor: strategy2.reward_factor,
|
|
66491
|
+
risk: strategy2.risk,
|
|
66492
|
+
max_reward_factor: strategy2.max_reward_factor
|
|
66511
66493
|
},
|
|
66512
66494
|
reduce_position: {
|
|
66513
66495
|
kind: reduce_position.kind,
|
|
@@ -66753,6 +66735,9 @@ class App {
|
|
|
66753
66735
|
owner: exchange.owner,
|
|
66754
66736
|
exchange: exchange.exchange
|
|
66755
66737
|
});
|
|
66738
|
+
if (exchange.exchange === "bybit" && symbol === "BTCUSDC") {
|
|
66739
|
+
continue;
|
|
66740
|
+
}
|
|
66756
66741
|
await exchange_account.placeProfitAndStop({
|
|
66757
66742
|
symbol,
|
|
66758
66743
|
trigger: true,
|
|
@@ -66847,11 +66832,11 @@ class App {
|
|
|
66847
66832
|
}
|
|
66848
66833
|
async runDbStrategyAccounts(callback) {
|
|
66849
66834
|
const strategies = await this.app_db.getRunningAccountStrategies();
|
|
66850
|
-
for (const
|
|
66851
|
-
console.log("Running strategy for ",
|
|
66835
|
+
for (const strategy2 of strategies) {
|
|
66836
|
+
console.log("Running strategy for ", strategy2.symbol, "for account", strategy2.expand.account.owner, strategy2.expand.account.exchange);
|
|
66852
66837
|
await callback({
|
|
66853
|
-
symbol:
|
|
66854
|
-
account:
|
|
66838
|
+
symbol: strategy2.symbol,
|
|
66839
|
+
account: strategy2.expand.account
|
|
66855
66840
|
});
|
|
66856
66841
|
}
|
|
66857
66842
|
}
|