@gbozee/ultimate 0.0.2-15 → 0.0.2-151

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