@gbozee/ultimate 0.0.2-93 → 0.0.2-95
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 +32 -0
- package/dist/frontend-index.js +38 -0
- package/dist/index.cjs +174 -8
- package/dist/index.d.ts +122 -24
- package/dist/index.js +174 -8
- package/dist/mcp-server.cjs +173 -8
- package/dist/mcp-server.js +173 -8
- package/package.json +1 -1
package/dist/frontend-index.d.ts
CHANGED
|
@@ -398,6 +398,38 @@ export declare function getRiskReward(payload: {
|
|
|
398
398
|
risk: number;
|
|
399
399
|
global_config: GlobalConfig;
|
|
400
400
|
}): any;
|
|
401
|
+
export declare function computeProfitDetail(payload: {
|
|
402
|
+
focus_position: {
|
|
403
|
+
kind: "long" | "short";
|
|
404
|
+
entry: number;
|
|
405
|
+
quantity: number;
|
|
406
|
+
avg_qty: number;
|
|
407
|
+
avg_price: number;
|
|
408
|
+
};
|
|
409
|
+
strategy: {
|
|
410
|
+
reward_factor: number;
|
|
411
|
+
max_reward_factor: number;
|
|
412
|
+
risk: number;
|
|
413
|
+
};
|
|
414
|
+
reduce_position: {
|
|
415
|
+
kind: "long" | "short";
|
|
416
|
+
entry: number;
|
|
417
|
+
quantity: number;
|
|
418
|
+
avg_qty: number;
|
|
419
|
+
avg_price: number;
|
|
420
|
+
};
|
|
421
|
+
price_places?: string;
|
|
422
|
+
decimal_places?: string;
|
|
423
|
+
}): {
|
|
424
|
+
pnl: number;
|
|
425
|
+
reward_factor: number;
|
|
426
|
+
profit_percent: number;
|
|
427
|
+
kind: "long" | "short";
|
|
428
|
+
sell_price: number;
|
|
429
|
+
quantity: number;
|
|
430
|
+
price_places: string;
|
|
431
|
+
decimal_places: string;
|
|
432
|
+
};
|
|
401
433
|
export type StrategyPosition = {
|
|
402
434
|
entry: number;
|
|
403
435
|
quantity: number;
|
package/dist/frontend-index.js
CHANGED
|
@@ -1761,6 +1761,43 @@ function getRiskReward(payload) {
|
|
|
1761
1761
|
});
|
|
1762
1762
|
return risk_reward;
|
|
1763
1763
|
}
|
|
1764
|
+
function computeProfitDetail(payload) {
|
|
1765
|
+
const {
|
|
1766
|
+
focus_position,
|
|
1767
|
+
strategy,
|
|
1768
|
+
price_places = "%.1f",
|
|
1769
|
+
reduce_position,
|
|
1770
|
+
decimal_places
|
|
1771
|
+
} = payload;
|
|
1772
|
+
let reward_factor = strategy.reward_factor;
|
|
1773
|
+
let risk = strategy.risk;
|
|
1774
|
+
if (strategy.max_reward_factor === 0) {
|
|
1775
|
+
reward_factor = strategy.reward_factor;
|
|
1776
|
+
}
|
|
1777
|
+
if (focus_position.avg_qty >= focus_position.quantity && strategy.max_reward_factor) {
|
|
1778
|
+
reward_factor = focus_position.quantity * strategy.max_reward_factor / focus_position.avg_qty;
|
|
1779
|
+
} else {
|
|
1780
|
+
reward_factor = strategy.reward_factor;
|
|
1781
|
+
}
|
|
1782
|
+
const full_pnl = reward_factor * risk;
|
|
1783
|
+
const profit_percent = to_f(full_pnl * 100 / (focus_position.avg_price * focus_position.avg_qty), "%.4f");
|
|
1784
|
+
const pnl = to_f(focus_position.entry * focus_position.quantity * profit_percent / 100, "%.2f");
|
|
1785
|
+
const diff = pnl / focus_position.quantity;
|
|
1786
|
+
const sell_price = to_f(focus_position.kind === "long" ? focus_position.entry + diff : focus_position.entry - diff, price_places);
|
|
1787
|
+
const loss = Math.abs(reduce_position.entry - sell_price) * reduce_position.quantity;
|
|
1788
|
+
const ratio = pnl / loss;
|
|
1789
|
+
const quantity = to_f(reduce_position.quantity * ratio, decimal_places);
|
|
1790
|
+
return {
|
|
1791
|
+
pnl,
|
|
1792
|
+
reward_factor,
|
|
1793
|
+
profit_percent,
|
|
1794
|
+
kind: focus_position.kind,
|
|
1795
|
+
sell_price: to_f(sell_price, price_places),
|
|
1796
|
+
quantity,
|
|
1797
|
+
price_places,
|
|
1798
|
+
decimal_places
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1764
1801
|
// src/helpers/strategy.ts
|
|
1765
1802
|
class Strategy {
|
|
1766
1803
|
position;
|
|
@@ -2196,6 +2233,7 @@ export {
|
|
|
2196
2233
|
computeTotalAverageForEachTrade,
|
|
2197
2234
|
computeSellZones,
|
|
2198
2235
|
computeRiskReward,
|
|
2236
|
+
computeProfitDetail,
|
|
2199
2237
|
buildConfig,
|
|
2200
2238
|
buildAvg,
|
|
2201
2239
|
buildAppConfig,
|
package/dist/index.cjs
CHANGED
|
@@ -41904,6 +41904,7 @@ __export(exports_src, {
|
|
|
41904
41904
|
database: () => exports_database,
|
|
41905
41905
|
createArray: () => createArray,
|
|
41906
41906
|
computeRiskReward: () => computeRiskReward,
|
|
41907
|
+
computeProfitDetail: () => computeProfitDetail,
|
|
41907
41908
|
buildConfig: () => buildConfig,
|
|
41908
41909
|
buildAvg: () => buildAvg,
|
|
41909
41910
|
buildAppConfig: () => buildAppConfig,
|
|
@@ -51603,7 +51604,7 @@ class AppDatabase {
|
|
|
51603
51604
|
table: "positions_view",
|
|
51604
51605
|
params: {
|
|
51605
51606
|
filter: `symbol:lower="${symbol.toLowerCase()}" && account:lower="${account.owner.toLowerCase()} ${account.exchange.toLowerCase()}"`,
|
|
51606
|
-
expand: "config"
|
|
51607
|
+
expand: "config, account_strategy, p_account"
|
|
51607
51608
|
}
|
|
51608
51609
|
} : {
|
|
51609
51610
|
table: "positions",
|
|
@@ -53840,6 +53841,43 @@ function getRiskReward(payload) {
|
|
|
53840
53841
|
});
|
|
53841
53842
|
return risk_reward;
|
|
53842
53843
|
}
|
|
53844
|
+
function computeProfitDetail(payload) {
|
|
53845
|
+
const {
|
|
53846
|
+
focus_position,
|
|
53847
|
+
strategy,
|
|
53848
|
+
price_places = "%.1f",
|
|
53849
|
+
reduce_position,
|
|
53850
|
+
decimal_places
|
|
53851
|
+
} = payload;
|
|
53852
|
+
let reward_factor = strategy.reward_factor;
|
|
53853
|
+
let risk = strategy.risk;
|
|
53854
|
+
if (strategy.max_reward_factor === 0) {
|
|
53855
|
+
reward_factor = strategy.reward_factor;
|
|
53856
|
+
}
|
|
53857
|
+
if (focus_position.avg_qty >= focus_position.quantity && strategy.max_reward_factor) {
|
|
53858
|
+
reward_factor = focus_position.quantity * strategy.max_reward_factor / focus_position.avg_qty;
|
|
53859
|
+
} else {
|
|
53860
|
+
reward_factor = strategy.reward_factor;
|
|
53861
|
+
}
|
|
53862
|
+
const full_pnl = reward_factor * risk;
|
|
53863
|
+
const profit_percent = to_f2(full_pnl * 100 / (focus_position.avg_price * focus_position.avg_qty), "%.4f");
|
|
53864
|
+
const pnl = to_f2(focus_position.entry * focus_position.quantity * profit_percent / 100, "%.2f");
|
|
53865
|
+
const diff = pnl / focus_position.quantity;
|
|
53866
|
+
const sell_price = to_f2(focus_position.kind === "long" ? focus_position.entry + diff : focus_position.entry - diff, price_places);
|
|
53867
|
+
const loss = Math.abs(reduce_position.entry - sell_price) * reduce_position.quantity;
|
|
53868
|
+
const ratio = pnl / loss;
|
|
53869
|
+
const quantity = to_f2(reduce_position.quantity * ratio, decimal_places);
|
|
53870
|
+
return {
|
|
53871
|
+
pnl,
|
|
53872
|
+
reward_factor,
|
|
53873
|
+
profit_percent,
|
|
53874
|
+
kind: focus_position.kind,
|
|
53875
|
+
sell_price: to_f2(sell_price, price_places),
|
|
53876
|
+
quantity,
|
|
53877
|
+
price_places,
|
|
53878
|
+
decimal_places
|
|
53879
|
+
};
|
|
53880
|
+
}
|
|
53843
53881
|
|
|
53844
53882
|
// src/helpers/strategy.ts
|
|
53845
53883
|
class Strategy {
|
|
@@ -54246,6 +54284,54 @@ class Strategy {
|
|
|
54246
54284
|
|
|
54247
54285
|
// src/exchanges/binance.ts
|
|
54248
54286
|
var import_binance = __toESM(require_lib2());
|
|
54287
|
+
|
|
54288
|
+
// src/types/index.ts
|
|
54289
|
+
class BaseExchange {
|
|
54290
|
+
client;
|
|
54291
|
+
constructor(client) {
|
|
54292
|
+
this.client = client;
|
|
54293
|
+
}
|
|
54294
|
+
async customStopLoss(payload) {
|
|
54295
|
+
const {
|
|
54296
|
+
symbol,
|
|
54297
|
+
kind,
|
|
54298
|
+
stop: _stop,
|
|
54299
|
+
quantity,
|
|
54300
|
+
increase = false,
|
|
54301
|
+
price_places,
|
|
54302
|
+
decimal_places
|
|
54303
|
+
} = payload;
|
|
54304
|
+
const spread = 1.00005;
|
|
54305
|
+
const stop = kind === "long" ? _stop * spread ** -1 : _stop * spread;
|
|
54306
|
+
const order = [
|
|
54307
|
+
{
|
|
54308
|
+
kind,
|
|
54309
|
+
side: kind === "long" ? "sell" : "buy",
|
|
54310
|
+
price: stop,
|
|
54311
|
+
quantity,
|
|
54312
|
+
stop: _stop,
|
|
54313
|
+
is_market: false
|
|
54314
|
+
}
|
|
54315
|
+
];
|
|
54316
|
+
if (increase) {
|
|
54317
|
+
order.push({
|
|
54318
|
+
kind,
|
|
54319
|
+
price: stop,
|
|
54320
|
+
side: kind === "long" ? "buy" : "sell",
|
|
54321
|
+
quantity,
|
|
54322
|
+
is_market: false
|
|
54323
|
+
});
|
|
54324
|
+
}
|
|
54325
|
+
return this.rawCreateLimitPurchaseOrders({
|
|
54326
|
+
orders: order,
|
|
54327
|
+
symbol,
|
|
54328
|
+
price_places,
|
|
54329
|
+
decimal_places
|
|
54330
|
+
});
|
|
54331
|
+
}
|
|
54332
|
+
}
|
|
54333
|
+
|
|
54334
|
+
// src/exchanges/binance.ts
|
|
54249
54335
|
var CONSTANTS = {
|
|
54250
54336
|
SPOT_TO_FIAT: "MAIN_C2C",
|
|
54251
54337
|
SPOT_TO_USDT_FUTURE: "MAIN_UMFUTURE",
|
|
@@ -55016,12 +55102,13 @@ async function getAllOpenOrders(payload) {
|
|
|
55016
55102
|
return response;
|
|
55017
55103
|
}
|
|
55018
55104
|
|
|
55019
|
-
class BinanceExchange {
|
|
55105
|
+
class BinanceExchange extends BaseExchange {
|
|
55020
55106
|
client;
|
|
55021
55107
|
main_client;
|
|
55022
55108
|
getCredentials;
|
|
55023
55109
|
proxyAgent;
|
|
55024
55110
|
constructor(client, main_client) {
|
|
55111
|
+
super(client);
|
|
55025
55112
|
this.client = client;
|
|
55026
55113
|
this.main_client = main_client;
|
|
55027
55114
|
}
|
|
@@ -55333,6 +55420,10 @@ class BinanceExchange {
|
|
|
55333
55420
|
}
|
|
55334
55421
|
]);
|
|
55335
55422
|
}
|
|
55423
|
+
async rawCreateLimitPurchaseOrders(payload) {
|
|
55424
|
+
const { symbol, orders, price_places, decimal_places } = payload;
|
|
55425
|
+
return createLimitPurchaseOrders(this.client, symbol, price_places, decimal_places, orders);
|
|
55426
|
+
}
|
|
55336
55427
|
}
|
|
55337
55428
|
function getPricePlaces(target) {
|
|
55338
55429
|
const numStr = target.toString();
|
|
@@ -55830,10 +55921,11 @@ async function analyzeCharts2(params) {
|
|
|
55830
55921
|
return finalPairs;
|
|
55831
55922
|
}
|
|
55832
55923
|
|
|
55833
|
-
class BybitExchange {
|
|
55924
|
+
class BybitExchange extends BaseExchange {
|
|
55834
55925
|
client;
|
|
55835
55926
|
main_client;
|
|
55836
55927
|
constructor(client, main_client) {
|
|
55928
|
+
super(client);
|
|
55837
55929
|
this.client = client;
|
|
55838
55930
|
this.main_client = main_client;
|
|
55839
55931
|
}
|
|
@@ -56007,6 +56099,10 @@ class BybitExchange {
|
|
|
56007
56099
|
}
|
|
56008
56100
|
async placeMarketOrder(payload) {
|
|
56009
56101
|
}
|
|
56102
|
+
async rawCreateLimitPurchaseOrders(payload) {
|
|
56103
|
+
const { symbol, orders, price_places, decimal_places } = payload;
|
|
56104
|
+
return createLimitPurchaseOrders2(this.client, symbol, price_places, decimal_places, orders);
|
|
56105
|
+
}
|
|
56010
56106
|
}
|
|
56011
56107
|
|
|
56012
56108
|
// src/helpers/accounts.ts
|
|
@@ -58771,15 +58867,19 @@ class ExchangeAccount {
|
|
|
58771
58867
|
async profitWithinGapStrategy(payload) {
|
|
58772
58868
|
const { symbol } = payload;
|
|
58773
58869
|
let reward_factor = 1;
|
|
58774
|
-
const strategy = await this.getAccountStrategy({ symbol });
|
|
58775
|
-
if (!strategy) {
|
|
58776
|
-
return;
|
|
58777
|
-
}
|
|
58778
58870
|
console.log("Fetching positions for ", symbol);
|
|
58779
58871
|
const positions = await this.syncAccount({
|
|
58780
58872
|
symbol,
|
|
58781
58873
|
as_view: true
|
|
58782
58874
|
});
|
|
58875
|
+
const focus_position = positions.find((k) => k.expand?.account_strategy);
|
|
58876
|
+
if (!focus_position) {
|
|
58877
|
+
return;
|
|
58878
|
+
}
|
|
58879
|
+
const strategy = focus_position?.expand?.account_strategy;
|
|
58880
|
+
if (!strategy) {
|
|
58881
|
+
return;
|
|
58882
|
+
}
|
|
58783
58883
|
const risk = strategy.risk;
|
|
58784
58884
|
const kind = strategy.kind;
|
|
58785
58885
|
const support = strategy.support;
|
|
@@ -58788,7 +58888,6 @@ class ExchangeAccount {
|
|
|
58788
58888
|
const long_position = positions.find((k) => k.kind === "long");
|
|
58789
58889
|
const short_position = positions.find((k) => k.kind === "short");
|
|
58790
58890
|
console.log("Getting focus position for ", symbol, kind);
|
|
58791
|
-
const focus_position = kind === "long" ? long_position : short_position;
|
|
58792
58891
|
const reverse_position = kind === "long" ? short_position : long_position;
|
|
58793
58892
|
if (strategy.max_reward_factor === 0) {
|
|
58794
58893
|
reward_factor = strategy.reward_factor;
|
|
@@ -58968,6 +59067,47 @@ class ExchangeAccount {
|
|
|
58968
59067
|
}
|
|
58969
59068
|
};
|
|
58970
59069
|
}
|
|
59070
|
+
async getSellPriceFromStrategy(payload) {
|
|
59071
|
+
const { symbol, reduce_position } = payload;
|
|
59072
|
+
const symbol_config = await this.recomputeSymbolConfig({
|
|
59073
|
+
symbol
|
|
59074
|
+
});
|
|
59075
|
+
const positions = await this.syncAccount({
|
|
59076
|
+
symbol,
|
|
59077
|
+
as_view: true
|
|
59078
|
+
});
|
|
59079
|
+
const focus_position = positions.find((k) => k.expand?.account_strategy);
|
|
59080
|
+
if (!focus_position) {
|
|
59081
|
+
return;
|
|
59082
|
+
}
|
|
59083
|
+
const strategy = focus_position?.expand?.account_strategy;
|
|
59084
|
+
if (!strategy) {
|
|
59085
|
+
return;
|
|
59086
|
+
}
|
|
59087
|
+
return computeProfitDetail({
|
|
59088
|
+
focus_position: {
|
|
59089
|
+
kind: focus_position.kind,
|
|
59090
|
+
entry: focus_position.entry,
|
|
59091
|
+
quantity: focus_position.quantity,
|
|
59092
|
+
avg_price: focus_position.avg_price,
|
|
59093
|
+
avg_qty: focus_position.avg_qty
|
|
59094
|
+
},
|
|
59095
|
+
strategy: {
|
|
59096
|
+
reward_factor: strategy.reward_factor,
|
|
59097
|
+
risk: strategy.risk,
|
|
59098
|
+
max_reward_factor: strategy.max_reward_factor
|
|
59099
|
+
},
|
|
59100
|
+
reduce_position: {
|
|
59101
|
+
kind: reduce_position.kind,
|
|
59102
|
+
entry: reduce_position.entry,
|
|
59103
|
+
quantity: reduce_position.quantity,
|
|
59104
|
+
avg_price: reduce_position.avg_price,
|
|
59105
|
+
avg_qty: reduce_position.avg_qty
|
|
59106
|
+
},
|
|
59107
|
+
price_places: symbol_config.price_places,
|
|
59108
|
+
decimal_places: symbol_config.decimal_places
|
|
59109
|
+
});
|
|
59110
|
+
}
|
|
58971
59111
|
}
|
|
58972
59112
|
function getExchangeKlass(exchange) {
|
|
58973
59113
|
const func = exchange === "binance" ? BinanceExchange : BybitExchange;
|
|
@@ -59300,6 +59440,32 @@ class App {
|
|
|
59300
59440
|
});
|
|
59301
59441
|
return result;
|
|
59302
59442
|
}
|
|
59443
|
+
async reduceExistingPosition(payload) {
|
|
59444
|
+
const { main_account, reduce_account, kind, place, increase } = payload;
|
|
59445
|
+
const main_exchange_account = await this.getExchangeAccount(main_account);
|
|
59446
|
+
const reduce_exchange_account = await this.getExchangeAccount(reduce_account);
|
|
59447
|
+
const reduce_position = await reduce_exchange_account.syncAccount({
|
|
59448
|
+
symbol: reduce_account.symbol,
|
|
59449
|
+
kind,
|
|
59450
|
+
as_view: true
|
|
59451
|
+
});
|
|
59452
|
+
const result = await main_exchange_account.getSellPriceFromStrategy({
|
|
59453
|
+
symbol: main_account.symbol,
|
|
59454
|
+
reduce_position
|
|
59455
|
+
});
|
|
59456
|
+
if (place) {
|
|
59457
|
+
return reduce_exchange_account.exchange.customStopLoss({
|
|
59458
|
+
symbol: reduce_account.symbol,
|
|
59459
|
+
kind: reduce_position.kind,
|
|
59460
|
+
stop: result.sell_price,
|
|
59461
|
+
quantity: result.quantity,
|
|
59462
|
+
price_places: result.price_places,
|
|
59463
|
+
decimal_places: result.decimal_places,
|
|
59464
|
+
increase
|
|
59465
|
+
});
|
|
59466
|
+
}
|
|
59467
|
+
return result;
|
|
59468
|
+
}
|
|
59303
59469
|
}
|
|
59304
59470
|
async function initApp(payload) {
|
|
59305
59471
|
const pb = await initPocketBaseClient(payload.db);
|
package/dist/index.d.ts
CHANGED
|
@@ -208,9 +208,26 @@ export interface Account {
|
|
|
208
208
|
short: any;
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
-
|
|
211
|
+
interface Order$1 {
|
|
212
|
+
order_id?: string;
|
|
213
|
+
symbol?: string;
|
|
214
|
+
price: number;
|
|
215
|
+
quantity: number;
|
|
216
|
+
kind: "long" | "short";
|
|
217
|
+
side: "buy" | "sell";
|
|
218
|
+
stop: number;
|
|
219
|
+
triggerPrice?: number;
|
|
220
|
+
}
|
|
221
|
+
declare abstract class BaseExchange {
|
|
212
222
|
client: any;
|
|
213
|
-
|
|
223
|
+
constructor(client: any);
|
|
224
|
+
abstract rawCreateLimitPurchaseOrders(payload: {
|
|
225
|
+
symbol: string;
|
|
226
|
+
orders: Order$1[];
|
|
227
|
+
price_places?: string;
|
|
228
|
+
decimal_places?: string;
|
|
229
|
+
}): Promise<any>;
|
|
230
|
+
abstract placeStopOrders(payload: {
|
|
214
231
|
symbol: string;
|
|
215
232
|
quantity: number;
|
|
216
233
|
kind: "long" | "short";
|
|
@@ -219,7 +236,7 @@ export interface BaseExchange {
|
|
|
219
236
|
decimal_places?: string;
|
|
220
237
|
place?: boolean;
|
|
221
238
|
}): Promise<any>;
|
|
222
|
-
bulkPlaceLimitOrders(payload: {
|
|
239
|
+
abstract bulkPlaceLimitOrders(payload: {
|
|
223
240
|
orders: any[];
|
|
224
241
|
kind: "long" | "short";
|
|
225
242
|
decimal_places?: string;
|
|
@@ -227,14 +244,14 @@ export interface BaseExchange {
|
|
|
227
244
|
symbol: string;
|
|
228
245
|
place?: boolean;
|
|
229
246
|
}): Promise<any>;
|
|
230
|
-
get_current_price(symbol: string): Promise<any>;
|
|
231
|
-
analyzeCharts(payload: {
|
|
247
|
+
abstract get_current_price(symbol: string): Promise<any>;
|
|
248
|
+
abstract analyzeCharts(payload: {
|
|
232
249
|
symbol: string;
|
|
233
250
|
chartType: any;
|
|
234
251
|
count: number;
|
|
235
252
|
raw?: boolean;
|
|
236
253
|
}): Promise<any>;
|
|
237
|
-
getExchangeAccountInfo(options: {
|
|
254
|
+
abstract getExchangeAccountInfo(options: {
|
|
238
255
|
price_places?: string;
|
|
239
256
|
decimal_places?: string;
|
|
240
257
|
account: {
|
|
@@ -243,11 +260,11 @@ export interface BaseExchange {
|
|
|
243
260
|
};
|
|
244
261
|
symbol: string;
|
|
245
262
|
}): Promise<any>;
|
|
246
|
-
cancelOrders(payload: {
|
|
263
|
+
abstract cancelOrders(payload: {
|
|
247
264
|
symbol: string;
|
|
248
265
|
orders: number[];
|
|
249
266
|
}): Promise<any>;
|
|
250
|
-
placeTpOrder(payload: {
|
|
267
|
+
abstract placeTpOrder(payload: {
|
|
251
268
|
symbol: string;
|
|
252
269
|
take_profit: number;
|
|
253
270
|
kind: "long" | "short";
|
|
@@ -256,7 +273,7 @@ export interface BaseExchange {
|
|
|
256
273
|
price_places?: string;
|
|
257
274
|
decimal_places?: string;
|
|
258
275
|
}): Promise<any>;
|
|
259
|
-
placeLimitOrder(payload: {
|
|
276
|
+
abstract placeLimitOrder(payload: {
|
|
260
277
|
symbol: string;
|
|
261
278
|
quantity: number;
|
|
262
279
|
kind: "long" | "short";
|
|
@@ -264,7 +281,7 @@ export interface BaseExchange {
|
|
|
264
281
|
price_places?: string;
|
|
265
282
|
decimal_places?: string;
|
|
266
283
|
}): Promise<any>;
|
|
267
|
-
placeStopOrder(payload: {
|
|
284
|
+
abstract placeStopOrder(payload: {
|
|
268
285
|
symbol: string;
|
|
269
286
|
stop: number;
|
|
270
287
|
quantity: number;
|
|
@@ -272,36 +289,36 @@ export interface BaseExchange {
|
|
|
272
289
|
price_places?: string;
|
|
273
290
|
decimal_places?: string;
|
|
274
291
|
}): Promise<any>;
|
|
275
|
-
setLeverage(payload: {
|
|
292
|
+
abstract setLeverage(payload: {
|
|
276
293
|
symbol: string;
|
|
277
294
|
leverage: number;
|
|
278
295
|
}): Promise<any>;
|
|
279
|
-
generateConfig(payload: {
|
|
296
|
+
abstract generateConfig(payload: {
|
|
280
297
|
symbol: string;
|
|
281
298
|
interval?: any;
|
|
282
299
|
limit?: number;
|
|
283
300
|
}): Promise<any>;
|
|
284
|
-
checkDelistedMovers(payload: {
|
|
301
|
+
abstract checkDelistedMovers(payload: {
|
|
285
302
|
movePercent: number;
|
|
286
303
|
include_delisted?: boolean;
|
|
287
304
|
}): Promise<any>;
|
|
288
|
-
closePosition(payload: {
|
|
305
|
+
abstract closePosition(payload: {
|
|
289
306
|
symbol: string;
|
|
290
307
|
kind: "long" | "short";
|
|
291
308
|
price_places?: string;
|
|
292
309
|
decimal_places?: string;
|
|
293
310
|
}): Promise<any>;
|
|
294
|
-
getAllOpenSymbols(): Promise<string[]>;
|
|
295
|
-
createLimitPurchaseOrders(payload: {
|
|
311
|
+
abstract getAllOpenSymbols(): Promise<string[]>;
|
|
312
|
+
abstract createLimitPurchaseOrders(payload: {
|
|
296
313
|
orders: any[];
|
|
297
314
|
kind: "long" | "short";
|
|
298
315
|
decimal_places?: string;
|
|
299
316
|
price_places?: string;
|
|
300
317
|
symbol: string;
|
|
301
318
|
}): Promise<any>;
|
|
302
|
-
getDelistedSpotSymbols(): Promise<any>;
|
|
303
|
-
getOpenPositions(): Promise<any>;
|
|
304
|
-
crossAccountTransfer(payload: {
|
|
319
|
+
abstract getDelistedSpotSymbols(): Promise<any>;
|
|
320
|
+
abstract getOpenPositions(): Promise<any>;
|
|
321
|
+
abstract crossAccountTransfer(payload: {
|
|
305
322
|
from: {
|
|
306
323
|
owner: string;
|
|
307
324
|
wallet: string;
|
|
@@ -313,13 +330,22 @@ export interface BaseExchange {
|
|
|
313
330
|
asset: string;
|
|
314
331
|
amount: number;
|
|
315
332
|
}): Promise<any>;
|
|
316
|
-
placeMarketOrder(payload: {
|
|
333
|
+
abstract placeMarketOrder(payload: {
|
|
317
334
|
symbol: string;
|
|
318
335
|
kind: "long" | "short";
|
|
319
336
|
quantity: number;
|
|
320
337
|
price_places?: string;
|
|
321
338
|
decimal_places?: string;
|
|
322
339
|
}): Promise<any>;
|
|
340
|
+
customStopLoss(payload: {
|
|
341
|
+
price_places: string;
|
|
342
|
+
decimal_places: string;
|
|
343
|
+
symbol: string;
|
|
344
|
+
kind: "long" | "short";
|
|
345
|
+
stop: number;
|
|
346
|
+
quantity: number;
|
|
347
|
+
increase?: boolean;
|
|
348
|
+
}): Promise<any>;
|
|
323
349
|
}
|
|
324
350
|
declare function initPocketBaseClient(proxy_credentials: {
|
|
325
351
|
host: string;
|
|
@@ -1029,6 +1055,38 @@ export declare function getRiskReward(payload: {
|
|
|
1029
1055
|
risk: number;
|
|
1030
1056
|
global_config: GlobalConfig;
|
|
1031
1057
|
}): any;
|
|
1058
|
+
export declare function computeProfitDetail(payload: {
|
|
1059
|
+
focus_position: {
|
|
1060
|
+
kind: "long" | "short";
|
|
1061
|
+
entry: number;
|
|
1062
|
+
quantity: number;
|
|
1063
|
+
avg_qty: number;
|
|
1064
|
+
avg_price: number;
|
|
1065
|
+
};
|
|
1066
|
+
strategy: {
|
|
1067
|
+
reward_factor: number;
|
|
1068
|
+
max_reward_factor: number;
|
|
1069
|
+
risk: number;
|
|
1070
|
+
};
|
|
1071
|
+
reduce_position: {
|
|
1072
|
+
kind: "long" | "short";
|
|
1073
|
+
entry: number;
|
|
1074
|
+
quantity: number;
|
|
1075
|
+
avg_qty: number;
|
|
1076
|
+
avg_price: number;
|
|
1077
|
+
};
|
|
1078
|
+
price_places?: string;
|
|
1079
|
+
decimal_places?: string;
|
|
1080
|
+
}): {
|
|
1081
|
+
pnl: number;
|
|
1082
|
+
reward_factor: number;
|
|
1083
|
+
profit_percent: number;
|
|
1084
|
+
kind: "long" | "short";
|
|
1085
|
+
sell_price: number;
|
|
1086
|
+
quantity: number;
|
|
1087
|
+
price_places: string;
|
|
1088
|
+
decimal_places: string;
|
|
1089
|
+
};
|
|
1032
1090
|
declare class ExchangePosition {
|
|
1033
1091
|
exchange: BaseExchange;
|
|
1034
1092
|
exchange_account: ExchangeAccount$1;
|
|
@@ -1728,8 +1786,16 @@ declare class ExchangeAccount$1 {
|
|
|
1728
1786
|
};
|
|
1729
1787
|
reverse_orders_to_buy: any;
|
|
1730
1788
|
positions: {
|
|
1731
|
-
long: PositionsView
|
|
1732
|
-
|
|
1789
|
+
long: PositionsView & {
|
|
1790
|
+
expand?: {
|
|
1791
|
+
account_strategy?: AccountStrategy;
|
|
1792
|
+
};
|
|
1793
|
+
};
|
|
1794
|
+
short: PositionsView & {
|
|
1795
|
+
expand?: {
|
|
1796
|
+
account_strategy?: AccountStrategy;
|
|
1797
|
+
};
|
|
1798
|
+
};
|
|
1733
1799
|
};
|
|
1734
1800
|
orders_to_place: any;
|
|
1735
1801
|
config_details: {
|
|
@@ -1779,6 +1845,19 @@ declare class ExchangeAccount$1 {
|
|
|
1779
1845
|
pnl: number;
|
|
1780
1846
|
};
|
|
1781
1847
|
}>;
|
|
1848
|
+
getSellPriceFromStrategy(payload: {
|
|
1849
|
+
symbol: string;
|
|
1850
|
+
reduce_position: PositionsView;
|
|
1851
|
+
}): Promise<{
|
|
1852
|
+
pnl: number;
|
|
1853
|
+
reward_factor: number;
|
|
1854
|
+
profit_percent: number;
|
|
1855
|
+
kind: "long" | "short";
|
|
1856
|
+
sell_price: number;
|
|
1857
|
+
quantity: number;
|
|
1858
|
+
price_places: string;
|
|
1859
|
+
decimal_places: string;
|
|
1860
|
+
}>;
|
|
1782
1861
|
}
|
|
1783
1862
|
declare function getExchangeAccount(payload: {
|
|
1784
1863
|
account: ExchangeType;
|
|
@@ -1942,8 +2021,16 @@ declare class App {
|
|
|
1942
2021
|
};
|
|
1943
2022
|
reverse_orders_to_buy: any;
|
|
1944
2023
|
positions: {
|
|
1945
|
-
long: PositionsView
|
|
1946
|
-
|
|
2024
|
+
long: PositionsView & {
|
|
2025
|
+
expand?: {
|
|
2026
|
+
account_strategy?: AccountStrategy;
|
|
2027
|
+
};
|
|
2028
|
+
};
|
|
2029
|
+
short: PositionsView & {
|
|
2030
|
+
expand?: {
|
|
2031
|
+
account_strategy?: AccountStrategy;
|
|
2032
|
+
};
|
|
2033
|
+
};
|
|
1947
2034
|
};
|
|
1948
2035
|
orders_to_place: any;
|
|
1949
2036
|
config_details: {
|
|
@@ -1993,6 +2080,17 @@ declare class App {
|
|
|
1993
2080
|
pnl: number;
|
|
1994
2081
|
};
|
|
1995
2082
|
}>;
|
|
2083
|
+
reduceExistingPosition(payload: {
|
|
2084
|
+
main_account: ExchangeType & {
|
|
2085
|
+
symbol: string;
|
|
2086
|
+
};
|
|
2087
|
+
reduce_account: ExchangeType & {
|
|
2088
|
+
symbol: string;
|
|
2089
|
+
};
|
|
2090
|
+
kind: "long" | "short";
|
|
2091
|
+
place?: boolean;
|
|
2092
|
+
increase?: boolean;
|
|
2093
|
+
}): Promise<any>;
|
|
1996
2094
|
}
|
|
1997
2095
|
export declare function initApp(payload: {
|
|
1998
2096
|
db: {
|