@gbozee/ultimate 0.0.2-16 → 0.0.2-162

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