@gbozee/ultimate 0.0.2-21 → 0.0.2-211

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,243 @@
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 interface GetEntriesParams {
9
+ kind: "long" | "short";
10
+ distribution: "arithmetic" | "geometric" | "normal" | "exponential" | "inverse-exponential";
11
+ margin_range: [
12
+ number,
13
+ number
14
+ ];
15
+ risk_reward: number;
16
+ price_places?: string;
17
+ distribution_params?: {
18
+ curveFactor?: number;
19
+ stdDevFactor?: number;
20
+ lambda?: number;
21
+ };
22
+ }
23
+ export type RecordModel = PocketBaseRecordModel;
24
+ export interface BaseSystemFields {
25
+ id: string;
26
+ created: string;
27
+ updated: string;
28
+ }
29
+ export interface ExchangeAccount extends BaseSystemFields {
30
+ exchange: "binance" | "bybit";
31
+ owner: string;
32
+ email?: string;
33
+ user?: string;
34
+ usdt?: number;
35
+ usdc?: number;
36
+ proxy?: string;
37
+ bullish?: boolean;
38
+ bearish?: boolean;
39
+ movePercent?: number;
40
+ totalRisk?: number;
41
+ max_non_essential?: number;
42
+ profit_percent?: number;
43
+ risk_reward?: number;
44
+ exclude_coins?: {
45
+ bullish?: string[];
46
+ };
47
+ include_delisted?: boolean;
48
+ }
49
+ export interface Order extends BaseSystemFields {
50
+ symbol: string;
51
+ account: string;
52
+ kind: "long" | "short";
53
+ price: number;
54
+ quantity: number;
55
+ side: "sell" | "buy";
56
+ stop: number;
57
+ order_id: string;
58
+ }
59
+ export interface SymbolConfig extends BaseSystemFields {
60
+ symbol: string;
61
+ support?: number;
62
+ resistance?: number;
63
+ stop_percent?: number;
64
+ price_places?: string;
65
+ decimal_places?: string;
66
+ min_size?: number;
67
+ weight?: number;
68
+ leverage?: number;
69
+ candle_count?: number;
70
+ interval?: any;
71
+ fee_percent?: number;
72
+ }
73
+ export interface ScheduledTrade extends BaseSystemFields {
74
+ symbol: string;
75
+ account: string;
76
+ profit?: number;
77
+ risk?: number;
78
+ entry?: number;
79
+ stop?: number;
80
+ risk_reward?: number;
81
+ profit_percent?: number;
82
+ place_tp?: boolean;
83
+ kind?: "long" | "short";
84
+ follow?: boolean | 1 | 0;
85
+ reduce_ratio?: number;
86
+ sell_ratio?: number;
87
+ threshold_qty?: number;
88
+ pause_tp?: boolean;
89
+ stop_percent?: number;
90
+ kelly?: {
91
+ use_kelly?: boolean;
92
+ kelly_confidence_factor?: number;
93
+ kelly_minimum_risk?: number;
94
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
95
+ };
96
+ distribution?: GetEntriesParams["distribution"];
97
+ distribution_params?: {
98
+ curveFactor?: number;
99
+ stdDevFactor?: number;
100
+ lambda?: number;
101
+ };
102
+ settings?: {
103
+ gap_trading?: {
104
+ entry_risk?: number;
105
+ hedge_stop_ratio?: number;
106
+ };
107
+ bad_hedge?: {
108
+ hedges_distribution?: GetEntriesParams["distribution"];
109
+ hedges_ratio?: number;
110
+ opposite_trade_distribution?: GetEntriesParams["distribution"];
111
+ opposite_trade_ratio?: number;
112
+ stop_loss?: number;
113
+ };
114
+ };
115
+ }
116
+ export interface AccountStrategy extends BaseSystemFields {
117
+ account: string;
118
+ symbol: string;
119
+ risk?: number;
120
+ reward_factor?: number;
121
+ kind?: "long" | "short";
122
+ support?: number;
123
+ resistance?: number;
124
+ running?: boolean;
125
+ max_reward_factor?: number;
126
+ follow?: boolean;
127
+ risk_reward?: number;
128
+ dynamic?: boolean;
129
+ }
130
+ interface Proxy$1 extends BaseSystemFields {
131
+ ip_address?: string;
132
+ type?: "http" | "socks5";
133
+ }
134
+ export interface PositionsView {
135
+ id: string;
136
+ symbol?: any;
137
+ entry?: any;
138
+ quantity?: any;
139
+ take_profit?: any;
140
+ account?: any;
141
+ kind?: any;
142
+ target_pnl?: number;
143
+ liquidation?: number;
144
+ avg_price?: number;
145
+ avg_qty?: number;
146
+ next_order?: number;
147
+ last_order?: number;
148
+ config?: any;
149
+ stop_loss?: {
150
+ price: number;
151
+ quantity: number;
152
+ };
153
+ stop_pnl?: any;
154
+ leverage?: any;
155
+ avg_liquidation?: any;
156
+ balance?: any;
157
+ reduce_ratio?: number;
158
+ sell_ratio?: number;
159
+ threshold_qty?: number;
160
+ follow?: boolean | 1 | 0;
161
+ current_price?: number;
162
+ usd_balance?: number;
163
+ tp?: {
164
+ price: number;
165
+ quantity: number;
166
+ };
167
+ next_risk?: number;
168
+ proxy?: string;
169
+ expand?: {
170
+ p_account?: ExchangeAccount;
171
+ b_config?: ScheduledTrade;
172
+ proxy?: Proxy$1;
173
+ account_strategy?: AccountStrategy;
174
+ compound_instance?: CompoundInstance;
175
+ support?: SupportTable;
176
+ symbol_config: SymbolConfig;
177
+ resistance?: SupportTable;
178
+ anchor?: Omit<PositionsView, "expand">;
179
+ };
180
+ pnl?: number;
181
+ support_price?: number;
182
+ }
183
+ export interface BullishMarket extends RecordModel {
184
+ id: string;
185
+ symbol: string;
186
+ risk: number;
187
+ }
188
+ export interface WindingDownMarket extends RecordModel {
189
+ id: string;
190
+ symbol: string;
191
+ risk_reward: number;
192
+ }
193
+ export interface Compounder extends BaseSystemFields {
194
+ risk?: number;
195
+ profit_percent?: number;
196
+ owner?: string;
197
+ completed?: boolean;
198
+ start_balance?: number;
199
+ starting_risk?: number;
200
+ fee_rate?: number;
201
+ }
202
+ export interface CompoundInstance extends BaseSystemFields {
203
+ ref?: string;
204
+ position?: string;
205
+ risk?: number;
206
+ hedged?: boolean;
207
+ loss?: number;
208
+ expand?: {
209
+ ref?: Compounder;
210
+ };
211
+ }
212
+ export interface SupportTable extends BaseSystemFields {
213
+ symbol?: string;
214
+ price?: number;
215
+ counter?: number;
216
+ last_updated?: string;
217
+ kind?: "long" | "short";
218
+ }
219
+ export type GlobalConfig = {
220
+ profit_percent?: number;
221
+ symbol: string;
222
+ profit?: number;
223
+ risk?: number;
224
+ stop_percent?: number;
225
+ kind: "long" | "short";
226
+ reduce_percent?: number;
227
+ support: number;
228
+ resistance: number;
229
+ price_places: string;
230
+ decimal_places: string;
231
+ min_size?: number;
232
+ accounts?: {
233
+ owner: string;
234
+ exchange?: string;
235
+ }[];
236
+ risk_reward?: number;
237
+ reverse_factor?: number;
238
+ leverage?: number;
239
+ max_quantity?: number;
240
+ fee_percent?: number;
241
+ };
8
242
  interface Position$1 {
9
243
  id: number;
10
244
  kind: "long" | "short";
@@ -20,6 +254,7 @@ interface Position$1 {
20
254
  target_pnl?: number;
21
255
  reduce_ratio?: number;
22
256
  use_full?: boolean;
257
+ liquidation?: number;
23
258
  }
24
259
  export interface Account {
25
260
  id: number | string;
@@ -59,8 +294,70 @@ export interface Account {
59
294
  short: any;
60
295
  };
61
296
  }
62
- export interface BaseExchange {
297
+ interface Order$1 {
298
+ order_id?: string;
299
+ symbol?: string;
300
+ price: number;
301
+ quantity: number;
302
+ kind: "long" | "short";
303
+ side: "buy" | "sell";
304
+ stop: number;
305
+ triggerPrice?: number;
306
+ }
307
+ export interface CandlestickAnalysisResult {
308
+ candlesticks: {
309
+ [key: string]: any[];
310
+ };
311
+ resistance: {
312
+ [key: string]: number;
313
+ };
314
+ support: {
315
+ [key: string]: number;
316
+ };
317
+ current_price: number;
318
+ minimum_weekly: number;
319
+ }
320
+ declare abstract class BaseExchange {
63
321
  client: any;
322
+ name: string;
323
+ getCredentials: (payload: {
324
+ account: string;
325
+ }) => Promise<{
326
+ api_key: string;
327
+ api_secret: string;
328
+ email: string;
329
+ }>;
330
+ proxyAgent?: any;
331
+ remoteActionBaseUrl?: string;
332
+ constructor(client: any);
333
+ protected abstract getPositionInfo(symbol: string): Promise<any>;
334
+ abstract cancelAllOrders(symbol: string, payload: {
335
+ type?: "limit" | "stop" | "tp";
336
+ side?: "buy" | "sell";
337
+ kind?: "long" | "short";
338
+ }): Promise<any>;
339
+ protected abstract getCurrentPrice(symbol: string): Promise<any>;
340
+ protected abstract getExchangeInfo(options: {
341
+ price_places?: string;
342
+ decimal_places?: string;
343
+ account: {
344
+ owner: string;
345
+ exchange: string;
346
+ };
347
+ symbol: string;
348
+ }): Promise<any>;
349
+ protected abstract _createLimitPurchaseOrders(payload: {
350
+ symbol: string;
351
+ orders: any[];
352
+ price_places?: string;
353
+ decimal_places?: string;
354
+ }): Promise<any>;
355
+ rawCreateLimitPurchaseOrders(payload: {
356
+ symbol: string;
357
+ orders: Order$1[];
358
+ price_places?: string;
359
+ decimal_places?: string;
360
+ }): Promise<any>;
64
361
  placeStopOrders(payload: {
65
362
  symbol: string;
66
363
  quantity: number;
@@ -68,21 +365,22 @@ export interface BaseExchange {
68
365
  stop: number;
69
366
  price_places?: string;
70
367
  decimal_places?: string;
368
+ hedge?: boolean;
71
369
  place?: boolean;
72
370
  }): Promise<any>;
73
371
  bulkPlaceLimitOrders(payload: {
74
- orders: any[];
372
+ orders: Order$1[];
75
373
  kind: "long" | "short";
76
374
  decimal_places?: string;
77
375
  price_places?: string;
78
376
  symbol: string;
79
377
  place?: boolean;
80
- }): Promise<any>;
378
+ }): Promise<any[]>;
81
379
  get_current_price(symbol: string): Promise<any>;
82
- analyzeCharts(payload: {
380
+ abstract analyzeCharts(payload: {
83
381
  symbol: string;
84
382
  chartType: any;
85
- count: number;
383
+ limit: number;
86
384
  raw?: boolean;
87
385
  }): Promise<any>;
88
386
  getExchangeAccountInfo(options: {
@@ -94,15 +392,43 @@ export interface BaseExchange {
94
392
  };
95
393
  symbol: string;
96
394
  }): Promise<any>;
395
+ protected abstract _cancelOrders(payload: {
396
+ symbol: string;
397
+ orders: Array<{
398
+ orderId?: any;
399
+ clientOrderId?: any;
400
+ }>;
401
+ }): Promise<any>;
97
402
  cancelOrders(payload: {
98
403
  symbol: string;
99
404
  orders: number[];
100
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>;
101
415
  placeTpOrder(payload: {
102
416
  symbol: string;
103
417
  take_profit: number;
104
418
  kind: "long" | "short";
105
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;
106
432
  price_places?: string;
107
433
  decimal_places?: string;
108
434
  }): Promise<any>;
@@ -114,6 +440,19 @@ export interface BaseExchange {
114
440
  price_places?: string;
115
441
  decimal_places?: string;
116
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
+ hedge?: boolean;
455
+ }): Promise<any>;
117
456
  placeStopOrder(payload: {
118
457
  symbol: string;
119
458
  stop: number;
@@ -121,18 +460,20 @@ export interface BaseExchange {
121
460
  kind: "long" | "short";
122
461
  price_places?: string;
123
462
  decimal_places?: string;
463
+ hedge?: boolean;
124
464
  }): Promise<any>;
125
- setLeverage(payload: {
465
+ abstract setLeverage(payload: {
126
466
  symbol: string;
127
467
  leverage: number;
128
468
  }): Promise<any>;
129
- generateConfig(payload: {
469
+ abstract generateConfig(payload: {
130
470
  symbol: string;
131
471
  interval?: any;
132
472
  limit?: number;
133
473
  }): Promise<any>;
134
- checkDelistedMovers(payload: {
474
+ abstract checkDelistedMovers(payload: {
135
475
  movePercent: number;
476
+ include_delisted?: boolean;
136
477
  }): Promise<any>;
137
478
  closePosition(payload: {
138
479
  symbol: string;
@@ -140,7 +481,8 @@ export interface BaseExchange {
140
481
  price_places?: string;
141
482
  decimal_places?: string;
142
483
  }): Promise<any>;
143
- getAllOpenSymbols(): Promise<string[]>;
484
+ protected abstract getAllOpenOrders(): Promise<any>;
485
+ getAllOpenSymbols(): Promise<unknown[]>;
144
486
  createLimitPurchaseOrders(payload: {
145
487
  orders: any[];
146
488
  kind: "long" | "short";
@@ -148,123 +490,124 @@ export interface BaseExchange {
148
490
  price_places?: string;
149
491
  symbol: string;
150
492
  }): Promise<any>;
151
- getDelistedSpotSymbols(): Promise<any>;
152
- }
153
- export interface BaseSystemFields {
154
- id: string;
155
- created: string;
156
- updated: string;
493
+ abstract getDelistedSpotSymbols(): Promise<any>;
494
+ abstract getOpenPositions(): Promise<any>;
495
+ abstract crossAccountTransfer(payload: {
496
+ from: {
497
+ owner: string;
498
+ wallet: string;
499
+ };
500
+ to: {
501
+ owner: string;
502
+ wallet: string;
503
+ };
504
+ asset: string;
505
+ amount: number;
506
+ }): Promise<any>;
507
+ placeMarketOrder(payload: {
508
+ symbol: string;
509
+ kind: "long" | "short";
510
+ quantity: number;
511
+ price_places?: string;
512
+ decimal_places?: string;
513
+ close?: boolean;
514
+ }): Promise<any>;
515
+ customStopLoss(payload: {
516
+ price_places: string;
517
+ decimal_places: string;
518
+ symbol: string;
519
+ kind: "long" | "short";
520
+ stop: number;
521
+ quantity: number;
522
+ increase?: boolean;
523
+ place?: boolean;
524
+ increase_ratio?: number;
525
+ }): Promise<any>;
526
+ abstract getOpenOrders(payload: {
527
+ symbol: string;
528
+ }): Promise<any>;
529
+ placeBadStopEntry(payload: {
530
+ symbol: string;
531
+ orders: Order$1[];
532
+ price_places?: string;
533
+ decimal_places?: string;
534
+ }): Promise<any>;
535
+ analyzeCandlesticks(payload: {
536
+ symbol: string;
537
+ }): Promise<CandlestickAnalysisResult>;
538
+ setAccountDetails(payload: {
539
+ getCredentials: (payload: {
540
+ account: string;
541
+ }) => Promise<{
542
+ api_key: string;
543
+ api_secret: string;
544
+ email: string;
545
+ }>;
546
+ proxyAgent?: any;
547
+ remoteActionBaseUrl?: string;
548
+ }): void;
549
+ getSymbolInformation(payload: {
550
+ symbol: string;
551
+ variant?: "full" | "short";
552
+ }): Promise<{
553
+ candlesticks: Record<string, any[]>;
554
+ resistance: Record<string, number>;
555
+ support: Record<string, number>;
556
+ currentPrice: number;
557
+ minimumWeekly?: number;
558
+ lowest?: number;
559
+ }>;
157
560
  }
158
- export interface ExchangeAccount extends BaseSystemFields {
159
- exchange: "binance" | "bybit";
561
+ declare function encryptObject(obj: any, password: string): string;
562
+ declare function decryptObject(encryptedString: string, password: string): any;
563
+ declare function initPocketBaseClient(proxy_credentials: {
564
+ host: string;
565
+ email: string;
566
+ password: string;
567
+ auto_cancellation?: boolean;
568
+ }): Promise<PocketBase>;
569
+ export type ExchangeType = {
160
570
  owner: string;
571
+ exchange: string;
572
+ };
573
+ export declare class AppDatabase {
574
+ pb: PocketBase;
161
575
  email?: string;
162
- user?: string;
163
- usdt?: number;
164
- usdc?: number;
165
- proxy?: string;
166
- bullish?: boolean;
167
- bearish?: boolean;
168
- movePercent?: number;
169
- totalRisk?: number;
170
- max_non_essential?: number;
171
- profit_percent?: number;
172
- exclude_coins?: {
173
- bullish?: string[];
174
- };
175
- }
176
- export interface SymbolConfig extends BaseSystemFields {
177
- symbol: string;
178
- support?: number;
179
- resistance?: number;
180
- stop_percent?: number;
181
- price_places?: string;
182
- decimal_places?: string;
183
- min_size?: number;
184
- weight?: number;
185
- leverage?: number;
186
- candle_count?: number;
187
- interval?: any;
188
- }
189
- export interface ScheduledTrade extends BaseSystemFields {
190
- symbol: string;
191
- account: string;
192
- profit?: number;
193
- risk?: number;
194
- entry?: number;
195
- stop?: number;
196
- risk_reward?: number;
197
- profit_percent?: number;
198
- place_tp?: boolean;
199
- kind?: "long" | "short";
200
- current_price?: number;
201
- }
202
- export interface Strategy extends BaseSystemFields {
203
- name: string;
204
- short_risk_factor?: number;
205
- long_risk_factor?: number;
206
- profit_percent?: number;
207
- cancel_short?: boolean;
208
- cancel_long?: boolean;
209
- recompute_short_config?: boolean;
210
- update_stop_loss?: boolean;
211
- liquidation_as_entry?: boolean;
212
- stop_as_entry?: boolean;
213
- tp_as_stop?: boolean;
214
- entry_as_stop?: boolean;
215
- place_stop?: boolean;
216
- save_config?: boolean;
217
- }
218
- interface Proxy$1 extends BaseSystemFields {
219
- ip_address?: string;
220
- type?: "http" | "socks5";
221
- }
222
- export interface TradeBlockTracking extends BaseSystemFields {
223
- account?: string;
224
- symbol?: string;
225
- running?: boolean;
226
- }
227
- export interface PositionsView {
228
- id: string;
229
- symbol?: any;
230
- entry?: any;
231
- quantity?: any;
232
- take_profit?: any;
233
- account?: any;
234
- kind?: any;
235
- target_pnl?: number;
236
- liquidation?: number;
237
- avg_price?: number;
238
- avg_qty?: number;
239
- next_order?: number;
240
- last_order?: number;
241
- config?: any;
242
- stop_loss?: {
243
- price: number;
244
- quantity: number;
245
- };
246
- stop_pnl?: any;
247
- leverage?: any;
248
- avg_liquidation?: any;
249
- balance?: any;
250
- }
251
- export interface BullishMarket extends RecordModel {
252
- id: string;
253
- symbol: string;
254
- risk: number;
255
- }
256
- export interface WindingDownMarket extends RecordModel {
257
- id: string;
258
- symbol: string;
259
- risk_reward: number;
260
- }
261
- export type ExchangeType = {
262
- owner: string;
263
- exchange: string;
264
- };
265
- export declare class AppDatabase {
266
- private pb;
267
- constructor(pb: PocketBase);
576
+ salt?: string;
577
+ constructor(pb: PocketBase, payload: {
578
+ email?: string;
579
+ salt?: string;
580
+ });
581
+ getUserByEmail(): Promise<import("pocketbase").RecordModel>;
582
+ verifyUserPassword(password: string): Promise<boolean>;
583
+ generateUserPassword(): Promise<boolean>;
584
+ getUserCredentials(): Promise<any>;
585
+ getCredentials(payload: {
586
+ password?: string;
587
+ }): Promise<any>;
588
+ saveCredentials(params: {
589
+ password?: string;
590
+ credentials: any;
591
+ }): Promise<import("pocketbase").RecordModel>;
592
+ changeUserPassword(payload: {
593
+ password: string;
594
+ }): Promise<boolean>;
595
+ verifyAdminPassword(password: string): Promise<boolean>;
596
+ setAdminPassword(payload: {
597
+ password: string;
598
+ salt: string;
599
+ }): Promise<boolean>;
600
+ addNewCredential(params: {
601
+ password?: string;
602
+ payload: {
603
+ name: string;
604
+ email: string;
605
+ exchange: string;
606
+ api_key: string;
607
+ api_secret: string;
608
+ };
609
+ }): Promise<void>;
610
+ getAccountWithActivePositions(): Promise<import("pocketbase").RecordModel[]>;
268
611
  getAllSymbolsFromPositions(options?: {
269
612
  no_position?: boolean;
270
613
  kind?: "long" | "short";
@@ -291,6 +634,12 @@ export declare class AppDatabase {
291
634
  proxy: Proxy$1;
292
635
  };
293
636
  }>;
637
+ get positionExpand(): string;
638
+ fetchCentralPositions(payload: {
639
+ asset?: string;
640
+ symbol?: string;
641
+ customFilter?: string;
642
+ }): Promise<import("pocketbase").RecordModel[]>;
294
643
  getPositions(options: {
295
644
  account?: ExchangeType;
296
645
  symbol?: string;
@@ -300,6 +649,7 @@ export declare class AppDatabase {
300
649
  expand?: {
301
650
  config: ScheduledTrade;
302
651
  account: ExchangeAccount;
652
+ proxy: Proxy$1;
303
653
  };
304
654
  })[]>;
305
655
  private _createOrUpdatePosition;
@@ -312,18 +662,15 @@ export declare class AppDatabase {
312
662
  expand?: {
313
663
  config: ScheduledTrade;
314
664
  account: ExchangeAccount;
665
+ proxy: Proxy$1;
315
666
  };
316
667
  })[]>;
317
668
  update_db_position(position: any, payload: any): Promise<import("pocketbase").RecordModel>;
318
669
  getSymbolConfigFromDB(symbol: string): Promise<SymbolConfig>;
319
- getRunningInstanceFromDB(account: ExchangeType, symbol: string, options?: {
320
- delay?: number;
321
- }): Promise<TradeBlockTracking>;
322
- updateRunningInstance(id: string, running: boolean): Promise<import("pocketbase").RecordModel>;
323
670
  getOrders(account: ExchangeType, options: {
324
671
  symbol: string;
325
672
  kind: "long" | "short";
326
- }): Promise<import("pocketbase").RecordModel[]>;
673
+ }): Promise<Order[]>;
327
674
  deleteAndRecreateOrders(account: ExchangeType, options: {
328
675
  symbol: string;
329
676
  kind: "long" | "short";
@@ -336,7 +683,34 @@ export declare class AppDatabase {
336
683
  stop: number;
337
684
  order_id: string;
338
685
  triggerPrice?: number;
339
- }>): Promise<import("pocketbase").RecordModel[]>;
686
+ }>): Promise<Order[]>;
687
+ deleteAndBulCreateAllOrders(payload: {
688
+ account: ExchangeType & {
689
+ id: string;
690
+ };
691
+ symbol: string;
692
+ all_orders: Array<{
693
+ symbol: string;
694
+ price: number;
695
+ quantity: number;
696
+ kind: "long" | "short";
697
+ side: "buy" | "sell";
698
+ stop: number;
699
+ order_id: string;
700
+ triggerPrice?: number;
701
+ clientOrderId?: string;
702
+ }>;
703
+ }): Promise<void>;
704
+ cancelLimitOrders(payload: {
705
+ symbol: string;
706
+ kind: "long" | "short";
707
+ account: ExchangeType;
708
+ raw?: boolean;
709
+ cancelExchangeOrders: (payload: {
710
+ symbol: string;
711
+ orders: number[];
712
+ }) => Promise<any>;
713
+ }): Promise<any[]>;
340
714
  cancelOrders(payload: {
341
715
  cancelExchangeOrders: (payload: {
342
716
  symbol: string;
@@ -366,6 +740,11 @@ export declare class AppDatabase {
366
740
  }>;
367
741
  getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
368
742
  updateScheduledTrade(id: string, payload: any): Promise<import("pocketbase").RecordModel>;
743
+ getPositionsToAutoFollow(): Promise<(Position$1 & {
744
+ expand: {
745
+ account: ExchangeAccount;
746
+ };
747
+ })[]>;
369
748
  createOrUpdatePositionConfig(db_position: any, payload: {
370
749
  entry: number;
371
750
  stop: number;
@@ -374,17 +753,26 @@ export declare class AppDatabase {
374
753
  profit_percent?: number;
375
754
  place_tp?: boolean;
376
755
  profit?: number;
377
- }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
756
+ reduce_ratio?: number;
757
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
378
758
  getPositionConfig(payload: {
379
759
  symbol: string;
380
760
  kind: "long" | "short";
381
761
  account: ExchangeType;
382
762
  }): Promise<ScheduledTrade | null>;
383
- getPositionStrategy(account: ExchangeType): Promise<{
384
- strategy_instance: Strategy;
385
- focus_account: ExchangeAccount;
386
- }>;
387
- createOrUpdateWindingDownMarket(symbol: string): Promise<import("pocketbase").RecordModel>;
763
+ getRunningAccountStrategies(filter?: string): Promise<(AccountStrategy & {
764
+ expand?: {
765
+ account: ExchangeAccount;
766
+ };
767
+ })[]>;
768
+ getAccountStrategy(payload: {
769
+ symbol: string;
770
+ account: ExchangeType;
771
+ }): Promise<AccountStrategy>;
772
+ createOrUpdateWindingDownMarket(payload: {
773
+ symbol: string;
774
+ risk_reward?: number;
775
+ }): Promise<import("pocketbase").RecordModel>;
388
776
  getWindingDownMarkets(symbol?: string): Promise<WindingDownMarket[]>;
389
777
  getBullishMarket(symbol: string): Promise<BullishMarket>;
390
778
  getBullishMarkets(options?: {
@@ -414,103 +802,1542 @@ export declare class AppDatabase {
414
802
  } | SymbolConfig[]>;
415
803
  unwindSymbolFromDB(symbol: string): Promise<boolean>;
416
804
  hasExistingPosition(symbol: string): Promise<import("pocketbase").RecordModel[]>;
805
+ getPositionWithLowestNextOrder(options: {
806
+ symbol?: string;
807
+ kind: "long" | "short";
808
+ asset?: string;
809
+ exclude?: ExchangeType[];
810
+ }): Promise<PositionsView | null>;
417
811
  hasExistingOrders(symbol: string): Promise<import("pocketbase").RecordModel[]>;
418
812
  removeSymbolFromUnwindingMarkets(symbol: string): Promise<boolean>;
419
813
  removePosition(position: any): Promise<void>;
420
814
  removePositionConfig(position: any): Promise<void>;
815
+ getConfigProfiles(payload: {
816
+ config_id: string;
817
+ }): Promise<{
818
+ id: any;
819
+ entry: any;
820
+ stop: any;
821
+ kind: "long" | "short";
822
+ risk_reward: any;
823
+ risk: any;
824
+ profit_percent: any;
825
+ }[]>;
826
+ editConfigProfile(payload: {
827
+ id: string;
828
+ params: {
829
+ entry?: number;
830
+ stop?: number;
831
+ risk_reward?: number;
832
+ risk?: number;
833
+ profit_percent?: number;
834
+ };
835
+ }): Promise<void>;
836
+ createConfigProfile(payload: {
837
+ config_id: string;
838
+ symbol: string;
839
+ params: {
840
+ entry: number;
841
+ stop: number;
842
+ kind: "long" | "short";
843
+ risk_reward: number;
844
+ risk: number;
845
+ profit_percent: number;
846
+ };
847
+ }): Promise<void>;
848
+ getCompoundInstance(payload: {
849
+ position: Position$1;
850
+ }): Promise<CompoundInstance & {
851
+ expand: {
852
+ ref: Compounder;
853
+ };
854
+ }>;
855
+ getSupportTable(payload: {
856
+ symbol: string;
857
+ kind: "long" | "short";
858
+ }): Promise<SupportTable>;
859
+ updateCompoundInstance(payload: {
860
+ id: string;
861
+ params: any;
862
+ }): Promise<import("pocketbase").RecordModel>;
863
+ getPositionsByAssetPair(payload: {
864
+ asset: string;
865
+ symbol?: string;
866
+ isCompound?: boolean;
867
+ }): Promise<{
868
+ pairObject: any;
869
+ asset: string;
870
+ }>;
421
871
  }
422
- export type AppConfig = {
423
- fee: number;
424
- risk_per_trade: number;
425
- risk_reward: number;
426
- symbol?: string;
427
- focus: number;
428
- budget: number;
429
- support: number;
430
- resistance: number;
431
- percent_change: number;
432
- tradeSplit?: number;
433
- take_profit?: number;
434
- kind: "long" | "short";
872
+ export type StrategyPosition = {
435
873
  entry: number;
874
+ quantity: number;
875
+ avg_price?: number;
876
+ avg_qty?: number;
877
+ };
878
+ export type GapCloserResult = {
879
+ avg_entry: number;
880
+ avg_size: number;
881
+ loss: number;
436
882
  stop: number;
437
- min_size: number;
438
- price_places?: string;
439
- strategy?: "quantity" | "entry";
440
- as_array?: boolean;
441
- decimal_places?: string;
442
- min_profit?: number;
443
- raw?: boolean;
444
- gap?: number;
445
- rr?: number;
446
- max_size?: number;
447
- last_value?: any;
448
- entries?: any[];
883
+ stop_quantity: number;
884
+ re_entry_quantity: number;
885
+ initial_pnl: number;
886
+ tp: number;
887
+ incurred_loss: number;
888
+ pnl: number;
889
+ remaining_quantity: number;
449
890
  };
450
- declare class ExchangeAccount$1 {
451
- private instance;
452
- exchange: BaseExchange;
453
- main_exchange?: BaseExchange;
454
- private app_db;
455
- constructor(payload: ExchangeType, options: {
456
- exchange: BaseExchange;
457
- app_db: AppDatabase;
458
- main_exchange?: BaseExchange;
891
+ export type Config = {
892
+ tp_percent: number;
893
+ short_tp_factor: number;
894
+ fee_percent?: number;
895
+ budget: number;
896
+ risk_reward: number;
897
+ reduce_ratio: number;
898
+ global_config: GlobalConfig;
899
+ };
900
+ export declare class Strategy {
901
+ position: {
902
+ long: StrategyPosition;
903
+ short: StrategyPosition;
904
+ };
905
+ dominant_position?: "long" | "short";
906
+ config: Config;
907
+ constructor(payload: {
908
+ long: StrategyPosition;
909
+ short: StrategyPosition;
910
+ config: Config;
911
+ dominant_position?: "long" | "short";
459
912
  });
460
- /**
461
- *In order to avoid rate limiting issues, we cache the live exchange
462
- details for each symbol for an account in the database with an option
463
- to refresh.
464
- */
465
- getLiveExchangeInstance(payload: {
466
- symbol: string;
467
- refresh?: boolean;
468
- refresh_symbol_config?: boolean;
469
- }): Promise<import("pocketbase").RecordModel>;
470
- getActiveAccount(payload: {
471
- symbol: string;
472
- full?: boolean;
473
- refresh?: boolean;
474
- }): Promise<Account | {
475
- liquidation: {
476
- long: number;
477
- short: number;
913
+ get price_places(): string;
914
+ get decimal_places(): string;
915
+ to_f(price: number): number;
916
+ to_df(quantity: number): number;
917
+ pnl(kind: "long" | "short", _position?: StrategyPosition): number;
918
+ tp(kind: "long" | "short"): number;
919
+ calculate_fee(position: {
920
+ price: number;
921
+ quantity: number;
922
+ }): number;
923
+ get long_tp(): number;
924
+ get short_tp(): number;
925
+ generateGapClosingAlgorithm(payload: {
926
+ kind: "long" | "short";
927
+ ignore_entries?: boolean;
928
+ reduce_ratio?: number;
929
+ sell_factor?: number;
930
+ }): {
931
+ last_entry: any;
932
+ first_entry: any;
933
+ threshold: any;
934
+ risk: number;
935
+ risk_reward: number;
936
+ spread: number;
937
+ gap_loss: number;
938
+ net_profit: number;
939
+ long: GapCloserResult;
940
+ short: GapCloserResult;
941
+ };
942
+ gapCloserHelper(payload: {
943
+ risk: number;
944
+ entries?: any[];
945
+ kind: "long" | "short";
946
+ sell_factor?: number;
947
+ reduce_ratio?: number;
948
+ }): {
949
+ risk: number;
950
+ risk_reward: number;
951
+ spread: number;
952
+ gap_loss: number;
953
+ net_profit: number;
954
+ long: GapCloserResult;
955
+ short: GapCloserResult;
956
+ };
957
+ runIterations(payload: {
958
+ kind: "long" | "short";
959
+ iterations: number;
960
+ risk_reward?: number;
961
+ ignore_entries?: boolean;
962
+ reduce_ratio?: number;
963
+ sell_factor?: number;
964
+ }): {
965
+ last_entry: any;
966
+ first_entry: any;
967
+ threshold: any;
968
+ risk: number;
969
+ risk_reward: number;
970
+ spread: number;
971
+ gap_loss: number;
972
+ net_profit: number;
973
+ long: GapCloserResult;
974
+ short: GapCloserResult;
975
+ }[];
976
+ getPositionAfterTp(payload: {
977
+ kind: "long" | "short";
978
+ include_fees?: boolean;
979
+ }): {
980
+ [x: string]: number | {
981
+ entry: number;
982
+ quantity: number;
983
+ diff?: undefined;
984
+ } | {
985
+ [x: string]: number;
986
+ diff: number;
987
+ entry?: undefined;
988
+ quantity?: undefined;
478
989
  };
479
- active_account: Account;
480
- current_price: any;
481
- exchange: any;
482
- }>;
483
- syncAccount(options: {
484
- symbol: string;
485
- kind?: "long" | "short";
486
- update?: boolean;
487
- as_view?: boolean;
488
- leverage?: number;
489
- live_refresh?: boolean;
490
- }): Promise<PositionsView | (PositionsView & {
491
- expand?: {
492
- config: ScheduledTrade;
493
- account: ExchangeAccount;
990
+ pnl: {
991
+ [x: string]: number;
992
+ diff: number;
494
993
  };
495
- })[]>;
496
- getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
497
- syncOrders(options: {
498
- symbol: string;
499
- kind: "long" | "short";
500
- update?: boolean;
501
- }): Promise<import("pocketbase").RecordModel[]>;
502
- toggleStopBuying(payload: {
503
- symbol: string;
994
+ spread: number;
995
+ };
996
+ getPositionAfterIteration(payload: {
504
997
  kind: "long" | "short";
505
- should_stop?: boolean;
506
- }): Promise<import("pocketbase").RecordModel>;
507
- cancelOrders(payload: {
508
- symbol: string;
998
+ iterations: number;
999
+ with_fees?: boolean;
1000
+ }): {
1001
+ [x: string]: number | {
1002
+ entry: number;
1003
+ quantity: number;
1004
+ diff?: undefined;
1005
+ } | {
1006
+ [x: string]: number;
1007
+ diff: number;
1008
+ entry?: undefined;
1009
+ quantity?: undefined;
1010
+ };
1011
+ pnl: {
1012
+ [x: string]: number;
1013
+ diff: number;
1014
+ };
1015
+ spread: number;
1016
+ }[];
1017
+ /**To be used as one of the agent tools eventually since
1018
+ * it is something that can be triggered continously without
1019
+ * any risk
1020
+ */
1021
+ generateOppositeTrades(payload: {
509
1022
  kind: "long" | "short";
1023
+ risk_factor?: number;
1024
+ avg_entry?: number;
1025
+ }): {
1026
+ avg: {
1027
+ entry: number;
1028
+ price: number;
1029
+ quantity: number;
1030
+ };
1031
+ loss: number;
1032
+ profit_percent: number;
1033
+ fee: number;
1034
+ risk_per_trade: number;
1035
+ risk_reward: number;
1036
+ symbol?: string;
1037
+ focus: number;
1038
+ budget: number;
1039
+ support: number;
1040
+ resistance: number;
1041
+ percent_change: number;
1042
+ tradeSplit?: number;
1043
+ take_profit?: number;
1044
+ kind: "long" | "short";
1045
+ entry: number;
1046
+ stop: number;
1047
+ min_size: number;
1048
+ price_places?: string;
1049
+ strategy?: "quantity" | "entry";
1050
+ as_array?: boolean;
1051
+ decimal_places?: string;
1052
+ min_profit?: number;
1053
+ raw?: boolean;
1054
+ gap?: number;
1055
+ rr?: number;
1056
+ max_size?: number;
1057
+ max_quantity?: number;
1058
+ kelly?: {
1059
+ use_kelly?: boolean;
1060
+ kelly_confidence_factor?: number;
1061
+ kelly_minimum_risk?: number;
1062
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1063
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1064
+ };
1065
+ distribution?: GetEntriesParams["distribution"];
1066
+ distribution_params?: {
1067
+ curveFactor?: number;
1068
+ stdDevFactor?: number;
1069
+ lambda?: number;
1070
+ };
1071
+ };
1072
+ identifyGapConfig(payload: {
1073
+ factor?: number;
1074
+ sell_factor?: number;
1075
+ kind?: "long" | "short";
1076
+ risk?: number;
1077
+ }): {
1078
+ profit_percent: {
1079
+ long: number;
1080
+ short: number;
1081
+ };
1082
+ risk: {
1083
+ short: number;
1084
+ long: number;
1085
+ };
1086
+ take_profit: {
1087
+ long: number;
1088
+ short: number;
1089
+ };
1090
+ to_reduce: {
1091
+ short: number;
1092
+ long: number;
1093
+ };
1094
+ full_reduce: {
1095
+ short: number;
1096
+ long: number;
1097
+ };
1098
+ sell_quantity: {
1099
+ short: number;
1100
+ long: number;
1101
+ };
1102
+ gap: number;
1103
+ gap_loss: number;
1104
+ };
1105
+ analyzeProfit(payload: {
1106
+ reward_factor?: number;
1107
+ max_reward_factor: number;
1108
+ risk: number;
1109
+ kind: "long" | "short";
1110
+ }): {
1111
+ pnl: number;
1112
+ loss: number;
1113
+ full_loss: number;
1114
+ original_pnl: number;
1115
+ reward_factor: number;
1116
+ profit_percent: number;
1117
+ kind: "long" | "short";
1118
+ sell_price: number;
1119
+ quantity: number;
1120
+ price_places: string;
1121
+ decimal_places: string;
1122
+ };
1123
+ simulateGapReduction(payload: {
1124
+ iterations?: number;
1125
+ factor?: number;
1126
+ direction: "long" | "short";
1127
+ kind?: "long" | "short";
1128
+ risk?: number;
1129
+ sell_factor?: number;
1130
+ }): {
1131
+ results: {
1132
+ profit_percent: {
1133
+ long: number;
1134
+ short: number;
1135
+ };
1136
+ risk: {
1137
+ short: number;
1138
+ long: number;
1139
+ };
1140
+ take_profit: {
1141
+ long: number;
1142
+ short: number;
1143
+ };
1144
+ sell_quantity: {
1145
+ short: number;
1146
+ long: number;
1147
+ };
1148
+ gap_loss: number;
1149
+ position: {
1150
+ long: {
1151
+ entry: number;
1152
+ quantity: number;
1153
+ };
1154
+ short: {
1155
+ entry: number;
1156
+ quantity: number;
1157
+ };
1158
+ };
1159
+ }[];
1160
+ quantity: number;
1161
+ };
1162
+ }
1163
+ export declare function determine_average_entry_and_size(orders: Array<{
1164
+ price: number;
1165
+ quantity: number;
1166
+ }>, places?: string, price_places?: string): {
1167
+ entry: number;
1168
+ price: number;
1169
+ quantity: number;
1170
+ };
1171
+ export declare const createArray: (start: number, stop: number, step: number) => number[];
1172
+ export type SignalConfigType = {
1173
+ symbol?: string;
1174
+ focus: number;
1175
+ budget: number;
1176
+ percent_change?: number;
1177
+ price_places?: string;
1178
+ decimal_places?: string;
1179
+ zone_risk?: number;
1180
+ fee?: number;
1181
+ support?: number;
1182
+ risk_reward?: number;
1183
+ resistance?: number;
1184
+ risk_per_trade?: number;
1185
+ increase_size?: boolean;
1186
+ additional_increase?: number;
1187
+ minimum_pnl?: number;
1188
+ take_profit?: number;
1189
+ increase_position?: boolean;
1190
+ minimum_size?: number;
1191
+ first_order_size?: number;
1192
+ gap?: number;
1193
+ max_size?: number;
1194
+ use_kelly?: boolean;
1195
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1196
+ kelly_confidence_factor?: number;
1197
+ kelly_minimum_risk?: number;
1198
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1199
+ full_distribution?: {
1200
+ long: GetEntriesParams["distribution"];
1201
+ short: GetEntriesParams["distribution"];
1202
+ };
1203
+ max_quantity?: number;
1204
+ distribution_params?: {
1205
+ curveFactor?: number;
1206
+ stdDevFactor?: number;
1207
+ lambda?: number;
1208
+ };
1209
+ };
1210
+ declare class Signal {
1211
+ focus: number;
1212
+ budget: number;
1213
+ percent_change: number;
1214
+ price_places: string;
1215
+ distribution_params: {
1216
+ curveFactor?: number;
1217
+ stdDevFactor?: number;
1218
+ lambda?: number;
1219
+ };
1220
+ decimal_places: string;
1221
+ zone_risk: number;
1222
+ fee: number;
1223
+ support?: number;
1224
+ risk_reward: number;
1225
+ resistance?: number;
1226
+ risk_per_trade?: number;
1227
+ increase_size: boolean;
1228
+ additional_increase: number;
1229
+ minimum_pnl: number;
1230
+ take_profit?: number;
1231
+ increase_position: boolean;
1232
+ minimum_size: any;
1233
+ first_order_size: number;
1234
+ gap: number;
1235
+ max_size: number;
1236
+ use_kelly: boolean;
1237
+ kelly_prediction_model: "exponential" | "normal" | "uniform";
1238
+ kelly_confidence_factor: number;
1239
+ kelly_minimum_risk: number;
1240
+ kelly_func: "theoretical" | "position_based" | "theoretical_fixed";
1241
+ symbol?: string;
1242
+ distribution: {
1243
+ long: GetEntriesParams["distribution"];
1244
+ short: GetEntriesParams["distribution"];
1245
+ };
1246
+ max_quantity: number;
1247
+ constructor({ focus, symbol, 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, full_distribution, max_quantity, distribution_params, }: SignalConfigType);
1248
+ build_entry({ current_price, stop_loss, pnl, stop_percent, kind, risk, no_of_trades, take_profit, distribution, distribution_params, }: {
1249
+ take_profit?: number;
1250
+ no_of_trades?: number;
1251
+ current_price: number;
1252
+ stop_loss?: number;
1253
+ kind?: "long" | "short";
1254
+ risk: number;
1255
+ stop_percent?: number;
1256
+ pnl?: number;
1257
+ distribution?: GetEntriesParams["distribution"];
1258
+ distribution_params?: {
1259
+ curveFactor?: number;
1260
+ stdDevFactor?: number;
1261
+ lambda?: number;
1262
+ };
1263
+ }): any;
1264
+ get risk(): number;
1265
+ get min_trades(): number;
1266
+ get min_price(): number;
1267
+ build_opposite_order({ current_price, kind, }: {
1268
+ current_price: number;
1269
+ kind?: "long" | "short";
1270
+ }): any;
1271
+ special_build_orders({ current_price, kind, }: {
1272
+ current_price: number;
1273
+ kind?: "long" | "short";
1274
+ }): any;
1275
+ build_orders({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
1276
+ current_price: number;
1277
+ kind?: "long" | "short";
1278
+ limit?: boolean;
1279
+ replace_focus?: boolean;
1280
+ max_index?: number;
1281
+ min_index?: number;
1282
+ }): any;
1283
+ build_orders_old({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
1284
+ current_price: number;
1285
+ kind?: "long" | "short";
1286
+ limit?: boolean;
1287
+ replace_focus?: boolean;
1288
+ max_index?: number;
1289
+ min_index?: number;
1290
+ }): any;
1291
+ get_bulk_trade_zones({ current_price, kind, limit, }: {
1292
+ current_price: number;
1293
+ kind?: "long" | "short";
1294
+ limit?: boolean;
1295
+ }): any;
1296
+ get_future_zones_simple({ current_price, kind, raw, }: {
1297
+ raw?: boolean;
1298
+ current_price: number;
1299
+ kind?: "long" | "short";
1300
+ }): number[];
1301
+ get_future_zones({ current_price, kind, raw, }: {
1302
+ raw?: boolean;
1303
+ current_price: number;
1304
+ kind?: "long" | "short";
1305
+ }): number[];
1306
+ to_f(value: number, places?: string): number;
1307
+ get_margin_zones({ current_price, kind, }: {
1308
+ current_price: number;
1309
+ kind?: "long" | "short";
1310
+ }): number[][];
1311
+ get_margin_range(current_price: number, kind?: string): number[];
1312
+ process_orders({ current_price, stop_loss, trade_zones, kind, }: {
1313
+ current_price: number;
1314
+ stop_loss: number;
1315
+ trade_zones: number[];
1316
+ kind?: "long" | "short";
1317
+ }): any[];
1318
+ get_risk_per_trade(number_of_orders: number): number;
1319
+ build_trade_dict({ entry, stop, risk, arr, index, new_fees, kind, start, take_profit, }: {
1320
+ entry: number;
1321
+ stop: number;
1322
+ risk: number;
1323
+ arr: number[];
1324
+ index: number;
1325
+ new_fees?: number;
1326
+ kind?: "long" | "short";
1327
+ start?: number;
1328
+ take_profit?: number;
1329
+ }): {
1330
+ entry: number;
1331
+ risk: number;
1332
+ quantity: number;
1333
+ sell_price: number;
1334
+ risk_sell: number;
1335
+ stop: number;
1336
+ pnl: number;
1337
+ fee: number;
1338
+ net: number;
1339
+ incurred: number;
1340
+ stop_percent: number;
1341
+ };
1342
+ to_df(currentPrice: number, places?: string): number;
1343
+ }
1344
+ export type AppConfig = {
1345
+ fee: number;
1346
+ risk_per_trade: number;
1347
+ risk_reward: number;
1348
+ symbol?: string;
1349
+ focus: number;
1350
+ budget: number;
1351
+ support: number;
1352
+ resistance: number;
1353
+ percent_change: number;
1354
+ tradeSplit?: number;
1355
+ take_profit?: number;
1356
+ kind: "long" | "short";
1357
+ entry: number;
1358
+ stop: number;
1359
+ min_size: number;
1360
+ price_places?: string;
1361
+ strategy?: "quantity" | "entry";
1362
+ as_array?: boolean;
1363
+ decimal_places?: string;
1364
+ min_profit?: number;
1365
+ raw?: boolean;
1366
+ gap?: number;
1367
+ rr?: number;
1368
+ max_size?: number;
1369
+ last_value?: any;
1370
+ entries?: any[];
1371
+ max_quantity?: number;
1372
+ kelly?: {
1373
+ use_kelly?: boolean;
1374
+ kelly_confidence_factor?: number;
1375
+ kelly_minimum_risk?: number;
1376
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1377
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1378
+ };
1379
+ distribution?: GetEntriesParams["distribution"];
1380
+ distribution_params?: {
1381
+ curveFactor?: number;
1382
+ stdDevFactor?: number;
1383
+ lambda?: number;
1384
+ };
1385
+ };
1386
+ export type ExtendConfigType = {
1387
+ take_profit?: number;
1388
+ entry: number;
1389
+ risk?: number;
1390
+ stop?: number;
1391
+ risk_reward?: number;
1392
+ raw_instance?: boolean;
1393
+ no_of_trades?: number;
1394
+ increase?: boolean;
1395
+ price_places?: string;
1396
+ decimal_places?: string;
1397
+ min_profit?: number;
1398
+ kind?: "long" | "short";
1399
+ gap?: number;
1400
+ rr?: number;
1401
+ min_avg_size?: number;
1402
+ use_kelly?: boolean;
1403
+ kelly_confidence_factor?: number;
1404
+ kelly_minimum_risk?: number;
1405
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1406
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1407
+ distribution?: GetEntriesParams["distribution"];
1408
+ distribution_params?: {
1409
+ curveFactor?: number;
1410
+ stdDevFactor?: number;
1411
+ lambda?: number;
1412
+ };
1413
+ };
1414
+ 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, min_avg_size, distribution, distribution_params, }: ExtendConfigType): any[] | Signal;
1415
+ export declare function buildAvg({ _trades, kind, }: {
1416
+ _trades: any[];
1417
+ kind: "long" | "short";
1418
+ }): any;
1419
+ export declare function sortedBuildConfig(app_config: AppConfig, options: any): any[];
1420
+ export declare function get_app_config_and_max_size(config: GlobalConfig, payload: {
1421
+ entry: number;
1422
+ stop: number;
1423
+ kind: "long" | "short";
1424
+ use_kelly?: boolean;
1425
+ kelly_confidence_factor?: number;
1426
+ kelly_minimum_risk?: number;
1427
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1428
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1429
+ distribution?: GetEntriesParams["distribution"];
1430
+ distribution_params?: {
1431
+ curveFactor?: number;
1432
+ stdDevFactor?: number;
1433
+ lambda?: number;
1434
+ };
1435
+ }): {
1436
+ app_config: AppConfig;
1437
+ max_size: any;
1438
+ last_value: any;
1439
+ entries: {
1440
+ entry: any;
1441
+ avg_entry: any;
1442
+ avg_size: any;
1443
+ neg_pnl: any;
1444
+ quantity: any;
1445
+ }[];
1446
+ };
1447
+ export declare function buildAppConfig(config: GlobalConfig, payload: {
1448
+ entry: number;
1449
+ stop: number;
1450
+ risk_reward: number;
1451
+ risk: number;
1452
+ symbol: string;
1453
+ profit?: number;
1454
+ use_kelly?: boolean;
1455
+ kelly_confidence_factor?: number;
1456
+ kelly_minimum_risk?: number;
1457
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1458
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1459
+ distribution?: GetEntriesParams["distribution"];
1460
+ distribution_params?: {
1461
+ curveFactor?: number;
1462
+ stdDevFactor?: number;
1463
+ lambda?: number;
1464
+ };
1465
+ }): AppConfig;
1466
+ export declare function getOptimumStopAndRisk(app_config: AppConfig, params: {
1467
+ max_size: number;
1468
+ target_stop: number;
1469
+ highest_risk?: number;
1470
+ distribution?: GetEntriesParams["distribution"];
1471
+ distribution_params?: {
1472
+ curveFactor?: number;
1473
+ stdDevFactor?: number;
1474
+ lambda?: number;
1475
+ };
1476
+ }): {
1477
+ optimal_stop: number;
1478
+ optimal_risk: number;
1479
+ avg_size: any;
1480
+ avg_entry: any;
1481
+ result: any[];
1482
+ first_entry: any;
1483
+ neg_pnl: any;
1484
+ risk_reward: number;
1485
+ size_diff: number;
1486
+ entry_diff: number;
1487
+ };
1488
+ export declare function generate_config_params(app_config: AppConfig, payload: {
1489
+ entry: number;
1490
+ stop: number;
1491
+ risk_reward: number;
1492
+ risk: number;
1493
+ symbol: string;
1494
+ }): {
1495
+ entry: number;
1496
+ stop: number;
1497
+ avg_size: any;
1498
+ avg_entry: any;
1499
+ risk_reward: number;
1500
+ neg_pnl: any;
1501
+ risk: number;
1502
+ };
1503
+ export declare function determine_break_even_price(payload: {
1504
+ long_position: {
1505
+ entry: number;
1506
+ quantity: number;
1507
+ };
1508
+ short_position: {
1509
+ entry: number;
1510
+ quantity: number;
1511
+ };
1512
+ fee_percent?: number;
1513
+ }): {
1514
+ price: number;
1515
+ direction: string;
1516
+ };
1517
+ export declare function determine_amount_to_buy(payload: {
1518
+ orders: any[];
1519
+ kind: "long" | "short";
1520
+ decimal_places?: string;
1521
+ price_places?: string;
1522
+ place?: boolean;
1523
+ position: any;
1524
+ existingOrders: any[];
1525
+ }): any[];
1526
+ export declare function generateOptimumAppConfig(config: GlobalConfig, payload: {
1527
+ entry: number;
1528
+ stop: number;
1529
+ risk_reward: number;
1530
+ start_risk: number;
1531
+ max_risk?: number;
1532
+ distribution?: GetEntriesParams["distribution"];
1533
+ distribution_params?: {
1534
+ curveFactor?: number;
1535
+ stdDevFactor?: number;
1536
+ lambda?: number;
1537
+ };
1538
+ }, position: {
1539
+ entry: number;
1540
+ quantity: number;
1541
+ kind: "long" | "short";
1542
+ }): AppConfig | null;
1543
+ export declare function determineOptimumReward(payload: {
1544
+ app_config: AppConfig;
1545
+ increase?: boolean;
1546
+ low_range?: number;
1547
+ high_range?: number;
1548
+ target_loss?: number;
1549
+ distribution?: GetEntriesParams["distribution"];
1550
+ distribution_params?: {
1551
+ curveFactor?: number;
1552
+ stdDevFactor?: number;
1553
+ lambda?: number;
1554
+ };
1555
+ max_size?: number;
1556
+ }): number | {
1557
+ result: any[];
1558
+ value: number;
1559
+ total: number;
1560
+ risk_per_trade: number;
1561
+ max: number;
1562
+ min: number;
1563
+ avg_size: any;
1564
+ neg_pnl: any;
1565
+ entry: any;
1566
+ };
1567
+ export declare function determineOptimumRisk(config: GlobalConfig, payload: {
1568
+ entry: number;
1569
+ stop: number;
1570
+ risk_reward: number;
1571
+ risk: number;
1572
+ symbol: string;
1573
+ distribution?: GetEntriesParams["distribution"];
1574
+ distribution_params?: {
1575
+ curveFactor?: number;
1576
+ stdDevFactor?: number;
1577
+ lambda?: number;
1578
+ };
1579
+ }, params: {
1580
+ highest_risk: number;
1581
+ tolerance?: number;
1582
+ max_iterations?: number;
1583
+ }): {
1584
+ optimal_risk: number;
1585
+ achieved_neg_pnl: number;
1586
+ target_neg_pnl: number;
1587
+ difference: number;
1588
+ iterations: number;
1589
+ converged: boolean;
1590
+ last_value: any;
1591
+ entries: any[];
1592
+ app_config: AppConfig;
1593
+ };
1594
+ export declare function computeRiskReward(payload: {
1595
+ app_config: AppConfig;
1596
+ entry: number;
1597
+ stop: number;
1598
+ risk_per_trade: number;
1599
+ target_loss?: number;
1600
+ distribution?: GetEntriesParams["distribution"];
1601
+ distribution_params?: {
1602
+ curveFactor?: number;
1603
+ stdDevFactor?: number;
1604
+ lambda?: number;
1605
+ };
1606
+ high_range?: number;
1607
+ max_size?: number;
1608
+ }): number | {
1609
+ result: any[];
1610
+ value: number;
1611
+ total: number;
1612
+ risk_per_trade: number;
1613
+ max: number;
1614
+ min: number;
1615
+ avg_size: any;
1616
+ neg_pnl: any;
1617
+ entry: any;
1618
+ };
1619
+ export declare function getRiskReward(payload: {
1620
+ entry: number;
1621
+ stop: number;
1622
+ risk: number;
1623
+ global_config: GlobalConfig;
1624
+ force_exact_risk?: boolean;
1625
+ target_loss?: number;
1626
+ max_size?: number;
1627
+ distribution?: GetEntriesParams["distribution"];
1628
+ distribution_params?: {
1629
+ curveFactor?: number;
1630
+ stdDevFactor?: number;
1631
+ lambda?: number;
1632
+ };
1633
+ risk_factor?: number;
1634
+ high_range?: number;
1635
+ }): any;
1636
+ export declare function computeProfitDetail(payload: {
1637
+ focus_position: {
1638
+ kind: "long" | "short";
1639
+ entry: number;
1640
+ quantity: number;
1641
+ avg_qty: number;
1642
+ avg_price: number;
1643
+ };
1644
+ strategy?: {
1645
+ reward_factor: number;
1646
+ max_reward_factor: number;
1647
+ risk: number;
1648
+ };
1649
+ pnl: number;
1650
+ reduce_position?: {
1651
+ kind: "long" | "short";
1652
+ entry: number;
1653
+ quantity: number;
1654
+ avg_qty: number;
1655
+ avg_price: number;
1656
+ };
1657
+ reverse_position?: {
1658
+ kind: "long" | "short";
1659
+ avg_qty: number;
1660
+ avg_price: number;
1661
+ stop_loss: {
1662
+ price: number;
1663
+ quantity: number;
1664
+ };
1665
+ };
1666
+ full_ratio?: number;
1667
+ price_places?: string;
1668
+ decimal_places?: string;
1669
+ }): {
1670
+ pnl: number;
1671
+ loss: number;
1672
+ full_loss: number;
1673
+ original_pnl: number;
1674
+ reward_factor: number;
1675
+ profit_percent: number;
1676
+ kind: "long" | "short";
1677
+ sell_price: number;
1678
+ quantity: number;
1679
+ price_places: string;
1680
+ decimal_places: string;
1681
+ };
1682
+ export declare function generateGapTp(payload: {
1683
+ long: {
1684
+ entry: number;
1685
+ quantity: number;
1686
+ };
1687
+ short: {
1688
+ entry: number;
1689
+ quantity: number;
1690
+ };
1691
+ risk?: number;
1692
+ kind?: "long" | "short";
1693
+ factor?: number;
1694
+ sell_factor?: number;
1695
+ price_places?: string;
1696
+ decimal_places?: string;
1697
+ }): {
1698
+ profit_percent: {
1699
+ long: number;
1700
+ short: number;
1701
+ };
1702
+ risk: {
1703
+ short: number;
1704
+ long: number;
1705
+ };
1706
+ take_profit: {
1707
+ long: number;
1708
+ short: number;
1709
+ };
1710
+ to_reduce: {
1711
+ short: number;
1712
+ long: number;
1713
+ };
1714
+ full_reduce: {
1715
+ short: number;
1716
+ long: number;
1717
+ };
1718
+ sell_quantity: {
1719
+ short: number;
1720
+ long: number;
1721
+ };
1722
+ gap: number;
1723
+ gap_loss: number;
1724
+ };
1725
+ export declare function calculateFactorFromTakeProfit(payload: {
1726
+ long: {
1727
+ entry: number;
1728
+ quantity: number;
1729
+ };
1730
+ short: {
1731
+ entry: number;
1732
+ quantity: number;
1733
+ };
1734
+ knownTp: number;
1735
+ tpType: "long" | "short";
1736
+ price_places?: string;
1737
+ }): number;
1738
+ export declare function calculateFactorFromSellQuantity(payload: {
1739
+ long: {
1740
+ entry: number;
1741
+ quantity: number;
1742
+ };
1743
+ short: {
1744
+ entry: number;
1745
+ quantity: number;
1746
+ };
1747
+ knownSellQuantity: number;
1748
+ sellType: "long" | "short";
1749
+ sell_factor?: number;
1750
+ price_places?: string;
1751
+ decimal_places?: string;
1752
+ }): number;
1753
+ export declare function determineRewardFactor(payload: {
1754
+ quantity: number;
1755
+ avg_qty: number;
1756
+ minimum_pnl: number;
1757
+ risk: number;
1758
+ }): number;
1759
+ export type BotPosition = {
1760
+ kind: "long" | "short";
1761
+ entry: number;
1762
+ quantity: number;
1763
+ tp: {
1764
+ price: number;
1765
+ };
1766
+ };
1767
+ export declare function getHedgeZone(payload: {
1768
+ symbol_config: GlobalConfig;
1769
+ risk: number;
1770
+ position: BotPosition;
1771
+ reward_factor?: number;
1772
+ risk_factor?: number;
1773
+ support?: number;
1774
+ }): {
1775
+ support: number;
1776
+ resistance: number;
1777
+ risk: number;
1778
+ profit_percent: number;
1779
+ };
1780
+ export declare function getOptimumHedgeFactor(payload: {
1781
+ target_support: number;
1782
+ tolerance?: number;
1783
+ max_iterations?: number;
1784
+ min_factor?: number;
1785
+ max_factor?: number;
1786
+ symbol_config: GlobalConfig;
1787
+ risk: number;
1788
+ position: BotPosition;
1789
+ }): {
1790
+ reward_factor: number;
1791
+ achieved_support: number;
1792
+ target_support: number;
1793
+ difference: number;
1794
+ iterations: number;
1795
+ converged?: undefined;
1796
+ } | {
1797
+ reward_factor: number;
1798
+ achieved_support: number;
1799
+ target_support: number;
1800
+ difference: number;
1801
+ iterations: number;
1802
+ converged: boolean;
1803
+ };
1804
+ export type CType = {
1805
+ next_order: number;
1806
+ take_profit: number;
1807
+ };
1808
+ export declare function determineCompoundLongTrade(payload: {
1809
+ focus_short_position: CType;
1810
+ focus_long_position: CType;
1811
+ shortConfig: {
1812
+ entry: number;
1813
+ stop: number;
1814
+ risk_reward: number;
1815
+ risk: number;
1816
+ symbol: string;
1817
+ profit_percent: number;
1818
+ };
1819
+ rr?: number;
1820
+ global_config: GlobalConfig;
1821
+ }): {
1822
+ start_risk: number;
1823
+ short_profit: number;
1824
+ support: number;
1825
+ resistance: number;
1826
+ long_v: any;
1827
+ profit_percent: number;
1828
+ result: any;
1829
+ short_max_size: any;
1830
+ };
1831
+ export declare function generateOppositeTradeConfig(payload: {
1832
+ kind: "long" | "short";
1833
+ entry: number;
1834
+ quantity: number;
1835
+ target_pnl: number;
1836
+ global_config: GlobalConfig;
1837
+ ratio?: number;
1838
+ }): {
1839
+ entry: number;
1840
+ stop: number;
1841
+ risk: number;
1842
+ risk_reward: number | {
1843
+ result: any[];
1844
+ value: number;
1845
+ total: number;
1846
+ risk_per_trade: number;
1847
+ max: number;
1848
+ min: number;
1849
+ avg_size: any;
1850
+ neg_pnl: any;
1851
+ entry: any;
1852
+ };
1853
+ };
1854
+ export declare function constructAppConfig(payload: {
1855
+ account: PositionsView;
1856
+ global_config: GlobalConfig;
1857
+ kelly_config?: {
1858
+ use_kelly: boolean;
1859
+ kelly_confidence_factor: number;
1860
+ kelly_minimum_risk: number;
1861
+ kelly_prediction_model: string;
1862
+ };
1863
+ distribution_config?: {
1864
+ distribution?: GetEntriesParams["distribution"];
1865
+ distribution_params?: {
1866
+ curveFactor?: number;
1867
+ stdDevFactor?: number;
1868
+ lambda?: number;
1869
+ };
1870
+ };
1871
+ }): {
1872
+ fee: number;
1873
+ risk_per_trade: number;
1874
+ risk_reward: number;
1875
+ symbol?: string;
1876
+ focus: number;
1877
+ budget: number;
1878
+ support: number;
1879
+ resistance: number;
1880
+ percent_change: number;
1881
+ tradeSplit?: number;
1882
+ take_profit?: number;
1883
+ kind: "long" | "short";
1884
+ entry: number;
1885
+ stop: number;
1886
+ min_size: number;
1887
+ price_places?: string;
1888
+ strategy?: "quantity" | "entry";
1889
+ as_array?: boolean;
1890
+ decimal_places?: string;
1891
+ min_profit?: number;
1892
+ raw?: boolean;
1893
+ gap?: number;
1894
+ rr?: number;
1895
+ max_size?: number;
1896
+ last_value?: any;
1897
+ max_quantity?: number;
1898
+ kelly?: {
1899
+ use_kelly?: boolean;
1900
+ kelly_confidence_factor?: number;
1901
+ kelly_minimum_risk?: number;
1902
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1903
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1904
+ };
1905
+ distribution?: GetEntriesParams["distribution"];
1906
+ distribution_params?: {
1907
+ curveFactor?: number;
1908
+ stdDevFactor?: number;
1909
+ lambda?: number;
1910
+ };
1911
+ };
1912
+ export declare function generateDangerousConfig(payload: {
1913
+ account: PositionsView;
1914
+ global_config: GlobalConfig;
1915
+ config: {
1916
+ quantity: number;
1917
+ stop: number;
1918
+ entry: number;
1919
+ };
1920
+ }): {
1921
+ entry: number;
1922
+ risk: number;
1923
+ stop: number;
1924
+ risk_reward: number | {
1925
+ result: any[];
1926
+ value: number;
1927
+ total: number;
1928
+ risk_per_trade: number;
1929
+ max: number;
1930
+ min: number;
1931
+ avg_size: any;
1932
+ neg_pnl: any;
1933
+ entry: any;
1934
+ };
1935
+ };
1936
+ export interface ComputedTrade {
1937
+ entry: number;
1938
+ quantity: number;
1939
+ avg_size: number;
1940
+ neg_pnl: number;
1941
+ avg_entry: number;
1942
+ stop: number;
1943
+ reverse_avg_entry: number;
1944
+ reverse_avg_quantity: number;
1945
+ fee: number;
1946
+ }
1947
+ export type TradeConfig = {
1948
+ entry: number;
1949
+ stop: number;
1950
+ risk_reward: number;
1951
+ risk: number;
1952
+ symbol: string;
1953
+ distribution?: GetEntriesParams["distribution"];
1954
+ distribution_params?: {
1955
+ curveFactor?: number;
1956
+ stdDevFactor?: number;
1957
+ lambda?: number;
1958
+ };
1959
+ };
1960
+ declare function constructAppConfig$1({ config, global_config, }: {
1961
+ config: TradeConfig;
1962
+ global_config: GlobalConfig;
1963
+ }): {
1964
+ fee: number;
1965
+ risk_per_trade: number;
1966
+ risk_reward: number;
1967
+ symbol?: string;
1968
+ focus: number;
1969
+ budget: number;
1970
+ support: number;
1971
+ resistance: number;
1972
+ percent_change: number;
1973
+ tradeSplit?: number;
1974
+ take_profit?: number;
1975
+ kind: "long" | "short";
1976
+ entry: number;
1977
+ stop: number;
1978
+ min_size: number;
1979
+ price_places?: string;
1980
+ strategy?: "quantity" | "entry";
1981
+ as_array?: boolean;
1982
+ decimal_places?: string;
1983
+ min_profit?: number;
1984
+ raw?: boolean;
1985
+ gap?: number;
1986
+ rr?: number;
1987
+ max_size?: number;
1988
+ last_value?: any;
1989
+ max_quantity?: number;
1990
+ kelly?: {
1991
+ use_kelly?: boolean;
1992
+ kelly_confidence_factor?: number;
1993
+ kelly_minimum_risk?: number;
1994
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1995
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1996
+ };
1997
+ distribution?: GetEntriesParams["distribution"];
1998
+ distribution_params?: {
1999
+ curveFactor?: number;
2000
+ stdDevFactor?: number;
2001
+ lambda?: number;
2002
+ };
2003
+ };
2004
+ declare function buildWithOptimumReward({ config, settings, global_config, force_exact, }: {
2005
+ config: TradeConfig;
2006
+ global_config: GlobalConfig;
2007
+ settings: {
2008
+ entry?: number;
2009
+ stop?: number;
2010
+ risk: number;
2011
+ stop_ratio?: number;
2012
+ risk_reward?: number;
2013
+ distribution?: GetEntriesParams["distribution"];
2014
+ distribution_params?: {
2015
+ curveFactor?: number;
2016
+ stdDevFactor?: number;
2017
+ lambda?: number;
2018
+ };
2019
+ };
2020
+ force_exact?: boolean;
2021
+ }): {
2022
+ trades: any[];
2023
+ summary: {
2024
+ entry: number;
2025
+ stop: number;
2026
+ risk: number;
2027
+ risk_reward: any;
2028
+ avg_entry: number;
2029
+ avg_size: number;
2030
+ first_entry: number;
2031
+ pnl: number;
2032
+ fee: number;
2033
+ loss: number;
2034
+ last_entry: number;
2035
+ margin: number;
2036
+ };
2037
+ config: any;
2038
+ stop_order: {
2039
+ quantity: number;
2040
+ price: number;
2041
+ };
2042
+ kind: string;
2043
+ };
2044
+ declare function generateOppositeOptimum({ config, global_config, settings, ratio, distribution, distribution_params, risk_factor, }: {
2045
+ settings: {
2046
+ entry: number;
2047
+ stop: number;
2048
+ risk: number;
2049
+ };
2050
+ config: TradeConfig;
2051
+ global_config: GlobalConfig;
2052
+ fee_percent?: number;
2053
+ ratio?: number;
2054
+ distribution?: any;
2055
+ distribution_params?: {
2056
+ curveFactor?: number;
2057
+ stdDevFactor?: number;
2058
+ lambda?: number;
2059
+ };
2060
+ risk_factor?: number;
2061
+ }): {
2062
+ trades: any[];
2063
+ summary: any;
2064
+ config: {
2065
+ entry: number;
2066
+ stop: number;
2067
+ risk: number;
2068
+ distribution: any;
2069
+ distribution_params: {
2070
+ curveFactor?: number;
2071
+ stdDevFactor?: number;
2072
+ lambda?: number;
2073
+ };
2074
+ risk_factor: number;
2075
+ };
2076
+ kind: string;
2077
+ } | {
2078
+ trades: any[];
2079
+ summary: {
2080
+ entry: number;
2081
+ stop: number;
2082
+ risk: number;
2083
+ risk_reward: any;
2084
+ avg_entry: number;
2085
+ avg_size: number;
2086
+ first_entry: number;
2087
+ pnl: number;
2088
+ fee: number;
2089
+ loss: number;
2090
+ last_entry: number;
2091
+ defaultEntry: number;
2092
+ };
2093
+ config: any;
2094
+ kind: string;
2095
+ };
2096
+ declare function increaseTradeHelper({ increase_qty, stop, config, global_config, style, entry, position, stop_ratio, distribution: default_distribution, distribution_params: default_distribution_params, }: {
2097
+ position: {
2098
+ entry: number;
2099
+ quantity: number;
2100
+ };
2101
+ entry: number;
2102
+ stop: number;
2103
+ config: TradeConfig;
2104
+ global_config: GlobalConfig;
2105
+ increase_qty: number;
2106
+ style: "minimum" | "optimum";
2107
+ stop_ratio?: number;
2108
+ distribution?: any;
2109
+ distribution_params?: {
2110
+ curveFactor?: number;
2111
+ stdDevFactor?: number;
2112
+ lambda?: number;
2113
+ };
2114
+ }): {
2115
+ trades: any[];
2116
+ summary: any;
2117
+ config: any;
2118
+ kind: string;
2119
+ current: {
2120
+ trades: any[];
2121
+ summary: {
2122
+ first_entry: number;
2123
+ last_entry: number;
2124
+ quantity: number;
2125
+ entry: number;
2126
+ loss: number;
2127
+ number_of_trades: number;
2128
+ fee: number;
2129
+ anchor_pnl: any;
2130
+ };
2131
+ };
2132
+ stop_order?: undefined;
2133
+ } | {
2134
+ trades: any[];
2135
+ summary: {
2136
+ entry: number;
2137
+ stop: number;
2138
+ risk: number;
2139
+ risk_reward: any;
2140
+ avg_entry: number;
2141
+ avg_size: number;
2142
+ first_entry: number;
2143
+ pnl: number;
2144
+ fee: number;
2145
+ loss: number;
2146
+ last_entry: number;
2147
+ margin: number;
2148
+ };
2149
+ stop_order: {
2150
+ quantity: number;
2151
+ price: number;
2152
+ };
2153
+ config: any;
2154
+ kind: string;
2155
+ current: {
2156
+ trades: any[];
2157
+ summary: {
2158
+ first_entry: number;
2159
+ last_entry: number;
2160
+ quantity: number;
2161
+ entry: number;
2162
+ loss: number;
2163
+ number_of_trades: number;
2164
+ fee: number;
2165
+ anchor_pnl: any;
2166
+ };
2167
+ };
2168
+ };
2169
+ declare function generatePositionIncreaseTrade({ account, zoneAccount, ratio, config, global_config, style, distribution, distribution_params, }: {
2170
+ style?: "optimum" | "minimum";
2171
+ account: {
2172
+ long: {
2173
+ entry: number;
2174
+ quantity: number;
2175
+ };
2176
+ short: {
2177
+ entry: number;
2178
+ quantity: number;
2179
+ };
2180
+ };
2181
+ config: TradeConfig;
2182
+ global_config: GlobalConfig;
2183
+ zoneAccount: {
2184
+ entry: number;
2185
+ stop: number;
2186
+ };
2187
+ ratio?: number;
2188
+ distribution?: any;
2189
+ distribution_params?: {
2190
+ curveFactor?: number;
2191
+ stdDevFactor?: number;
2192
+ lambda?: number;
2193
+ };
2194
+ }): {
2195
+ trades: any[];
2196
+ summary: any;
2197
+ config: any;
2198
+ kind: string;
2199
+ current: {
2200
+ trades: any[];
2201
+ summary: {
2202
+ first_entry: number;
2203
+ last_entry: number;
2204
+ quantity: number;
2205
+ entry: number;
2206
+ loss: number;
2207
+ number_of_trades: number;
2208
+ fee: number;
2209
+ anchor_pnl: any;
2210
+ };
2211
+ };
2212
+ stop_order?: undefined;
2213
+ } | {
2214
+ trades: any[];
2215
+ summary: {
2216
+ entry: number;
2217
+ stop: number;
2218
+ risk: number;
2219
+ risk_reward: any;
2220
+ avg_entry: number;
2221
+ avg_size: number;
2222
+ first_entry: number;
2223
+ pnl: number;
2224
+ fee: number;
2225
+ loss: number;
2226
+ last_entry: number;
2227
+ margin: number;
2228
+ };
2229
+ stop_order: {
2230
+ quantity: number;
2231
+ price: number;
2232
+ };
2233
+ config: any;
2234
+ kind: string;
2235
+ current: {
2236
+ trades: any[];
2237
+ summary: {
2238
+ first_entry: number;
2239
+ last_entry: number;
2240
+ quantity: number;
2241
+ entry: number;
2242
+ loss: number;
2243
+ number_of_trades: number;
2244
+ fee: number;
2245
+ anchor_pnl: any;
2246
+ };
2247
+ };
2248
+ };
2249
+ declare function determineHedgeTradeToPlace({ position, config, global_config, profit_risk, allowable_loss, }: {
2250
+ position: {
2251
+ entry: number;
2252
+ quantity: number;
2253
+ kind: "long" | "short";
2254
+ };
2255
+ config: TradeConfig;
2256
+ global_config: GlobalConfig;
2257
+ profit_risk?: number;
2258
+ allowable_loss?: number;
2259
+ }): {
2260
+ opposite: {
2261
+ trades: any[];
2262
+ summary: {
2263
+ entry: number;
2264
+ stop: number;
2265
+ risk: number;
2266
+ risk_reward: any;
2267
+ avg_entry: number;
2268
+ avg_size: number;
2269
+ first_entry: number;
2270
+ pnl: number;
2271
+ fee: number;
2272
+ loss: number;
2273
+ last_entry: number;
2274
+ margin: number;
2275
+ };
2276
+ config: any;
2277
+ stop_order: {
2278
+ quantity: number;
2279
+ price: number;
2280
+ };
2281
+ kind: string;
2282
+ };
2283
+ take_profit: number;
2284
+ };
2285
+ export declare const compoundAPI: {
2286
+ determineHedgeTradeToPlace: typeof determineHedgeTradeToPlace;
2287
+ buildWithOptimumReward: typeof buildWithOptimumReward;
2288
+ constructAppConfig: typeof constructAppConfig$1;
2289
+ generateOppositeOptimum: typeof generateOppositeOptimum;
2290
+ increaseTradeHelper: typeof increaseTradeHelper;
2291
+ generatePositionIncreaseTrade: typeof generatePositionIncreaseTrade;
2292
+ };
2293
+ export type ExchangeOrder = {
2294
+ symbol: string;
2295
+ price: number;
2296
+ quantity: number;
2297
+ kind: "long" | "short";
2298
+ side: "buy" | "sell";
2299
+ stop: number;
2300
+ order_id: string;
2301
+ triggerPrice?: number;
2302
+ };
2303
+ export declare class ExchangePosition {
2304
+ exchange: BaseExchange;
2305
+ exchange_account: ExchangeAccount$1;
2306
+ private app_db;
2307
+ private instance;
2308
+ orders: {
2309
+ entries: ExchangeOrder[];
2310
+ stop_orders: ExchangeOrder[];
2311
+ tp_orders: ExchangeOrder[];
2312
+ };
2313
+ constructor(payload: {
2314
+ exchange: BaseExchange;
2315
+ app_db: AppDatabase;
2316
+ instance: PositionsView;
2317
+ exchange_account: ExchangeAccount$1;
2318
+ without_view?: PositionsView;
2319
+ orders?: {
2320
+ entries: any[];
2321
+ stop_orders: any[];
2322
+ tp_orders: any[];
2323
+ };
2324
+ });
2325
+ get symbol_config(): SymbolConfig;
2326
+ initialize(): Promise<void>;
2327
+ getInstance(): PositionsView;
2328
+ get symbol(): any;
2329
+ get kind(): any;
2330
+ get account(): ExchangeAccount;
2331
+ get compound(): CompoundInstance & {
2332
+ amount_to_risk?: number;
2333
+ profit_percent?: number;
2334
+ };
2335
+ getProxyForAccount(): Promise<HttpsProxyAgent<`http://${string}`> | SocksProxyAgent>;
2336
+ cancelOrders(payload: {
2337
+ limit?: boolean;
510
2338
  price?: number;
511
- all?: boolean;
512
- stop?: boolean;
513
- }): Promise<{
2339
+ raw?: boolean;
2340
+ }): Promise<any[] | {
514
2341
  success: boolean;
515
2342
  message: string;
516
2343
  exchange_result?: undefined;
@@ -526,19 +2353,69 @@ declare class ExchangeAccount$1 {
526
2353
  message?: undefined;
527
2354
  exchange_result?: undefined;
528
2355
  }>;
529
- cancelExchangeOrders(payload: {
530
- symbol: string;
531
- orders: number[];
2356
+ getConfig(payload?: {
2357
+ params?: {
2358
+ entry?: number;
2359
+ stop?: number;
2360
+ risk_reward?: number;
2361
+ risk?: number;
2362
+ profit_percent?: number;
2363
+ place_tp?: boolean;
2364
+ profit?: number;
2365
+ reduce_ratio?: number;
2366
+ };
2367
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
2368
+ updateTargetPnl(): Promise<any>;
2369
+ updateConfigPnl(): Promise<void>;
2370
+ triggerTradeFromConfig(payload: {
2371
+ place?: boolean;
2372
+ raw?: boolean;
2373
+ tp?: boolean;
2374
+ stop?: boolean;
2375
+ use_current?: boolean;
2376
+ ignore_config?: boolean;
2377
+ risky?: boolean;
2378
+ hedge?: boolean;
2379
+ stop_ratio?: number;
2380
+ }): Promise<any>;
2381
+ placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders" | "dangerous_entry_orders", payload: {
2382
+ entry: number;
2383
+ stop: number;
2384
+ risk_reward: number;
2385
+ risk: number;
2386
+ place?: boolean;
2387
+ update_db?: boolean;
2388
+ raw?: boolean;
2389
+ use_current?: boolean;
2390
+ stop_percent?: number;
2391
+ distribution?: GetEntriesParams["distribution"];
2392
+ distribution_params?: {
2393
+ curveFactor?: number;
2394
+ stdDevFactor?: number;
2395
+ lambda?: number;
2396
+ };
2397
+ hedge?: boolean;
2398
+ stop_ratio?: number;
532
2399
  }): Promise<any>;
533
2400
  buildAppConfig(payload: {
534
2401
  entry: number;
535
2402
  stop: number;
536
2403
  risk_reward: number;
537
2404
  risk: number;
538
- symbol: string;
539
2405
  profit?: number;
540
2406
  update_db?: boolean;
541
2407
  profit_percent?: number;
2408
+ use_kelly?: boolean;
2409
+ kelly_confidence_factor?: number;
2410
+ kelly_minimum_risk?: number;
2411
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2412
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
2413
+ distribution?: GetEntriesParams["distribution"];
2414
+ distribution_params?: {
2415
+ curveFactor?: number;
2416
+ stdDevFactor?: number;
2417
+ lambda?: number;
2418
+ };
542
2419
  }): Promise<AppConfig>;
543
2420
  placeConfigOrders(app_config: AppConfig, solution: {
544
2421
  risk_reward: number;
@@ -549,6 +2426,18 @@ declare class ExchangeAccount$1 {
549
2426
  neg_pnl: number;
550
2427
  min_size: number;
551
2428
  symbol: string;
2429
+ stop_percent?: number;
2430
+ use_kelly?: boolean;
2431
+ kelly_confidence_factor?: number;
2432
+ kelly_minimum_risk?: number;
2433
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2434
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
2435
+ distribution?: GetEntriesParams["distribution"];
2436
+ distribution_params?: {
2437
+ curveFactor?: number;
2438
+ stdDevFactor?: number;
2439
+ lambda?: number;
2440
+ };
552
2441
  }, place?: boolean, skip_stop?: boolean): Promise<{
553
2442
  entry_orders: {
554
2443
  orders: {
@@ -571,15 +2460,476 @@ declare class ExchangeAccount$1 {
571
2460
  };
572
2461
  trades: any[];
573
2462
  }>;
574
- determineAmountToBuy(payload: {
575
- orders: any[];
2463
+ determineAmountToBuy(payload: {
2464
+ orders: any[];
2465
+ kind: "long" | "short";
2466
+ refresh?: boolean;
2467
+ decimal_places?: string;
2468
+ price_places?: string;
2469
+ cancel?: boolean;
2470
+ place?: boolean;
2471
+ }): Promise<any[]>;
2472
+ refresh(live_refresh?: boolean): Promise<{
2473
+ instance: PositionsView;
2474
+ existingOrders: void | Order[];
2475
+ }>;
2476
+ placeTrade(payload: {
2477
+ place?: boolean;
2478
+ tp?: boolean;
2479
+ stop?: boolean;
2480
+ raw?: boolean;
2481
+ limit?: boolean;
2482
+ cancel?: boolean;
2483
+ ignore_config?: boolean;
2484
+ risky?: boolean;
2485
+ target_pnl?: number;
2486
+ hedge?: boolean;
2487
+ stop_ratio?: number;
2488
+ }): Promise<any>;
2489
+ placeStopLimit(payload: {
2490
+ place?: boolean;
2491
+ stop: number;
2492
+ quantity?: number;
2493
+ }): Promise<any>;
2494
+ computeTargetPnl(payload: {
2495
+ secondary: ExchangePosition;
2496
+ }): Promise<number>;
2497
+ runSimulation(payload: {
2498
+ iterations?: number;
2499
+ long_position: ExchangePosition;
2500
+ short_position: ExchangePosition;
2501
+ raw?: boolean;
2502
+ }): Promise<Strategy | {
2503
+ last_entry: any;
2504
+ first_entry: any;
2505
+ threshold: any;
2506
+ risk: number;
2507
+ risk_reward: number;
2508
+ spread: number;
2509
+ gap_loss: number;
2510
+ net_profit: number;
2511
+ long: {
2512
+ avg_entry: number;
2513
+ avg_size: number;
2514
+ loss: number;
2515
+ stop: number;
2516
+ stop_quantity: number;
2517
+ re_entry_quantity: number;
2518
+ initial_pnl: number;
2519
+ tp: number;
2520
+ incurred_loss: number;
2521
+ pnl: number;
2522
+ remaining_quantity: number;
2523
+ };
2524
+ short: {
2525
+ avg_entry: number;
2526
+ avg_size: number;
2527
+ loss: number;
2528
+ stop: number;
2529
+ stop_quantity: number;
2530
+ re_entry_quantity: number;
2531
+ initial_pnl: number;
2532
+ tp: number;
2533
+ incurred_loss: number;
2534
+ pnl: number;
2535
+ remaining_quantity: number;
2536
+ };
2537
+ }[]>;
2538
+ rawConfigUpdate(payload: any): Promise<void>;
2539
+ /**
2540
+ * This method is used to place the opposite trade action
2541
+ */
2542
+ placeOppositeTradeAction(payload: {
2543
+ data: {
2544
+ avg: {
2545
+ quantity: number;
2546
+ price: number;
2547
+ };
2548
+ entry: number;
2549
+ stop: number;
2550
+ risk_per_trade: number;
2551
+ profit_percent: number;
2552
+ risk_reward: number;
2553
+ };
2554
+ }): Promise<void>;
2555
+ /**
2556
+ * Updates the risk configuration for an empty position using the next_risk value.
2557
+ * This implements progressive risk management where successful trades increase future risk tolerance.
2558
+ *
2559
+ * @param payload.symbol - The trading symbol (e.g., "BTCUSDT")
2560
+ * @param payload.kind - Position type: "long" or "short"
2561
+ * @returns Object indicating if update was successful with old/new risk values
2562
+ */
2563
+ updateRiskOnEmpty(): Promise<{
2564
+ updated: boolean;
2565
+ symbol: any;
2566
+ kind: any;
2567
+ old_risk: number;
2568
+ new_risk: number;
2569
+ reason?: undefined;
2570
+ } | {
2571
+ updated: boolean;
2572
+ symbol: any;
2573
+ kind: any;
2574
+ reason: string;
2575
+ old_risk?: undefined;
2576
+ new_risk?: undefined;
2577
+ }>;
2578
+ increasePositionAtStop(payload: {
2579
+ place?: boolean;
2580
+ price?: number;
2581
+ quantity?: number;
2582
+ increase?: boolean;
2583
+ ratio_to_loose?: number;
2584
+ reverse_position?: ExchangePosition;
2585
+ increase_ratio?: number;
2586
+ }): Promise<any>;
2587
+ lockReduction({ pnl, place, pause_tp, }: {
2588
+ pnl: number;
2589
+ place?: boolean;
2590
+ pause_tp?: boolean;
2591
+ }): Promise<{
2592
+ sell_ratio: number;
2593
+ current_pnl: number;
2594
+ profit_percent: number;
2595
+ current_price: number;
2596
+ notional_value: number;
2597
+ }>;
2598
+ placeSingleOrder(payload: {
2599
+ long_position: ExchangePosition;
2600
+ short_position: ExchangePosition;
2601
+ }): Promise<string>;
2602
+ placeMarketOrder(payload: {
2603
+ quantity?: number;
2604
+ close?: boolean;
2605
+ }): Promise<void>;
2606
+ generate_config_params(payload: {
2607
+ entry: number;
2608
+ stop: number;
2609
+ risk_reward: number;
2610
+ risk: number;
2611
+ with_trades?: boolean;
2612
+ }): Promise<any>;
2613
+ extrapolateConfig(payload: {
2614
+ risk_reward?: number;
2615
+ risk?: number;
2616
+ kind?: "long" | "short";
2617
+ }): Promise<any>;
2618
+ build_short_order(): Promise<any>;
2619
+ /**
2620
+ * This function builds a config for a symbol
2621
+ * @param payload
2622
+ * @returns
2623
+ */
2624
+ buildConfigForSymbol(payload: {
2625
+ risk: number;
2626
+ risk_reward?: number;
2627
+ as_config?: boolean;
2628
+ with_trades?: boolean;
2629
+ }): Promise<any>;
2630
+ buildTrades(payload: {
2631
+ risk?: number;
2632
+ }): Promise<{
2633
+ trades: any[];
2634
+ max_size: any;
2635
+ last_price: any;
2636
+ total_size: number;
2637
+ avg_entry: number;
2638
+ }>;
2639
+ tradeConfig(payload: {
2640
+ override?: any;
2641
+ }): Promise<AppConfig>;
2642
+ getOrCreatePositionConfig(payload: {
2643
+ risk?: number;
2644
+ risk_reward?: number;
2645
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
2646
+ getOppositeConfig(payload: {
2647
+ ratio?: number;
2648
+ }): {
2649
+ entry: number;
2650
+ stop: number;
2651
+ risk: number;
2652
+ risk_reward: number | {
2653
+ result: any[];
2654
+ value: number;
2655
+ total: number;
2656
+ risk_per_trade: number;
2657
+ max: number;
2658
+ min: number;
2659
+ avg_size: any;
2660
+ neg_pnl: any;
2661
+ entry: any;
2662
+ };
2663
+ };
2664
+ getOptimumRiskReward(): Promise<number | {
2665
+ result: any[];
2666
+ value: number;
2667
+ total: number;
2668
+ risk_per_trade: number;
2669
+ max: number;
2670
+ min: number;
2671
+ avg_size: any;
2672
+ neg_pnl: any;
2673
+ entry: any;
2674
+ }>;
2675
+ get appConfig(): {
2676
+ fee: number;
2677
+ risk_per_trade: number;
2678
+ risk_reward: number;
2679
+ symbol?: string;
2680
+ focus: number;
2681
+ budget: number;
2682
+ support: number;
2683
+ resistance: number;
2684
+ percent_change: number;
2685
+ tradeSplit?: number;
2686
+ take_profit?: number;
2687
+ kind: "long" | "short";
2688
+ entry: number;
2689
+ stop: number;
2690
+ min_size: number;
2691
+ price_places?: string;
2692
+ strategy?: "quantity" | "entry";
2693
+ as_array?: boolean;
2694
+ decimal_places?: string;
2695
+ min_profit?: number;
2696
+ raw?: boolean;
2697
+ gap?: number;
2698
+ rr?: number;
2699
+ max_size?: number;
2700
+ last_value?: any;
2701
+ max_quantity?: number;
2702
+ kelly?: {
2703
+ use_kelly?: boolean;
2704
+ kelly_confidence_factor?: number;
2705
+ kelly_minimum_risk?: number;
2706
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2707
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
2708
+ };
2709
+ distribution?: GetEntriesParams["distribution"];
2710
+ distribution_params?: {
2711
+ curveFactor?: number;
2712
+ stdDevFactor?: number;
2713
+ lambda?: number;
2714
+ };
2715
+ };
2716
+ updateProfitPercentWithRisk(payload: {
2717
+ focus_position: ExchangePosition;
2718
+ }): Promise<{
2719
+ profit_percent: number;
2720
+ take_profit: number;
2721
+ last_order: number;
2722
+ }>;
2723
+ getOrders(payload: {
2724
+ type?: "limit" | "stop" | "tp";
2725
+ }): {
2726
+ symbol: any;
2727
+ price: any;
2728
+ quantity: any;
2729
+ kind: any;
2730
+ side: any;
2731
+ stop: any;
2732
+ order_id: any;
2733
+ triggerPrice: any;
2734
+ client_order_id: any;
2735
+ }[];
2736
+ cancelExchangeOrder(payload: {
2737
+ type: "limit" | "stop" | "tp";
2738
+ refresh?: boolean;
2739
+ }): Promise<any>;
2740
+ placeDangerousTrade(payload: {
2741
+ entry: number;
2742
+ quantity: number;
2743
+ stop?: number;
2744
+ }): {
2745
+ entry: number;
2746
+ risk: number;
2747
+ stop: number;
2748
+ risk_reward: number | {
2749
+ result: any[];
2750
+ value: number;
2751
+ total: number;
2752
+ risk_per_trade: number;
2753
+ max: number;
2754
+ min: number;
2755
+ avg_size: any;
2756
+ neg_pnl: any;
2757
+ entry: any;
2758
+ };
2759
+ };
2760
+ followStop(payload: {
2761
+ focus_position: ExchangePosition;
2762
+ fee_percent?: number;
2763
+ place?: boolean;
2764
+ }): Promise<any>;
2765
+ get support(): SupportTable;
2766
+ get linkedConfig(): ScheduledTrade;
2767
+ get isActiveTrade(): {
2768
+ config: ScheduledTrade;
2769
+ condition: boolean;
2770
+ };
2771
+ updateCompound(payload?: {
2772
+ place?: boolean;
2773
+ }): Promise<{
2774
+ support: number;
2775
+ counter: number;
2776
+ new_risk: number;
2777
+ condition: boolean;
2778
+ stop: number;
2779
+ }>;
2780
+ cleanOnActiveCompoundInstance(): Promise<void>;
2781
+ }
2782
+ declare class ExchangeAccount$1 {
2783
+ instance: {
2784
+ owner: string;
2785
+ exchange: string;
2786
+ };
2787
+ exchange: BaseExchange;
2788
+ main_exchange?: BaseExchange;
2789
+ private app_db;
2790
+ long_position?: ExchangePosition;
2791
+ short_position?: ExchangePosition;
2792
+ raw_positions?: PositionsView[];
2793
+ constructor(payload: ExchangeType, options: {
2794
+ exchange: BaseExchange;
2795
+ app_db: AppDatabase;
2796
+ main_exchange?: BaseExchange;
2797
+ });
2798
+ /**
2799
+ *In order to avoid rate limiting issues, we cache the live exchange
2800
+ details for each symbol for an account in the database with an option
2801
+ to refresh.
2802
+ */
2803
+ getDBInstance(): AppDatabase;
2804
+ getLiveExchangeInstance(payload: {
2805
+ symbol: string;
2806
+ refresh?: boolean;
2807
+ refresh_symbol_config?: boolean;
2808
+ }): Promise<import("pocketbase").RecordModel>;
2809
+ initializePositions(payload: {
2810
+ symbol: string;
2811
+ kind: "long" | "short";
2812
+ update?: boolean;
2813
+ }): Promise<ExchangePosition>;
2814
+ getActiveAccount(payload: {
2815
+ symbol: string;
2816
+ full?: boolean;
2817
+ refresh?: boolean;
2818
+ }): Promise<Account | {
2819
+ liquidation: {
2820
+ long: number;
2821
+ short: number;
2822
+ };
2823
+ active_account: Account;
2824
+ current_price: any;
2825
+ exchange: any;
2826
+ }>;
2827
+ refreshAccount(payload: {
2828
+ symbol: string;
2829
+ live_refresh?: boolean;
2830
+ leverage?: number;
2831
+ }): Promise<(PositionsView & {
2832
+ expand?: {
2833
+ config: ScheduledTrade;
2834
+ account: ExchangeAccount;
2835
+ proxy: Proxy$1;
2836
+ };
2837
+ })[]>;
2838
+ syncAccount(options: {
2839
+ symbol: string;
2840
+ kind?: "long" | "short";
2841
+ update?: boolean;
2842
+ as_view?: boolean;
2843
+ leverage?: number;
2844
+ live_refresh?: boolean;
2845
+ }): Promise<PositionsView | (PositionsView & {
2846
+ expand?: {
2847
+ config: ScheduledTrade;
2848
+ account: ExchangeAccount;
2849
+ proxy: Proxy$1;
2850
+ };
2851
+ })[]>;
2852
+ syncOrders(options: {
2853
+ symbol: string;
2854
+ kind?: "long" | "short";
2855
+ update?: boolean;
2856
+ }): Promise<void | Order[]>;
2857
+ toggleStopBuying(payload: {
2858
+ symbol: string;
2859
+ kind: "long" | "short";
2860
+ should_stop?: boolean;
2861
+ }): Promise<import("pocketbase").RecordModel>;
2862
+ getFocusPosition(payload: {
2863
+ symbol: string;
2864
+ kind: "long" | "short";
2865
+ update?: boolean;
2866
+ }): Promise<ExchangePosition>;
2867
+ cancelOrders(payload: {
2868
+ symbol: string;
2869
+ kind: "long" | "short";
2870
+ price?: number;
2871
+ all?: boolean;
2872
+ stop?: boolean;
2873
+ limit?: boolean;
2874
+ raw?: boolean;
2875
+ }): Promise<any[] | {
2876
+ success: boolean;
2877
+ message: string;
2878
+ exchange_result?: undefined;
2879
+ error?: undefined;
2880
+ } | {
2881
+ success: boolean;
2882
+ exchange_result: any;
2883
+ message?: undefined;
2884
+ error?: undefined;
2885
+ } | {
2886
+ success: boolean;
2887
+ error: any;
2888
+ message?: undefined;
2889
+ exchange_result?: undefined;
2890
+ }>;
2891
+ cancelExchangeOrders(payload: {
2892
+ symbol: string;
2893
+ orders: number[];
2894
+ }): Promise<any>;
2895
+ getBreakEvenPrice(payload: {
2896
+ symbol: string;
2897
+ }): Promise<{
2898
+ price: number;
2899
+ direction: string;
2900
+ }>;
2901
+ tradeConfig(payload: {
2902
+ symbol: string;
576
2903
  kind: "long" | "short";
577
- decimal_places?: string;
578
- price_places?: string;
2904
+ override?: any;
2905
+ }): Promise<AppConfig>;
2906
+ justInTimeProfit(payload: {
579
2907
  symbol: string;
2908
+ target_pnl: number;
2909
+ kind: "long" | "short";
2910
+ refresh?: boolean;
580
2911
  place?: boolean;
581
- }): Promise<any[]>;
582
- placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
2912
+ take_profit?: number;
2913
+ pause_tp?: boolean;
2914
+ }): Promise<{
2915
+ sell_ratio: number;
2916
+ current_pnl: number;
2917
+ profit_percent: number;
2918
+ current_price: number;
2919
+ notional_value: number;
2920
+ }>;
2921
+ buildTrades(payload: {
2922
+ symbol: string;
2923
+ kind: "long" | "short";
2924
+ risk?: number;
2925
+ }): Promise<{
2926
+ trades: any[];
2927
+ max_size: any;
2928
+ last_price: any;
2929
+ total_size: number;
2930
+ avg_entry: number;
2931
+ }>;
2932
+ placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders" | "dangerous_entry_orders", payload: {
583
2933
  symbol: string;
584
2934
  entry: number;
585
2935
  stop: number;
@@ -588,7 +2938,15 @@ declare class ExchangeAccount$1 {
588
2938
  place?: boolean;
589
2939
  update_db?: boolean;
590
2940
  raw?: boolean;
2941
+ use_current?: boolean;
2942
+ stop_percent?: number;
591
2943
  }): Promise<any>;
2944
+ getOrCreatePositionConfig(payload: {
2945
+ symbol: string;
2946
+ kind: "long" | "short";
2947
+ risk?: number;
2948
+ risk_reward?: number;
2949
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
592
2950
  getPositionConfig(payload: {
593
2951
  symbol: string;
594
2952
  kind: "long" | "short";
@@ -601,16 +2959,16 @@ declare class ExchangeAccount$1 {
601
2959
  place_tp?: boolean;
602
2960
  profit?: number;
603
2961
  };
604
- }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
2962
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
605
2963
  getCurrentPrice(symbol: string): Promise<any>;
606
- getPositionStrategy(): Promise<{
607
- strategy_instance: Strategy;
608
- focus_account: ExchangeAccount;
609
- }>;
2964
+ getAccountStrategy(payload: {
2965
+ symbol: string;
2966
+ }): Promise<AccountStrategy>;
610
2967
  buildReduceConfig(payload: {
611
2968
  symbol: string;
612
2969
  kind?: "long" | "short";
613
2970
  as_dict?: boolean;
2971
+ target_pnl?: number;
614
2972
  trigger?: {
615
2973
  long: boolean;
616
2974
  short: boolean;
@@ -640,6 +2998,7 @@ declare class ExchangeAccount$1 {
640
2998
  not_reduce: boolean;
641
2999
  ratio: any;
642
3000
  use_full: boolean;
3001
+ sell_ratio: any;
643
3002
  };
644
3003
  short: {
645
3004
  minimum_pnl: number;
@@ -649,6 +3008,7 @@ declare class ExchangeAccount$1 {
649
3008
  not_reduce: boolean;
650
3009
  ratio: any;
651
3010
  use_full: boolean;
3011
+ sell_ratio: number;
652
3012
  };
653
3013
  trigger: {
654
3014
  long: boolean;
@@ -678,16 +3038,9 @@ declare class ExchangeAccount$1 {
678
3038
  trigger?: boolean;
679
3039
  refresh?: boolean;
680
3040
  kind?: "long" | "short";
3041
+ target_pnl?: number;
681
3042
  }): Promise<any>;
682
3043
  reEnterPositionOnEmpty(symbol: string): Promise<void>;
683
- generate_config_params(payload: {
684
- entry: number;
685
- stop: number;
686
- risk_reward: number;
687
- risk: number;
688
- symbol: string;
689
- with_trades?: boolean;
690
- }): Promise<any>;
691
3044
  build_short_order(payload: {
692
3045
  symbol: string;
693
3046
  kind: "long" | "short";
@@ -698,18 +3051,48 @@ declare class ExchangeAccount$1 {
698
3051
  risk_reward?: number;
699
3052
  risk?: number;
700
3053
  }): Promise<any>;
3054
+ placeMarketOrder(payload: {
3055
+ symbol: string;
3056
+ kind: "long" | "short";
3057
+ quantity?: number;
3058
+ close?: boolean;
3059
+ }): Promise<void>;
3060
+ placeSingleOrder(payload: {
3061
+ symbol: string;
3062
+ kind: "long" | "short";
3063
+ }): Promise<string>;
3064
+ followStop(payload: {
3065
+ symbol: string;
3066
+ kind: "long" | "short";
3067
+ fee_percent?: number;
3068
+ focus_position: ExchangePosition;
3069
+ place?: boolean;
3070
+ }): Promise<any>;
3071
+ increasePositionAtStop(payload: {
3072
+ symbol: string;
3073
+ kind: "long" | "short";
3074
+ place?: boolean;
3075
+ price?: number;
3076
+ quantity?: number;
3077
+ increase?: boolean;
3078
+ ratio_to_loose?: number;
3079
+ }): Promise<any>;
701
3080
  triggerTradeFromConfig(payload: {
702
3081
  symbol: string;
703
3082
  kind: "long" | "short";
704
3083
  place?: boolean;
705
3084
  raw?: boolean;
706
3085
  tp?: boolean;
3086
+ stop?: boolean;
3087
+ use_current?: boolean;
3088
+ ignore_config?: boolean;
3089
+ risky?: boolean;
707
3090
  }): Promise<any>;
708
3091
  verifyStopLoss(payload: {
709
3092
  symbol: string;
710
3093
  kind: "long" | "short";
711
3094
  revert?: boolean;
712
- }): Promise<import("pocketbase").RecordModel[]>;
3095
+ }): Promise<void | Order[]>;
713
3096
  windDownSymbol(payload: {
714
3097
  symbol: string;
715
3098
  risk_reward?: number;
@@ -718,7 +3101,159 @@ declare class ExchangeAccount$1 {
718
3101
  updateTargetPnl(payload: {
719
3102
  symbol: string;
720
3103
  kind: "long" | "short";
721
- }): Promise<number>;
3104
+ }): Promise<any>;
3105
+ updateRiskOnEmpty(payload: {
3106
+ symbol: string;
3107
+ kind: "long" | "short";
3108
+ }): Promise<{
3109
+ updated: boolean;
3110
+ symbol: any;
3111
+ kind: any;
3112
+ old_risk: number;
3113
+ new_risk: number;
3114
+ reason?: undefined;
3115
+ } | {
3116
+ updated: boolean;
3117
+ symbol: any;
3118
+ kind: any;
3119
+ reason: string;
3120
+ old_risk?: undefined;
3121
+ new_risk?: undefined;
3122
+ }>;
3123
+ updateGoodHedgeConfig(payload: {
3124
+ symbol: string;
3125
+ params?: {
3126
+ support: number;
3127
+ resistance: number;
3128
+ risk: number;
3129
+ profit_percent: number;
3130
+ };
3131
+ risk_factor?: number;
3132
+ update?: boolean;
3133
+ place?: boolean;
3134
+ update_tp?: boolean;
3135
+ }): Promise<{
3136
+ support: number;
3137
+ resistance: number;
3138
+ risk: number;
3139
+ profit_percent: number;
3140
+ }>;
3141
+ /**
3142
+ * This method is used to place the opposite trade action
3143
+ */
3144
+ placeOppositeTradeAction(payload: {
3145
+ symbol: string;
3146
+ kind: "long" | "short";
3147
+ data: {
3148
+ avg: {
3149
+ quantity: number;
3150
+ price: number;
3151
+ };
3152
+ entry: number;
3153
+ stop: number;
3154
+ risk_per_trade: number;
3155
+ profit_percent: number;
3156
+ risk_reward: number;
3157
+ };
3158
+ }): Promise<void>;
3159
+ buildOppositeTrades(payload: {
3160
+ symbol: string;
3161
+ kind: "long" | "short";
3162
+ place?: boolean;
3163
+ place_symbol?: string;
3164
+ }): Promise<{
3165
+ avg: {
3166
+ entry: number;
3167
+ price: number;
3168
+ quantity: number;
3169
+ };
3170
+ loss: number;
3171
+ profit_percent: number;
3172
+ fee: number;
3173
+ risk_per_trade: number;
3174
+ risk_reward: number;
3175
+ symbol?: string;
3176
+ focus: number;
3177
+ budget: number;
3178
+ support: number;
3179
+ resistance: number;
3180
+ percent_change: number;
3181
+ tradeSplit?: number;
3182
+ take_profit?: number;
3183
+ kind: "long" | "short";
3184
+ entry: number;
3185
+ stop: number;
3186
+ min_size: number;
3187
+ price_places?: string;
3188
+ strategy?: "quantity" | "entry";
3189
+ as_array?: boolean;
3190
+ decimal_places?: string;
3191
+ min_profit?: number;
3192
+ raw?: boolean;
3193
+ gap?: number;
3194
+ rr?: number;
3195
+ max_size?: number;
3196
+ max_quantity?: number;
3197
+ kelly?: {
3198
+ use_kelly?: boolean;
3199
+ kelly_confidence_factor?: number;
3200
+ kelly_minimum_risk?: number;
3201
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
3202
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
3203
+ };
3204
+ distribution?: GetEntriesParams["distribution"];
3205
+ distribution_params?: {
3206
+ curveFactor?: number;
3207
+ stdDevFactor?: number;
3208
+ lambda?: number;
3209
+ };
3210
+ }>;
3211
+ runSimulation(payload: {
3212
+ symbol: string;
3213
+ kind: "long" | "short";
3214
+ iterations?: number;
3215
+ raw?: boolean;
3216
+ }): Promise<Strategy | {
3217
+ last_entry: any;
3218
+ first_entry: any;
3219
+ threshold: any;
3220
+ risk: number;
3221
+ risk_reward: number;
3222
+ spread: number;
3223
+ gap_loss: number;
3224
+ net_profit: number;
3225
+ long: {
3226
+ avg_entry: number;
3227
+ avg_size: number;
3228
+ loss: number;
3229
+ stop: number;
3230
+ stop_quantity: number;
3231
+ re_entry_quantity: number;
3232
+ initial_pnl: number;
3233
+ tp: number;
3234
+ incurred_loss: number;
3235
+ pnl: number;
3236
+ remaining_quantity: number;
3237
+ };
3238
+ short: {
3239
+ avg_entry: number;
3240
+ avg_size: number;
3241
+ loss: number;
3242
+ stop: number;
3243
+ stop_quantity: number;
3244
+ re_entry_quantity: number;
3245
+ initial_pnl: number;
3246
+ tp: number;
3247
+ incurred_loss: number;
3248
+ pnl: number;
3249
+ remaining_quantity: number;
3250
+ };
3251
+ }[]>;
3252
+ getCurrentRun(payload: {
3253
+ symbol: string;
3254
+ kind?: "long" | "short";
3255
+ pnl?: number;
3256
+ }): Promise<true | import("pocketbase").RecordModel>;
722
3257
  recomputeSymbolConfig(payload: {
723
3258
  symbol: string;
724
3259
  refresh?: boolean;
@@ -756,8 +3291,7 @@ declare class ExchangeAccount$1 {
756
3291
  symbol: string;
757
3292
  kind: "long" | "short";
758
3293
  type: "limit" | "stop" | "tp";
759
- refresh?: boolean;
760
- }): Promise<import("pocketbase").RecordModel[]>;
3294
+ }): Promise<Order[]>;
761
3295
  syncPositionConfigs(payload: {
762
3296
  symbol: string;
763
3297
  kind: "long" | "short";
@@ -774,20 +3308,235 @@ declare class ExchangeAccount$1 {
774
3308
  symbol: string;
775
3309
  kind: "long" | "short";
776
3310
  }): Promise<number>;
3311
+ placeStopLimit(payload: {
3312
+ symbol: string;
3313
+ kind: "long" | "short";
3314
+ place?: boolean;
3315
+ stop: number;
3316
+ quantity?: number;
3317
+ }): Promise<any>;
3318
+ placeDangerousTrade(payload: {
3319
+ symbol: string;
3320
+ config: {
3321
+ entry: number;
3322
+ quantity: number;
3323
+ stop: number;
3324
+ };
3325
+ kind: "long" | "short";
3326
+ }): Promise<{
3327
+ entry: number;
3328
+ risk: number;
3329
+ stop: number;
3330
+ risk_reward: number | {
3331
+ result: any[];
3332
+ value: number;
3333
+ total: number;
3334
+ risk_per_trade: number;
3335
+ max: number;
3336
+ min: number;
3337
+ avg_size: any;
3338
+ neg_pnl: any;
3339
+ entry: any;
3340
+ };
3341
+ }>;
777
3342
  placeTrade(payload: {
778
3343
  symbol: string;
779
3344
  kind: "long" | "short";
780
3345
  place?: boolean;
3346
+ limit?: boolean;
781
3347
  tp?: boolean;
3348
+ stop?: boolean;
3349
+ raw?: boolean;
3350
+ cancel?: boolean;
3351
+ ignore_config?: boolean;
3352
+ target_pnl?: number;
3353
+ risky?: boolean;
782
3354
  }): Promise<any>;
3355
+ updateConfigPnl(payload: {
3356
+ symbol: string;
3357
+ kind: "long" | "short";
3358
+ }): Promise<void>;
3359
+ determineReduceTp(payload: {
3360
+ symbol: string;
3361
+ factor: number;
3362
+ }): Promise<{
3363
+ long_diff: number;
3364
+ short_diff: number;
3365
+ gap: number;
3366
+ gap_cost: number;
3367
+ long_tp: number;
3368
+ short_tp: number;
3369
+ long_percent: number;
3370
+ short_percent: number;
3371
+ }>;
3372
+ oppositeGapExists(payload: {
3373
+ symbol: string;
3374
+ kind: "long" | "short";
3375
+ }): Promise<void>;
3376
+ profitWithinGapStrategy(payload: {
3377
+ symbol: string;
3378
+ callback?: (params: {
3379
+ symbol: string;
3380
+ account: ExchangeType;
3381
+ kind: "long" | "short";
3382
+ }) => Promise<any>;
3383
+ }): Promise<{
3384
+ config_details: {
3385
+ app_config: {
3386
+ fee: number;
3387
+ risk_per_trade: number;
3388
+ risk_reward: number;
3389
+ symbol?: string;
3390
+ focus: number;
3391
+ budget: number;
3392
+ support: number;
3393
+ resistance: number;
3394
+ percent_change: number;
3395
+ tradeSplit?: number;
3396
+ take_profit?: number;
3397
+ kind: "long" | "short";
3398
+ entry: number;
3399
+ stop: number;
3400
+ min_size: number;
3401
+ price_places?: string;
3402
+ strategy?: "quantity" | "entry";
3403
+ as_array?: boolean;
3404
+ decimal_places?: string;
3405
+ min_profit?: number;
3406
+ raw?: boolean;
3407
+ gap?: number;
3408
+ rr?: number;
3409
+ max_size?: number;
3410
+ max_quantity?: number;
3411
+ kelly?: {
3412
+ use_kelly?: boolean;
3413
+ kelly_confidence_factor?: number;
3414
+ kelly_minimum_risk?: number;
3415
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
3416
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
3417
+ };
3418
+ distribution?: GetEntriesParams["distribution"];
3419
+ distribution_params?: {
3420
+ curveFactor?: number;
3421
+ stdDevFactor?: number;
3422
+ lambda?: number;
3423
+ };
3424
+ };
3425
+ last_value: any;
3426
+ };
3427
+ }>;
3428
+ generateGapTp(payload: {
3429
+ symbol: string;
3430
+ factor?: number;
3431
+ }): Promise<{
3432
+ profit_percent: {
3433
+ long: number;
3434
+ short: number;
3435
+ };
3436
+ risk: {
3437
+ short: number;
3438
+ long: number;
3439
+ };
3440
+ take_profit: {
3441
+ long: number;
3442
+ short: number;
3443
+ };
3444
+ to_reduce: {
3445
+ short: number;
3446
+ long: number;
3447
+ };
3448
+ full_reduce: {
3449
+ short: number;
3450
+ long: number;
3451
+ };
3452
+ sell_quantity: {
3453
+ short: number;
3454
+ long: number;
3455
+ };
3456
+ gap: number;
3457
+ gap_loss: number;
3458
+ }>;
3459
+ getSellPriceFromStrategy(payload: {
3460
+ symbol: string;
3461
+ reduce_position: PositionsView;
3462
+ kind?: "long" | "short";
3463
+ full_ratio?: number;
3464
+ }): Promise<{
3465
+ pnl: number;
3466
+ loss: number;
3467
+ full_loss: number;
3468
+ original_pnl: number;
3469
+ reward_factor: number;
3470
+ profit_percent: number;
3471
+ kind: "long" | "short";
3472
+ sell_price: number;
3473
+ quantity: number;
3474
+ price_places: string;
3475
+ decimal_places: string;
3476
+ }>;
3477
+ placeCompoundShortTrade(payload: {}): Promise<void>;
3478
+ placeCompoundLongTrade(payload: {
3479
+ symbol: string;
3480
+ params: {
3481
+ resistance: number;
3482
+ support: number;
3483
+ profit_percent: number;
3484
+ risk_reward: number;
3485
+ risk: number;
3486
+ };
3487
+ place?: boolean;
3488
+ }): Promise<void>;
3489
+ getConfigProfiles(payload: {
3490
+ symbol: string;
3491
+ kind: "long" | "short";
3492
+ }): Promise<{
3493
+ id: any;
3494
+ entry: any;
3495
+ stop: any;
3496
+ kind: "long" | "short";
3497
+ risk_reward: any;
3498
+ risk: any;
3499
+ profit_percent: any;
3500
+ }[]>;
783
3501
  }
3502
+ declare function getExchangeAccount(payload: {
3503
+ account: ExchangeType;
3504
+ app_db: AppDatabase;
3505
+ getCredentials: (payload: {
3506
+ account: string;
3507
+ exchange: string;
3508
+ app_db: AppDatabase;
3509
+ }) => Promise<{
3510
+ api_key: string;
3511
+ api_secret: string;
3512
+ email: string;
3513
+ }>;
3514
+ proxyOptions?: {
3515
+ proxy?: any;
3516
+ ignore_proxy?: boolean;
3517
+ };
3518
+ canWithdraw?: boolean;
3519
+ }): Promise<ExchangeAccount$1>;
784
3520
  declare class App {
785
- private app_db;
3521
+ app_db: AppDatabase;
3522
+ proxyOptions?: {
3523
+ proxy?: any;
3524
+ ignore_proxy?: boolean;
3525
+ canWithdraw?: boolean;
3526
+ };
786
3527
  private getCredentials;
787
- constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
3528
+ constructor(app_db: AppDatabase, getCredentials: (payload: {
3529
+ account: string;
3530
+ exchange: string;
3531
+ }) => Promise<{
788
3532
  api_key: string;
789
3533
  api_secret: string;
790
- }>);
3534
+ email: string;
3535
+ }>, proxyOptions?: {
3536
+ proxy?: any;
3537
+ ignore_proxy?: boolean;
3538
+ canWithdraw?: boolean;
3539
+ });
791
3540
  getExchangeAccount(account: ExchangeType): Promise<ExchangeAccount$1>;
792
3541
  syncAccount(payload: {
793
3542
  account: ExchangeType;
@@ -799,13 +3548,14 @@ declare class App {
799
3548
  expand?: {
800
3549
  config: ScheduledTrade;
801
3550
  account: ExchangeAccount;
3551
+ proxy: Proxy$1;
802
3552
  };
803
3553
  })[]>;
804
3554
  syncOrders(payload: {
805
3555
  account: ExchangeType;
806
3556
  symbol: string;
807
3557
  kind: "long" | "short";
808
- }): Promise<any>;
3558
+ }): Promise<boolean>;
809
3559
  cancelOrders(payload: {
810
3560
  account: ExchangeType;
811
3561
  symbol: string;
@@ -813,7 +3563,7 @@ declare class App {
813
3563
  price?: number;
814
3564
  all?: boolean;
815
3565
  stop?: boolean;
816
- }): Promise<{
3566
+ }): Promise<any[] | {
817
3567
  success: boolean;
818
3568
  message: string;
819
3569
  exchange_result?: undefined;
@@ -829,23 +3579,6 @@ declare class App {
829
3579
  message?: undefined;
830
3580
  exchange_result?: undefined;
831
3581
  }>;
832
- generateConfig(payload: {
833
- account: ExchangeType;
834
- symbol: string;
835
- kind: "long" | "short";
836
- update_orders?: boolean;
837
- place_orders?: boolean;
838
- }): Promise<any>;
839
- updateReduceRatio(payload: {
840
- account: ExchangeType;
841
- symbol: string;
842
- }): Promise<{
843
- long_position: any;
844
- short_position: any;
845
- long_db_position: any;
846
- short_db_position: any;
847
- balance: any;
848
- }>;
849
3582
  getWindingDownMarkets(): Promise<WindingDownMarket[]>;
850
3583
  updateSymbolConfigs(payload: {
851
3584
  configs: {
@@ -869,9 +3602,16 @@ declare class App {
869
3602
  getNonEssentialSymbols(): Promise<Set<any>>;
870
3603
  refreshAllPositionsWithSymbol(payload: {
871
3604
  symbol: string;
3605
+ callback?: (payload: {
3606
+ symbol: string;
3607
+ account: ExchangeType;
3608
+ }) => Promise<any>;
872
3609
  }): Promise<void>;
3610
+ autoFollowPositions(): Promise<void>;
873
3611
  getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
874
- updateTpOnAllMarkets(): Promise<void>;
3612
+ updateTpOnAllMarkets(callback?: (payload: {
3613
+ account: ExchangeType;
3614
+ }) => Promise<any>): Promise<void>;
875
3615
  triggerMoverTask(payload: {
876
3616
  callback: (params: {
877
3617
  symbol: string;
@@ -882,6 +3622,107 @@ declare class App {
882
3622
  account: ExchangeType;
883
3623
  }) => Promise<any>;
884
3624
  }): Promise<void>;
3625
+ placeTrade(payload: {
3626
+ account: ExchangeType;
3627
+ symbol: string;
3628
+ kind: "long" | "short";
3629
+ place?: boolean;
3630
+ tp?: boolean;
3631
+ cancel?: boolean;
3632
+ raw?: boolean;
3633
+ }): Promise<any>;
3634
+ runDbStrategyAccounts(payload: {
3635
+ runningCallback: (params: {
3636
+ symbol: string;
3637
+ account: ExchangeType;
3638
+ }) => Promise<any>;
3639
+ notRunningCallback: (params: {
3640
+ symbol: string;
3641
+ account: ExchangeType;
3642
+ kind: "long" | "short";
3643
+ }) => Promise<any>;
3644
+ }): Promise<void>;
3645
+ profitWithinGapStrategy(payload: {
3646
+ account: ExchangeType;
3647
+ symbol: string;
3648
+ }): Promise<{
3649
+ config_details: {
3650
+ app_config: {
3651
+ fee: number;
3652
+ risk_per_trade: number;
3653
+ risk_reward: number;
3654
+ symbol?: string;
3655
+ focus: number;
3656
+ budget: number;
3657
+ support: number;
3658
+ resistance: number;
3659
+ percent_change: number;
3660
+ tradeSplit?: number;
3661
+ take_profit?: number;
3662
+ kind: "long" | "short";
3663
+ entry: number;
3664
+ stop: number;
3665
+ min_size: number;
3666
+ price_places?: string;
3667
+ strategy?: "quantity" | "entry";
3668
+ as_array?: boolean;
3669
+ decimal_places?: string;
3670
+ min_profit?: number;
3671
+ raw?: boolean;
3672
+ gap?: number;
3673
+ rr?: number;
3674
+ max_size?: number;
3675
+ max_quantity?: number;
3676
+ kelly?: {
3677
+ use_kelly?: boolean;
3678
+ kelly_confidence_factor?: number;
3679
+ kelly_minimum_risk?: number;
3680
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
3681
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
3682
+ };
3683
+ distribution?: GetEntriesParams["distribution"];
3684
+ distribution_params?: {
3685
+ curveFactor?: number;
3686
+ stdDevFactor?: number;
3687
+ lambda?: number;
3688
+ };
3689
+ };
3690
+ last_value: any;
3691
+ };
3692
+ }>;
3693
+ compoundLongTrade(payload: {
3694
+ main_account: ExchangeType & {
3695
+ symbol: string;
3696
+ };
3697
+ focus_account: ExchangeType & {
3698
+ symbol: string;
3699
+ };
3700
+ place?: boolean;
3701
+ rr?: number;
3702
+ }): Promise<{
3703
+ start_risk: number;
3704
+ short_profit: number;
3705
+ support: number;
3706
+ resistance: number;
3707
+ long_v: any;
3708
+ profit_percent: number;
3709
+ result: any;
3710
+ short_max_size: any;
3711
+ }>;
3712
+ reduceExistingPosition(payload: {
3713
+ main_account: ExchangeType & {
3714
+ symbol: string;
3715
+ kind?: "long" | "short";
3716
+ };
3717
+ reduce_account: ExchangeType & {
3718
+ symbol: string;
3719
+ };
3720
+ kind: "long" | "short";
3721
+ place?: boolean;
3722
+ increase?: boolean;
3723
+ full_ratio?: number;
3724
+ cancel_limit?: boolean;
3725
+ }): Promise<any>;
885
3726
  }
886
3727
  export declare function initApp(payload: {
887
3728
  db: {
@@ -889,15 +3730,50 @@ export declare function initApp(payload: {
889
3730
  email: string;
890
3731
  password: string;
891
3732
  };
892
- getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
3733
+ password?: string;
3734
+ salt?: string;
3735
+ email?: string;
3736
+ getCredentials: (payload: {
3737
+ account: string;
3738
+ exchange: string;
3739
+ app_db: AppDatabase;
3740
+ }) => Promise<{
893
3741
  api_key: string;
894
3742
  api_secret: string;
3743
+ email: string;
895
3744
  }>;
3745
+ proxy?: any;
3746
+ ignore_proxy?: boolean;
3747
+ canWithdraw?: boolean;
3748
+ triggerToken?: string;
3749
+ }): Promise<App>;
3750
+ declare function getCredentials(payload: {
3751
+ account: string;
3752
+ exchange: string;
3753
+ app_db: AppDatabase;
3754
+ }): Promise<any>;
3755
+ export declare function initialize(payload: {
3756
+ password?: string;
3757
+ proxy?: any;
3758
+ ignore_proxy?: boolean;
3759
+ canWithdraw?: boolean;
896
3760
  }): Promise<App>;
897
- export declare function initialize(): Promise<App>;
3761
+
3762
+ declare namespace database {
3763
+ export { AppDatabase, ExchangeType, decryptObject, encryptObject, initPocketBaseClient };
3764
+ }
3765
+ declare namespace exchange_account {
3766
+ export { ExchangeAccount$1 as ExchangeAccount, getExchangeAccount };
3767
+ }
3768
+ declare namespace app {
3769
+ export { App, getCredentials, initApp, initialize };
3770
+ }
898
3771
 
899
3772
  export {
900
3773
  ExchangeAccount$1 as ExchangeAccount,
3774
+ app,
3775
+ database,
3776
+ exchange_account,
901
3777
  };
902
3778
 
903
3779
  export {};