@gbozee/ultimate 0.0.2-18 → 0.0.2-181

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,2234 @@ 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
+ ratio_to_loose?: number;
2153
+ reverse_position?: ExchangePosition;
2154
+ }): Promise<any>;
2155
+ lockReduction({ pnl, place, pause_tp, }: {
2156
+ pnl: number;
2157
+ place?: boolean;
2158
+ pause_tp?: boolean;
2159
+ }): Promise<{
2160
+ sell_ratio: number;
2161
+ current_pnl: number;
2162
+ profit_percent: number;
2163
+ current_price: number;
2164
+ notional_value: number;
2165
+ }>;
2166
+ placeSingleOrder(payload: {
2167
+ long_position: ExchangePosition;
2168
+ short_position: ExchangePosition;
2169
+ }): Promise<string>;
2170
+ placeMarketOrder(payload: {
2171
+ quantity?: number;
2172
+ close?: boolean;
2173
+ }): Promise<void>;
2174
+ generate_config_params(payload: {
2175
+ entry: number;
2176
+ stop: number;
2177
+ risk_reward: number;
2178
+ risk: number;
2179
+ with_trades?: boolean;
2180
+ }): Promise<any>;
2181
+ extrapolateConfig(payload: {
2182
+ risk_reward?: number;
2183
+ risk?: number;
2184
+ kind?: "long" | "short";
2185
+ }): Promise<any>;
2186
+ build_short_order(): Promise<any>;
2187
+ /**
2188
+ * This function builds a config for a symbol
2189
+ * @param payload
2190
+ * @returns
2191
+ */
2192
+ buildConfigForSymbol(payload: {
2193
+ risk: number;
2194
+ risk_reward?: number;
2195
+ as_config?: boolean;
2196
+ with_trades?: boolean;
2197
+ }): Promise<any>;
2198
+ buildTrades(payload: {
2199
+ risk?: number;
2200
+ }): Promise<{
2201
+ trades: any[];
2202
+ max_size: any;
2203
+ last_price: any;
2204
+ total_size: number;
2205
+ avg_entry: number;
2206
+ }>;
2207
+ tradeConfig(payload: {
2208
+ override?: any;
2209
+ }): Promise<AppConfig>;
2210
+ getOrCreatePositionConfig(payload: {
2211
+ risk?: number;
2212
+ risk_reward?: number;
2213
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
2214
+ getOppositeConfig(payload: {
2215
+ ratio?: number;
2216
+ }): {
2217
+ entry: number;
2218
+ stop: number;
2219
+ risk: number;
2220
+ risk_reward: number | {
2221
+ result: any[];
2222
+ value: number;
2223
+ total: number;
2224
+ risk_per_trade: number;
2225
+ max: number;
2226
+ min: number;
2227
+ neg_pnl: any;
2228
+ entry: any;
2229
+ };
2230
+ };
2231
+ getOptimumRiskReward(): Promise<number | {
2232
+ result: any[];
2233
+ value: number;
2234
+ total: number;
2235
+ risk_per_trade: number;
2236
+ max: number;
2237
+ min: number;
2238
+ neg_pnl: any;
2239
+ entry: any;
2240
+ }>;
2241
+ get appConfig(): {
2242
+ fee: number;
2243
+ risk_per_trade: number;
2244
+ risk_reward: number;
2245
+ symbol?: string;
2246
+ focus: number;
2247
+ budget: number;
2248
+ support: number;
2249
+ resistance: number;
2250
+ percent_change: number;
2251
+ tradeSplit?: number;
2252
+ take_profit?: number;
2253
+ kind: "long" | "short";
2254
+ entry: number;
2255
+ stop: number;
2256
+ min_size: number;
2257
+ price_places?: string;
2258
+ strategy?: "quantity" | "entry";
2259
+ as_array?: boolean;
2260
+ decimal_places?: string;
2261
+ min_profit?: number;
2262
+ raw?: boolean;
2263
+ gap?: number;
2264
+ rr?: number;
2265
+ max_size?: number;
2266
+ last_value?: any;
2267
+ max_quantity?: number;
2268
+ kelly?: {
2269
+ use_kelly?: boolean;
2270
+ kelly_confidence_factor?: number;
2271
+ kelly_minimum_risk?: number;
2272
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2273
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
2274
+ };
2275
+ };
2276
+ updateProfitPercentWithRisk(payload: {
2277
+ focus_position: ExchangePosition;
2278
+ }): Promise<{
2279
+ profit_percent: number;
2280
+ take_profit: number;
2281
+ last_order: number;
2282
+ }>;
2283
+ getOrders(payload: {
2284
+ type?: "limit" | "stop" | "tp";
2285
+ }): {
2286
+ symbol: any;
2287
+ price: any;
2288
+ quantity: any;
2289
+ kind: any;
2290
+ side: any;
2291
+ stop: any;
2292
+ order_id: any;
2293
+ triggerPrice: any;
2294
+ }[];
2295
+ cancelExchangeOrder(payload: {
2296
+ type: "limit" | "stop" | "tp";
2297
+ refresh?: boolean;
2298
+ }): Promise<any>;
2299
+ placeDangerousTrade(payload: {
2300
+ entry: number;
2301
+ quantity: number;
2302
+ stop?: number;
2303
+ }): {
2304
+ entry: number;
2305
+ risk: number;
2306
+ stop: number;
2307
+ risk_reward: number | {
2308
+ result: any[];
2309
+ value: number;
2310
+ total: number;
2311
+ risk_per_trade: number;
2312
+ max: number;
2313
+ min: number;
2314
+ neg_pnl: any;
2315
+ entry: any;
2316
+ };
2317
+ };
2318
+ followStop(payload: {
2319
+ focus_position: ExchangePosition;
2320
+ fee_percent?: number;
2321
+ place?: boolean;
2322
+ }): Promise<any>;
2323
+ get support(): SupportTable;
2324
+ get linkedConfig(): ScheduledTrade;
2325
+ get isActiveTrade(): {
2326
+ config: ScheduledTrade;
2327
+ condition: boolean;
2328
+ };
2329
+ updateCompound(payload?: {
2330
+ place?: boolean;
2331
+ }): Promise<{
2332
+ support: number;
2333
+ counter: number;
2334
+ new_risk: number;
2335
+ condition: boolean;
2336
+ stop: number;
2337
+ }>;
2338
+ cleanOnActiveCompoundInstance(): Promise<void>;
2339
+ }
2340
+ declare class ExchangeAccount$1 {
2341
+ instance: {
2342
+ owner: string;
2343
+ exchange: string;
2344
+ };
2345
+ exchange: BaseExchange;
2346
+ main_exchange?: BaseExchange;
2347
+ private app_db;
2348
+ long_position?: ExchangePosition;
2349
+ short_position?: ExchangePosition;
2350
+ raw_positions?: PositionsView[];
2351
+ constructor(payload: ExchangeType, options: {
2352
+ exchange: BaseExchange;
2353
+ app_db: AppDatabase;
2354
+ main_exchange?: BaseExchange;
2355
+ });
2356
+ /**
2357
+ *In order to avoid rate limiting issues, we cache the live exchange
2358
+ details for each symbol for an account in the database with an option
2359
+ to refresh.
2360
+ */
2361
+ getDBInstance(): AppDatabase;
2362
+ getLiveExchangeInstance(payload: {
2363
+ symbol: string;
2364
+ refresh?: boolean;
2365
+ refresh_symbol_config?: boolean;
2366
+ }): Promise<import("pocketbase").RecordModel>;
2367
+ initializePositions(payload: {
2368
+ symbol: string;
2369
+ kind: "long" | "short";
2370
+ update?: boolean;
2371
+ }): Promise<ExchangePosition>;
2372
+ getActiveAccount(payload: {
2373
+ symbol: string;
2374
+ full?: boolean;
2375
+ refresh?: boolean;
2376
+ }): Promise<Account | {
2377
+ liquidation: {
2378
+ long: number;
2379
+ short: number;
2380
+ };
2381
+ active_account: Account;
2382
+ current_price: any;
2383
+ exchange: any;
2384
+ }>;
2385
+ refreshAccount(payload: {
2386
+ symbol: string;
2387
+ live_refresh?: boolean;
2388
+ leverage?: number;
2389
+ }): Promise<(PositionsView & {
2390
+ expand?: {
2391
+ config: ScheduledTrade;
2392
+ account: ExchangeAccount;
2393
+ proxy: Proxy$1;
2394
+ };
2395
+ })[]>;
2396
+ syncAccount(options: {
446
2397
  symbol: string;
447
- kind: "long" | "short";
2398
+ kind?: "long" | "short";
448
2399
  update?: boolean;
449
- }): Promise<import("pocketbase").RecordModel[]>;
2400
+ as_view?: boolean;
2401
+ leverage?: number;
2402
+ live_refresh?: boolean;
2403
+ }): Promise<PositionsView | (PositionsView & {
2404
+ expand?: {
2405
+ config: ScheduledTrade;
2406
+ account: ExchangeAccount;
2407
+ proxy: Proxy$1;
2408
+ };
2409
+ })[]>;
2410
+ getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
2411
+ syncOrders(options: {
2412
+ symbol: string;
2413
+ kind?: "long" | "short";
2414
+ update?: boolean;
2415
+ }): Promise<void | Order[]>;
450
2416
  toggleStopBuying(payload: {
451
2417
  symbol: string;
452
2418
  kind: "long" | "short";
453
- should_stop?: boolean;
454
- }): Promise<import("pocketbase").RecordModel>;
455
- cancelOrders(payload: {
2419
+ should_stop?: boolean;
2420
+ }): Promise<import("pocketbase").RecordModel>;
2421
+ getFocusPosition(payload: {
2422
+ symbol: string;
2423
+ kind: "long" | "short";
2424
+ update?: boolean;
2425
+ }): Promise<ExchangePosition>;
2426
+ cancelOrders(payload: {
2427
+ symbol: string;
2428
+ kind: "long" | "short";
2429
+ price?: number;
2430
+ all?: boolean;
2431
+ stop?: boolean;
2432
+ limit?: boolean;
2433
+ raw?: boolean;
2434
+ }): Promise<any[] | {
2435
+ success: boolean;
2436
+ message: string;
2437
+ exchange_result?: undefined;
2438
+ error?: undefined;
2439
+ } | {
2440
+ success: boolean;
2441
+ exchange_result: any;
2442
+ message?: undefined;
2443
+ error?: undefined;
2444
+ } | {
2445
+ success: boolean;
2446
+ error: any;
2447
+ message?: undefined;
2448
+ exchange_result?: undefined;
2449
+ }>;
2450
+ cancelExchangeOrders(payload: {
2451
+ symbol: string;
2452
+ orders: number[];
2453
+ }): Promise<any>;
2454
+ getBreakEvenPrice(payload: {
2455
+ symbol: string;
2456
+ }): Promise<{
2457
+ price: number;
2458
+ direction: string;
2459
+ }>;
2460
+ tradeConfig(payload: {
2461
+ symbol: string;
2462
+ kind: "long" | "short";
2463
+ override?: any;
2464
+ }): Promise<AppConfig>;
2465
+ justInTimeProfit(payload: {
2466
+ symbol: string;
2467
+ target_pnl: number;
2468
+ kind: "long" | "short";
2469
+ refresh?: boolean;
2470
+ place?: boolean;
2471
+ take_profit?: number;
2472
+ pause_tp?: boolean;
2473
+ }): Promise<{
2474
+ sell_ratio: number;
2475
+ current_pnl: number;
2476
+ profit_percent: number;
2477
+ current_price: number;
2478
+ notional_value: number;
2479
+ }>;
2480
+ buildTrades(payload: {
2481
+ symbol: string;
2482
+ kind: "long" | "short";
2483
+ risk?: number;
2484
+ }): Promise<{
2485
+ trades: any[];
2486
+ max_size: any;
2487
+ last_price: any;
2488
+ total_size: number;
2489
+ avg_entry: number;
2490
+ }>;
2491
+ placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders" | "dangerous_entry_orders", payload: {
2492
+ symbol: string;
2493
+ entry: number;
2494
+ stop: number;
2495
+ risk_reward: number;
2496
+ risk: number;
2497
+ place?: boolean;
2498
+ update_db?: boolean;
2499
+ raw?: boolean;
2500
+ use_current?: boolean;
2501
+ stop_percent?: number;
2502
+ }): Promise<any>;
2503
+ getOrCreatePositionConfig(payload: {
2504
+ symbol: string;
2505
+ kind: "long" | "short";
2506
+ risk?: number;
2507
+ risk_reward?: number;
2508
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
2509
+ getPositionConfig(payload: {
2510
+ symbol: string;
2511
+ kind: "long" | "short";
2512
+ params?: {
2513
+ entry?: number;
2514
+ stop?: number;
2515
+ risk_reward?: number;
2516
+ risk?: number;
2517
+ profit_percent?: number;
2518
+ place_tp?: boolean;
2519
+ profit?: number;
2520
+ };
2521
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
2522
+ getCurrentPrice(symbol: string): Promise<any>;
2523
+ getAccountStrategy(payload: {
2524
+ symbol: string;
2525
+ }): Promise<AccountStrategy>;
2526
+ buildReduceConfig(payload: {
2527
+ symbol: string;
2528
+ kind?: "long" | "short";
2529
+ as_dict?: boolean;
2530
+ target_pnl?: number;
2531
+ trigger?: {
2532
+ long: boolean;
2533
+ short: boolean;
2534
+ };
2535
+ use_full?: boolean;
2536
+ }): Promise<{
2537
+ trigger_short: boolean;
2538
+ trigger_long: boolean;
2539
+ symbol: string;
2540
+ short_minimum_pnl: number;
2541
+ long_minimum_pnl: number;
2542
+ short_profit: any;
2543
+ long_profit: any;
2544
+ owner: string;
2545
+ exchange: string;
2546
+ not_reduce: boolean;
2547
+ reduce_ratio_long: any;
2548
+ reduce_ratio_short: any;
2549
+ use_full_long: any;
2550
+ use_full_short: any;
2551
+ } | {
2552
+ long: {
2553
+ minimum_pnl: number;
2554
+ max_size: number;
2555
+ profit: any;
2556
+ increase: boolean;
2557
+ not_reduce: boolean;
2558
+ ratio: any;
2559
+ use_full: boolean;
2560
+ sell_ratio: any;
2561
+ };
2562
+ short: {
2563
+ minimum_pnl: number;
2564
+ max_size: number;
2565
+ profit: any;
2566
+ increase: boolean;
2567
+ not_reduce: boolean;
2568
+ ratio: any;
2569
+ use_full: boolean;
2570
+ sell_ratio: any;
2571
+ };
2572
+ trigger: {
2573
+ long: boolean;
2574
+ short: boolean;
2575
+ };
2576
+ }>;
2577
+ getOriginalPlannedStop(payload: {
2578
+ symbol: string;
2579
+ kind: "long" | "short";
2580
+ }): Promise<any>;
2581
+ syncReduceClosePosition(payload?: {
2582
+ symbol: string;
2583
+ kind?: "long" | "short";
2584
+ trigger?: boolean;
2585
+ }): Promise<any>;
2586
+ reduceMajorPositionEntry(payload: {
2587
+ symbol: string;
2588
+ long: any;
2589
+ short: any;
2590
+ trigger: {
2591
+ long: boolean;
2592
+ short: boolean;
2593
+ };
2594
+ }): Promise<any>;
2595
+ placeProfitAndStop(payload: {
2596
+ symbol: string;
2597
+ trigger?: boolean;
2598
+ refresh?: boolean;
2599
+ kind?: "long" | "short";
2600
+ target_pnl?: number;
2601
+ }): Promise<any>;
2602
+ reEnterPositionOnEmpty(symbol: string): Promise<void>;
2603
+ build_short_order(payload: {
2604
+ symbol: string;
2605
+ kind: "long" | "short";
2606
+ }): Promise<any>;
2607
+ extrapolateShortConfig(payload: {
2608
+ kind: "long" | "short";
2609
+ symbol: string;
2610
+ risk_reward?: number;
2611
+ risk?: number;
2612
+ }): Promise<any>;
2613
+ placeMarketOrder(payload: {
2614
+ symbol: string;
2615
+ kind: "long" | "short";
2616
+ quantity?: number;
2617
+ close?: boolean;
2618
+ }): Promise<void>;
2619
+ placeSingleOrder(payload: {
2620
+ symbol: string;
2621
+ kind: "long" | "short";
2622
+ }): Promise<string>;
2623
+ followStop(payload: {
2624
+ symbol: string;
2625
+ kind: "long" | "short";
2626
+ fee_percent?: number;
2627
+ focus_position: ExchangePosition;
2628
+ place?: boolean;
2629
+ }): Promise<any>;
2630
+ increasePositionAtStop(payload: {
2631
+ symbol: string;
2632
+ kind: "long" | "short";
2633
+ place?: boolean;
2634
+ price?: number;
2635
+ quantity?: number;
2636
+ increase?: boolean;
2637
+ ratio_to_loose?: number;
2638
+ }): Promise<any>;
2639
+ triggerTradeFromConfig(payload: {
2640
+ symbol: string;
2641
+ kind: "long" | "short";
2642
+ place?: boolean;
2643
+ raw?: boolean;
2644
+ tp?: boolean;
2645
+ stop?: boolean;
2646
+ use_current?: boolean;
2647
+ ignore_config?: boolean;
2648
+ risky?: boolean;
2649
+ }): Promise<any>;
2650
+ verifyStopLoss(payload: {
2651
+ symbol: string;
2652
+ kind: "long" | "short";
2653
+ revert?: boolean;
2654
+ }): Promise<void | Order[]>;
2655
+ windDownSymbol(payload: {
2656
+ symbol: string;
2657
+ risk_reward?: number;
2658
+ risk?: number;
2659
+ }): Promise<void>;
2660
+ updateTargetPnl(payload: {
2661
+ symbol: string;
2662
+ kind: "long" | "short";
2663
+ }): Promise<any>;
2664
+ updateRiskOnEmpty(payload: {
2665
+ symbol: string;
2666
+ kind: "long" | "short";
2667
+ }): Promise<{
2668
+ updated: boolean;
2669
+ symbol: any;
2670
+ kind: any;
2671
+ old_risk: number;
2672
+ new_risk: number;
2673
+ reason?: undefined;
2674
+ } | {
2675
+ updated: boolean;
2676
+ symbol: any;
2677
+ kind: any;
2678
+ reason: string;
2679
+ old_risk?: undefined;
2680
+ new_risk?: undefined;
2681
+ }>;
2682
+ updateGoodHedgeConfig(payload: {
2683
+ symbol: string;
2684
+ params?: {
2685
+ support: number;
2686
+ resistance: number;
2687
+ risk: number;
2688
+ profit_percent: number;
2689
+ };
2690
+ risk_factor?: number;
2691
+ update?: boolean;
2692
+ place?: boolean;
2693
+ update_tp?: boolean;
2694
+ }): Promise<{
2695
+ support: number;
2696
+ resistance: number;
2697
+ risk: number;
2698
+ profit_percent: number;
2699
+ }>;
2700
+ /**
2701
+ * This method is used to place the opposite trade action
2702
+ */
2703
+ placeOppositeTradeAction(payload: {
2704
+ symbol: string;
2705
+ kind: "long" | "short";
2706
+ data: {
2707
+ avg: {
2708
+ quantity: number;
2709
+ price: number;
2710
+ };
2711
+ entry: number;
2712
+ stop: number;
2713
+ risk_per_trade: number;
2714
+ profit_percent: number;
2715
+ risk_reward: number;
2716
+ };
2717
+ }): Promise<void>;
2718
+ buildOppositeTrades(payload: {
2719
+ symbol: string;
2720
+ kind: "long" | "short";
2721
+ place?: boolean;
2722
+ place_symbol?: string;
2723
+ }): Promise<{
2724
+ avg: {
2725
+ entry: number;
2726
+ price: number;
2727
+ quantity: number;
2728
+ };
2729
+ loss: number;
2730
+ profit_percent: number;
2731
+ fee: number;
2732
+ risk_per_trade: number;
2733
+ risk_reward: number;
2734
+ symbol?: string;
2735
+ focus: number;
2736
+ budget: number;
2737
+ support: number;
2738
+ resistance: number;
2739
+ percent_change: number;
2740
+ tradeSplit?: number;
2741
+ take_profit?: number;
2742
+ kind: "long" | "short";
2743
+ entry: number;
2744
+ stop: number;
2745
+ min_size: number;
2746
+ price_places?: string;
2747
+ strategy?: "quantity" | "entry";
2748
+ as_array?: boolean;
2749
+ decimal_places?: string;
2750
+ min_profit?: number;
2751
+ raw?: boolean;
2752
+ gap?: number;
2753
+ rr?: number;
2754
+ max_size?: number;
2755
+ max_quantity?: number;
2756
+ kelly?: {
2757
+ use_kelly?: boolean;
2758
+ kelly_confidence_factor?: number;
2759
+ kelly_minimum_risk?: number;
2760
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2761
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
2762
+ };
2763
+ }>;
2764
+ runSimulation(payload: {
2765
+ symbol: string;
2766
+ kind: "long" | "short";
2767
+ iterations?: number;
2768
+ raw?: boolean;
2769
+ }): Promise<Strategy | {
2770
+ last_entry: any;
2771
+ first_entry: any;
2772
+ threshold: any;
2773
+ risk: number;
2774
+ risk_reward: number;
2775
+ spread: number;
2776
+ gap_loss: number;
2777
+ net_profit: number;
2778
+ long: {
2779
+ avg_entry: number;
2780
+ avg_size: number;
2781
+ loss: number;
2782
+ stop: number;
2783
+ stop_quantity: number;
2784
+ re_entry_quantity: number;
2785
+ initial_pnl: number;
2786
+ tp: number;
2787
+ incurred_loss: number;
2788
+ pnl: number;
2789
+ remaining_quantity: number;
2790
+ };
2791
+ short: {
2792
+ avg_entry: number;
2793
+ avg_size: number;
2794
+ loss: number;
2795
+ stop: number;
2796
+ stop_quantity: number;
2797
+ re_entry_quantity: number;
2798
+ initial_pnl: number;
2799
+ tp: number;
2800
+ incurred_loss: number;
2801
+ pnl: number;
2802
+ remaining_quantity: number;
2803
+ };
2804
+ }[]>;
2805
+ getCurrentRun(payload: {
2806
+ symbol: string;
2807
+ kind?: "long" | "short";
2808
+ pnl?: number;
2809
+ }): Promise<true | import("pocketbase").RecordModel>;
2810
+ recomputeSymbolConfig(payload: {
2811
+ symbol: string;
2812
+ refresh?: boolean;
2813
+ }): Promise<SymbolConfig>;
2814
+ /**
2815
+ * This function builds a config for a symbol
2816
+ * @param payload
2817
+ * @returns
2818
+ */
2819
+ buildConfigForSymbol(payload: {
2820
+ symbol: string;
2821
+ risk: number;
2822
+ kind?: "long" | "short";
2823
+ risk_reward?: number;
2824
+ as_config?: boolean;
2825
+ with_trades?: boolean;
2826
+ }): Promise<any>;
2827
+ triggerBullishMarket(payload: {
2828
+ symbol: string;
2829
+ profit_percent?: number;
2830
+ risk_reward?: number;
2831
+ }): Promise<any>;
2832
+ updateAllActiveSymbols(payload: {
2833
+ interval?: number;
2834
+ }): Promise<void>;
2835
+ updateAllPositionsWithNoConfig(payload: {
2836
+ kind: "long" | "short";
2837
+ }): Promise<void>;
2838
+ getSymbolsForPositions(): Promise<any[]>;
2839
+ getNonEssentialSymbols(): Promise<any[]>;
2840
+ _terminatePositions(payload: {
2841
+ symbol: string;
2842
+ }): Promise<void>;
2843
+ getOrders(payload: {
2844
+ symbol: string;
2845
+ kind: "long" | "short";
2846
+ type: "limit" | "stop" | "tp";
2847
+ }): Promise<Order[]>;
2848
+ syncPositionConfigs(payload: {
2849
+ symbol: string;
2850
+ kind: "long" | "short";
2851
+ refresh?: boolean;
2852
+ }): Promise<void>;
2853
+ terminatePositions(payload: {
2854
+ symbol: string;
2855
+ }): Promise<void>;
2856
+ fetchAndUpdateTopMovers(): Promise<{
2857
+ updated_bullish: BullishMarket[];
2858
+ moved_to_winding: WindingDownMarket[];
2859
+ }>;
2860
+ computeTargetPnl(payload: {
2861
+ symbol: string;
2862
+ kind: "long" | "short";
2863
+ }): Promise<number>;
2864
+ placeStopLimit(payload: {
2865
+ symbol: string;
2866
+ kind: "long" | "short";
2867
+ place?: boolean;
2868
+ stop: number;
2869
+ quantity?: number;
2870
+ }): Promise<any>;
2871
+ placeDangerousTrade(payload: {
456
2872
  symbol: string;
2873
+ config: {
2874
+ entry: number;
2875
+ quantity: number;
2876
+ stop: number;
2877
+ };
457
2878
  kind: "long" | "short";
458
- price?: number;
459
- all?: boolean;
460
- stop?: boolean;
461
2879
  }): 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
2880
  entry: number;
483
- stop: number;
484
- risk_reward: number;
485
2881
  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
2882
  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;
2883
+ risk_reward: number | {
2884
+ result: any[];
2885
+ value: number;
2886
+ total: number;
2887
+ risk_per_trade: number;
2888
+ max: number;
2889
+ min: number;
2890
+ neg_pnl: any;
2891
+ entry: any;
518
2892
  };
519
- trades: any[];
520
2893
  }>;
521
- placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
2894
+ placeTrade(payload: {
522
2895
  symbol: string;
523
- entry: number;
524
- stop: number;
525
- risk_reward: number;
526
- risk: number;
2896
+ kind: "long" | "short";
527
2897
  place?: boolean;
528
- update_db?: boolean;
2898
+ limit?: boolean;
2899
+ tp?: boolean;
2900
+ stop?: boolean;
2901
+ raw?: boolean;
2902
+ cancel?: boolean;
2903
+ ignore_config?: boolean;
2904
+ target_pnl?: number;
2905
+ risky?: boolean;
529
2906
  }): Promise<any>;
530
- getPositionConfig(payload: {
2907
+ updateConfigPnl(payload: {
531
2908
  symbol: string;
532
2909
  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;
2910
+ }): Promise<void>;
2911
+ determineReduceTp(payload: {
2912
+ symbol: string;
2913
+ factor: number;
2914
+ }): Promise<{
2915
+ long_diff: number;
2916
+ short_diff: number;
2917
+ gap: number;
2918
+ gap_cost: number;
2919
+ long_tp: number;
2920
+ short_tp: number;
2921
+ long_percent: number;
2922
+ short_percent: number;
545
2923
  }>;
546
- getOriginalPlannedStop(payload: {
2924
+ oppositeGapExists(payload: {
547
2925
  symbol: string;
548
2926
  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;
2927
+ }): Promise<void>;
2928
+ profitWithinGapStrategy(payload: {
2929
+ symbol: string;
2930
+ callback?: (params: {
2931
+ symbol: string;
2932
+ account: ExchangeType;
2933
+ kind: "long" | "short";
2934
+ }) => Promise<any>;
2935
+ }): Promise<{
2936
+ config_details: {
2937
+ app_config: {
2938
+ fee: number;
2939
+ risk_per_trade: number;
2940
+ risk_reward: number;
2941
+ symbol?: string;
2942
+ focus: number;
2943
+ budget: number;
2944
+ support: number;
2945
+ resistance: number;
2946
+ percent_change: number;
2947
+ tradeSplit?: number;
2948
+ take_profit?: number;
2949
+ kind: "long" | "short";
2950
+ entry: number;
2951
+ stop: number;
2952
+ min_size: number;
2953
+ price_places?: string;
2954
+ strategy?: "quantity" | "entry";
2955
+ as_array?: boolean;
2956
+ decimal_places?: string;
2957
+ min_profit?: number;
2958
+ raw?: boolean;
2959
+ gap?: number;
2960
+ rr?: number;
2961
+ max_size?: number;
2962
+ max_quantity?: number;
2963
+ kelly?: {
2964
+ use_kelly?: boolean;
2965
+ kelly_confidence_factor?: number;
2966
+ kelly_minimum_risk?: number;
2967
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
2968
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
2969
+ };
2970
+ };
2971
+ last_value: any;
557
2972
  };
558
- }): Promise<any>;
559
- generate_config_params(payload: {
560
- entry: number;
561
- stop: number;
562
- risk_reward: number;
563
- risk: number;
2973
+ }>;
2974
+ generateGapTp(payload: {
564
2975
  symbol: string;
2976
+ factor?: number;
565
2977
  }): 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;
2978
+ profit_percent: {
2979
+ long: number;
2980
+ short: number;
2981
+ };
2982
+ risk: {
2983
+ short: number;
2984
+ long: number;
2985
+ };
2986
+ take_profit: {
2987
+ long: number;
2988
+ short: number;
2989
+ };
2990
+ to_reduce: {
2991
+ short: number;
2992
+ long: number;
2993
+ };
2994
+ full_reduce: {
2995
+ short: number;
2996
+ long: number;
2997
+ };
2998
+ sell_quantity: {
2999
+ short: number;
3000
+ long: number;
3001
+ };
3002
+ gap: number;
3003
+ gap_loss: number;
575
3004
  }>;
576
- extrapolateShortConfig(payload: {
577
- kind: "long" | "short";
3005
+ getSellPriceFromStrategy(payload: {
578
3006
  symbol: string;
579
- risk_reward?: number;
3007
+ reduce_position: PositionsView;
3008
+ kind?: "long" | "short";
3009
+ full_ratio?: number;
580
3010
  }): Promise<{
581
- place_stop: boolean;
3011
+ pnl: number;
3012
+ loss: number;
3013
+ full_loss: number;
3014
+ original_pnl: number;
3015
+ reward_factor: number;
582
3016
  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;
3017
+ kind: "long" | "short";
3018
+ sell_price: number;
3019
+ quantity: number;
3020
+ price_places: string;
3021
+ decimal_places: string;
590
3022
  }>;
591
- triggerTradeFromConfig(payload: {
3023
+ placeCompoundShortTrade(payload: {}): Promise<void>;
3024
+ placeCompoundLongTrade(payload: {
592
3025
  symbol: string;
593
- kind: "long" | "short";
594
- }): Promise<any>;
595
- verifyStopLoss(payload: {
3026
+ params: {
3027
+ resistance: number;
3028
+ support: number;
3029
+ profit_percent: number;
3030
+ risk_reward: number;
3031
+ risk: number;
3032
+ };
3033
+ place?: boolean;
3034
+ }): Promise<void>;
3035
+ getConfigProfiles(payload: {
596
3036
  symbol: string;
597
3037
  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>;
3038
+ }): Promise<{
3039
+ id: any;
3040
+ entry: any;
3041
+ stop: any;
3042
+ kind: "long" | "short";
3043
+ risk_reward: any;
3044
+ risk: any;
3045
+ profit_percent: any;
3046
+ }[]>;
605
3047
  }
3048
+ declare function getExchangeAccount(payload: {
3049
+ account: ExchangeType;
3050
+ app_db: AppDatabase;
3051
+ getCredentials: (payload: {
3052
+ account: string;
3053
+ exchange: string;
3054
+ app_db: AppDatabase;
3055
+ }) => Promise<{
3056
+ api_key: string;
3057
+ api_secret: string;
3058
+ email: string;
3059
+ }>;
3060
+ proxyOptions?: {
3061
+ proxy?: any;
3062
+ ignore_proxy?: boolean;
3063
+ };
3064
+ canWithdraw?: boolean;
3065
+ }): Promise<ExchangeAccount$1>;
606
3066
  declare class App {
607
- private app_db;
3067
+ app_db: AppDatabase;
3068
+ proxyOptions?: {
3069
+ proxy?: any;
3070
+ ignore_proxy?: boolean;
3071
+ canWithdraw?: boolean;
3072
+ };
608
3073
  private getCredentials;
609
- constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
3074
+ constructor(app_db: AppDatabase, getCredentials: (payload: {
3075
+ account: string;
3076
+ exchange: string;
3077
+ }) => Promise<{
610
3078
  api_key: string;
611
3079
  api_secret: string;
612
- }>);
3080
+ email: string;
3081
+ }>, proxyOptions?: {
3082
+ proxy?: any;
3083
+ ignore_proxy?: boolean;
3084
+ canWithdraw?: boolean;
3085
+ });
613
3086
  getExchangeAccount(account: ExchangeType): Promise<ExchangeAccount$1>;
614
3087
  syncAccount(payload: {
615
3088
  account: ExchangeType;
@@ -620,6 +3093,8 @@ declare class App {
620
3093
  }): Promise<PositionsView | (PositionsView & {
621
3094
  expand?: {
622
3095
  config: ScheduledTrade;
3096
+ account: ExchangeAccount;
3097
+ proxy: Proxy$1;
623
3098
  };
624
3099
  })[]>;
625
3100
  syncOrders(payload: {
@@ -634,7 +3109,7 @@ declare class App {
634
3109
  price?: number;
635
3110
  all?: boolean;
636
3111
  stop?: boolean;
637
- }): Promise<{
3112
+ }): Promise<any[] | {
638
3113
  success: boolean;
639
3114
  message: string;
640
3115
  exchange_result?: undefined;
@@ -650,39 +3125,6 @@ declare class App {
650
3125
  message?: undefined;
651
3126
  exchange_result?: undefined;
652
3127
  }>;
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
3128
  getWindingDownMarkets(): Promise<WindingDownMarket[]>;
687
3129
  updateSymbolConfigs(payload: {
688
3130
  configs: {
@@ -699,7 +3141,128 @@ declare class App {
699
3141
  created: number;
700
3142
  }>;
701
3143
  updateAllAccountWithSymbols(with_positions?: boolean): Promise<void>;
702
- windDownSymbol(symbol: string): Promise<boolean>;
3144
+ windDownSymbol(payload: {
3145
+ symbol: string;
3146
+ risk?: number;
3147
+ }): Promise<boolean>;
3148
+ getNonEssentialSymbols(): Promise<Set<any>>;
3149
+ refreshAllPositionsWithSymbol(payload: {
3150
+ symbol: string;
3151
+ callback?: (payload: {
3152
+ symbol: string;
3153
+ account: ExchangeType;
3154
+ }) => Promise<any>;
3155
+ }): Promise<void>;
3156
+ autoFollowPositions(): Promise<void>;
3157
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
3158
+ updateTpOnAllMarkets(callback?: (payload: {
3159
+ account: ExchangeType;
3160
+ }) => Promise<any>): Promise<void>;
3161
+ triggerMoverTask(payload: {
3162
+ callback: (params: {
3163
+ symbol: string;
3164
+ account: ExchangeType;
3165
+ }) => Promise<any>;
3166
+ removeCallback?: (params: {
3167
+ symbol: string;
3168
+ account: ExchangeType;
3169
+ }) => Promise<any>;
3170
+ }): Promise<void>;
3171
+ placeTrade(payload: {
3172
+ account: ExchangeType;
3173
+ symbol: string;
3174
+ kind: "long" | "short";
3175
+ place?: boolean;
3176
+ tp?: boolean;
3177
+ cancel?: boolean;
3178
+ raw?: boolean;
3179
+ }): Promise<any>;
3180
+ runDbStrategyAccounts(payload: {
3181
+ runningCallback: (params: {
3182
+ symbol: string;
3183
+ account: ExchangeType;
3184
+ }) => Promise<any>;
3185
+ notRunningCallback: (params: {
3186
+ symbol: string;
3187
+ account: ExchangeType;
3188
+ kind: "long" | "short";
3189
+ }) => Promise<any>;
3190
+ }): Promise<void>;
3191
+ profitWithinGapStrategy(payload: {
3192
+ account: ExchangeType;
3193
+ symbol: string;
3194
+ }): Promise<{
3195
+ config_details: {
3196
+ app_config: {
3197
+ fee: number;
3198
+ risk_per_trade: number;
3199
+ risk_reward: number;
3200
+ symbol?: string;
3201
+ focus: number;
3202
+ budget: number;
3203
+ support: number;
3204
+ resistance: number;
3205
+ percent_change: number;
3206
+ tradeSplit?: number;
3207
+ take_profit?: number;
3208
+ kind: "long" | "short";
3209
+ entry: number;
3210
+ stop: number;
3211
+ min_size: number;
3212
+ price_places?: string;
3213
+ strategy?: "quantity" | "entry";
3214
+ as_array?: boolean;
3215
+ decimal_places?: string;
3216
+ min_profit?: number;
3217
+ raw?: boolean;
3218
+ gap?: number;
3219
+ rr?: number;
3220
+ max_size?: number;
3221
+ max_quantity?: number;
3222
+ kelly?: {
3223
+ use_kelly?: boolean;
3224
+ kelly_confidence_factor?: number;
3225
+ kelly_minimum_risk?: number;
3226
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
3227
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
3228
+ };
3229
+ };
3230
+ last_value: any;
3231
+ };
3232
+ }>;
3233
+ compoundLongTrade(payload: {
3234
+ main_account: ExchangeType & {
3235
+ symbol: string;
3236
+ };
3237
+ focus_account: ExchangeType & {
3238
+ symbol: string;
3239
+ };
3240
+ place?: boolean;
3241
+ rr?: number;
3242
+ }): Promise<{
3243
+ start_risk: number;
3244
+ short_profit: number;
3245
+ support: number;
3246
+ resistance: number;
3247
+ long_v: any;
3248
+ profit_percent: number;
3249
+ result: any;
3250
+ short_max_size: any;
3251
+ }>;
3252
+ reduceExistingPosition(payload: {
3253
+ main_account: ExchangeType & {
3254
+ symbol: string;
3255
+ kind?: "long" | "short";
3256
+ };
3257
+ reduce_account: ExchangeType & {
3258
+ symbol: string;
3259
+ };
3260
+ kind: "long" | "short";
3261
+ place?: boolean;
3262
+ increase?: boolean;
3263
+ full_ratio?: number;
3264
+ cancel_limit?: boolean;
3265
+ }): Promise<any>;
703
3266
  }
704
3267
  export declare function initApp(payload: {
705
3268
  db: {
@@ -707,14 +3270,50 @@ export declare function initApp(payload: {
707
3270
  email: string;
708
3271
  password: string;
709
3272
  };
710
- getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
3273
+ password?: string;
3274
+ salt?: string;
3275
+ email?: string;
3276
+ getCredentials: (payload: {
3277
+ account: string;
3278
+ exchange: string;
3279
+ app_db: AppDatabase;
3280
+ }) => Promise<{
711
3281
  api_key: string;
712
3282
  api_secret: string;
3283
+ email: string;
713
3284
  }>;
3285
+ proxy?: any;
3286
+ ignore_proxy?: boolean;
3287
+ canWithdraw?: boolean;
3288
+ triggerToken?: string;
3289
+ }): Promise<App>;
3290
+ declare function getCredentials(payload: {
3291
+ account: string;
3292
+ exchange: string;
3293
+ app_db: AppDatabase;
3294
+ }): Promise<any>;
3295
+ export declare function initialize(payload: {
3296
+ password?: string;
3297
+ proxy?: any;
3298
+ ignore_proxy?: boolean;
3299
+ canWithdraw?: boolean;
714
3300
  }): Promise<App>;
715
3301
 
3302
+ declare namespace database {
3303
+ export { AppDatabase, ExchangeType, decryptObject, encryptObject, initPocketBaseClient };
3304
+ }
3305
+ declare namespace exchange_account {
3306
+ export { ExchangeAccount$1 as ExchangeAccount, getExchangeAccount };
3307
+ }
3308
+ declare namespace app {
3309
+ export { App, getCredentials, initApp, initialize };
3310
+ }
3311
+
716
3312
  export {
717
3313
  ExchangeAccount$1 as ExchangeAccount,
3314
+ app,
3315
+ database,
3316
+ exchange_account,
718
3317
  };
719
3318
 
720
3319
  export {};