@gbozee/ultimate 0.0.2-15 → 0.0.2-150

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.d.ts CHANGED
@@ -2,9 +2,239 @@
2
2
 
3
3
  import { HttpsProxyAgent } from 'https-proxy-agent';
4
4
  import PocketBase from 'pocketbase';
5
- import { RecordModel } from 'pocketbase';
5
+ import { RecordModel as PocketBaseRecordModel } from 'pocketbase';
6
6
  import { SocksProxyAgent } from 'socks-proxy-agent';
7
7
 
8
+ export type RecordModel = PocketBaseRecordModel;
9
+ export interface BaseSystemFields {
10
+ id: string;
11
+ created: string;
12
+ updated: string;
13
+ }
14
+ export interface ExchangeAccount extends BaseSystemFields {
15
+ exchange: "binance" | "bybit";
16
+ owner: string;
17
+ email?: string;
18
+ user?: string;
19
+ usdt?: number;
20
+ usdc?: number;
21
+ proxy?: string;
22
+ bullish?: boolean;
23
+ bearish?: boolean;
24
+ movePercent?: number;
25
+ totalRisk?: number;
26
+ max_non_essential?: number;
27
+ profit_percent?: number;
28
+ risk_reward?: number;
29
+ exclude_coins?: {
30
+ bullish?: string[];
31
+ };
32
+ include_delisted?: boolean;
33
+ }
34
+ export interface Order extends BaseSystemFields {
35
+ symbol: string;
36
+ account: string;
37
+ kind: "long" | "short";
38
+ price: number;
39
+ quantity: number;
40
+ side: "sell" | "buy";
41
+ stop: number;
42
+ order_id: string;
43
+ }
44
+ export interface SymbolConfig extends BaseSystemFields {
45
+ symbol: string;
46
+ support?: number;
47
+ resistance?: number;
48
+ stop_percent?: number;
49
+ price_places?: string;
50
+ decimal_places?: string;
51
+ min_size?: number;
52
+ weight?: number;
53
+ leverage?: number;
54
+ candle_count?: number;
55
+ interval?: any;
56
+ fee_percent?: number;
57
+ }
58
+ export interface ScheduledTrade extends BaseSystemFields {
59
+ symbol: string;
60
+ account: string;
61
+ profit?: number;
62
+ risk?: number;
63
+ entry?: number;
64
+ stop?: number;
65
+ risk_reward?: number;
66
+ profit_percent?: number;
67
+ place_tp?: boolean;
68
+ kind?: "long" | "short";
69
+ follow?: boolean | 1 | 0;
70
+ reduce_ratio?: number;
71
+ sell_ratio?: number;
72
+ threshold_qty?: number;
73
+ pause_tp?: boolean;
74
+ stop_percent?: number;
75
+ kelly?: {
76
+ use_kelly?: boolean;
77
+ kelly_confidence_factor?: number;
78
+ kelly_minimum_risk?: number;
79
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
80
+ };
81
+ }
82
+ export interface AccountStrategy extends BaseSystemFields {
83
+ account: string;
84
+ symbol: string;
85
+ risk?: number;
86
+ reward_factor?: number;
87
+ kind?: "long" | "short";
88
+ support?: number;
89
+ resistance?: number;
90
+ running?: boolean;
91
+ max_reward_factor?: number;
92
+ follow?: boolean;
93
+ risk_reward?: number;
94
+ dynamic?: boolean;
95
+ }
96
+ interface Proxy$1 extends BaseSystemFields {
97
+ ip_address?: string;
98
+ type?: "http" | "socks5";
99
+ }
100
+ export interface TradeBlockTracking extends BaseSystemFields {
101
+ account?: string;
102
+ symbol?: string;
103
+ running?: boolean;
104
+ }
105
+ export interface PositionsView {
106
+ id: string;
107
+ symbol?: any;
108
+ entry?: any;
109
+ quantity?: any;
110
+ take_profit?: any;
111
+ account?: any;
112
+ kind?: any;
113
+ target_pnl?: number;
114
+ liquidation?: number;
115
+ avg_price?: number;
116
+ avg_qty?: number;
117
+ next_order?: number;
118
+ last_order?: number;
119
+ config?: any;
120
+ stop_loss?: {
121
+ price: number;
122
+ quantity: number;
123
+ };
124
+ stop_pnl?: any;
125
+ leverage?: any;
126
+ avg_liquidation?: any;
127
+ balance?: any;
128
+ reduce_ratio?: number;
129
+ sell_ratio?: number;
130
+ threshold_qty?: number;
131
+ follow?: boolean | 1 | 0;
132
+ current_price?: number;
133
+ usd_balance?: number;
134
+ tp?: {
135
+ price: number;
136
+ quantity: number;
137
+ };
138
+ next_risk?: number;
139
+ }
140
+ export interface BullishMarket extends RecordModel {
141
+ id: string;
142
+ symbol: string;
143
+ risk: number;
144
+ }
145
+ export interface WindingDownMarket extends RecordModel {
146
+ id: string;
147
+ symbol: string;
148
+ risk_reward: number;
149
+ }
150
+ export interface BotInstance extends BaseSystemFields {
151
+ asset: string;
152
+ main_account?: string;
153
+ secondary_account?: string;
154
+ main_symbol: string;
155
+ secondary_symbol?: string;
156
+ direction?: "long" | "short";
157
+ budget?: number;
158
+ settings?: Record<string, any>;
159
+ user?: string;
160
+ }
161
+ export interface BotState extends BaseSystemFields {
162
+ bot: string;
163
+ running?: boolean;
164
+ status?: "main-trading" | "hedge-mode";
165
+ spot_quantity?: number;
166
+ exchange_details?: Record<string, any>;
167
+ completed?: boolean;
168
+ }
169
+ export interface BotOrderHistory extends BaseSystemFields {
170
+ field: string;
171
+ symbol: string;
172
+ pnl?: number;
173
+ kind?: "long" | "short";
174
+ type?: "future" | "spot";
175
+ }
176
+ export interface BotPositionData {
177
+ entry: number;
178
+ quantity: number;
179
+ tp: {
180
+ price: number;
181
+ quantity: number;
182
+ pnl: number;
183
+ };
184
+ current_price: number;
185
+ balance: number;
186
+ kind: "long" | "short";
187
+ next_order: number;
188
+ last_order: number;
189
+ avg: {
190
+ price: number;
191
+ quantity: number;
192
+ };
193
+ sl: {
194
+ price: number;
195
+ quantity: number;
196
+ pnl: number;
197
+ };
198
+ }
199
+ export interface BotView extends RecordModel {
200
+ id: string;
201
+ direction?: "long" | "short";
202
+ budget?: number;
203
+ main_symbol?: string;
204
+ main_long_position?: BotPositionData;
205
+ main_short_position?: BotPositionData;
206
+ secondary_symbol?: string;
207
+ secondary_long_position?: BotPositionData;
208
+ secondary_short_position?: BotPositionData;
209
+ main_account?: string;
210
+ secondary_account?: string;
211
+ settings?: Record<string, any>;
212
+ main_long_strategy?: string;
213
+ main_short_strategy?: string;
214
+ secondary_long_strategy?: string;
215
+ secondary_short_strategy?: string;
216
+ }
217
+ export type GlobalConfig = {
218
+ profit_percent: number;
219
+ symbol: string;
220
+ profit: number;
221
+ risk: number;
222
+ stop_percent: number;
223
+ kind: "long" | "short";
224
+ reduce_percent: number;
225
+ support: number;
226
+ resistance: number;
227
+ price_places: string;
228
+ decimal_places: string;
229
+ min_size: number;
230
+ accounts: {
231
+ owner: string;
232
+ exchange?: string;
233
+ }[];
234
+ risk_reward: number;
235
+ reverse_factor: number;
236
+ leverage?: number;
237
+ };
8
238
  interface Position$1 {
9
239
  id: number;
10
240
  kind: "long" | "short";
@@ -20,6 +250,7 @@ interface Position$1 {
20
250
  target_pnl?: number;
21
251
  reduce_ratio?: number;
22
252
  use_full?: boolean;
253
+ liquidation?: number;
23
254
  }
24
255
  export interface Account {
25
256
  id: number | string;
@@ -59,8 +290,68 @@ export interface Account {
59
290
  short: any;
60
291
  };
61
292
  }
62
- export interface BaseExchange {
293
+ interface Order$1 {
294
+ order_id?: string;
295
+ symbol?: string;
296
+ price: number;
297
+ quantity: number;
298
+ kind: "long" | "short";
299
+ side: "buy" | "sell";
300
+ stop: number;
301
+ triggerPrice?: number;
302
+ }
303
+ export interface CandlestickAnalysisResult {
304
+ candlesticks: {
305
+ [key: string]: any[];
306
+ };
307
+ resistance: {
308
+ [key: string]: number;
309
+ };
310
+ support: {
311
+ [key: string]: number;
312
+ };
313
+ current_price: number;
314
+ minimum_weekly: number;
315
+ }
316
+ declare abstract class BaseExchange {
63
317
  client: any;
318
+ getCredentials: (payload: {
319
+ account: string;
320
+ }) => Promise<{
321
+ api_key: string;
322
+ api_secret: string;
323
+ email: string;
324
+ }>;
325
+ proxyAgent?: any;
326
+ constructor(client: any);
327
+ protected abstract getPositionInfo(symbol: string): Promise<any>;
328
+ abstract cancelAllOrders(symbol: string, payload: {
329
+ type?: "limit" | "stop" | "tp";
330
+ side?: "buy" | "sell";
331
+ kind?: "long" | "short";
332
+ }): Promise<any>;
333
+ protected abstract getCurrentPrice(symbol: string): Promise<any>;
334
+ protected abstract getExchangeInfo(options: {
335
+ price_places?: string;
336
+ decimal_places?: string;
337
+ account: {
338
+ owner: string;
339
+ exchange: string;
340
+ };
341
+ symbol: string;
342
+ }): Promise<any>;
343
+ protected abstract _createLimitPurchaseOrders(payload: {
344
+ symbol: string;
345
+ orders: any[];
346
+ price_places?: string;
347
+ decimal_places?: string;
348
+ }): Promise<any>;
349
+ rawCreateLimitPurchaseOrders(payload: {
350
+ symbol: string;
351
+ orders: Order$1[];
352
+ price_places?: string;
353
+ decimal_places?: string;
354
+ }): Promise<any>;
64
355
  placeStopOrders(payload: {
65
356
  symbol: string;
66
357
  quantity: number;
@@ -71,33 +362,65 @@ export interface BaseExchange {
71
362
  place?: boolean;
72
363
  }): Promise<any>;
73
364
  bulkPlaceLimitOrders(payload: {
74
- orders: any[];
365
+ orders: Order$1[];
75
366
  kind: "long" | "short";
76
367
  decimal_places?: string;
77
368
  price_places?: string;
78
369
  symbol: string;
79
370
  place?: boolean;
80
- }): Promise<any>;
371
+ }): Promise<any[]>;
81
372
  get_current_price(symbol: string): Promise<any>;
82
- analyzeCharts(payload: {
373
+ abstract analyzeCharts(payload: {
83
374
  symbol: string;
84
375
  chartType: any;
85
- count: number;
376
+ limit: number;
86
377
  raw?: boolean;
87
378
  }): Promise<any>;
88
- getExchangeAccountInfo(account: {
89
- owner: string;
90
- exchange: string;
91
- }, symbol: string): Promise<any>;
379
+ getExchangeAccountInfo(options: {
380
+ price_places?: string;
381
+ decimal_places?: string;
382
+ account: {
383
+ owner: string;
384
+ exchange: string;
385
+ };
386
+ symbol: string;
387
+ }): Promise<any>;
388
+ protected abstract _cancelOrders(payload: {
389
+ symbol: string;
390
+ orders: Array<{
391
+ orderId: number;
392
+ }>;
393
+ }): Promise<any>;
92
394
  cancelOrders(payload: {
93
395
  symbol: string;
94
396
  orders: number[];
95
397
  }): Promise<any>;
398
+ protected abstract _placeTpOrder(payload: {
399
+ symbol: string;
400
+ tp: number;
401
+ kind: "long" | "short";
402
+ cancel?: boolean;
403
+ quantity?: number;
404
+ price_places?: string;
405
+ decimal_places?: string;
406
+ }): Promise<any>;
96
407
  placeTpOrder(payload: {
97
408
  symbol: string;
98
409
  take_profit: number;
99
410
  kind: "long" | "short";
100
411
  cancel?: boolean;
412
+ quantity?: number;
413
+ price_places?: string;
414
+ decimal_places?: string;
415
+ }): Promise<any>;
416
+ protected abstract placeLimitOrders(payload: {
417
+ symbol: string;
418
+ orders: Array<{
419
+ entry: number;
420
+ quantity: number;
421
+ }>;
422
+ kind: "long" | "short";
423
+ cancel?: boolean;
101
424
  price_places?: string;
102
425
  decimal_places?: string;
103
426
  }): Promise<any>;
@@ -109,6 +432,18 @@ export interface BaseExchange {
109
432
  price_places?: string;
110
433
  decimal_places?: string;
111
434
  }): Promise<any>;
435
+ protected abstract _placeStopOrder(payload: {
436
+ symbol: string;
437
+ stop: number;
438
+ quantity: number;
439
+ kind: "long" | "short";
440
+ price_places?: string;
441
+ decimal_places?: string;
442
+ final_stop: number;
443
+ cancel?: boolean;
444
+ is_limit?: boolean;
445
+ current_price: number;
446
+ }): Promise<any>;
112
447
  placeStopOrder(payload: {
113
448
  symbol: string;
114
449
  stop: number;
@@ -117,119 +452,143 @@ export interface BaseExchange {
117
452
  price_places?: string;
118
453
  decimal_places?: string;
119
454
  }): Promise<any>;
120
- setLeverage(payload: {
455
+ abstract setLeverage(payload: {
121
456
  symbol: string;
122
457
  leverage: number;
123
458
  }): Promise<any>;
124
- generateConfig(payload: {
459
+ abstract generateConfig(payload: {
125
460
  symbol: string;
461
+ interval?: any;
126
462
  limit?: number;
127
463
  }): Promise<any>;
464
+ abstract checkDelistedMovers(payload: {
465
+ movePercent: number;
466
+ include_delisted?: boolean;
467
+ }): Promise<any>;
468
+ closePosition(payload: {
469
+ symbol: string;
470
+ kind: "long" | "short";
471
+ price_places?: string;
472
+ decimal_places?: string;
473
+ }): Promise<any>;
474
+ protected abstract getAllOpenOrders(): Promise<any>;
475
+ getAllOpenSymbols(): Promise<unknown[]>;
476
+ createLimitPurchaseOrders(payload: {
477
+ orders: any[];
478
+ kind: "long" | "short";
479
+ decimal_places?: string;
480
+ price_places?: string;
481
+ symbol: string;
482
+ }): Promise<any>;
483
+ abstract getDelistedSpotSymbols(): Promise<any>;
484
+ abstract getOpenPositions(): Promise<any>;
485
+ abstract crossAccountTransfer(payload: {
486
+ from: {
487
+ owner: string;
488
+ wallet: string;
489
+ };
490
+ to: {
491
+ owner: string;
492
+ wallet: string;
493
+ };
494
+ asset: string;
495
+ amount: number;
496
+ }): Promise<any>;
497
+ placeMarketOrder(payload: {
498
+ symbol: string;
499
+ kind: "long" | "short";
500
+ quantity: number;
501
+ price_places?: string;
502
+ decimal_places?: string;
503
+ }): Promise<any>;
504
+ customStopLoss(payload: {
505
+ price_places: string;
506
+ decimal_places: string;
507
+ symbol: string;
508
+ kind: "long" | "short";
509
+ stop: number;
510
+ quantity: number;
511
+ increase?: boolean;
512
+ place?: boolean;
513
+ }): Promise<any>;
514
+ abstract getOpenOrders(payload: {
515
+ symbol: string;
516
+ }): Promise<any>;
517
+ placeBadStopEntry(payload: {
518
+ symbol: string;
519
+ orders: Order$1[];
520
+ price_places?: string;
521
+ decimal_places?: string;
522
+ }): Promise<any>;
523
+ analyzeCandlesticks(payload: {
524
+ symbol: string;
525
+ }): Promise<CandlestickAnalysisResult>;
526
+ setAccountDetails(payload: {
527
+ getCredentials: (payload: {
528
+ account: string;
529
+ }) => Promise<{
530
+ api_key: string;
531
+ api_secret: string;
532
+ email: string;
533
+ }>;
534
+ proxyAgent?: any;
535
+ }): void;
128
536
  }
129
- export interface BaseSystemFields {
130
- id: string;
131
- created: string;
132
- updated: string;
133
- }
134
- export interface ExchangeAccount extends BaseSystemFields {
135
- exchange: "binance" | "bybit";
537
+ declare function encryptObject(obj: any, password: string): string;
538
+ declare function decryptObject(encryptedString: string, password: string): any;
539
+ declare function initPocketBaseClient(proxy_credentials: {
540
+ host: string;
541
+ email: string;
542
+ password: string;
543
+ auto_cancellation?: boolean;
544
+ }): Promise<PocketBase>;
545
+ export type ExchangeType = {
136
546
  owner: string;
547
+ exchange: string;
548
+ };
549
+ export declare class AppDatabase {
550
+ pb: PocketBase;
137
551
  email?: string;
138
- user?: string;
139
- usdt?: number;
140
- usdc?: number;
141
- proxy?: string;
142
- }
143
- export interface SymbolConfig extends BaseSystemFields {
144
- symbol: string;
145
- support?: number;
146
- resistance?: number;
147
- stop_percent?: number;
148
- price_places?: string;
149
- decimal_places?: string;
150
- min_size?: number;
151
- weight?: number;
152
- leverage?: number;
153
- }
154
- export interface ScheduledTrade extends BaseSystemFields {
155
- symbol: string;
156
- account: string;
157
- profit?: number;
158
- risk?: number;
159
- entry?: number;
160
- stop?: number;
161
- risk_reward?: number;
162
- profit_percent?: number;
163
- place_tp?: boolean;
164
- kind?: "long" | "short";
165
- current_price?: number;
166
- }
167
- export interface Strategy extends BaseSystemFields {
168
- name: string;
169
- short_risk_factor?: number;
170
- long_risk_factor?: number;
171
- profit_percent?: number;
172
- cancel_short?: boolean;
173
- cancel_long?: boolean;
174
- recompute_short_config?: boolean;
175
- update_stop_loss?: boolean;
176
- liquidation_as_entry?: boolean;
177
- stop_as_entry?: boolean;
178
- tp_as_stop?: boolean;
179
- entry_as_stop?: boolean;
180
- place_stop?: boolean;
181
- save_config?: boolean;
182
- }
183
- interface Proxy$1 extends BaseSystemFields {
184
- ip_address?: string;
185
- type?: "http" | "socks5";
186
- }
187
- export interface TradeBlockTracking extends BaseSystemFields {
188
- account?: string;
189
- symbol?: string;
190
- running?: boolean;
191
- }
192
- export interface PositionsView {
193
- id: string;
194
- symbol?: any;
195
- entry?: any;
196
- quantity?: any;
197
- take_profit?: any;
198
- account?: any;
199
- kind?: any;
200
- target_pnl?: number;
201
- liquidation?: number;
202
- avg_price?: number;
203
- avg_qty?: number;
204
- next_order?: number;
205
- last_order?: number;
206
- config?: any;
207
- stop_loss?: {
208
- price: number;
209
- quantity: number;
210
- };
211
- stop_pnl?: any;
212
- leverage?: any;
213
- avg_liquidation?: any;
214
- balance?: any;
215
- }
216
- export interface BullishMarket extends RecordModel {
217
- id: string;
218
- symbol: string;
219
- risk: number;
220
- }
221
- export interface WindingDownMarket extends RecordModel {
222
- id: string;
223
- symbol: string;
224
- risk_reward: number;
225
- }
226
- export type ExchangeType = {
227
- owner: string;
228
- exchange: string;
229
- };
230
- export declare class AppDatabase {
231
- private pb;
232
- constructor(pb: PocketBase);
552
+ salt?: string;
553
+ constructor(pb: PocketBase, payload: {
554
+ email?: string;
555
+ salt?: string;
556
+ });
557
+ getUserByEmail(): Promise<import("pocketbase").RecordModel>;
558
+ verifyUserPassword(password: string): Promise<boolean>;
559
+ generateUserPassword(): Promise<boolean>;
560
+ getUserCredentials(): Promise<any>;
561
+ getCredentials(payload: {
562
+ password?: string;
563
+ }): Promise<any>;
564
+ saveCredentials(params: {
565
+ password?: string;
566
+ credentials: any;
567
+ }): Promise<import("pocketbase").RecordModel>;
568
+ changeUserPassword(payload: {
569
+ password: string;
570
+ }): Promise<boolean>;
571
+ verifyAdminPassword(password: string): Promise<boolean>;
572
+ setAdminPassword(payload: {
573
+ password: string;
574
+ salt: string;
575
+ }): Promise<boolean>;
576
+ addNewCredential(params: {
577
+ password?: string;
578
+ payload: {
579
+ name: string;
580
+ email: string;
581
+ exchange: string;
582
+ api_key: string;
583
+ api_secret: string;
584
+ };
585
+ }): Promise<void>;
586
+ getAccountWithActivePositions(): Promise<import("pocketbase").RecordModel[]>;
587
+ getAllSymbolsFromPositions(options?: {
588
+ no_position?: boolean;
589
+ kind?: "long" | "short";
590
+ custom_filter?: string;
591
+ }): Promise<any[]>;
233
592
  createOrUpdateLiveExchangeInstance(payload: {
234
593
  account: ExchangeType;
235
594
  symbol: string;
@@ -242,18 +601,24 @@ export declare class AppDatabase {
242
601
  }): Promise<import("pocketbase").RecordModel>;
243
602
  getProxyForAccount(account: ExchangeType): Promise<HttpsProxyAgent<`http://${string}`> | SocksProxyAgent>;
244
603
  getAccounts(): Promise<ExchangeAccount[]>;
245
- getAllSymbolConfigs(with_positions?: boolean): Promise<SymbolConfig[]>;
604
+ getAllSymbolConfigs(payload?: {
605
+ with_positions?: boolean;
606
+ custom_filter?: string;
607
+ }): Promise<SymbolConfig[]>;
246
608
  get_exchange_db_instance(account: ExchangeType): Promise<ExchangeAccount & {
247
609
  expand?: {
248
610
  proxy: Proxy$1;
249
611
  };
250
612
  }>;
251
- getPositions(account: ExchangeType, options: {
252
- symbol: string;
613
+ getPositions(options: {
614
+ account?: ExchangeType;
615
+ symbol?: string;
253
616
  as_view?: boolean;
617
+ custom_filter?: string;
254
618
  }): Promise<(PositionsView & {
255
619
  expand?: {
256
620
  config: ScheduledTrade;
621
+ account: ExchangeAccount;
257
622
  };
258
623
  })[]>;
259
624
  private _createOrUpdatePosition;
@@ -265,6 +630,7 @@ export declare class AppDatabase {
265
630
  }): Promise<(PositionsView & {
266
631
  expand?: {
267
632
  config: ScheduledTrade;
633
+ account: ExchangeAccount;
268
634
  };
269
635
  })[]>;
270
636
  update_db_position(position: any, payload: any): Promise<import("pocketbase").RecordModel>;
@@ -276,7 +642,7 @@ export declare class AppDatabase {
276
642
  getOrders(account: ExchangeType, options: {
277
643
  symbol: string;
278
644
  kind: "long" | "short";
279
- }): Promise<import("pocketbase").RecordModel[]>;
645
+ }): Promise<Order[]>;
280
646
  deleteAndRecreateOrders(account: ExchangeType, options: {
281
647
  symbol: string;
282
648
  kind: "long" | "short";
@@ -289,7 +655,33 @@ export declare class AppDatabase {
289
655
  stop: number;
290
656
  order_id: string;
291
657
  triggerPrice?: number;
292
- }>): Promise<import("pocketbase").RecordModel[]>;
658
+ }>): Promise<Order[]>;
659
+ deleteAndBulCreateAllOrders(payload: {
660
+ account: ExchangeType & {
661
+ id: string;
662
+ };
663
+ symbol: string;
664
+ all_orders: Array<{
665
+ symbol: string;
666
+ price: number;
667
+ quantity: number;
668
+ kind: "long" | "short";
669
+ side: "buy" | "sell";
670
+ stop: number;
671
+ order_id: string;
672
+ triggerPrice?: number;
673
+ }>;
674
+ }): Promise<void>;
675
+ cancelLimitOrders(payload: {
676
+ symbol: string;
677
+ kind: "long" | "short";
678
+ account: ExchangeType;
679
+ raw?: boolean;
680
+ cancelExchangeOrders: (payload: {
681
+ symbol: string;
682
+ orders: number[];
683
+ }) => Promise<any>;
684
+ }): Promise<any[]>;
293
685
  cancelOrders(payload: {
294
686
  cancelExchangeOrders: (payload: {
295
687
  symbol: string;
@@ -317,23 +709,60 @@ export declare class AppDatabase {
317
709
  message?: undefined;
318
710
  exchange_result?: undefined;
319
711
  }>;
712
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
713
+ updateScheduledTrade(id: string, payload: any): Promise<import("pocketbase").RecordModel>;
714
+ getPositionsToAutoFollow(): Promise<(Position$1 & {
715
+ expand: {
716
+ account: ExchangeAccount;
717
+ };
718
+ })[]>;
320
719
  createOrUpdatePositionConfig(db_position: any, payload: {
321
720
  entry: number;
322
721
  stop: number;
323
722
  risk_reward: number;
324
723
  risk: number;
325
724
  profit_percent?: number;
326
- }): Promise<void>;
725
+ place_tp?: boolean;
726
+ profit?: number;
727
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
327
728
  getPositionConfig(payload: {
328
729
  symbol: string;
329
730
  kind: "long" | "short";
330
731
  account: ExchangeType;
331
732
  }): Promise<ScheduledTrade | null>;
332
- getPositionStrategy(account: ExchangeType): Promise<{
333
- strategy_instance: Strategy;
334
- focus_account: ExchangeAccount;
335
- }>;
336
- createOrUpdateWindingDownMarket(symbol: string): Promise<import("pocketbase").RecordModel>;
733
+ getRunningAccountStrategies(): Promise<(AccountStrategy & {
734
+ expand?: {
735
+ account: ExchangeAccount;
736
+ };
737
+ })[]>;
738
+ getAccountStrategy(payload: {
739
+ symbol: string;
740
+ account: ExchangeType;
741
+ }): Promise<AccountStrategy>;
742
+ getBotViewInstance(payload: {
743
+ asset: string;
744
+ main_account: ExchangeType;
745
+ }): Promise<BotView | null>;
746
+ getBotInstance(payload: {
747
+ asset: string;
748
+ main_account: ExchangeType;
749
+ }): Promise<BotInstance | null>;
750
+ getBotState(payload: {
751
+ asset: string;
752
+ main_account: ExchangeType;
753
+ running?: boolean;
754
+ }): Promise<BotState[]>;
755
+ getBotOrderHistories(payload: {
756
+ asset: string;
757
+ main_account: ExchangeType;
758
+ symbol?: string;
759
+ kind?: "long" | "short";
760
+ type?: "future" | "spot";
761
+ }): Promise<BotOrderHistory[]>;
762
+ createOrUpdateWindingDownMarket(payload: {
763
+ symbol: string;
764
+ risk_reward?: number;
765
+ }): Promise<import("pocketbase").RecordModel>;
337
766
  getWindingDownMarkets(symbol?: string): Promise<WindingDownMarket[]>;
338
767
  getBullishMarket(symbol: string): Promise<BullishMarket>;
339
768
  getBullishMarkets(options?: {
@@ -342,6 +771,7 @@ export declare class AppDatabase {
342
771
  percent: number;
343
772
  }>;
344
773
  totalRisk: number;
774
+ max_count?: number;
345
775
  }): Promise<{
346
776
  updated_bullish: BullishMarket[];
347
777
  moved_to_winding: WindingDownMarket[];
@@ -362,93 +792,1067 @@ export declare class AppDatabase {
362
792
  } | SymbolConfig[]>;
363
793
  unwindSymbolFromDB(symbol: string): Promise<boolean>;
364
794
  hasExistingPosition(symbol: string): Promise<import("pocketbase").RecordModel[]>;
795
+ getPositionWithLowestNextOrder(options: {
796
+ symbol?: string;
797
+ kind: "long" | "short";
798
+ asset?: string;
799
+ exclude?: ExchangeType[];
800
+ }): Promise<PositionsView | null>;
801
+ hasExistingOrders(symbol: string): Promise<import("pocketbase").RecordModel[]>;
365
802
  removeSymbolFromUnwindingMarkets(symbol: string): Promise<boolean>;
366
803
  removePosition(position: any): Promise<void>;
367
804
  removePositionConfig(position: any): Promise<void>;
805
+ getConfigProfiles(payload: {
806
+ config_id: string;
807
+ }): Promise<{
808
+ id: any;
809
+ entry: any;
810
+ stop: any;
811
+ kind: "long" | "short";
812
+ risk_reward: any;
813
+ risk: any;
814
+ profit_percent: any;
815
+ }[]>;
816
+ editConfigProfile(payload: {
817
+ id: string;
818
+ params: {
819
+ entry?: number;
820
+ stop?: number;
821
+ risk_reward?: number;
822
+ risk?: number;
823
+ profit_percent?: number;
824
+ };
825
+ }): Promise<void>;
826
+ createConfigProfile(payload: {
827
+ config_id: string;
828
+ symbol: string;
829
+ params: {
830
+ entry: number;
831
+ stop: number;
832
+ kind: "long" | "short";
833
+ risk_reward: number;
834
+ risk: number;
835
+ profit_percent: number;
836
+ };
837
+ }): Promise<void>;
368
838
  }
369
- export interface CodeNode {
370
- minimum_pnl: number;
371
- max_size: number;
372
- profit: number;
373
- ratio?: number;
374
- increase: boolean;
375
- not_reduce?: boolean;
376
- reduce_ratio?: number;
377
- use_full?: boolean;
378
- }
379
- export type AppConfig = {
380
- fee: number;
381
- risk_per_trade: number;
382
- risk_reward: number;
383
- symbol?: string;
384
- focus: number;
385
- budget: number;
386
- support: number;
387
- resistance: number;
388
- percent_change: number;
389
- tradeSplit?: number;
390
- take_profit?: number;
391
- kind: "long" | "short";
839
+ export type StrategyPosition = {
392
840
  entry: number;
841
+ quantity: number;
842
+ avg_price?: number;
843
+ avg_qty?: number;
844
+ };
845
+ export type GapCloserResult = {
846
+ avg_entry: number;
847
+ avg_size: number;
848
+ loss: number;
393
849
  stop: number;
394
- min_size: number;
395
- price_places?: string;
396
- strategy?: "quantity" | "entry";
397
- as_array?: boolean;
398
- decimal_places?: string;
399
- min_profit?: number;
400
- raw?: boolean;
401
- gap?: number;
402
- rr?: number;
403
- max_size?: number;
850
+ stop_quantity: number;
851
+ re_entry_quantity: number;
852
+ initial_pnl: number;
853
+ tp: number;
854
+ incurred_loss: number;
855
+ pnl: number;
856
+ remaining_quantity: number;
404
857
  };
405
- declare class ExchangeAccount$1 {
406
- private instance;
407
- private exchange;
408
- private app_db;
409
- constructor(payload: ExchangeType, options: {
410
- exchange: BaseExchange;
411
- app_db: AppDatabase;
858
+ export type Config = {
859
+ tp_percent: number;
860
+ short_tp_factor: number;
861
+ fee_percent?: number;
862
+ budget: number;
863
+ risk_reward: number;
864
+ reduce_ratio: number;
865
+ global_config: GlobalConfig;
866
+ };
867
+ export declare class Strategy {
868
+ position: {
869
+ long: StrategyPosition;
870
+ short: StrategyPosition;
871
+ };
872
+ dominant_position?: "long" | "short";
873
+ config: Config;
874
+ constructor(payload: {
875
+ long: StrategyPosition;
876
+ short: StrategyPosition;
877
+ config: Config;
878
+ dominant_position?: "long" | "short";
412
879
  });
413
- /**
414
- *In order to avoid rate limiting issues, we cache the live exchange
415
- details for each symbol for an account in the database with an option
416
- to refresh.
880
+ get price_places(): string;
881
+ get decimal_places(): string;
882
+ to_f(price: number): number;
883
+ to_df(quantity: number): number;
884
+ pnl(kind: "long" | "short", _position?: StrategyPosition): number;
885
+ tp(kind: "long" | "short"): number;
886
+ calculate_fee(position: {
887
+ price: number;
888
+ quantity: number;
889
+ }): number;
890
+ get long_tp(): number;
891
+ get short_tp(): number;
892
+ generateGapClosingAlgorithm(payload: {
893
+ kind: "long" | "short";
894
+ ignore_entries?: boolean;
895
+ reduce_ratio?: number;
896
+ sell_factor?: number;
897
+ }): {
898
+ last_entry: any;
899
+ first_entry: any;
900
+ threshold: any;
901
+ risk: number;
902
+ risk_reward: number;
903
+ spread: number;
904
+ gap_loss: number;
905
+ net_profit: number;
906
+ long: GapCloserResult;
907
+ short: GapCloserResult;
908
+ };
909
+ gapCloserHelper(payload: {
910
+ risk: number;
911
+ entries?: any[];
912
+ kind: "long" | "short";
913
+ sell_factor?: number;
914
+ reduce_ratio?: number;
915
+ }): {
916
+ risk: number;
917
+ risk_reward: number;
918
+ spread: number;
919
+ gap_loss: number;
920
+ net_profit: number;
921
+ long: GapCloserResult;
922
+ short: GapCloserResult;
923
+ };
924
+ runIterations(payload: {
925
+ kind: "long" | "short";
926
+ iterations: number;
927
+ risk_reward?: number;
928
+ ignore_entries?: boolean;
929
+ reduce_ratio?: number;
930
+ sell_factor?: number;
931
+ }): {
932
+ last_entry: any;
933
+ first_entry: any;
934
+ threshold: any;
935
+ risk: number;
936
+ risk_reward: number;
937
+ spread: number;
938
+ gap_loss: number;
939
+ net_profit: number;
940
+ long: GapCloserResult;
941
+ short: GapCloserResult;
942
+ }[];
943
+ getPositionAfterTp(payload: {
944
+ kind: "long" | "short";
945
+ include_fees?: boolean;
946
+ }): {
947
+ [x: string]: number | {
948
+ entry: number;
949
+ quantity: number;
950
+ diff?: undefined;
951
+ } | {
952
+ [x: string]: number;
953
+ diff: number;
954
+ entry?: undefined;
955
+ quantity?: undefined;
956
+ };
957
+ pnl: {
958
+ [x: string]: number;
959
+ diff: number;
960
+ };
961
+ spread: number;
962
+ };
963
+ getPositionAfterIteration(payload: {
964
+ kind: "long" | "short";
965
+ iterations: number;
966
+ with_fees?: boolean;
967
+ }): {
968
+ [x: string]: number | {
969
+ entry: number;
970
+ quantity: number;
971
+ diff?: undefined;
972
+ } | {
973
+ [x: string]: number;
974
+ diff: number;
975
+ entry?: undefined;
976
+ quantity?: undefined;
977
+ };
978
+ pnl: {
979
+ [x: string]: number;
980
+ diff: number;
981
+ };
982
+ spread: number;
983
+ }[];
984
+ /**To be used as one of the agent tools eventually since
985
+ * it is something that can be triggered continously without
986
+ * any risk
417
987
  */
418
- getLiveExchangeInstance(payload: {
419
- symbol: string;
420
- refresh?: boolean;
988
+ generateOppositeTrades(payload: {
989
+ kind: "long" | "short";
990
+ risk_factor?: number;
991
+ avg_entry?: number;
992
+ }): {
993
+ avg: {
994
+ entry: number;
995
+ price: number;
996
+ quantity: number;
997
+ };
998
+ loss: number;
999
+ profit_percent: number;
1000
+ fee: number;
1001
+ risk_per_trade: number;
1002
+ risk_reward: number;
1003
+ symbol?: string;
1004
+ focus: number;
1005
+ budget: number;
1006
+ support: number;
1007
+ resistance: number;
1008
+ percent_change: number;
1009
+ tradeSplit?: number;
1010
+ take_profit?: number;
1011
+ kind: "long" | "short";
1012
+ entry: number;
1013
+ stop: number;
1014
+ min_size: number;
421
1015
  price_places?: string;
1016
+ strategy?: "quantity" | "entry";
1017
+ as_array?: boolean;
422
1018
  decimal_places?: string;
423
- }): Promise<import("pocketbase").RecordModel>;
424
- getActiveAccount(symbol: string, full?: boolean): Promise<Account | {
425
- liquidation: {
1019
+ min_profit?: number;
1020
+ raw?: boolean;
1021
+ gap?: number;
1022
+ rr?: number;
1023
+ max_size?: number;
1024
+ max_quantity?: number;
1025
+ kelly?: {
1026
+ use_kelly?: boolean;
1027
+ kelly_confidence_factor?: number;
1028
+ kelly_minimum_risk?: number;
1029
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1030
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1031
+ };
1032
+ };
1033
+ identifyGapConfig(payload: {
1034
+ factor?: number;
1035
+ sell_factor?: number;
1036
+ kind?: "long" | "short";
1037
+ risk?: number;
1038
+ }): {
1039
+ profit_percent: {
426
1040
  long: number;
427
1041
  short: number;
428
1042
  };
429
- active_account: Account;
430
- current_price: any;
431
- exchange: any;
432
- }>;
433
- syncAccount(options: {
434
- symbol: string;
435
- kind?: "long" | "short";
436
- update?: boolean;
437
- as_view?: boolean;
438
- leverage?: number;
439
- }): Promise<PositionsView | (PositionsView & {
440
- expand?: {
441
- config: ScheduledTrade;
1043
+ risk: {
1044
+ short: number;
1045
+ long: number;
442
1046
  };
443
- })[]>;
444
- getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
445
- syncOrders(options: {
446
- symbol: string;
1047
+ take_profit: {
1048
+ long: number;
1049
+ short: number;
1050
+ };
1051
+ to_reduce: {
1052
+ short: number;
1053
+ long: number;
1054
+ };
1055
+ full_reduce: {
1056
+ short: number;
1057
+ long: number;
1058
+ };
1059
+ sell_quantity: {
1060
+ short: number;
1061
+ long: number;
1062
+ };
1063
+ gap: number;
1064
+ gap_loss: number;
1065
+ };
1066
+ analyzeProfit(payload: {
1067
+ reward_factor?: number;
1068
+ max_reward_factor: number;
1069
+ risk: number;
447
1070
  kind: "long" | "short";
448
- update?: boolean;
449
- }): Promise<import("pocketbase").RecordModel[]>;
450
- toggleStopBuying(payload: {
451
- symbol: string;
1071
+ }): {
1072
+ pnl: number;
1073
+ loss: number;
1074
+ full_loss: number;
1075
+ original_pnl: number;
1076
+ reward_factor: number;
1077
+ profit_percent: number;
1078
+ kind: "long" | "short";
1079
+ sell_price: number;
1080
+ quantity: number;
1081
+ price_places: string;
1082
+ decimal_places: string;
1083
+ };
1084
+ simulateGapReduction(payload: {
1085
+ iterations?: number;
1086
+ factor?: number;
1087
+ direction: "long" | "short";
1088
+ kind?: "long" | "short";
1089
+ risk?: number;
1090
+ sell_factor?: number;
1091
+ }): {
1092
+ results: {
1093
+ profit_percent: {
1094
+ long: number;
1095
+ short: number;
1096
+ };
1097
+ risk: {
1098
+ short: number;
1099
+ long: number;
1100
+ };
1101
+ take_profit: {
1102
+ long: number;
1103
+ short: number;
1104
+ };
1105
+ sell_quantity: {
1106
+ short: number;
1107
+ long: number;
1108
+ };
1109
+ gap_loss: number;
1110
+ position: {
1111
+ long: {
1112
+ entry: number;
1113
+ quantity: number;
1114
+ };
1115
+ short: {
1116
+ entry: number;
1117
+ quantity: number;
1118
+ };
1119
+ };
1120
+ }[];
1121
+ quantity: number;
1122
+ };
1123
+ }
1124
+ export type SignalConfigType = {
1125
+ focus: number;
1126
+ budget: number;
1127
+ percent_change?: number;
1128
+ price_places?: string;
1129
+ decimal_places?: string;
1130
+ zone_risk?: number;
1131
+ fee?: number;
1132
+ support?: number;
1133
+ risk_reward?: number;
1134
+ resistance?: number;
1135
+ risk_per_trade?: number;
1136
+ increase_size?: boolean;
1137
+ additional_increase?: number;
1138
+ minimum_pnl?: number;
1139
+ take_profit?: number;
1140
+ increase_position?: boolean;
1141
+ minimum_size?: number;
1142
+ first_order_size?: number;
1143
+ gap?: number;
1144
+ max_size?: number;
1145
+ use_kelly?: boolean;
1146
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1147
+ kelly_confidence_factor?: number;
1148
+ kelly_minimum_risk?: number;
1149
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1150
+ };
1151
+ declare class Signal {
1152
+ focus: number;
1153
+ budget: number;
1154
+ percent_change: number;
1155
+ price_places: string;
1156
+ decimal_places: string;
1157
+ zone_risk: number;
1158
+ fee: number;
1159
+ support?: number;
1160
+ risk_reward: number;
1161
+ resistance?: number;
1162
+ risk_per_trade?: number;
1163
+ increase_size: boolean;
1164
+ additional_increase: number;
1165
+ minimum_pnl: number;
1166
+ take_profit?: number;
1167
+ increase_position: boolean;
1168
+ minimum_size: any;
1169
+ first_order_size: number;
1170
+ gap: number;
1171
+ max_size: number;
1172
+ use_kelly: boolean;
1173
+ kelly_prediction_model: "exponential" | "normal" | "uniform";
1174
+ kelly_confidence_factor: number;
1175
+ kelly_minimum_risk: number;
1176
+ kelly_func: "theoretical" | "position_based" | "theoretical_fixed";
1177
+ constructor({ focus, budget, percent_change, price_places, decimal_places, zone_risk, fee, support, risk_reward, resistance, risk_per_trade, increase_size, additional_increase, minimum_pnl, take_profit, increase_position, minimum_size, first_order_size, gap, max_size, use_kelly, kelly_prediction_model, kelly_confidence_factor, kelly_minimum_risk, kelly_func, }: SignalConfigType);
1178
+ build_entry({ current_price, stop_loss, pnl, stop_percent, kind, risk, no_of_trades, take_profit, }: {
1179
+ take_profit?: number;
1180
+ no_of_trades?: number;
1181
+ current_price: number;
1182
+ stop_loss?: number;
1183
+ kind?: "long" | "short";
1184
+ risk: number;
1185
+ stop_percent?: number;
1186
+ pnl?: number;
1187
+ }): any;
1188
+ get risk(): number;
1189
+ get min_trades(): number;
1190
+ get min_price(): number;
1191
+ build_opposite_order({ current_price, kind, }: {
1192
+ current_price: number;
1193
+ kind?: "long" | "short";
1194
+ }): any;
1195
+ special_build_orders({ current_price, kind, }: {
1196
+ current_price: number;
1197
+ kind?: "long" | "short";
1198
+ }): any;
1199
+ build_orders({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
1200
+ current_price: number;
1201
+ kind?: "long" | "short";
1202
+ limit?: boolean;
1203
+ replace_focus?: boolean;
1204
+ max_index?: number;
1205
+ min_index?: number;
1206
+ }): any;
1207
+ build_orders_old({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
1208
+ current_price: number;
1209
+ kind?: "long" | "short";
1210
+ limit?: boolean;
1211
+ replace_focus?: boolean;
1212
+ max_index?: number;
1213
+ min_index?: number;
1214
+ }): any;
1215
+ get_bulk_trade_zones({ current_price, kind, limit, }: {
1216
+ current_price: number;
1217
+ kind?: "long" | "short";
1218
+ limit?: boolean;
1219
+ }): any;
1220
+ get_future_zones({ current_price, kind, raw, }: {
1221
+ raw?: boolean;
1222
+ current_price: number;
1223
+ kind?: "long" | "short";
1224
+ }): number[];
1225
+ to_f(value: number, places?: string): number;
1226
+ get_margin_zones({ current_price, kind, }: {
1227
+ current_price: number;
1228
+ kind?: "long" | "short";
1229
+ }): number[][];
1230
+ get_margin_range(current_price: number, kind?: string): number[];
1231
+ process_orders({ current_price, stop_loss, trade_zones, kind, }: {
1232
+ current_price: number;
1233
+ stop_loss: number;
1234
+ trade_zones: number[];
1235
+ kind?: "long" | "short";
1236
+ }): any[];
1237
+ get_risk_per_trade(number_of_orders: number): number;
1238
+ build_trade_dict({ entry, stop, risk, arr, index, new_fees, kind, start, take_profit, }: {
1239
+ entry: number;
1240
+ stop: number;
1241
+ risk: number;
1242
+ arr: number[];
1243
+ index: number;
1244
+ new_fees?: number;
1245
+ kind?: "long" | "short";
1246
+ start?: number;
1247
+ take_profit?: number;
1248
+ }): {
1249
+ entry: number;
1250
+ risk: number;
1251
+ quantity: number;
1252
+ sell_price: number;
1253
+ risk_sell: number;
1254
+ stop: number;
1255
+ pnl: number;
1256
+ fee: number;
1257
+ net: number;
1258
+ incurred: number;
1259
+ stop_percent: number;
1260
+ };
1261
+ to_df(currentPrice: number, places?: string): number;
1262
+ }
1263
+ export declare function determine_average_entry_and_size(orders: Array<{
1264
+ price: number;
1265
+ quantity: number;
1266
+ }>, places?: string, price_places?: string): {
1267
+ entry: number;
1268
+ price: number;
1269
+ quantity: number;
1270
+ };
1271
+ export declare const createArray: (start: number, stop: number, step: number) => number[];
1272
+ export type AppConfig = {
1273
+ fee: number;
1274
+ risk_per_trade: number;
1275
+ risk_reward: number;
1276
+ symbol?: string;
1277
+ focus: number;
1278
+ budget: number;
1279
+ support: number;
1280
+ resistance: number;
1281
+ percent_change: number;
1282
+ tradeSplit?: number;
1283
+ take_profit?: number;
1284
+ kind: "long" | "short";
1285
+ entry: number;
1286
+ stop: number;
1287
+ min_size: number;
1288
+ price_places?: string;
1289
+ strategy?: "quantity" | "entry";
1290
+ as_array?: boolean;
1291
+ decimal_places?: string;
1292
+ min_profit?: number;
1293
+ raw?: boolean;
1294
+ gap?: number;
1295
+ rr?: number;
1296
+ max_size?: number;
1297
+ last_value?: any;
1298
+ entries?: any[];
1299
+ max_quantity?: number;
1300
+ kelly?: {
1301
+ use_kelly?: boolean;
1302
+ kelly_confidence_factor?: number;
1303
+ kelly_minimum_risk?: number;
1304
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1305
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1306
+ };
1307
+ };
1308
+ export type ExtendConfigType = {
1309
+ take_profit?: number;
1310
+ entry: number;
1311
+ risk?: number;
1312
+ stop?: number;
1313
+ risk_reward?: number;
1314
+ raw_instance?: boolean;
1315
+ no_of_trades?: number;
1316
+ increase?: boolean;
1317
+ price_places?: string;
1318
+ decimal_places?: string;
1319
+ min_profit?: number;
1320
+ kind?: "long" | "short";
1321
+ gap?: number;
1322
+ rr?: number;
1323
+ use_kelly?: boolean;
1324
+ kelly_confidence_factor?: number;
1325
+ kelly_minimum_risk?: number;
1326
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1327
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1328
+ };
1329
+ export declare function buildConfig(app_config: AppConfig, { take_profit, entry, stop, raw_instance, risk, no_of_trades, min_profit, risk_reward, kind, increase, gap, rr, price_places, decimal_places, use_kelly, kelly_confidence_factor, kelly_minimum_risk, kelly_prediction_model, kelly_func, }: ExtendConfigType): any[] | Signal;
1330
+ export declare function buildAvg({ _trades, kind, }: {
1331
+ _trades: any[];
1332
+ kind: "long" | "short";
1333
+ }): any;
1334
+ export declare function sortedBuildConfig(app_config: AppConfig, options: any): any[];
1335
+ export declare function get_app_config_and_max_size(config: GlobalConfig, payload: {
1336
+ entry: number;
1337
+ stop: number;
1338
+ kind: "long" | "short";
1339
+ use_kelly?: boolean;
1340
+ kelly_confidence_factor?: number;
1341
+ kelly_minimum_risk?: number;
1342
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1343
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1344
+ }): {
1345
+ app_config: AppConfig;
1346
+ max_size: any;
1347
+ last_value: any;
1348
+ entries: {
1349
+ entry: any;
1350
+ avg_entry: any;
1351
+ avg_size: any;
1352
+ neg_pnl: any;
1353
+ quantity: any;
1354
+ }[];
1355
+ };
1356
+ export declare function buildAppConfig(config: GlobalConfig, payload: {
1357
+ entry: number;
1358
+ stop: number;
1359
+ risk_reward: number;
1360
+ risk: number;
1361
+ symbol: string;
1362
+ profit?: number;
1363
+ use_kelly?: boolean;
1364
+ kelly_confidence_factor?: number;
1365
+ kelly_minimum_risk?: number;
1366
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1367
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1368
+ }): AppConfig;
1369
+ export declare function getOptimumStopAndRisk(app_config: AppConfig, params: {
1370
+ max_size: number;
1371
+ target_stop: number;
1372
+ highest_risk?: number;
1373
+ }): {
1374
+ optimal_stop: number;
1375
+ optimal_risk: number;
1376
+ avg_size: any;
1377
+ avg_entry: any;
1378
+ result: any[];
1379
+ first_entry: any;
1380
+ neg_pnl: any;
1381
+ risk_reward: number;
1382
+ size_diff: number;
1383
+ entry_diff: number;
1384
+ };
1385
+ export declare function generate_config_params(app_config: AppConfig, payload: {
1386
+ entry: number;
1387
+ stop: number;
1388
+ risk_reward: number;
1389
+ risk: number;
1390
+ symbol: string;
1391
+ }): {
1392
+ entry: number;
1393
+ stop: number;
1394
+ avg_size: any;
1395
+ avg_entry: any;
1396
+ risk_reward: number;
1397
+ neg_pnl: any;
1398
+ risk: number;
1399
+ };
1400
+ export declare function determine_break_even_price(payload: {
1401
+ long_position: {
1402
+ entry: number;
1403
+ quantity: number;
1404
+ };
1405
+ short_position: {
1406
+ entry: number;
1407
+ quantity: number;
1408
+ };
1409
+ fee_percent?: number;
1410
+ }): {
1411
+ price: number;
1412
+ direction: string;
1413
+ };
1414
+ export declare function determine_amount_to_buy(payload: {
1415
+ orders: any[];
1416
+ kind: "long" | "short";
1417
+ decimal_places?: string;
1418
+ price_places?: string;
1419
+ place?: boolean;
1420
+ position: any;
1421
+ existingOrders: any[];
1422
+ }): any[];
1423
+ export declare function generateOptimumAppConfig(config: GlobalConfig, payload: {
1424
+ entry: number;
1425
+ stop: number;
1426
+ risk_reward: number;
1427
+ start_risk: number;
1428
+ max_risk?: number;
1429
+ }, position: {
1430
+ entry: number;
1431
+ quantity: number;
1432
+ kind: "long" | "short";
1433
+ }): AppConfig | null;
1434
+ export declare function determineOptimumReward(app_config: AppConfig, increase?: boolean, low_range?: number, high_range?: number): number | {
1435
+ result: any[];
1436
+ value: number;
1437
+ total: number;
1438
+ risk_per_trade: number;
1439
+ max: number;
1440
+ min: number;
1441
+ neg_pnl: any;
1442
+ entry: any;
1443
+ };
1444
+ export declare function determineOptimumRisk(config: GlobalConfig, payload: {
1445
+ entry: number;
1446
+ stop: number;
1447
+ risk_reward: number;
1448
+ risk: number;
1449
+ symbol: string;
1450
+ }, params: {
1451
+ highest_risk: number;
1452
+ tolerance?: number;
1453
+ max_iterations?: number;
1454
+ }): {
1455
+ optimal_risk: number;
1456
+ achieved_neg_pnl: number;
1457
+ target_neg_pnl: number;
1458
+ difference: number;
1459
+ iterations: number;
1460
+ converged: boolean;
1461
+ last_value: any;
1462
+ entries: any[];
1463
+ app_config: AppConfig;
1464
+ };
1465
+ export declare function computeRiskReward(payload: {
1466
+ app_config: AppConfig;
1467
+ entry: number;
1468
+ stop: number;
1469
+ risk_per_trade: number;
1470
+ }): number | {
1471
+ result: any[];
1472
+ value: number;
1473
+ total: number;
1474
+ risk_per_trade: number;
1475
+ max: number;
1476
+ min: number;
1477
+ neg_pnl: any;
1478
+ entry: any;
1479
+ };
1480
+ export declare function getRiskReward(payload: {
1481
+ entry: number;
1482
+ stop: number;
1483
+ risk: number;
1484
+ global_config: GlobalConfig;
1485
+ force_exact_risk?: boolean;
1486
+ }): any;
1487
+ export declare function computeProfitDetail(payload: {
1488
+ focus_position: {
1489
+ kind: "long" | "short";
1490
+ entry: number;
1491
+ quantity: number;
1492
+ avg_qty: number;
1493
+ avg_price: number;
1494
+ };
1495
+ strategy?: {
1496
+ reward_factor: number;
1497
+ max_reward_factor: number;
1498
+ risk: number;
1499
+ };
1500
+ pnl: number;
1501
+ reduce_position?: {
1502
+ kind: "long" | "short";
1503
+ entry: number;
1504
+ quantity: number;
1505
+ avg_qty: number;
1506
+ avg_price: number;
1507
+ };
1508
+ reverse_position?: {
1509
+ kind: "long" | "short";
1510
+ avg_qty: number;
1511
+ avg_price: number;
1512
+ stop_loss: {
1513
+ price: number;
1514
+ quantity: number;
1515
+ };
1516
+ };
1517
+ full_ratio?: number;
1518
+ price_places?: string;
1519
+ decimal_places?: string;
1520
+ }): {
1521
+ pnl: number;
1522
+ loss: number;
1523
+ full_loss: number;
1524
+ original_pnl: number;
1525
+ reward_factor: number;
1526
+ profit_percent: number;
1527
+ kind: "long" | "short";
1528
+ sell_price: number;
1529
+ quantity: number;
1530
+ price_places: string;
1531
+ decimal_places: string;
1532
+ };
1533
+ export declare function generateGapTp(payload: {
1534
+ long: {
1535
+ entry: number;
1536
+ quantity: number;
1537
+ };
1538
+ short: {
1539
+ entry: number;
1540
+ quantity: number;
1541
+ };
1542
+ risk?: number;
1543
+ kind?: "long" | "short";
1544
+ factor?: number;
1545
+ sell_factor?: number;
1546
+ price_places?: string;
1547
+ decimal_places?: string;
1548
+ }): {
1549
+ profit_percent: {
1550
+ long: number;
1551
+ short: number;
1552
+ };
1553
+ risk: {
1554
+ short: number;
1555
+ long: number;
1556
+ };
1557
+ take_profit: {
1558
+ long: number;
1559
+ short: number;
1560
+ };
1561
+ to_reduce: {
1562
+ short: number;
1563
+ long: number;
1564
+ };
1565
+ full_reduce: {
1566
+ short: number;
1567
+ long: number;
1568
+ };
1569
+ sell_quantity: {
1570
+ short: number;
1571
+ long: number;
1572
+ };
1573
+ gap: number;
1574
+ gap_loss: number;
1575
+ };
1576
+ export declare function determineRewardFactor(payload: {
1577
+ quantity: number;
1578
+ avg_qty: number;
1579
+ minimum_pnl: number;
1580
+ risk: number;
1581
+ }): number;
1582
+ export type BotPosition = {
1583
+ kind: "long" | "short";
1584
+ entry: number;
1585
+ quantity: number;
1586
+ tp: {
1587
+ price: number;
1588
+ };
1589
+ };
1590
+ export declare function getHedgeZone(payload: {
1591
+ symbol_config: GlobalConfig;
1592
+ risk: number;
1593
+ position: BotPosition;
1594
+ reward_factor?: number;
1595
+ risk_factor?: number;
1596
+ support?: number;
1597
+ }): {
1598
+ support: number;
1599
+ resistance: number;
1600
+ risk: number;
1601
+ profit_percent: number;
1602
+ };
1603
+ export declare function getOptimumHedgeFactor(payload: {
1604
+ target_support: number;
1605
+ tolerance?: number;
1606
+ max_iterations?: number;
1607
+ min_factor?: number;
1608
+ max_factor?: number;
1609
+ symbol_config: GlobalConfig;
1610
+ risk: number;
1611
+ position: BotPosition;
1612
+ }): {
1613
+ reward_factor: number;
1614
+ achieved_support: number;
1615
+ target_support: number;
1616
+ difference: number;
1617
+ iterations: number;
1618
+ converged?: undefined;
1619
+ } | {
1620
+ reward_factor: number;
1621
+ achieved_support: number;
1622
+ target_support: number;
1623
+ difference: number;
1624
+ iterations: number;
1625
+ converged: boolean;
1626
+ };
1627
+ export type CType = {
1628
+ next_order: number;
1629
+ take_profit: number;
1630
+ };
1631
+ export declare function determineCompoundLongTrade(payload: {
1632
+ focus_short_position: CType;
1633
+ focus_long_position: CType;
1634
+ shortConfig: {
1635
+ entry: number;
1636
+ stop: number;
1637
+ risk_reward: number;
1638
+ risk: number;
1639
+ symbol: string;
1640
+ profit_percent: number;
1641
+ };
1642
+ rr?: number;
1643
+ global_config: GlobalConfig;
1644
+ }): {
1645
+ start_risk: number;
1646
+ short_profit: number;
1647
+ support: number;
1648
+ resistance: number;
1649
+ long_v: any;
1650
+ profit_percent: number;
1651
+ result: any;
1652
+ short_max_size: any;
1653
+ };
1654
+ declare class ExchangePosition {
1655
+ exchange: BaseExchange;
1656
+ exchange_account: ExchangeAccount$1;
1657
+ private app_db;
1658
+ private instance;
1659
+ constructor(payload: {
1660
+ exchange: BaseExchange;
1661
+ app_db: AppDatabase;
1662
+ instance: PositionsView;
1663
+ exchange_account: ExchangeAccount$1;
1664
+ without_view?: PositionsView;
1665
+ });
1666
+ get symbol(): any;
1667
+ get kind(): any;
1668
+ get account(): any;
1669
+ cancelOrders(payload: {
1670
+ limit?: boolean;
1671
+ price?: number;
1672
+ }): Promise<any[] | {
1673
+ success: boolean;
1674
+ message: string;
1675
+ exchange_result?: undefined;
1676
+ error?: undefined;
1677
+ } | {
1678
+ success: boolean;
1679
+ exchange_result: any;
1680
+ message?: undefined;
1681
+ error?: undefined;
1682
+ } | {
1683
+ success: boolean;
1684
+ error: any;
1685
+ message?: undefined;
1686
+ exchange_result?: undefined;
1687
+ }>;
1688
+ getConfig(payload?: {
1689
+ params?: {
1690
+ entry?: number;
1691
+ stop?: number;
1692
+ risk_reward?: number;
1693
+ risk?: number;
1694
+ profit_percent?: number;
1695
+ place_tp?: boolean;
1696
+ profit?: number;
1697
+ };
1698
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
1699
+ updateTargetPnl(): Promise<number>;
1700
+ updateConfigPnl(): Promise<void>;
1701
+ triggerTradeFromConfig(payload: {
1702
+ place?: boolean;
1703
+ raw?: boolean;
1704
+ tp?: boolean;
1705
+ stop?: boolean;
1706
+ use_current?: boolean;
1707
+ ignore_config?: boolean;
1708
+ }): Promise<any>;
1709
+ placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
1710
+ entry: number;
1711
+ stop: number;
1712
+ risk_reward: number;
1713
+ risk: number;
1714
+ place?: boolean;
1715
+ update_db?: boolean;
1716
+ raw?: boolean;
1717
+ use_current?: boolean;
1718
+ }): Promise<any>;
1719
+ buildAppConfig(payload: {
1720
+ entry: number;
1721
+ stop: number;
1722
+ risk_reward: number;
1723
+ risk: number;
1724
+ profit?: number;
1725
+ update_db?: boolean;
1726
+ profit_percent?: number;
1727
+ }): Promise<AppConfig>;
1728
+ placeConfigOrders(app_config: AppConfig, solution: {
1729
+ risk_reward: number;
1730
+ entry: number;
1731
+ stop: number;
1732
+ risk_per_trade: number;
1733
+ avg_size: number;
1734
+ neg_pnl: number;
1735
+ min_size: number;
1736
+ symbol: string;
1737
+ }, place?: boolean, skip_stop?: boolean): Promise<{
1738
+ entry_orders: {
1739
+ orders: {
1740
+ entry: any;
1741
+ quantity: any;
1742
+ reverse_avg_entry: any;
1743
+ reverse_avg_quantity: any;
1744
+ avg_entry: any;
1745
+ avg_size: any;
1746
+ }[];
1747
+ kind: "long" | "short";
1748
+ };
1749
+ stop_orders: {
1750
+ stop: number;
1751
+ final_stop: number;
1752
+ kind: "long" | "short";
1753
+ quantity: any;
1754
+ is_limit: boolean;
1755
+ neg_pnl: any;
1756
+ };
1757
+ trades: any[];
1758
+ }>;
1759
+ determineAmountToBuy(payload: {
1760
+ orders: any[];
1761
+ kind: "long" | "short";
1762
+ refresh?: boolean;
1763
+ decimal_places?: string;
1764
+ price_places?: string;
1765
+ cancel?: boolean;
1766
+ place?: boolean;
1767
+ }): Promise<any[]>;
1768
+ refresh(live_refresh?: boolean): Promise<{
1769
+ instance: PositionsView;
1770
+ existingOrders: void | Order[];
1771
+ }>;
1772
+ placeTrade(payload: {
1773
+ place?: boolean;
1774
+ tp?: boolean;
1775
+ stop?: boolean;
1776
+ raw?: boolean;
1777
+ cancel?: boolean;
1778
+ ignore_config?: boolean;
1779
+ }): Promise<any>;
1780
+ }
1781
+ declare class ExchangeAccount$1 {
1782
+ instance: {
1783
+ owner: string;
1784
+ exchange: string;
1785
+ };
1786
+ exchange: BaseExchange;
1787
+ main_exchange?: BaseExchange;
1788
+ private app_db;
1789
+ private long_position?;
1790
+ private short_position?;
1791
+ constructor(payload: ExchangeType, options: {
1792
+ exchange: BaseExchange;
1793
+ app_db: AppDatabase;
1794
+ main_exchange?: BaseExchange;
1795
+ });
1796
+ /**
1797
+ *In order to avoid rate limiting issues, we cache the live exchange
1798
+ details for each symbol for an account in the database with an option
1799
+ to refresh.
1800
+ */
1801
+ getDBInstance(): AppDatabase;
1802
+ getLiveExchangeInstance(payload: {
1803
+ symbol: string;
1804
+ refresh?: boolean;
1805
+ refresh_symbol_config?: boolean;
1806
+ }): Promise<import("pocketbase").RecordModel>;
1807
+ initializePositions(payload: {
1808
+ symbol: string;
1809
+ as_view?: boolean;
1810
+ kind: "long" | "short";
1811
+ }): Promise<ExchangePosition>;
1812
+ getActiveAccount(payload: {
1813
+ symbol: string;
1814
+ full?: boolean;
1815
+ refresh?: boolean;
1816
+ }): Promise<Account | {
1817
+ liquidation: {
1818
+ long: number;
1819
+ short: number;
1820
+ };
1821
+ active_account: Account;
1822
+ current_price: any;
1823
+ exchange: any;
1824
+ }>;
1825
+ refreshAccount(payload: {
1826
+ symbol: string;
1827
+ live_refresh?: boolean;
1828
+ leverage?: number;
1829
+ }): Promise<(PositionsView & {
1830
+ expand?: {
1831
+ config: ScheduledTrade;
1832
+ account: ExchangeAccount;
1833
+ };
1834
+ })[]>;
1835
+ syncAccount(options: {
1836
+ symbol: string;
1837
+ kind?: "long" | "short";
1838
+ update?: boolean;
1839
+ as_view?: boolean;
1840
+ leverage?: number;
1841
+ live_refresh?: boolean;
1842
+ }): Promise<PositionsView | (PositionsView & {
1843
+ expand?: {
1844
+ config: ScheduledTrade;
1845
+ account: ExchangeAccount;
1846
+ };
1847
+ })[]>;
1848
+ getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
1849
+ syncOrders(options: {
1850
+ symbol: string;
1851
+ kind?: "long" | "short";
1852
+ update?: boolean;
1853
+ }): Promise<void | Order[]>;
1854
+ toggleStopBuying(payload: {
1855
+ symbol: string;
452
1856
  kind: "long" | "short";
453
1857
  should_stop?: boolean;
454
1858
  }): Promise<import("pocketbase").RecordModel>;
@@ -458,7 +1862,9 @@ declare class ExchangeAccount$1 {
458
1862
  price?: number;
459
1863
  all?: boolean;
460
1864
  stop?: boolean;
461
- }): Promise<{
1865
+ limit?: boolean;
1866
+ raw?: boolean;
1867
+ }): Promise<any[] | {
462
1868
  success: boolean;
463
1869
  message: string;
464
1870
  exchange_result?: undefined;
@@ -478,135 +1884,706 @@ declare class ExchangeAccount$1 {
478
1884
  symbol: string;
479
1885
  orders: number[];
480
1886
  }): Promise<any>;
1887
+ getBreakEvenPrice(payload: {
1888
+ symbol: string;
1889
+ }): Promise<{
1890
+ price: number;
1891
+ direction: string;
1892
+ }>;
481
1893
  buildAppConfig(payload: {
482
1894
  entry: number;
483
1895
  stop: number;
484
1896
  risk_reward: number;
485
1897
  risk: number;
486
1898
  symbol: string;
487
- profit?: number;
488
- update_db?: boolean;
489
- profit_percent?: number;
490
- }): Promise<AppConfig>;
491
- placeConfigOrders(app_config: AppConfig, solution: {
1899
+ profit?: number;
1900
+ update_db?: boolean;
1901
+ profit_percent?: number;
1902
+ use_kelly?: boolean;
1903
+ kelly_confidence_factor?: number;
1904
+ kelly_minimum_risk?: number;
1905
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1906
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1907
+ }): Promise<AppConfig>;
1908
+ tradeConfig(payload: {
1909
+ symbol: string;
1910
+ kind: "long" | "short";
1911
+ override?: any;
1912
+ }): Promise<AppConfig>;
1913
+ justInTimeProfit(payload: {
1914
+ symbol: string;
1915
+ target_pnl: number;
1916
+ kind: "long" | "short";
1917
+ refresh?: boolean;
1918
+ place?: boolean;
1919
+ take_profit?: number;
1920
+ pause_tp?: boolean;
1921
+ }): Promise<{
1922
+ sell_ratio: number;
1923
+ current_pnl: number;
1924
+ profit_percent: number;
1925
+ current_price: number;
1926
+ notional_value: number;
1927
+ }>;
1928
+ buildTrades(payload: {
1929
+ symbol: string;
1930
+ kind: "long" | "short";
1931
+ risk?: number;
1932
+ }): Promise<{
1933
+ trades: any[];
1934
+ max_size: any;
1935
+ last_price: any;
1936
+ total_size: number;
1937
+ avg_entry: number;
1938
+ }>;
1939
+ placeConfigOrders(app_config: AppConfig, solution: {
1940
+ risk_reward: number;
1941
+ entry: number;
1942
+ stop: number;
1943
+ risk_per_trade: number;
1944
+ avg_size: number;
1945
+ neg_pnl: number;
1946
+ min_size: number;
1947
+ symbol: string;
1948
+ stop_percent?: number;
1949
+ use_kelly?: boolean;
1950
+ kelly_confidence_factor?: number;
1951
+ kelly_minimum_risk?: number;
1952
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1953
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1954
+ }, place?: boolean, skip_stop?: boolean): Promise<{
1955
+ entry_orders: {
1956
+ orders: {
1957
+ entry: any;
1958
+ quantity: any;
1959
+ reverse_avg_entry: any;
1960
+ reverse_avg_quantity: any;
1961
+ avg_entry: any;
1962
+ avg_size: any;
1963
+ }[];
1964
+ kind: "long" | "short";
1965
+ };
1966
+ stop_orders: {
1967
+ stop: number;
1968
+ final_stop: number;
1969
+ kind: "long" | "short";
1970
+ quantity: any;
1971
+ is_limit: boolean;
1972
+ neg_pnl: any;
1973
+ original_stop: number;
1974
+ last_entry: any;
1975
+ };
1976
+ trades: any[];
1977
+ }>;
1978
+ determineAmountToBuy(payload: {
1979
+ orders: any[];
1980
+ kind: "long" | "short";
1981
+ refresh?: boolean;
1982
+ decimal_places?: string;
1983
+ price_places?: string;
1984
+ symbol: string;
1985
+ cancel?: boolean;
1986
+ place?: boolean;
1987
+ }): Promise<any[]>;
1988
+ placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders" | "dangerous_entry_orders", payload: {
1989
+ symbol: string;
1990
+ entry: number;
1991
+ stop: number;
1992
+ risk_reward: number;
1993
+ risk: number;
1994
+ place?: boolean;
1995
+ update_db?: boolean;
1996
+ raw?: boolean;
1997
+ use_current?: boolean;
1998
+ stop_percent?: number;
1999
+ }): Promise<any>;
2000
+ getOrCreatePositionConfig(payload: {
2001
+ symbol: string;
2002
+ kind: "long" | "short";
2003
+ risk?: number;
2004
+ risk_reward?: number;
2005
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
2006
+ getPositionConfig(payload: {
2007
+ symbol: string;
2008
+ kind: "long" | "short";
2009
+ params?: {
2010
+ entry?: number;
2011
+ stop?: number;
2012
+ risk_reward?: number;
2013
+ risk?: number;
2014
+ profit_percent?: number;
2015
+ place_tp?: boolean;
2016
+ profit?: number;
2017
+ };
2018
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
2019
+ getCurrentPrice(symbol: string): Promise<any>;
2020
+ getAccountStrategy(payload: {
2021
+ symbol: string;
2022
+ }): Promise<AccountStrategy>;
2023
+ buildReduceConfig(payload: {
2024
+ symbol: string;
2025
+ kind?: "long" | "short";
2026
+ as_dict?: boolean;
2027
+ target_pnl?: number;
2028
+ trigger?: {
2029
+ long: boolean;
2030
+ short: boolean;
2031
+ };
2032
+ use_full?: boolean;
2033
+ }): Promise<{
2034
+ trigger_short: boolean;
2035
+ trigger_long: boolean;
2036
+ symbol: string;
2037
+ short_minimum_pnl: number;
2038
+ long_minimum_pnl: number;
2039
+ short_profit: any;
2040
+ long_profit: any;
2041
+ owner: string;
2042
+ exchange: string;
2043
+ not_reduce: boolean;
2044
+ reduce_ratio_long: any;
2045
+ reduce_ratio_short: any;
2046
+ use_full_long: any;
2047
+ use_full_short: any;
2048
+ } | {
2049
+ long: {
2050
+ minimum_pnl: number;
2051
+ max_size: number;
2052
+ profit: any;
2053
+ increase: boolean;
2054
+ not_reduce: boolean;
2055
+ ratio: any;
2056
+ use_full: boolean;
2057
+ sell_ratio: any;
2058
+ };
2059
+ short: {
2060
+ minimum_pnl: number;
2061
+ max_size: number;
2062
+ profit: any;
2063
+ increase: boolean;
2064
+ not_reduce: boolean;
2065
+ ratio: any;
2066
+ use_full: boolean;
2067
+ sell_ratio: any;
2068
+ };
2069
+ trigger: {
2070
+ long: boolean;
2071
+ short: boolean;
2072
+ };
2073
+ }>;
2074
+ getOriginalPlannedStop(payload: {
2075
+ symbol: string;
2076
+ kind: "long" | "short";
2077
+ }): Promise<any>;
2078
+ syncReduceClosePosition(payload?: {
2079
+ symbol: string;
2080
+ kind?: "long" | "short";
2081
+ trigger?: boolean;
2082
+ }): Promise<any>;
2083
+ reduceMajorPositionEntry(payload: {
2084
+ symbol: string;
2085
+ long: any;
2086
+ short: any;
2087
+ trigger: {
2088
+ long: boolean;
2089
+ short: boolean;
2090
+ };
2091
+ }): Promise<any>;
2092
+ placeProfitAndStop(payload: {
2093
+ symbol: string;
2094
+ trigger?: boolean;
2095
+ refresh?: boolean;
2096
+ kind?: "long" | "short";
2097
+ target_pnl?: number;
2098
+ }): Promise<any>;
2099
+ reEnterPositionOnEmpty(symbol: string): Promise<void>;
2100
+ generate_config_params(payload: {
2101
+ entry: number;
2102
+ stop: number;
2103
+ risk_reward: number;
2104
+ risk: number;
2105
+ symbol: string;
2106
+ with_trades?: boolean;
2107
+ }): Promise<any>;
2108
+ build_short_order(payload: {
2109
+ symbol: string;
2110
+ kind: "long" | "short";
2111
+ }): Promise<any>;
2112
+ extrapolateShortConfig(payload: {
2113
+ kind: "long" | "short";
2114
+ symbol: string;
2115
+ risk_reward?: number;
2116
+ risk?: number;
2117
+ }): Promise<any>;
2118
+ placeMarketOrder(payload: {
2119
+ symbol: string;
2120
+ kind: "long" | "short";
2121
+ quantity: number;
2122
+ }): Promise<void>;
2123
+ placeSingleOrder(payload: {
2124
+ symbol: string;
2125
+ kind: "long" | "short";
2126
+ }): Promise<string>;
2127
+ increasePositionAtStop(payload: {
2128
+ symbol: string;
2129
+ kind: "long" | "short";
2130
+ place?: boolean;
2131
+ price?: number;
2132
+ quantity?: number;
2133
+ increase?: boolean;
2134
+ }): Promise<any>;
2135
+ triggerTradeFromConfig(payload: {
2136
+ symbol: string;
2137
+ kind: "long" | "short";
2138
+ place?: boolean;
2139
+ raw?: boolean;
2140
+ tp?: boolean;
2141
+ stop?: boolean;
2142
+ use_current?: boolean;
2143
+ ignore_config?: boolean;
2144
+ risky?: boolean;
2145
+ }): Promise<any>;
2146
+ verifyStopLoss(payload: {
2147
+ symbol: string;
2148
+ kind: "long" | "short";
2149
+ revert?: boolean;
2150
+ }): Promise<void | Order[]>;
2151
+ windDownSymbol(payload: {
2152
+ symbol: string;
2153
+ risk_reward?: number;
2154
+ risk?: number;
2155
+ }): Promise<void>;
2156
+ updateTargetPnl(payload: {
2157
+ symbol: string;
2158
+ kind: "long" | "short";
2159
+ }): Promise<number>;
2160
+ /**
2161
+ * Updates the risk configuration for an empty position using the next_risk value.
2162
+ * This implements progressive risk management where successful trades increase future risk tolerance.
2163
+ *
2164
+ * @param payload.symbol - The trading symbol (e.g., "BTCUSDT")
2165
+ * @param payload.kind - Position type: "long" or "short"
2166
+ * @returns Object indicating if update was successful with old/new risk values
2167
+ */
2168
+ updateRiskOnEmpty(payload: {
2169
+ symbol: string;
2170
+ kind: "long" | "short";
2171
+ }): Promise<{
2172
+ updated: boolean;
2173
+ symbol: string;
2174
+ kind: "long" | "short";
2175
+ old_risk: number;
2176
+ new_risk: number;
2177
+ reason?: undefined;
2178
+ } | {
2179
+ updated: boolean;
2180
+ symbol: string;
2181
+ kind: "long" | "short";
2182
+ reason: string;
2183
+ old_risk?: undefined;
2184
+ new_risk?: undefined;
2185
+ }>;
2186
+ updateGoodHedgeConfig(payload: {
2187
+ symbol: string;
2188
+ params?: {
2189
+ support: number;
2190
+ resistance: number;
2191
+ risk: number;
2192
+ profit_percent: number;
2193
+ };
2194
+ risk_factor?: number;
2195
+ update?: boolean;
2196
+ place?: boolean;
2197
+ update_tp?: boolean;
2198
+ }): Promise<{
2199
+ support: number;
2200
+ resistance: number;
2201
+ risk: number;
2202
+ profit_percent: number;
2203
+ }>;
2204
+ /**
2205
+ * This method is used to place the opposite trade action
2206
+ */
2207
+ placeOppositeTradeAction(payload: {
2208
+ symbol: string;
2209
+ kind: "long" | "short";
2210
+ data: {
2211
+ avg: {
2212
+ quantity: number;
2213
+ price: number;
2214
+ };
2215
+ entry: number;
2216
+ stop: number;
2217
+ risk_per_trade: number;
2218
+ profit_percent: number;
2219
+ risk_reward: number;
2220
+ };
2221
+ }): Promise<void>;
2222
+ buildOppositeTrades(payload: {
2223
+ symbol: string;
2224
+ kind: "long" | "short";
2225
+ place?: boolean;
2226
+ place_symbol?: string;
2227
+ }): Promise<{
2228
+ avg: {
2229
+ entry: number;
2230
+ price: number;
2231
+ quantity: number;
2232
+ };
2233
+ loss: number;
2234
+ profit_percent: number;
2235
+ fee: number;
2236
+ risk_per_trade: number;
492
2237
  risk_reward: number;
2238
+ symbol?: string;
2239
+ focus: number;
2240
+ budget: number;
2241
+ support: number;
2242
+ resistance: number;
2243
+ percent_change: number;
2244
+ tradeSplit?: number;
2245
+ take_profit?: number;
2246
+ kind: "long" | "short";
493
2247
  entry: number;
494
2248
  stop: number;
495
- risk_per_trade: number;
496
- avg_size: number;
497
- neg_pnl: number;
498
2249
  min_size: number;
2250
+ price_places?: string;
2251
+ strategy?: "quantity" | "entry";
2252
+ as_array?: boolean;
2253
+ decimal_places?: string;
2254
+ min_profit?: number;
2255
+ raw?: boolean;
2256
+ gap?: number;
2257
+ rr?: number;
2258
+ max_size?: number;
2259
+ max_quantity?: number;
2260
+ kelly?: {
2261
+ use_kelly?: boolean;
2262
+ kelly_confidence_factor?: number;
2263
+ kelly_minimum_risk?: number;
2264
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2265
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
2266
+ };
2267
+ }>;
2268
+ runSimulation(payload: {
499
2269
  symbol: string;
500
- }, place?: boolean, skip_stop?: boolean): Promise<{
501
- entry_orders: {
502
- orders: {
503
- entry: any;
504
- quantity: any;
505
- reverse_avg_entry: any;
506
- reverse_avg_quantity: any;
507
- avg_entry: any;
508
- avg_size: any;
509
- }[];
510
- kind: "long" | "short";
2270
+ kind: "long" | "short";
2271
+ iterations?: number;
2272
+ raw?: boolean;
2273
+ }): Promise<Strategy | {
2274
+ last_entry: any;
2275
+ first_entry: any;
2276
+ threshold: any;
2277
+ risk: number;
2278
+ risk_reward: number;
2279
+ spread: number;
2280
+ gap_loss: number;
2281
+ net_profit: number;
2282
+ long: {
2283
+ avg_entry: number;
2284
+ avg_size: number;
2285
+ loss: number;
2286
+ stop: number;
2287
+ stop_quantity: number;
2288
+ re_entry_quantity: number;
2289
+ initial_pnl: number;
2290
+ tp: number;
2291
+ incurred_loss: number;
2292
+ pnl: number;
2293
+ remaining_quantity: number;
511
2294
  };
512
- stop_orders: {
2295
+ short: {
2296
+ avg_entry: number;
2297
+ avg_size: number;
2298
+ loss: number;
513
2299
  stop: number;
514
- final_stop: number;
515
- kind: "long" | "short";
516
- quantity: any;
517
- is_limit: boolean;
2300
+ stop_quantity: number;
2301
+ re_entry_quantity: number;
2302
+ initial_pnl: number;
2303
+ tp: number;
2304
+ incurred_loss: number;
2305
+ pnl: number;
2306
+ remaining_quantity: number;
518
2307
  };
519
- trades: any[];
520
- }>;
521
- placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
2308
+ }[]>;
2309
+ getCurrentRun(payload: {
2310
+ symbol: string;
2311
+ kind?: "long" | "short";
2312
+ pnl?: number;
2313
+ }): Promise<true | import("pocketbase").RecordModel>;
2314
+ recomputeSymbolConfig(payload: {
2315
+ symbol: string;
2316
+ refresh?: boolean;
2317
+ }): Promise<SymbolConfig>;
2318
+ /**
2319
+ * This function builds a config for a symbol
2320
+ * @param payload
2321
+ * @returns
2322
+ */
2323
+ buildConfigForSymbol(payload: {
522
2324
  symbol: string;
523
- entry: number;
524
- stop: number;
525
- risk_reward: number;
526
2325
  risk: number;
527
- place?: boolean;
528
- update_db?: boolean;
2326
+ kind?: "long" | "short";
2327
+ risk_reward?: number;
2328
+ as_config?: boolean;
2329
+ with_trades?: boolean;
529
2330
  }): Promise<any>;
530
- getPositionConfig(payload: {
2331
+ triggerBullishMarket(payload: {
2332
+ symbol: string;
2333
+ profit_percent?: number;
2334
+ risk_reward?: number;
2335
+ }): Promise<any>;
2336
+ updateAllActiveSymbols(payload: {
2337
+ interval?: number;
2338
+ }): Promise<void>;
2339
+ updateAllPositionsWithNoConfig(payload: {
2340
+ kind: "long" | "short";
2341
+ }): Promise<void>;
2342
+ getSymbolsForPositions(): Promise<any[]>;
2343
+ getNonEssentialSymbols(): Promise<any[]>;
2344
+ _terminatePositions(payload: {
2345
+ symbol: string;
2346
+ }): Promise<void>;
2347
+ getOrders(payload: {
531
2348
  symbol: string;
532
2349
  kind: "long" | "short";
533
- params?: {
534
- entry: number;
535
- stop: number;
536
- risk_reward: number;
537
- risk: number;
538
- profit_percent?: number;
539
- };
540
- }): Promise<ScheduledTrade>;
541
- getCurrentPrice(symbol: string): Promise<any>;
542
- getPositionStrategy(): Promise<{
543
- strategy_instance: Strategy;
544
- focus_account: ExchangeAccount;
2350
+ type: "limit" | "stop" | "tp";
2351
+ }): Promise<Order[]>;
2352
+ syncPositionConfigs(payload: {
2353
+ symbol: string;
2354
+ kind: "long" | "short";
2355
+ refresh?: boolean;
2356
+ }): Promise<void>;
2357
+ terminatePositions(payload: {
2358
+ symbol: string;
2359
+ }): Promise<void>;
2360
+ fetchAndUpdateTopMovers(): Promise<{
2361
+ updated_bullish: BullishMarket[];
2362
+ moved_to_winding: WindingDownMarket[];
545
2363
  }>;
546
- getOriginalPlannedStop(payload: {
2364
+ computeTargetPnl(payload: {
2365
+ symbol: string;
2366
+ kind: "long" | "short";
2367
+ }): Promise<number>;
2368
+ placeStopLimit(payload: {
547
2369
  symbol: string;
548
2370
  kind: "long" | "short";
2371
+ place?: boolean;
2372
+ stop: number;
2373
+ quantity?: number;
549
2374
  }): Promise<any>;
550
- syncReduceClosePosition(symbol: string, payload?: {
551
- kind?: "long" | "short";
552
- long?: CodeNode;
553
- short?: CodeNode;
554
- trigger?: {
555
- long: boolean;
556
- short: boolean;
557
- };
2375
+ placeTrade(payload: {
2376
+ symbol: string;
2377
+ kind: "long" | "short";
2378
+ place?: boolean;
2379
+ limit?: boolean;
2380
+ tp?: boolean;
2381
+ stop?: boolean;
2382
+ raw?: boolean;
2383
+ cancel?: boolean;
2384
+ ignore_config?: boolean;
2385
+ target_pnl?: number;
2386
+ risky?: boolean;
558
2387
  }): Promise<any>;
559
- generate_config_params(payload: {
560
- entry: number;
561
- stop: number;
562
- risk_reward: number;
563
- risk: number;
2388
+ updateConfigPnl(payload: {
2389
+ symbol: string;
2390
+ kind: "long" | "short";
2391
+ }): Promise<void>;
2392
+ determineReduceTp(payload: {
564
2393
  symbol: string;
2394
+ factor: number;
565
2395
  }): Promise<{
566
- place_stop: boolean;
567
- profit_percent: number;
568
- entry: number;
569
- stop: number;
570
- avg_size: any;
571
- avg_entry: any;
572
- risk_reward: number;
573
- neg_pnl: any;
574
- risk: number;
2396
+ long_diff: number;
2397
+ short_diff: number;
2398
+ gap: number;
2399
+ gap_cost: number;
2400
+ long_tp: number;
2401
+ short_tp: number;
2402
+ long_percent: number;
2403
+ short_percent: number;
575
2404
  }>;
576
- extrapolateShortConfig(payload: {
577
- kind: "long" | "short";
2405
+ profitWithinGapStrategy(payload: {
578
2406
  symbol: string;
579
- risk_reward?: number;
580
2407
  }): Promise<{
581
- place_stop: boolean;
582
- profit_percent: number;
583
- entry: number;
584
- stop: number;
585
- avg_size: any;
586
- avg_entry: any;
587
- risk_reward: number;
588
- neg_pnl: any;
589
- risk: number;
2408
+ positions: {
2409
+ long: PositionsView & {
2410
+ expand?: {
2411
+ account_strategy?: AccountStrategy;
2412
+ };
2413
+ };
2414
+ short: PositionsView & {
2415
+ expand?: {
2416
+ account_strategy?: AccountStrategy;
2417
+ };
2418
+ };
2419
+ };
2420
+ config_details: {
2421
+ app_config: {
2422
+ fee: number;
2423
+ risk_per_trade: number;
2424
+ risk_reward: number;
2425
+ symbol?: string;
2426
+ focus: number;
2427
+ budget: number;
2428
+ support: number;
2429
+ resistance: number;
2430
+ percent_change: number;
2431
+ tradeSplit?: number;
2432
+ take_profit?: number;
2433
+ kind: "long" | "short";
2434
+ entry: number;
2435
+ stop: number;
2436
+ min_size: number;
2437
+ price_places?: string;
2438
+ strategy?: "quantity" | "entry";
2439
+ as_array?: boolean;
2440
+ decimal_places?: string;
2441
+ min_profit?: number;
2442
+ raw?: boolean;
2443
+ gap?: number;
2444
+ rr?: number;
2445
+ max_size?: number;
2446
+ max_quantity?: number;
2447
+ kelly?: {
2448
+ use_kelly?: boolean;
2449
+ kelly_confidence_factor?: number;
2450
+ kelly_minimum_risk?: number;
2451
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2452
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
2453
+ };
2454
+ };
2455
+ last_value: any;
2456
+ config: {
2457
+ entry: number;
2458
+ stop: number;
2459
+ risk: number;
2460
+ risk_reward: number | {
2461
+ result: any[];
2462
+ value: number;
2463
+ total: number;
2464
+ risk_per_trade: number;
2465
+ max: number;
2466
+ min: number;
2467
+ neg_pnl: any;
2468
+ entry: any;
2469
+ };
2470
+ profit_percent: number;
2471
+ };
2472
+ pnl: number;
2473
+ };
590
2474
  }>;
591
- triggerTradeFromConfig(payload: {
2475
+ generateGapTp(payload: {
2476
+ symbol: string;
2477
+ factor?: number;
2478
+ }): Promise<{
2479
+ profit_percent: {
2480
+ long: number;
2481
+ short: number;
2482
+ };
2483
+ risk: {
2484
+ short: number;
2485
+ long: number;
2486
+ };
2487
+ take_profit: {
2488
+ long: number;
2489
+ short: number;
2490
+ };
2491
+ to_reduce: {
2492
+ short: number;
2493
+ long: number;
2494
+ };
2495
+ full_reduce: {
2496
+ short: number;
2497
+ long: number;
2498
+ };
2499
+ sell_quantity: {
2500
+ short: number;
2501
+ long: number;
2502
+ };
2503
+ gap: number;
2504
+ gap_loss: number;
2505
+ }>;
2506
+ getSellPriceFromStrategy(payload: {
592
2507
  symbol: string;
2508
+ reduce_position: PositionsView;
2509
+ kind?: "long" | "short";
2510
+ full_ratio?: number;
2511
+ }): Promise<{
2512
+ pnl: number;
2513
+ loss: number;
2514
+ full_loss: number;
2515
+ original_pnl: number;
2516
+ reward_factor: number;
2517
+ profit_percent: number;
593
2518
  kind: "long" | "short";
594
- }): Promise<any>;
595
- verifyStopLoss(payload: {
2519
+ sell_price: number;
2520
+ quantity: number;
2521
+ price_places: string;
2522
+ decimal_places: string;
2523
+ }>;
2524
+ placeCompoundShortTrade(payload: {}): Promise<void>;
2525
+ placeCompoundLongTrade(payload: {
2526
+ symbol: string;
2527
+ params: {
2528
+ resistance: number;
2529
+ support: number;
2530
+ profit_percent: number;
2531
+ risk_reward: number;
2532
+ risk: number;
2533
+ };
2534
+ place?: boolean;
2535
+ }): Promise<void>;
2536
+ getConfigProfiles(payload: {
596
2537
  symbol: string;
597
2538
  kind: "long" | "short";
598
- revert?: boolean;
599
- }): Promise<import("pocketbase").RecordModel[]>;
600
- windDownSymbol(symbol: string, risk_reward?: number): Promise<void>;
601
- triggerBullishMarket(symbol: string): Promise<any>;
2539
+ }): Promise<{
2540
+ id: any;
2541
+ entry: any;
2542
+ stop: any;
2543
+ kind: "long" | "short";
2544
+ risk_reward: any;
2545
+ risk: any;
2546
+ profit_percent: any;
2547
+ }[]>;
602
2548
  }
2549
+ declare function getExchangeAccount(payload: {
2550
+ account: ExchangeType;
2551
+ app_db: AppDatabase;
2552
+ getCredentials: (payload: {
2553
+ account: string;
2554
+ exchange: string;
2555
+ app_db: AppDatabase;
2556
+ }) => Promise<{
2557
+ api_key: string;
2558
+ api_secret: string;
2559
+ email: string;
2560
+ }>;
2561
+ proxyOptions?: {
2562
+ proxy?: any;
2563
+ ignore_proxy?: boolean;
2564
+ };
2565
+ canWithdraw?: boolean;
2566
+ }): Promise<ExchangeAccount$1>;
603
2567
  declare class App {
604
- private app_db;
2568
+ app_db: AppDatabase;
2569
+ proxyOptions?: {
2570
+ proxy?: any;
2571
+ ignore_proxy?: boolean;
2572
+ canWithdraw?: boolean;
2573
+ };
605
2574
  private getCredentials;
606
- constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
2575
+ constructor(app_db: AppDatabase, getCredentials: (payload: {
2576
+ account: string;
2577
+ exchange: string;
2578
+ }) => Promise<{
607
2579
  api_key: string;
608
2580
  api_secret: string;
609
- }>);
2581
+ email: string;
2582
+ }>, proxyOptions?: {
2583
+ proxy?: any;
2584
+ ignore_proxy?: boolean;
2585
+ canWithdraw?: boolean;
2586
+ });
610
2587
  getExchangeAccount(account: ExchangeType): Promise<ExchangeAccount$1>;
611
2588
  syncAccount(payload: {
612
2589
  account: ExchangeType;
@@ -617,6 +2594,7 @@ declare class App {
617
2594
  }): Promise<PositionsView | (PositionsView & {
618
2595
  expand?: {
619
2596
  config: ScheduledTrade;
2597
+ account: ExchangeAccount;
620
2598
  };
621
2599
  })[]>;
622
2600
  syncOrders(payload: {
@@ -631,7 +2609,7 @@ declare class App {
631
2609
  price?: number;
632
2610
  all?: boolean;
633
2611
  stop?: boolean;
634
- }): Promise<{
2612
+ }): Promise<any[] | {
635
2613
  success: boolean;
636
2614
  message: string;
637
2615
  exchange_result?: undefined;
@@ -647,39 +2625,6 @@ declare class App {
647
2625
  message?: undefined;
648
2626
  exchange_result?: undefined;
649
2627
  }>;
650
- generateConfig(payload: {
651
- account: ExchangeType;
652
- symbol: string;
653
- kind: "long" | "short";
654
- update_orders?: boolean;
655
- place_orders?: boolean;
656
- }): Promise<any>;
657
- updateReduceRatio(payload: {
658
- account: ExchangeType;
659
- symbol: string;
660
- }): Promise<{
661
- long_position: any;
662
- short_position: any;
663
- long_db_position: any;
664
- short_db_position: any;
665
- balance: any;
666
- }>;
667
- verifyStopLoss(payload: {
668
- account: ExchangeType;
669
- symbol: string;
670
- kind: "long" | "short";
671
- revert?: boolean;
672
- }): Promise<import("pocketbase").RecordModel[]>;
673
- updateTopMovers(payload?: {
674
- new_markets: {
675
- symbol: string;
676
- percent: number;
677
- }[];
678
- totalRisk: number;
679
- }): Promise<{
680
- updated_bullish: BullishMarket[];
681
- moved_to_winding: WindingDownMarket[];
682
- }>;
683
2628
  getWindingDownMarkets(): Promise<WindingDownMarket[]>;
684
2629
  updateSymbolConfigs(payload: {
685
2630
  configs: {
@@ -696,7 +2641,144 @@ declare class App {
696
2641
  created: number;
697
2642
  }>;
698
2643
  updateAllAccountWithSymbols(with_positions?: boolean): Promise<void>;
699
- windDownSymbol(symbol: string): Promise<boolean>;
2644
+ windDownSymbol(payload: {
2645
+ symbol: string;
2646
+ risk?: number;
2647
+ }): Promise<boolean>;
2648
+ getNonEssentialSymbols(): Promise<Set<any>>;
2649
+ refreshAllPositionsWithSymbol(payload: {
2650
+ symbol: string;
2651
+ }): Promise<void>;
2652
+ autoFollowPositions(): Promise<void>;
2653
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
2654
+ updateTpOnAllMarkets(): Promise<void>;
2655
+ triggerMoverTask(payload: {
2656
+ callback: (params: {
2657
+ symbol: string;
2658
+ account: ExchangeType;
2659
+ }) => Promise<any>;
2660
+ removeCallback?: (params: {
2661
+ symbol: string;
2662
+ account: ExchangeType;
2663
+ }) => Promise<any>;
2664
+ }): Promise<void>;
2665
+ placeTrade(payload: {
2666
+ account: ExchangeType;
2667
+ symbol: string;
2668
+ kind: "long" | "short";
2669
+ place?: boolean;
2670
+ tp?: boolean;
2671
+ cancel?: boolean;
2672
+ raw?: boolean;
2673
+ }): Promise<any>;
2674
+ runDbStrategyAccounts(callback: (params: {
2675
+ symbol: string;
2676
+ account: ExchangeType;
2677
+ }) => Promise<any>): Promise<void>;
2678
+ profitWithinGapStrategy(payload: {
2679
+ account: ExchangeType;
2680
+ symbol: string;
2681
+ }): Promise<{
2682
+ positions: {
2683
+ long: PositionsView & {
2684
+ expand?: {
2685
+ account_strategy?: AccountStrategy;
2686
+ };
2687
+ };
2688
+ short: PositionsView & {
2689
+ expand?: {
2690
+ account_strategy?: AccountStrategy;
2691
+ };
2692
+ };
2693
+ };
2694
+ config_details: {
2695
+ app_config: {
2696
+ fee: number;
2697
+ risk_per_trade: number;
2698
+ risk_reward: number;
2699
+ symbol?: string;
2700
+ focus: number;
2701
+ budget: number;
2702
+ support: number;
2703
+ resistance: number;
2704
+ percent_change: number;
2705
+ tradeSplit?: number;
2706
+ take_profit?: number;
2707
+ kind: "long" | "short";
2708
+ entry: number;
2709
+ stop: number;
2710
+ min_size: number;
2711
+ price_places?: string;
2712
+ strategy?: "quantity" | "entry";
2713
+ as_array?: boolean;
2714
+ decimal_places?: string;
2715
+ min_profit?: number;
2716
+ raw?: boolean;
2717
+ gap?: number;
2718
+ rr?: number;
2719
+ max_size?: number;
2720
+ max_quantity?: number;
2721
+ kelly?: {
2722
+ use_kelly?: boolean;
2723
+ kelly_confidence_factor?: number;
2724
+ kelly_minimum_risk?: number;
2725
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2726
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
2727
+ };
2728
+ };
2729
+ last_value: any;
2730
+ config: {
2731
+ entry: number;
2732
+ stop: number;
2733
+ risk: number;
2734
+ risk_reward: number | {
2735
+ result: any[];
2736
+ value: number;
2737
+ total: number;
2738
+ risk_per_trade: number;
2739
+ max: number;
2740
+ min: number;
2741
+ neg_pnl: any;
2742
+ entry: any;
2743
+ };
2744
+ profit_percent: number;
2745
+ };
2746
+ pnl: number;
2747
+ };
2748
+ }>;
2749
+ compoundLongTrade(payload: {
2750
+ main_account: ExchangeType & {
2751
+ symbol: string;
2752
+ };
2753
+ focus_account: ExchangeType & {
2754
+ symbol: string;
2755
+ };
2756
+ place?: boolean;
2757
+ rr?: number;
2758
+ }): Promise<{
2759
+ start_risk: number;
2760
+ short_profit: number;
2761
+ support: number;
2762
+ resistance: number;
2763
+ long_v: any;
2764
+ profit_percent: number;
2765
+ result: any;
2766
+ short_max_size: any;
2767
+ }>;
2768
+ reduceExistingPosition(payload: {
2769
+ main_account: ExchangeType & {
2770
+ symbol: string;
2771
+ kind?: "long" | "short";
2772
+ };
2773
+ reduce_account: ExchangeType & {
2774
+ symbol: string;
2775
+ };
2776
+ kind: "long" | "short";
2777
+ place?: boolean;
2778
+ increase?: boolean;
2779
+ full_ratio?: number;
2780
+ cancel_limit?: boolean;
2781
+ }): Promise<any>;
700
2782
  }
701
2783
  export declare function initApp(payload: {
702
2784
  db: {
@@ -704,14 +2786,50 @@ export declare function initApp(payload: {
704
2786
  email: string;
705
2787
  password: string;
706
2788
  };
707
- getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
2789
+ password?: string;
2790
+ salt?: string;
2791
+ email?: string;
2792
+ getCredentials: (payload: {
2793
+ account: string;
2794
+ exchange: string;
2795
+ app_db: AppDatabase;
2796
+ }) => Promise<{
708
2797
  api_key: string;
709
2798
  api_secret: string;
2799
+ email: string;
710
2800
  }>;
2801
+ proxy?: any;
2802
+ ignore_proxy?: boolean;
2803
+ canWithdraw?: boolean;
2804
+ triggerToken?: string;
2805
+ }): Promise<App>;
2806
+ declare function getCredentials(payload: {
2807
+ account: string;
2808
+ exchange: string;
2809
+ app_db: AppDatabase;
2810
+ }): Promise<any>;
2811
+ export declare function initialize(payload: {
2812
+ password?: string;
2813
+ proxy?: any;
2814
+ ignore_proxy?: boolean;
2815
+ canWithdraw?: boolean;
711
2816
  }): Promise<App>;
712
2817
 
2818
+ declare namespace database {
2819
+ export { AppDatabase, ExchangeType, decryptObject, encryptObject, initPocketBaseClient };
2820
+ }
2821
+ declare namespace exchange_account {
2822
+ export { ExchangeAccount$1 as ExchangeAccount, getExchangeAccount };
2823
+ }
2824
+ declare namespace app {
2825
+ export { App, getCredentials, initApp, initialize };
2826
+ }
2827
+
713
2828
  export {
714
2829
  ExchangeAccount$1 as ExchangeAccount,
2830
+ app,
2831
+ database,
2832
+ exchange_account,
715
2833
  };
716
2834
 
717
2835
  export {};