@gbozee/ultimate 0.0.2-51 → 0.0.2-53
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 -3
- package/dist/frontend-index.js +8 -2
- package/dist/index.d.ts +49 -7
- package/dist/index.js +64 -19
- package/package.json +1 -1
package/dist/frontend-index.d.ts
CHANGED
|
@@ -367,11 +367,8 @@ export type StrategyPosition = {
|
|
|
367
367
|
quantity: number;
|
|
368
368
|
};
|
|
369
369
|
export type Config = {
|
|
370
|
-
leverage: number;
|
|
371
370
|
tp_percent: number;
|
|
372
371
|
short_tp_factor: number;
|
|
373
|
-
price_places: string;
|
|
374
|
-
decimal_places: string;
|
|
375
372
|
fee_percent?: number;
|
|
376
373
|
budget: number;
|
|
377
374
|
global_config: GlobalConfig;
|
|
@@ -387,6 +384,8 @@ export declare class Strategy {
|
|
|
387
384
|
short: StrategyPosition;
|
|
388
385
|
config: Config;
|
|
389
386
|
});
|
|
387
|
+
get price_places(): string;
|
|
388
|
+
get decimal_places(): string;
|
|
390
389
|
to_f(price: number): number;
|
|
391
390
|
to_df(quantity: number): number;
|
|
392
391
|
pnl(kind: "long" | "short"): number;
|
package/dist/frontend-index.js
CHANGED
|
@@ -1651,11 +1651,17 @@ class Strategy {
|
|
|
1651
1651
|
this.config.fee_percent = 0.05;
|
|
1652
1652
|
}
|
|
1653
1653
|
}
|
|
1654
|
+
get price_places() {
|
|
1655
|
+
return this.config.global_config.price_places;
|
|
1656
|
+
}
|
|
1657
|
+
get decimal_places() {
|
|
1658
|
+
return this.config.global_config.decimal_places;
|
|
1659
|
+
}
|
|
1654
1660
|
to_f(price) {
|
|
1655
|
-
return to_f(price, this.
|
|
1661
|
+
return to_f(price, this.price_places);
|
|
1656
1662
|
}
|
|
1657
1663
|
to_df(quantity) {
|
|
1658
|
-
return to_f(quantity, this.
|
|
1664
|
+
return to_f(quantity, this.decimal_places);
|
|
1659
1665
|
}
|
|
1660
1666
|
pnl(kind) {
|
|
1661
1667
|
const position2 = this.position[kind];
|
package/dist/index.d.ts
CHANGED
|
@@ -59,7 +59,10 @@ export interface ScheduledTrade extends BaseSystemFields {
|
|
|
59
59
|
export interface AccountStrategy extends BaseSystemFields {
|
|
60
60
|
account: string;
|
|
61
61
|
symbol: string;
|
|
62
|
-
|
|
62
|
+
tp_percent: number;
|
|
63
|
+
short_tp_factor: number;
|
|
64
|
+
fee_percent: number;
|
|
65
|
+
budget: number;
|
|
63
66
|
}
|
|
64
67
|
interface Proxy$1 extends BaseSystemFields {
|
|
65
68
|
ip_address?: string;
|
|
@@ -291,6 +294,12 @@ export interface BaseExchange {
|
|
|
291
294
|
decimal_places?: string;
|
|
292
295
|
}): Promise<any>;
|
|
293
296
|
}
|
|
297
|
+
declare function initPocketBaseClient(proxy_credentials: {
|
|
298
|
+
host: string;
|
|
299
|
+
email: string;
|
|
300
|
+
password: string;
|
|
301
|
+
auto_cancellation?: boolean;
|
|
302
|
+
}): Promise<PocketBase>;
|
|
294
303
|
export type ExchangeType = {
|
|
295
304
|
owner: string;
|
|
296
305
|
exchange: string;
|
|
@@ -1096,9 +1105,6 @@ declare class ExchangeAccount$1 {
|
|
|
1096
1105
|
}): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
|
|
1097
1106
|
getCurrentPrice(symbol: string): Promise<any>;
|
|
1098
1107
|
getPositionStrategy(): Promise<AccountStrategy>;
|
|
1099
|
-
toUpdate(payload: {
|
|
1100
|
-
refresh?: boolean;
|
|
1101
|
-
}): Promise<void>;
|
|
1102
1108
|
buildReduceConfig(payload: {
|
|
1103
1109
|
symbol: string;
|
|
1104
1110
|
kind?: "long" | "short";
|
|
@@ -1223,6 +1229,11 @@ declare class ExchangeAccount$1 {
|
|
|
1223
1229
|
symbol: string;
|
|
1224
1230
|
kind: "long" | "short";
|
|
1225
1231
|
}): Promise<number>;
|
|
1232
|
+
getCurrentRun(payload: {
|
|
1233
|
+
symbol: string;
|
|
1234
|
+
kind?: "long" | "short";
|
|
1235
|
+
pnl?: number;
|
|
1236
|
+
}): Promise<true | import("pocketbase").RecordModel>;
|
|
1226
1237
|
recomputeSymbolConfig(payload: {
|
|
1227
1238
|
symbol: string;
|
|
1228
1239
|
refresh?: boolean;
|
|
@@ -1292,6 +1303,20 @@ declare class ExchangeAccount$1 {
|
|
|
1292
1303
|
kind: "long" | "short";
|
|
1293
1304
|
}): Promise<void>;
|
|
1294
1305
|
}
|
|
1306
|
+
declare function getExchangeAccount(payload: {
|
|
1307
|
+
account: ExchangeType;
|
|
1308
|
+
app_db: AppDatabase;
|
|
1309
|
+
getCredentials: (account: string, exchange: string) => {
|
|
1310
|
+
api_key: string;
|
|
1311
|
+
api_secret: string;
|
|
1312
|
+
email: string;
|
|
1313
|
+
};
|
|
1314
|
+
proxyOptions?: {
|
|
1315
|
+
proxy?: any;
|
|
1316
|
+
ignore_proxy?: boolean;
|
|
1317
|
+
};
|
|
1318
|
+
canWithdraw?: boolean;
|
|
1319
|
+
}): Promise<ExchangeAccount$1>;
|
|
1295
1320
|
declare class App {
|
|
1296
1321
|
app_db: AppDatabase;
|
|
1297
1322
|
proxyOptions?: {
|
|
@@ -1424,6 +1449,11 @@ export declare function initApp(payload: {
|
|
|
1424
1449
|
canWithdraw?: boolean;
|
|
1425
1450
|
triggerToken?: string;
|
|
1426
1451
|
}): Promise<App>;
|
|
1452
|
+
declare function getCredentials(account: string, exchange: string): {
|
|
1453
|
+
api_key: string;
|
|
1454
|
+
api_secret: string;
|
|
1455
|
+
email: string;
|
|
1456
|
+
};
|
|
1427
1457
|
export declare function initialize(payload: {
|
|
1428
1458
|
password?: string;
|
|
1429
1459
|
proxy?: any;
|
|
@@ -1435,11 +1465,8 @@ export type StrategyPosition = {
|
|
|
1435
1465
|
quantity: number;
|
|
1436
1466
|
};
|
|
1437
1467
|
export type Config = {
|
|
1438
|
-
leverage: number;
|
|
1439
1468
|
tp_percent: number;
|
|
1440
1469
|
short_tp_factor: number;
|
|
1441
|
-
price_places: string;
|
|
1442
|
-
decimal_places: string;
|
|
1443
1470
|
fee_percent?: number;
|
|
1444
1471
|
budget: number;
|
|
1445
1472
|
global_config: GlobalConfig;
|
|
@@ -1455,6 +1482,8 @@ export declare class Strategy {
|
|
|
1455
1482
|
short: StrategyPosition;
|
|
1456
1483
|
config: Config;
|
|
1457
1484
|
});
|
|
1485
|
+
get price_places(): string;
|
|
1486
|
+
get decimal_places(): string;
|
|
1458
1487
|
to_f(price: number): number;
|
|
1459
1488
|
to_df(quantity: number): number;
|
|
1460
1489
|
pnl(kind: "long" | "short"): number;
|
|
@@ -1488,8 +1517,21 @@ export declare class Strategy {
|
|
|
1488
1517
|
}[];
|
|
1489
1518
|
}
|
|
1490
1519
|
|
|
1520
|
+
declare namespace database {
|
|
1521
|
+
export { AppDatabase, ExchangeType, initPocketBaseClient };
|
|
1522
|
+
}
|
|
1523
|
+
declare namespace exchange_account {
|
|
1524
|
+
export { ExchangeAccount$1 as ExchangeAccount, getExchangeAccount };
|
|
1525
|
+
}
|
|
1526
|
+
declare namespace app {
|
|
1527
|
+
export { App, getCredentials, initApp, initialize };
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1491
1530
|
export {
|
|
1492
1531
|
ExchangeAccount$1 as ExchangeAccount,
|
|
1532
|
+
app,
|
|
1533
|
+
database,
|
|
1534
|
+
exchange_account,
|
|
1493
1535
|
};
|
|
1494
1536
|
|
|
1495
1537
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -41711,6 +41711,15 @@ var require_lib3 = __commonJS((exports) => {
|
|
|
41711
41711
|
__exportStar(require_enum(), exports);
|
|
41712
41712
|
});
|
|
41713
41713
|
|
|
41714
|
+
// src/app.ts
|
|
41715
|
+
var exports_app = {};
|
|
41716
|
+
__export(exports_app, {
|
|
41717
|
+
initialize: () => initialize,
|
|
41718
|
+
initApp: () => initApp,
|
|
41719
|
+
getCredentials: () => getCredentials,
|
|
41720
|
+
App: () => App
|
|
41721
|
+
});
|
|
41722
|
+
|
|
41714
41723
|
// node_modules/zod/lib/index.mjs
|
|
41715
41724
|
var util;
|
|
41716
41725
|
(function(util2) {
|
|
@@ -50103,6 +50112,11 @@ function configure(options) {
|
|
|
50103
50112
|
apiClientManager.setGlobalAPIClientConfiguration(options);
|
|
50104
50113
|
}
|
|
50105
50114
|
// src/database.ts
|
|
50115
|
+
var exports_database = {};
|
|
50116
|
+
__export(exports_database, {
|
|
50117
|
+
initPocketBaseClient: () => initPocketBaseClient,
|
|
50118
|
+
AppDatabase: () => AppDatabase
|
|
50119
|
+
});
|
|
50106
50120
|
var import_https_proxy_agent = __toESM(require_dist2(), 1);
|
|
50107
50121
|
import {
|
|
50108
50122
|
createCipheriv as createCipheriv3,
|
|
@@ -51989,6 +52003,13 @@ class AppDatabase {
|
|
|
51989
52003
|
}
|
|
51990
52004
|
}
|
|
51991
52005
|
|
|
52006
|
+
// src/exchange-account.ts
|
|
52007
|
+
var exports_exchange_account = {};
|
|
52008
|
+
__export(exports_exchange_account, {
|
|
52009
|
+
getExchangeAccount: () => getExchangeAccount,
|
|
52010
|
+
ExchangeAccount: () => ExchangeAccount
|
|
52011
|
+
});
|
|
52012
|
+
|
|
51992
52013
|
// src/exchanges/binance.ts
|
|
51993
52014
|
var import_binance = __toESM(require_lib2(), 1);
|
|
51994
52015
|
|
|
@@ -56487,23 +56508,6 @@ class ExchangeAccount {
|
|
|
56487
56508
|
async getPositionStrategy() {
|
|
56488
56509
|
return await this.app_db.getPositionStrategy(this.instance);
|
|
56489
56510
|
}
|
|
56490
|
-
async toUpdate(payload) {
|
|
56491
|
-
const { refresh } = payload;
|
|
56492
|
-
const strategy = await this.getPositionStrategy();
|
|
56493
|
-
if (!strategy) {
|
|
56494
|
-
return;
|
|
56495
|
-
}
|
|
56496
|
-
const { symbol: _symbol, watch_symbol } = strategy;
|
|
56497
|
-
const watch_positions = await this.syncAccount({
|
|
56498
|
-
symbol: watch_symbol,
|
|
56499
|
-
live_refresh: refresh,
|
|
56500
|
-
update: true
|
|
56501
|
-
});
|
|
56502
|
-
const long_watch_position = watch_positions.find((x) => x.kind === "long");
|
|
56503
|
-
const short_watch_position = watch_positions.find((x) => x.kind === "short");
|
|
56504
|
-
if (long_watch_position.quantity === short_watch_position.quantity && long_watch_position.quantity > 0) {
|
|
56505
|
-
}
|
|
56506
|
-
}
|
|
56507
56511
|
async buildReduceConfig(payload) {
|
|
56508
56512
|
const positions = await this.syncAccount({
|
|
56509
56513
|
symbol: payload.symbol
|
|
@@ -57061,6 +57065,38 @@ class ExchangeAccount {
|
|
|
57061
57065
|
}
|
|
57062
57066
|
return 0;
|
|
57063
57067
|
}
|
|
57068
|
+
async getCurrentRun(payload) {
|
|
57069
|
+
const { symbol, kind = "long", pnl } = payload;
|
|
57070
|
+
const instances = await this.app_db.pb.collection("strategy_runs").getFullList({
|
|
57071
|
+
filter: `account.owner:lower = "${this.instance.owner.toLowerCase()}" && account.exchange:lower = "${this.instance.exchange.toLowerCase()}" && symbol = "${symbol}" && kind = "${kind}" && completed = false`
|
|
57072
|
+
});
|
|
57073
|
+
if (instances.length > 0) {
|
|
57074
|
+
const instance = instances[0];
|
|
57075
|
+
if (!pnl) {
|
|
57076
|
+
return instance;
|
|
57077
|
+
}
|
|
57078
|
+
await this.app_db.pb.collection("strategy_runs").update(instance.id, {
|
|
57079
|
+
completed: true,
|
|
57080
|
+
pnl
|
|
57081
|
+
});
|
|
57082
|
+
return true;
|
|
57083
|
+
}
|
|
57084
|
+
const position2 = await this.syncAccount({
|
|
57085
|
+
symbol,
|
|
57086
|
+
kind
|
|
57087
|
+
});
|
|
57088
|
+
if (position2.quantity == 0) {
|
|
57089
|
+
return null;
|
|
57090
|
+
}
|
|
57091
|
+
return await this.app_db.pb.collection("strategy_runs").create({
|
|
57092
|
+
account: position2.account,
|
|
57093
|
+
symbol,
|
|
57094
|
+
kind,
|
|
57095
|
+
entry: position2.entry,
|
|
57096
|
+
quantity: position2.quantity,
|
|
57097
|
+
completed: false
|
|
57098
|
+
});
|
|
57099
|
+
}
|
|
57064
57100
|
async recomputeSymbolConfig(payload) {
|
|
57065
57101
|
const { symbol, refresh = false } = payload;
|
|
57066
57102
|
const _config = await this.app_db.getSymbolConfigFromDB(symbol);
|
|
@@ -58084,11 +58120,17 @@ class Strategy {
|
|
|
58084
58120
|
this.config.fee_percent = 0.05;
|
|
58085
58121
|
}
|
|
58086
58122
|
}
|
|
58123
|
+
get price_places() {
|
|
58124
|
+
return this.config.global_config.price_places;
|
|
58125
|
+
}
|
|
58126
|
+
get decimal_places() {
|
|
58127
|
+
return this.config.global_config.decimal_places;
|
|
58128
|
+
}
|
|
58087
58129
|
to_f(price) {
|
|
58088
|
-
return to_f(price, this.
|
|
58130
|
+
return to_f(price, this.price_places);
|
|
58089
58131
|
}
|
|
58090
58132
|
to_df(quantity) {
|
|
58091
|
-
return to_f(quantity, this.
|
|
58133
|
+
return to_f(quantity, this.decimal_places);
|
|
58092
58134
|
}
|
|
58093
58135
|
pnl(kind) {
|
|
58094
58136
|
const position2 = this.position[kind];
|
|
@@ -58275,13 +58317,16 @@ export {
|
|
|
58275
58317
|
getOptimumStopAndRisk,
|
|
58276
58318
|
generate_config_params,
|
|
58277
58319
|
generateOptimumAppConfig,
|
|
58320
|
+
exports_exchange_account as exchange_account,
|
|
58278
58321
|
determine_break_even_price,
|
|
58279
58322
|
determine_average_entry_and_size,
|
|
58280
58323
|
determine_amount_to_buy,
|
|
58324
|
+
exports_database as database,
|
|
58281
58325
|
createArray,
|
|
58282
58326
|
buildConfig,
|
|
58283
58327
|
buildAvg,
|
|
58284
58328
|
buildAppConfig,
|
|
58329
|
+
exports_app as app,
|
|
58285
58330
|
Strategy,
|
|
58286
58331
|
ExchangeAccount,
|
|
58287
58332
|
AppDatabase
|