@gbozee/ultimate 0.0.2-20 → 0.0.2-200

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