@gbozee/ultimate 0.0.2-18 → 0.0.2-180

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