@gbozee/ultimate 0.0.2-10 → 0.0.2-101

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,159 @@
2
2
 
3
3
  import { HttpsProxyAgent } from 'https-proxy-agent';
4
4
  import PocketBase from 'pocketbase';
5
- import { RecordModel } from 'pocketbase';
5
+ import { RecordModel as PocketBaseRecordModel } from 'pocketbase';
6
6
  import { SocksProxyAgent } from 'socks-proxy-agent';
7
7
 
8
+ export type RecordModel = PocketBaseRecordModel;
9
+ export interface BaseSystemFields {
10
+ id: string;
11
+ created: string;
12
+ updated: string;
13
+ }
14
+ export interface ExchangeAccount extends BaseSystemFields {
15
+ exchange: "binance" | "bybit";
16
+ owner: string;
17
+ email?: string;
18
+ user?: string;
19
+ usdt?: number;
20
+ usdc?: number;
21
+ proxy?: string;
22
+ bullish?: boolean;
23
+ bearish?: boolean;
24
+ movePercent?: number;
25
+ totalRisk?: number;
26
+ max_non_essential?: number;
27
+ profit_percent?: number;
28
+ risk_reward?: number;
29
+ exclude_coins?: {
30
+ bullish?: string[];
31
+ };
32
+ include_delisted?: boolean;
33
+ }
34
+ export interface Order extends BaseSystemFields {
35
+ symbol: string;
36
+ account: string;
37
+ kind: "long" | "short";
38
+ price: number;
39
+ quantity: number;
40
+ side: "sell" | "buy";
41
+ stop: number;
42
+ order_id: string;
43
+ }
44
+ export interface SymbolConfig extends BaseSystemFields {
45
+ symbol: string;
46
+ support?: number;
47
+ resistance?: number;
48
+ stop_percent?: number;
49
+ price_places?: string;
50
+ decimal_places?: string;
51
+ min_size?: number;
52
+ weight?: number;
53
+ leverage?: number;
54
+ candle_count?: number;
55
+ interval?: any;
56
+ fee_percent?: number;
57
+ }
58
+ export interface ScheduledTrade extends BaseSystemFields {
59
+ symbol: string;
60
+ account: string;
61
+ profit?: number;
62
+ risk?: number;
63
+ entry?: number;
64
+ stop?: number;
65
+ risk_reward?: number;
66
+ profit_percent?: number;
67
+ place_tp?: boolean;
68
+ kind?: "long" | "short";
69
+ follow?: boolean | 1 | 0;
70
+ reduce_ratio?: number;
71
+ sell_ratio?: number;
72
+ threshold_qty?: number;
73
+ pause_tp?: boolean;
74
+ }
75
+ export interface AccountStrategy extends BaseSystemFields {
76
+ account: string;
77
+ symbol: string;
78
+ risk?: number;
79
+ reward_factor?: number;
80
+ kind?: "long" | "short";
81
+ support?: number;
82
+ resistance?: number;
83
+ running?: boolean;
84
+ max_reward_factor?: number;
85
+ follow?: boolean;
86
+ risk_reward?: number;
87
+ }
88
+ interface Proxy$1 extends BaseSystemFields {
89
+ ip_address?: string;
90
+ type?: "http" | "socks5";
91
+ }
92
+ export interface TradeBlockTracking extends BaseSystemFields {
93
+ account?: string;
94
+ symbol?: string;
95
+ running?: boolean;
96
+ }
97
+ export interface PositionsView {
98
+ id: string;
99
+ symbol?: any;
100
+ entry?: any;
101
+ quantity?: any;
102
+ take_profit?: any;
103
+ account?: any;
104
+ kind?: any;
105
+ target_pnl?: number;
106
+ liquidation?: number;
107
+ avg_price?: number;
108
+ avg_qty?: number;
109
+ next_order?: number;
110
+ last_order?: number;
111
+ config?: any;
112
+ stop_loss?: {
113
+ price: number;
114
+ quantity: number;
115
+ };
116
+ stop_pnl?: any;
117
+ leverage?: any;
118
+ avg_liquidation?: any;
119
+ balance?: any;
120
+ reduce_ratio?: number;
121
+ sell_ratio?: number;
122
+ threshold_qty?: number;
123
+ follow?: boolean | 1 | 0;
124
+ current_price?: number;
125
+ usd_balance?: number;
126
+ }
127
+ export interface BullishMarket extends RecordModel {
128
+ id: string;
129
+ symbol: string;
130
+ risk: number;
131
+ }
132
+ export interface WindingDownMarket extends RecordModel {
133
+ id: string;
134
+ symbol: string;
135
+ risk_reward: number;
136
+ }
137
+ export type GlobalConfig = {
138
+ profit_percent: number;
139
+ symbol: string;
140
+ profit: number;
141
+ risk: number;
142
+ stop_percent: number;
143
+ kind: "long" | "short";
144
+ reduce_percent: number;
145
+ support: number;
146
+ resistance: number;
147
+ price_places: string;
148
+ decimal_places: string;
149
+ min_size: number;
150
+ accounts: {
151
+ owner: string;
152
+ exchange?: string;
153
+ }[];
154
+ risk_reward: number;
155
+ reverse_factor: number;
156
+ leverage?: number;
157
+ };
8
158
  interface Position$1 {
9
159
  id: number;
10
160
  kind: "long" | "short";
@@ -59,9 +209,26 @@ export interface Account {
59
209
  short: any;
60
210
  };
61
211
  }
62
- export interface BaseExchange {
212
+ interface Order$1 {
213
+ order_id?: string;
214
+ symbol?: string;
215
+ price: number;
216
+ quantity: number;
217
+ kind: "long" | "short";
218
+ side: "buy" | "sell";
219
+ stop: number;
220
+ triggerPrice?: number;
221
+ }
222
+ declare abstract class BaseExchange {
63
223
  client: any;
64
- placeStopOrders(payload: {
224
+ constructor(client: any);
225
+ abstract rawCreateLimitPurchaseOrders(payload: {
226
+ symbol: string;
227
+ orders: Order$1[];
228
+ price_places?: string;
229
+ decimal_places?: string;
230
+ }): Promise<any>;
231
+ abstract placeStopOrders(payload: {
65
232
  symbol: string;
66
233
  quantity: number;
67
234
  kind: "long" | "short";
@@ -70,7 +237,7 @@ export interface BaseExchange {
70
237
  decimal_places?: string;
71
238
  place?: boolean;
72
239
  }): Promise<any>;
73
- bulkPlaceLimitOrders(payload: {
240
+ abstract bulkPlaceLimitOrders(payload: {
74
241
  orders: any[];
75
242
  kind: "long" | "short";
76
243
  decimal_places?: string;
@@ -78,30 +245,36 @@ export interface BaseExchange {
78
245
  symbol: string;
79
246
  place?: boolean;
80
247
  }): Promise<any>;
81
- get_current_price(symbol: string): Promise<any>;
82
- analyzeCharts(payload: {
248
+ abstract get_current_price(symbol: string): Promise<any>;
249
+ abstract analyzeCharts(payload: {
83
250
  symbol: string;
84
251
  chartType: any;
85
252
  count: number;
86
253
  raw?: boolean;
87
254
  }): Promise<any>;
88
- getExchangeAccountInfo(account: {
89
- owner: string;
90
- exchange: string;
91
- }, symbol: string): Promise<any>;
92
- cancelOrders(payload: {
255
+ abstract getExchangeAccountInfo(options: {
256
+ price_places?: string;
257
+ decimal_places?: string;
258
+ account: {
259
+ owner: string;
260
+ exchange: string;
261
+ };
262
+ symbol: string;
263
+ }): Promise<any>;
264
+ abstract cancelOrders(payload: {
93
265
  symbol: string;
94
266
  orders: number[];
95
267
  }): Promise<any>;
96
- placeTpOrder(payload: {
268
+ abstract placeTpOrder(payload: {
97
269
  symbol: string;
98
270
  take_profit: number;
99
271
  kind: "long" | "short";
100
272
  cancel?: boolean;
273
+ quantity?: number;
101
274
  price_places?: string;
102
275
  decimal_places?: string;
103
276
  }): Promise<any>;
104
- placeLimitOrder(payload: {
277
+ abstract placeLimitOrder(payload: {
105
278
  symbol: string;
106
279
  quantity: number;
107
280
  kind: "long" | "short";
@@ -109,7 +282,7 @@ export interface BaseExchange {
109
282
  price_places?: string;
110
283
  decimal_places?: string;
111
284
  }): Promise<any>;
112
- placeStopOrder(payload: {
285
+ abstract placeStopOrder(payload: {
113
286
  symbol: string;
114
287
  stop: number;
115
288
  quantity: number;
@@ -117,114 +290,100 @@ export interface BaseExchange {
117
290
  price_places?: string;
118
291
  decimal_places?: string;
119
292
  }): Promise<any>;
120
- setLeverage(payload: {
293
+ abstract setLeverage(payload: {
121
294
  symbol: string;
122
295
  leverage: number;
123
296
  }): Promise<any>;
124
- }
125
- export interface BaseSystemFields {
126
- id: string;
127
- created: string;
128
- updated: string;
129
- }
130
- export interface ExchangeAccount extends BaseSystemFields {
131
- exchange: "binance" | "bybit";
132
- owner: string;
133
- email?: string;
134
- user?: string;
135
- usdt?: number;
136
- usdc?: number;
137
- proxy?: string;
138
- }
139
- export interface SymbolConfig extends BaseSystemFields {
140
- symbol: string;
141
- support?: number;
142
- resistance?: number;
143
- stop_percent?: number;
144
- price_places?: string;
145
- decimal_places?: string;
146
- min_size?: number;
147
- weight?: number;
148
- leverage?: number;
149
- }
150
- export interface ScheduledTrade extends BaseSystemFields {
151
- symbol: string;
152
- account: string;
153
- profit?: number;
154
- risk?: number;
155
- entry?: number;
156
- stop?: number;
157
- risk_reward?: number;
158
- profit_percent?: number;
159
- place_tp?: boolean;
160
- kind?: "long" | "short";
161
- current_price?: number;
162
- }
163
- export interface Strategy extends BaseSystemFields {
164
- name: string;
165
- short_risk_factor?: number;
166
- long_risk_factor?: number;
167
- profit_percent?: number;
168
- cancel_short?: boolean;
169
- cancel_long?: boolean;
170
- recompute_short_config?: boolean;
171
- update_stop_loss?: boolean;
172
- liquidation_as_entry?: boolean;
173
- stop_as_entry?: boolean;
174
- tp_as_stop?: boolean;
175
- entry_as_stop?: boolean;
176
- place_stop?: boolean;
177
- save_config?: boolean;
178
- }
179
- interface Proxy$1 extends BaseSystemFields {
180
- ip_address?: string;
181
- type?: "http" | "socks5";
182
- }
183
- export interface TradeBlockTracking extends BaseSystemFields {
184
- account?: string;
185
- symbol?: string;
186
- running?: boolean;
187
- }
188
- export interface PositionsView {
189
- id: string;
190
- symbol?: any;
191
- entry?: any;
192
- quantity?: any;
193
- take_profit?: any;
194
- account?: any;
195
- kind?: any;
196
- target_pnl?: number;
197
- liquidation?: number;
198
- avg_price?: number;
199
- avg_qty?: number;
200
- next_order?: number;
201
- last_order?: number;
202
- config?: any;
203
- stop_loss?: {
204
- price: number;
297
+ abstract generateConfig(payload: {
298
+ symbol: string;
299
+ interval?: any;
300
+ limit?: number;
301
+ }): Promise<any>;
302
+ abstract checkDelistedMovers(payload: {
303
+ movePercent: number;
304
+ include_delisted?: boolean;
305
+ }): Promise<any>;
306
+ abstract closePosition(payload: {
307
+ symbol: string;
308
+ kind: "long" | "short";
309
+ price_places?: string;
310
+ decimal_places?: string;
311
+ }): Promise<any>;
312
+ abstract getAllOpenSymbols(): Promise<string[]>;
313
+ abstract createLimitPurchaseOrders(payload: {
314
+ orders: any[];
315
+ kind: "long" | "short";
316
+ decimal_places?: string;
317
+ price_places?: string;
318
+ symbol: string;
319
+ }): Promise<any>;
320
+ abstract getDelistedSpotSymbols(): Promise<any>;
321
+ abstract getOpenPositions(): Promise<any>;
322
+ abstract crossAccountTransfer(payload: {
323
+ from: {
324
+ owner: string;
325
+ wallet: string;
326
+ };
327
+ to: {
328
+ owner: string;
329
+ wallet: string;
330
+ };
331
+ asset: string;
332
+ amount: number;
333
+ }): Promise<any>;
334
+ abstract placeMarketOrder(payload: {
335
+ symbol: string;
336
+ kind: "long" | "short";
205
337
  quantity: number;
206
- };
207
- stop_pnl?: any;
208
- leverage?: any;
209
- avg_liquidation?: any;
210
- balance?: any;
211
- }
212
- export interface BullishMarket extends RecordModel {
213
- id: string;
214
- symbol: string;
215
- risk: number;
216
- }
217
- export interface WindingDownMarket extends RecordModel {
218
- id: string;
219
- symbol: string;
338
+ price_places?: string;
339
+ decimal_places?: string;
340
+ }): Promise<any>;
341
+ customStopLoss(payload: {
342
+ price_places: string;
343
+ decimal_places: string;
344
+ symbol: string;
345
+ kind: "long" | "short";
346
+ stop: number;
347
+ quantity: number;
348
+ increase?: boolean;
349
+ }): Promise<any>;
350
+ abstract getOpenOrders(payload: {
351
+ symbol: string;
352
+ }): Promise<any>;
353
+ abstract placeBadStopEntry(payload: {
354
+ symbol: string;
355
+ orders: Order$1[];
356
+ price_places?: string;
357
+ decimal_places?: string;
358
+ }): Promise<any>;
220
359
  }
360
+ declare function initPocketBaseClient(proxy_credentials: {
361
+ host: string;
362
+ email: string;
363
+ password: string;
364
+ auto_cancellation?: boolean;
365
+ }): Promise<PocketBase>;
221
366
  export type ExchangeType = {
222
367
  owner: string;
223
368
  exchange: string;
224
369
  };
225
370
  export declare class AppDatabase {
226
- private pb;
371
+ pb: PocketBase;
227
372
  constructor(pb: PocketBase);
373
+ getCredentials(password: string): any;
374
+ saveCredentials(password: string, credentials: any): Promise<void>;
375
+ addNewCredential(password: string, payload: {
376
+ name: string;
377
+ exchange: string;
378
+ api_key: string;
379
+ api_secret: string;
380
+ }): Promise<void>;
381
+ getAccountWithActivePositions(): Promise<import("pocketbase").RecordModel[]>;
382
+ getAllSymbolsFromPositions(options?: {
383
+ no_position?: boolean;
384
+ kind?: "long" | "short";
385
+ custom_filter?: string;
386
+ }): Promise<any[]>;
228
387
  createOrUpdateLiveExchangeInstance(payload: {
229
388
  account: ExchangeType;
230
389
  symbol: string;
@@ -237,18 +396,24 @@ export declare class AppDatabase {
237
396
  }): Promise<import("pocketbase").RecordModel>;
238
397
  getProxyForAccount(account: ExchangeType): Promise<HttpsProxyAgent<`http://${string}`> | SocksProxyAgent>;
239
398
  getAccounts(): Promise<ExchangeAccount[]>;
240
- getAllSymbolConfigs(with_positions?: boolean): Promise<SymbolConfig[]>;
399
+ getAllSymbolConfigs(payload?: {
400
+ with_positions?: boolean;
401
+ custom_filter?: string;
402
+ }): Promise<SymbolConfig[]>;
241
403
  get_exchange_db_instance(account: ExchangeType): Promise<ExchangeAccount & {
242
404
  expand?: {
243
405
  proxy: Proxy$1;
244
406
  };
245
407
  }>;
246
- getPositions(account: ExchangeType, options: {
247
- symbol: string;
408
+ getPositions(options: {
409
+ account?: ExchangeType;
410
+ symbol?: string;
248
411
  as_view?: boolean;
412
+ custom_filter?: string;
249
413
  }): Promise<(PositionsView & {
250
414
  expand?: {
251
415
  config: ScheduledTrade;
416
+ account: ExchangeAccount;
252
417
  };
253
418
  })[]>;
254
419
  private _createOrUpdatePosition;
@@ -260,6 +425,7 @@ export declare class AppDatabase {
260
425
  }): Promise<(PositionsView & {
261
426
  expand?: {
262
427
  config: ScheduledTrade;
428
+ account: ExchangeAccount;
263
429
  };
264
430
  })[]>;
265
431
  update_db_position(position: any, payload: any): Promise<import("pocketbase").RecordModel>;
@@ -271,7 +437,7 @@ export declare class AppDatabase {
271
437
  getOrders(account: ExchangeType, options: {
272
438
  symbol: string;
273
439
  kind: "long" | "short";
274
- }): Promise<import("pocketbase").RecordModel[]>;
440
+ }): Promise<Order[]>;
275
441
  deleteAndRecreateOrders(account: ExchangeType, options: {
276
442
  symbol: string;
277
443
  kind: "long" | "short";
@@ -284,9 +450,34 @@ export declare class AppDatabase {
284
450
  stop: number;
285
451
  order_id: string;
286
452
  triggerPrice?: number;
287
- }>): Promise<import("pocketbase").RecordModel[]>;
288
- cancelOrders(payload: {
289
- cancelExchangeOrders: (payload: {
453
+ }>): Promise<Order[]>;
454
+ deleteAndBulCreateAllOrders(payload: {
455
+ account: ExchangeType & {
456
+ id: string;
457
+ };
458
+ symbol: string;
459
+ all_orders: Array<{
460
+ symbol: string;
461
+ price: number;
462
+ quantity: number;
463
+ kind: "long" | "short";
464
+ side: "buy" | "sell";
465
+ stop: number;
466
+ order_id: string;
467
+ triggerPrice?: number;
468
+ }>;
469
+ }): Promise<void>;
470
+ cancelLimitOrders(payload: {
471
+ symbol: string;
472
+ kind: "long" | "short";
473
+ account: ExchangeType;
474
+ cancelExchangeOrders: (payload: {
475
+ symbol: string;
476
+ orders: number[];
477
+ }) => Promise<any>;
478
+ }): Promise<void>;
479
+ cancelOrders(payload: {
480
+ cancelExchangeOrders: (payload: {
290
481
  symbol: string;
291
482
  orders: number[];
292
483
  }) => Promise<any>;
@@ -312,30 +503,49 @@ export declare class AppDatabase {
312
503
  message?: undefined;
313
504
  exchange_result?: undefined;
314
505
  }>;
506
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
507
+ updateScheduledTrade(id: string, payload: any): Promise<import("pocketbase").RecordModel>;
508
+ getPositionsToAutoFollow(): Promise<(Position$1 & {
509
+ expand: {
510
+ account: ExchangeAccount;
511
+ };
512
+ })[]>;
315
513
  createOrUpdatePositionConfig(db_position: any, payload: {
316
514
  entry: number;
317
515
  stop: number;
318
516
  risk_reward: number;
319
517
  risk: number;
320
518
  profit_percent?: number;
321
- }): Promise<void>;
519
+ place_tp?: boolean;
520
+ profit?: number;
521
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
322
522
  getPositionConfig(payload: {
323
523
  symbol: string;
324
524
  kind: "long" | "short";
325
525
  account: ExchangeType;
526
+ }): Promise<ScheduledTrade | null>;
527
+ getRunningAccountStrategies(): Promise<(AccountStrategy & {
528
+ expand?: {
529
+ account: ExchangeAccount;
530
+ };
531
+ })[]>;
532
+ getAccountStrategy(payload: {
533
+ symbol: string;
534
+ account: ExchangeType;
535
+ }): Promise<AccountStrategy>;
536
+ createOrUpdateWindingDownMarket(payload: {
537
+ symbol: string;
538
+ risk_reward?: number;
326
539
  }): Promise<import("pocketbase").RecordModel>;
327
- getPositionStrategy(account: ExchangeType): Promise<{
328
- strategy_instance: Strategy;
329
- focus_account: ExchangeAccount;
330
- }>;
331
- createOrUpdateWindingDownMarket(symbol: string): Promise<import("pocketbase").RecordModel>;
332
- getWindingDownMarkets(): Promise<WindingDownMarket[]>;
540
+ getWindingDownMarkets(symbol?: string): Promise<WindingDownMarket[]>;
541
+ getBullishMarket(symbol: string): Promise<BullishMarket>;
333
542
  getBullishMarkets(options?: {
334
543
  new_markets: Array<{
335
544
  symbol: string;
336
545
  percent: number;
337
546
  }>;
338
547
  totalRisk: number;
548
+ max_count?: number;
339
549
  }): Promise<{
340
550
  updated_bullish: BullishMarket[];
341
551
  moved_to_winding: WindingDownMarket[];
@@ -354,18 +564,423 @@ export declare class AppDatabase {
354
564
  updated: number;
355
565
  created: number;
356
566
  } | SymbolConfig[]>;
357
- unwindSymbolFromDB(symbol: string): Promise<void>;
567
+ unwindSymbolFromDB(symbol: string): Promise<boolean>;
568
+ hasExistingPosition(symbol: string): Promise<import("pocketbase").RecordModel[]>;
569
+ hasExistingOrders(symbol: string): Promise<import("pocketbase").RecordModel[]>;
570
+ removeSymbolFromUnwindingMarkets(symbol: string): Promise<boolean>;
571
+ removePosition(position: any): Promise<void>;
572
+ removePositionConfig(position: any): Promise<void>;
573
+ }
574
+ export type StrategyPosition = {
575
+ entry: number;
576
+ quantity: number;
577
+ avg_price?: number;
578
+ avg_qty?: number;
579
+ };
580
+ export type GapCloserResult = {
581
+ avg_entry: number;
582
+ avg_size: number;
583
+ loss: number;
584
+ stop: number;
585
+ stop_quantity: number;
586
+ re_entry_quantity: number;
587
+ initial_pnl: number;
588
+ tp: number;
589
+ incurred_loss: number;
590
+ pnl: number;
591
+ remaining_quantity: number;
592
+ };
593
+ export type Config = {
594
+ tp_percent: number;
595
+ short_tp_factor: number;
596
+ fee_percent?: number;
597
+ budget: number;
598
+ risk_reward: number;
599
+ reduce_ratio: number;
600
+ global_config: GlobalConfig;
601
+ };
602
+ export declare class Strategy {
603
+ position: {
604
+ long: StrategyPosition;
605
+ short: StrategyPosition;
606
+ };
607
+ dominant_position?: "long" | "short";
608
+ config: Config;
609
+ constructor(payload: {
610
+ long: StrategyPosition;
611
+ short: StrategyPosition;
612
+ config: Config;
613
+ dominant_position?: "long" | "short";
614
+ });
615
+ get price_places(): string;
616
+ get decimal_places(): string;
617
+ to_f(price: number): number;
618
+ to_df(quantity: number): number;
619
+ pnl(kind: "long" | "short", _position?: StrategyPosition): number;
620
+ tp(kind: "long" | "short"): number;
621
+ calculate_fee(position: {
622
+ price: number;
623
+ quantity: number;
624
+ }): number;
625
+ get long_tp(): number;
626
+ get short_tp(): number;
627
+ generateGapClosingAlgorithm(payload: {
628
+ kind: "long" | "short";
629
+ ignore_entries?: boolean;
630
+ reduce_ratio?: number;
631
+ sell_factor?: number;
632
+ }): {
633
+ last_entry: any;
634
+ first_entry: any;
635
+ threshold: any;
636
+ risk: number;
637
+ risk_reward: number;
638
+ spread: number;
639
+ gap_loss: number;
640
+ net_profit: number;
641
+ long: GapCloserResult;
642
+ short: GapCloserResult;
643
+ };
644
+ gapCloserHelper(payload: {
645
+ risk: number;
646
+ entries?: any[];
647
+ kind: "long" | "short";
648
+ sell_factor?: number;
649
+ reduce_ratio?: number;
650
+ }): {
651
+ risk: number;
652
+ risk_reward: number;
653
+ spread: number;
654
+ gap_loss: number;
655
+ net_profit: number;
656
+ long: GapCloserResult;
657
+ short: GapCloserResult;
658
+ };
659
+ runIterations(payload: {
660
+ kind: "long" | "short";
661
+ iterations: number;
662
+ risk_reward?: number;
663
+ ignore_entries?: boolean;
664
+ reduce_ratio?: number;
665
+ sell_factor?: number;
666
+ }): {
667
+ last_entry: any;
668
+ first_entry: any;
669
+ threshold: any;
670
+ risk: number;
671
+ risk_reward: number;
672
+ spread: number;
673
+ gap_loss: number;
674
+ net_profit: number;
675
+ long: GapCloserResult;
676
+ short: GapCloserResult;
677
+ }[];
678
+ getPositionAfterTp(payload: {
679
+ kind: "long" | "short";
680
+ include_fees?: boolean;
681
+ }): {
682
+ [x: string]: number | {
683
+ entry: number;
684
+ quantity: number;
685
+ diff?: undefined;
686
+ } | {
687
+ [x: string]: number;
688
+ diff: number;
689
+ entry?: undefined;
690
+ quantity?: undefined;
691
+ };
692
+ pnl: {
693
+ [x: string]: number;
694
+ diff: number;
695
+ };
696
+ spread: number;
697
+ };
698
+ getPositionAfterIteration(payload: {
699
+ kind: "long" | "short";
700
+ iterations: number;
701
+ with_fees?: boolean;
702
+ }): {
703
+ [x: string]: number | {
704
+ entry: number;
705
+ quantity: number;
706
+ diff?: undefined;
707
+ } | {
708
+ [x: string]: number;
709
+ diff: number;
710
+ entry?: undefined;
711
+ quantity?: undefined;
712
+ };
713
+ pnl: {
714
+ [x: string]: number;
715
+ diff: number;
716
+ };
717
+ spread: number;
718
+ }[];
719
+ /**To be used as one of the agent tools eventually since
720
+ * it is something that can be triggered continously without
721
+ * any risk
722
+ */
723
+ generateOppositeTrades(payload: {
724
+ kind: "long" | "short";
725
+ risk_factor?: number;
726
+ avg_entry?: number;
727
+ }): {
728
+ avg: {
729
+ entry: number;
730
+ price: number;
731
+ quantity: number;
732
+ };
733
+ loss: number;
734
+ profit_percent: number;
735
+ fee: number;
736
+ risk_per_trade: number;
737
+ risk_reward: number;
738
+ symbol?: string;
739
+ focus: number;
740
+ budget: number;
741
+ support: number;
742
+ resistance: number;
743
+ percent_change: number;
744
+ tradeSplit?: number;
745
+ take_profit?: number;
746
+ kind: "long" | "short";
747
+ entry: number;
748
+ stop: number;
749
+ min_size: number;
750
+ price_places?: string;
751
+ strategy?: "quantity" | "entry";
752
+ as_array?: boolean;
753
+ decimal_places?: string;
754
+ min_profit?: number;
755
+ raw?: boolean;
756
+ gap?: number;
757
+ rr?: number;
758
+ max_size?: number;
759
+ };
760
+ identifyGapConfig(payload: {
761
+ factor?: number;
762
+ sell_factor?: number;
763
+ }): {
764
+ profit_percent: {
765
+ long: number;
766
+ short: number;
767
+ };
768
+ risk: {
769
+ short: number;
770
+ long: number;
771
+ };
772
+ take_profit: {
773
+ long: number;
774
+ short: number;
775
+ };
776
+ to_reduce: {
777
+ short: number;
778
+ long: number;
779
+ };
780
+ full_reduce: {
781
+ short: number;
782
+ long: number;
783
+ };
784
+ sell_quantity: {
785
+ short: number;
786
+ long: number;
787
+ };
788
+ gap: number;
789
+ gap_loss: number;
790
+ };
791
+ analyzeProfit(payload: {
792
+ reward_factor?: number;
793
+ max_reward_factor: number;
794
+ risk: number;
795
+ kind: "long" | "short";
796
+ }): {
797
+ pnl: number;
798
+ loss: number;
799
+ original_pnl: number;
800
+ reward_factor: number;
801
+ profit_percent: number;
802
+ kind: "long" | "short";
803
+ sell_price: number;
804
+ quantity: number;
805
+ price_places: string;
806
+ decimal_places: string;
807
+ };
808
+ simulateGapReduction(payload: {
809
+ factor: number;
810
+ kind: "long" | "short";
811
+ sell_factor?: number;
812
+ }): {
813
+ results: {
814
+ profit_percent: {
815
+ long: number;
816
+ short: number;
817
+ };
818
+ risk: {
819
+ short: number;
820
+ long: number;
821
+ };
822
+ take_profit: {
823
+ long: number;
824
+ short: number;
825
+ };
826
+ sell_quantity: {
827
+ short: number;
828
+ long: number;
829
+ };
830
+ gap_loss: number;
831
+ position: {
832
+ long: {
833
+ entry: number;
834
+ quantity: number;
835
+ };
836
+ short: {
837
+ entry: number;
838
+ quantity: number;
839
+ };
840
+ };
841
+ }[];
842
+ quantity: number;
843
+ counter: number;
844
+ };
358
845
  }
359
- export interface CodeNode {
846
+ export type SignalConfigType = {
847
+ focus: number;
848
+ budget: number;
849
+ percent_change?: number;
850
+ price_places?: string;
851
+ decimal_places?: string;
852
+ zone_risk?: number;
853
+ fee?: number;
854
+ support?: number;
855
+ risk_reward?: number;
856
+ resistance?: number;
857
+ risk_per_trade?: number;
858
+ increase_size?: boolean;
859
+ additional_increase?: number;
860
+ minimum_pnl?: number;
861
+ take_profit?: number;
862
+ increase_position?: boolean;
863
+ minimum_size?: number;
864
+ first_order_size?: number;
865
+ gap?: number;
866
+ max_size?: number;
867
+ };
868
+ declare class Signal {
869
+ focus: number;
870
+ budget: number;
871
+ percent_change: number;
872
+ price_places: string;
873
+ decimal_places: string;
874
+ zone_risk: number;
875
+ fee: number;
876
+ support?: number;
877
+ risk_reward: number;
878
+ resistance?: number;
879
+ risk_per_trade?: number;
880
+ increase_size: boolean;
881
+ additional_increase: number;
360
882
  minimum_pnl: number;
883
+ take_profit?: number;
884
+ increase_position: boolean;
885
+ minimum_size: any;
886
+ first_order_size: number;
887
+ gap: number;
361
888
  max_size: number;
362
- profit: number;
363
- ratio?: number;
364
- increase: boolean;
365
- not_reduce?: boolean;
366
- reduce_ratio?: number;
367
- use_full?: boolean;
889
+ constructor({ focus, budget, percent_change, price_places, decimal_places, zone_risk, fee, support, risk_reward, resistance, risk_per_trade, increase_size, additional_increase, minimum_pnl, take_profit, increase_position, minimum_size, first_order_size, gap, max_size, }: SignalConfigType);
890
+ build_entry({ current_price, stop_loss, pnl, stop_percent, kind, risk, no_of_trades, take_profit, }: {
891
+ take_profit?: number;
892
+ no_of_trades?: number;
893
+ current_price: number;
894
+ stop_loss?: number;
895
+ kind?: "long" | "short";
896
+ risk: number;
897
+ stop_percent?: number;
898
+ pnl?: number;
899
+ }): any;
900
+ get risk(): number;
901
+ get min_trades(): number;
902
+ get min_price(): number;
903
+ build_opposite_order({ current_price, kind, }: {
904
+ current_price: number;
905
+ kind?: "long" | "short";
906
+ }): any;
907
+ special_build_orders({ current_price, kind, }: {
908
+ current_price: number;
909
+ kind?: "long" | "short";
910
+ }): any;
911
+ build_orders({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
912
+ current_price: number;
913
+ kind?: "long" | "short";
914
+ limit?: boolean;
915
+ replace_focus?: boolean;
916
+ max_index?: number;
917
+ min_index?: number;
918
+ }): any;
919
+ build_orders_old({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
920
+ current_price: number;
921
+ kind?: "long" | "short";
922
+ limit?: boolean;
923
+ replace_focus?: boolean;
924
+ max_index?: number;
925
+ min_index?: number;
926
+ }): any;
927
+ get_bulk_trade_zones({ current_price, kind, limit, }: {
928
+ current_price: number;
929
+ kind?: "long" | "short";
930
+ limit?: boolean;
931
+ }): any;
932
+ get_future_zones({ current_price, kind, raw, }: {
933
+ raw?: boolean;
934
+ current_price: number;
935
+ kind?: "long" | "short";
936
+ }): number[];
937
+ to_f(value: number, places?: string): number;
938
+ get_margin_zones({ current_price, kind, }: {
939
+ current_price: number;
940
+ kind?: "long" | "short";
941
+ }): number[][];
942
+ get_margin_range(current_price: number, kind?: string): number[];
943
+ process_orders({ current_price, stop_loss, trade_zones, kind, }: {
944
+ current_price: number;
945
+ stop_loss: number;
946
+ trade_zones: number[];
947
+ kind?: "long" | "short";
948
+ }): any[];
949
+ get_risk_per_trade(number_of_orders: number): number;
950
+ build_trade_dict({ entry, stop, risk, arr, index, new_fees, kind, start, take_profit, }: {
951
+ entry: number;
952
+ stop: number;
953
+ risk: number;
954
+ arr: number[];
955
+ index: number;
956
+ new_fees?: number;
957
+ kind?: "long" | "short";
958
+ start?: number;
959
+ take_profit?: number;
960
+ }): {
961
+ entry: number;
962
+ risk: number;
963
+ quantity: number;
964
+ sell_price: number;
965
+ risk_sell: number;
966
+ stop: number;
967
+ pnl: number;
968
+ fee: number;
969
+ net: number;
970
+ incurred: number;
971
+ stop_percent: number;
972
+ };
973
+ to_df(currentPrice: number, places?: string): number;
368
974
  }
975
+ export declare function determine_average_entry_and_size(orders: Array<{
976
+ price: number;
977
+ quantity: number;
978
+ }>, places?: string, price_places?: string): {
979
+ entry: number;
980
+ price: number;
981
+ quantity: number;
982
+ };
983
+ export declare const createArray: (start: number, stop: number, step: number) => number[];
369
984
  export type AppConfig = {
370
985
  fee: number;
371
986
  risk_per_trade: number;
@@ -391,63 +1006,445 @@ export type AppConfig = {
391
1006
  gap?: number;
392
1007
  rr?: number;
393
1008
  max_size?: number;
1009
+ last_value?: any;
1010
+ entries?: any[];
394
1011
  };
395
- declare class ExchangeAccount$1 {
396
- private instance;
397
- private exchange;
398
- private app_db;
399
- constructor(payload: ExchangeType, options: {
400
- exchange: BaseExchange;
401
- app_db: AppDatabase;
402
- });
403
- /**
404
- *In order to avoid rate limiting issues, we cache the live exchange
405
- details for each symbol for an account in the database with an option
406
- to refresh.
407
- */
408
- getLiveExchangeInstance(payload: {
409
- symbol: string;
410
- refresh?: boolean;
411
- price_places?: string;
412
- decimal_places?: string;
413
- }): Promise<import("pocketbase").RecordModel>;
414
- getActiveAccount(symbol: string, full?: boolean): Promise<Account | {
415
- liquidation: {
416
- long: number;
417
- short: number;
1012
+ export type ExtendConfigType = {
1013
+ take_profit?: number;
1014
+ entry: number;
1015
+ risk?: number;
1016
+ stop?: number;
1017
+ risk_reward?: number;
1018
+ raw_instance?: boolean;
1019
+ no_of_trades?: number;
1020
+ increase?: boolean;
1021
+ price_places?: string;
1022
+ decimal_places?: string;
1023
+ min_profit?: number;
1024
+ kind?: "long" | "short";
1025
+ gap?: number;
1026
+ rr?: number;
1027
+ };
1028
+ 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, }: ExtendConfigType): any[] | Signal;
1029
+ export declare function buildAvg({ _trades, kind, }: {
1030
+ _trades: any[];
1031
+ kind: "long" | "short";
1032
+ }): any;
1033
+ export declare function sortedBuildConfig(app_config: AppConfig, options: any): any[];
1034
+ export declare function get_app_config_and_max_size(config: GlobalConfig, payload: {
1035
+ entry: number;
1036
+ stop: number;
1037
+ kind: "long" | "short";
1038
+ }): {
1039
+ app_config: AppConfig;
1040
+ max_size: any;
1041
+ last_value: any;
1042
+ entries: {
1043
+ entry: any;
1044
+ avg_entry: any;
1045
+ avg_size: any;
1046
+ neg_pnl: any;
1047
+ quantity: any;
1048
+ }[];
1049
+ };
1050
+ export declare function buildAppConfig(config: GlobalConfig, payload: {
1051
+ entry: number;
1052
+ stop: number;
1053
+ risk_reward: number;
1054
+ risk: number;
1055
+ symbol: string;
1056
+ profit?: number;
1057
+ }): AppConfig;
1058
+ export declare function getOptimumStopAndRisk(app_config: AppConfig, params: {
1059
+ max_size: number;
1060
+ target_stop: number;
1061
+ highest_risk?: number;
1062
+ }): {
1063
+ optimal_stop: number;
1064
+ optimal_risk: number;
1065
+ avg_size: any;
1066
+ avg_entry: any;
1067
+ result: any[];
1068
+ first_entry: any;
1069
+ neg_pnl: any;
1070
+ risk_reward: number;
1071
+ size_diff: number;
1072
+ entry_diff: number;
1073
+ };
1074
+ export declare function generate_config_params(app_config: AppConfig, payload: {
1075
+ entry: number;
1076
+ stop: number;
1077
+ risk_reward: number;
1078
+ risk: number;
1079
+ symbol: string;
1080
+ }): {
1081
+ entry: number;
1082
+ stop: number;
1083
+ avg_size: any;
1084
+ avg_entry: any;
1085
+ risk_reward: number;
1086
+ neg_pnl: any;
1087
+ risk: number;
1088
+ };
1089
+ export declare function determine_break_even_price(payload: {
1090
+ long_position: {
1091
+ entry: number;
1092
+ quantity: number;
1093
+ };
1094
+ short_position: {
1095
+ entry: number;
1096
+ quantity: number;
1097
+ };
1098
+ fee_percent?: number;
1099
+ }): {
1100
+ price: number;
1101
+ direction: string;
1102
+ };
1103
+ export declare function determine_amount_to_buy(payload: {
1104
+ orders: any[];
1105
+ kind: "long" | "short";
1106
+ decimal_places?: string;
1107
+ price_places?: string;
1108
+ place?: boolean;
1109
+ position: any;
1110
+ existingOrders: any[];
1111
+ }): any[];
1112
+ export declare function generateOptimumAppConfig(config: GlobalConfig, payload: {
1113
+ entry: number;
1114
+ stop: number;
1115
+ risk_reward: number;
1116
+ start_risk: number;
1117
+ max_risk?: number;
1118
+ }, position: {
1119
+ entry: number;
1120
+ quantity: number;
1121
+ kind: "long" | "short";
1122
+ }): AppConfig | null;
1123
+ export declare function determineOptimumReward(app_config: AppConfig, increase?: boolean, low_range?: number, high_range?: number): number | {
1124
+ result: any[];
1125
+ value: number;
1126
+ total: number;
1127
+ risk_per_trade: number;
1128
+ max: number;
1129
+ min: number;
1130
+ neg_pnl: any;
1131
+ entry: any;
1132
+ };
1133
+ export declare function computeRiskReward(payload: {
1134
+ app_config: AppConfig;
1135
+ entry: number;
1136
+ stop: number;
1137
+ risk_per_trade: number;
1138
+ }): number | {
1139
+ result: any[];
1140
+ value: number;
1141
+ total: number;
1142
+ risk_per_trade: number;
1143
+ max: number;
1144
+ min: number;
1145
+ neg_pnl: any;
1146
+ entry: any;
1147
+ };
1148
+ export declare function getRiskReward(payload: {
1149
+ entry: number;
1150
+ stop: number;
1151
+ risk: number;
1152
+ global_config: GlobalConfig;
1153
+ }): any;
1154
+ export declare function computeProfitDetail(payload: {
1155
+ focus_position: {
1156
+ kind: "long" | "short";
1157
+ entry: number;
1158
+ quantity: number;
1159
+ avg_qty: number;
1160
+ avg_price: number;
1161
+ };
1162
+ strategy: {
1163
+ reward_factor: number;
1164
+ max_reward_factor: number;
1165
+ risk: number;
1166
+ };
1167
+ reduce_position?: {
1168
+ kind: "long" | "short";
1169
+ entry: number;
1170
+ quantity: number;
1171
+ avg_qty: number;
1172
+ avg_price: number;
1173
+ };
1174
+ reverse_position?: {
1175
+ kind: "long" | "short";
1176
+ avg_qty: number;
1177
+ avg_price: number;
1178
+ stop_loss: {
1179
+ price: number;
1180
+ quantity: number;
1181
+ };
1182
+ };
1183
+ price_places?: string;
1184
+ decimal_places?: string;
1185
+ }): {
1186
+ pnl: number;
1187
+ loss: number;
1188
+ original_pnl: number;
1189
+ reward_factor: number;
1190
+ profit_percent: number;
1191
+ kind: "long" | "short";
1192
+ sell_price: number;
1193
+ quantity: number;
1194
+ price_places: string;
1195
+ decimal_places: string;
1196
+ };
1197
+ export declare function generateGapTp(payload: {
1198
+ long: {
1199
+ entry: number;
1200
+ quantity: number;
1201
+ };
1202
+ short: {
1203
+ entry: number;
1204
+ quantity: number;
1205
+ };
1206
+ factor?: number;
1207
+ sell_factor?: number;
1208
+ price_places?: string;
1209
+ decimal_places?: string;
1210
+ }): {
1211
+ profit_percent: {
1212
+ long: number;
1213
+ short: number;
1214
+ };
1215
+ risk: {
1216
+ short: number;
1217
+ long: number;
1218
+ };
1219
+ take_profit: {
1220
+ long: number;
1221
+ short: number;
1222
+ };
1223
+ to_reduce: {
1224
+ short: number;
1225
+ long: number;
1226
+ };
1227
+ full_reduce: {
1228
+ short: number;
1229
+ long: number;
1230
+ };
1231
+ sell_quantity: {
1232
+ short: number;
1233
+ long: number;
1234
+ };
1235
+ gap: number;
1236
+ gap_loss: number;
1237
+ };
1238
+ declare class ExchangePosition {
1239
+ exchange: BaseExchange;
1240
+ exchange_account: ExchangeAccount$1;
1241
+ private app_db;
1242
+ private instance;
1243
+ constructor(payload: {
1244
+ exchange: BaseExchange;
1245
+ app_db: AppDatabase;
1246
+ instance: PositionsView;
1247
+ exchange_account: ExchangeAccount$1;
1248
+ without_view?: PositionsView;
1249
+ });
1250
+ get symbol(): any;
1251
+ get kind(): any;
1252
+ get account(): any;
1253
+ cancelOrders(payload: {
1254
+ limit?: boolean;
1255
+ price?: number;
1256
+ }): Promise<void | {
1257
+ success: boolean;
1258
+ message: string;
1259
+ exchange_result?: undefined;
1260
+ error?: undefined;
1261
+ } | {
1262
+ success: boolean;
1263
+ exchange_result: any;
1264
+ message?: undefined;
1265
+ error?: undefined;
1266
+ } | {
1267
+ success: boolean;
1268
+ error: any;
1269
+ message?: undefined;
1270
+ exchange_result?: undefined;
1271
+ }>;
1272
+ getConfig(payload?: {
1273
+ params?: {
1274
+ entry?: number;
1275
+ stop?: number;
1276
+ risk_reward?: number;
1277
+ risk?: number;
1278
+ profit_percent?: number;
1279
+ place_tp?: boolean;
1280
+ profit?: number;
1281
+ };
1282
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
1283
+ updateTargetPnl(): Promise<number>;
1284
+ updateConfigPnl(): Promise<void>;
1285
+ triggerTradeFromConfig(payload: {
1286
+ place?: boolean;
1287
+ raw?: boolean;
1288
+ tp?: boolean;
1289
+ stop?: boolean;
1290
+ use_current?: boolean;
1291
+ ignore_config?: boolean;
1292
+ }): Promise<any>;
1293
+ placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
1294
+ entry: number;
1295
+ stop: number;
1296
+ risk_reward: number;
1297
+ risk: number;
1298
+ place?: boolean;
1299
+ update_db?: boolean;
1300
+ raw?: boolean;
1301
+ use_current?: boolean;
1302
+ }): Promise<any>;
1303
+ buildAppConfig(payload: {
1304
+ entry: number;
1305
+ stop: number;
1306
+ risk_reward: number;
1307
+ risk: number;
1308
+ profit?: number;
1309
+ update_db?: boolean;
1310
+ profit_percent?: number;
1311
+ }): Promise<AppConfig>;
1312
+ placeConfigOrders(app_config: AppConfig, solution: {
1313
+ risk_reward: number;
1314
+ entry: number;
1315
+ stop: number;
1316
+ risk_per_trade: number;
1317
+ avg_size: number;
1318
+ neg_pnl: number;
1319
+ min_size: number;
1320
+ symbol: string;
1321
+ }, place?: boolean, skip_stop?: boolean): Promise<{
1322
+ entry_orders: {
1323
+ orders: {
1324
+ entry: any;
1325
+ quantity: any;
1326
+ reverse_avg_entry: any;
1327
+ reverse_avg_quantity: any;
1328
+ avg_entry: any;
1329
+ avg_size: any;
1330
+ }[];
1331
+ kind: "long" | "short";
1332
+ };
1333
+ stop_orders: {
1334
+ stop: number;
1335
+ final_stop: number;
1336
+ kind: "long" | "short";
1337
+ quantity: any;
1338
+ is_limit: boolean;
1339
+ neg_pnl: any;
1340
+ };
1341
+ trades: any[];
1342
+ }>;
1343
+ determineAmountToBuy(payload: {
1344
+ orders: any[];
1345
+ kind: "long" | "short";
1346
+ refresh?: boolean;
1347
+ decimal_places?: string;
1348
+ price_places?: string;
1349
+ cancel?: boolean;
1350
+ place?: boolean;
1351
+ }): Promise<any[]>;
1352
+ refresh(live_refresh?: boolean): Promise<{
1353
+ instance: PositionsView;
1354
+ existingOrders: void | Order[];
1355
+ }>;
1356
+ placeTrade(payload: {
1357
+ place?: boolean;
1358
+ tp?: boolean;
1359
+ stop?: boolean;
1360
+ raw?: boolean;
1361
+ cancel?: boolean;
1362
+ ignore_config?: boolean;
1363
+ }): Promise<any>;
1364
+ }
1365
+ declare class ExchangeAccount$1 {
1366
+ private instance;
1367
+ exchange: BaseExchange;
1368
+ main_exchange?: BaseExchange;
1369
+ private app_db;
1370
+ private long_position?;
1371
+ private short_position?;
1372
+ constructor(payload: ExchangeType, options: {
1373
+ exchange: BaseExchange;
1374
+ app_db: AppDatabase;
1375
+ main_exchange?: BaseExchange;
1376
+ });
1377
+ /**
1378
+ *In order to avoid rate limiting issues, we cache the live exchange
1379
+ details for each symbol for an account in the database with an option
1380
+ to refresh.
1381
+ */
1382
+ getDBInstance(): AppDatabase;
1383
+ getLiveExchangeInstance(payload: {
1384
+ symbol: string;
1385
+ refresh?: boolean;
1386
+ refresh_symbol_config?: boolean;
1387
+ }): Promise<import("pocketbase").RecordModel>;
1388
+ initializePositions(payload: {
1389
+ symbol: string;
1390
+ as_view?: boolean;
1391
+ kind: "long" | "short";
1392
+ }): Promise<ExchangePosition>;
1393
+ getActiveAccount(payload: {
1394
+ symbol: string;
1395
+ full?: boolean;
1396
+ refresh?: boolean;
1397
+ }): Promise<Account | {
1398
+ liquidation: {
1399
+ long: number;
1400
+ short: number;
418
1401
  };
419
1402
  active_account: Account;
420
1403
  current_price: any;
421
1404
  exchange: any;
422
1405
  }>;
423
- syncAccount(options: {
1406
+ refreshAccount(payload: {
424
1407
  symbol: string;
425
- kind?: "long" | "short";
426
- update?: boolean;
427
- as_view?: boolean;
1408
+ live_refresh?: boolean;
428
1409
  leverage?: number;
429
1410
  }): Promise<(PositionsView & {
430
1411
  expand?: {
431
1412
  config: ScheduledTrade;
1413
+ account: ExchangeAccount;
432
1414
  };
433
- }) | (PositionsView & {
1415
+ })[]>;
1416
+ syncAccount(options: {
1417
+ symbol: string;
1418
+ kind?: "long" | "short";
1419
+ update?: boolean;
1420
+ as_view?: boolean;
1421
+ leverage?: number;
1422
+ live_refresh?: boolean;
1423
+ }): Promise<PositionsView | (PositionsView & {
434
1424
  expand?: {
435
1425
  config: ScheduledTrade;
1426
+ account: ExchangeAccount;
436
1427
  };
437
1428
  })[]>;
438
1429
  getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
439
1430
  syncOrders(options: {
440
1431
  symbol: string;
441
- kind: "long" | "short";
1432
+ kind?: "long" | "short";
442
1433
  update?: boolean;
443
- }): Promise<import("pocketbase").RecordModel[]>;
1434
+ }): Promise<void | Order[]>;
1435
+ toggleStopBuying(payload: {
1436
+ symbol: string;
1437
+ kind: "long" | "short";
1438
+ should_stop?: boolean;
1439
+ }): Promise<import("pocketbase").RecordModel>;
444
1440
  cancelOrders(payload: {
445
1441
  symbol: string;
446
1442
  kind: "long" | "short";
447
1443
  price?: number;
448
1444
  all?: boolean;
449
1445
  stop?: boolean;
450
- }): Promise<{
1446
+ limit?: boolean;
1447
+ }): Promise<void | {
451
1448
  success: boolean;
452
1449
  message: string;
453
1450
  exchange_result?: undefined;
@@ -467,6 +1464,12 @@ declare class ExchangeAccount$1 {
467
1464
  symbol: string;
468
1465
  orders: number[];
469
1466
  }): Promise<any>;
1467
+ getBreakEvenPrice(payload: {
1468
+ symbol: string;
1469
+ }): Promise<{
1470
+ price: number;
1471
+ direction: string;
1472
+ }>;
470
1473
  buildAppConfig(payload: {
471
1474
  entry: number;
472
1475
  stop: number;
@@ -477,82 +1480,604 @@ declare class ExchangeAccount$1 {
477
1480
  update_db?: boolean;
478
1481
  profit_percent?: number;
479
1482
  }): Promise<AppConfig>;
1483
+ tradeConfig(payload: {
1484
+ symbol: string;
1485
+ kind: "long" | "short";
1486
+ }): Promise<AppConfig>;
1487
+ justInTimeProfit(payload: {
1488
+ symbol: string;
1489
+ target_pnl: number;
1490
+ kind: "long" | "short";
1491
+ refresh?: boolean;
1492
+ place?: boolean;
1493
+ take_profit?: number;
1494
+ pause_tp?: boolean;
1495
+ }): Promise<{
1496
+ sell_ratio: number;
1497
+ current_pnl: number;
1498
+ profit_percent: number;
1499
+ current_price: number;
1500
+ notional_value: number;
1501
+ }>;
1502
+ buildTrades(payload: {
1503
+ symbol: string;
1504
+ kind: "long" | "short";
1505
+ risk?: number;
1506
+ }): Promise<{
1507
+ trades: any[];
1508
+ max_size: any;
1509
+ last_price: any;
1510
+ total_size: number;
1511
+ avg_entry: number;
1512
+ }>;
480
1513
  placeConfigOrders(app_config: AppConfig, solution: {
481
1514
  risk_reward: number;
482
1515
  entry: number;
483
1516
  stop: number;
484
- risk_per_trade: number;
485
- avg_size: number;
486
- neg_pnl: number;
1517
+ risk_per_trade: number;
1518
+ avg_size: number;
1519
+ neg_pnl: number;
1520
+ min_size: number;
1521
+ symbol: string;
1522
+ }, place?: boolean, skip_stop?: boolean): Promise<{
1523
+ entry_orders: {
1524
+ orders: {
1525
+ entry: any;
1526
+ quantity: any;
1527
+ reverse_avg_entry: any;
1528
+ reverse_avg_quantity: any;
1529
+ avg_entry: any;
1530
+ avg_size: any;
1531
+ }[];
1532
+ kind: "long" | "short";
1533
+ };
1534
+ stop_orders: {
1535
+ stop: number;
1536
+ final_stop: number;
1537
+ kind: "long" | "short";
1538
+ quantity: any;
1539
+ is_limit: boolean;
1540
+ neg_pnl: any;
1541
+ };
1542
+ trades: any[];
1543
+ }>;
1544
+ determineAmountToBuy(payload: {
1545
+ orders: any[];
1546
+ kind: "long" | "short";
1547
+ refresh?: boolean;
1548
+ decimal_places?: string;
1549
+ price_places?: string;
1550
+ symbol: string;
1551
+ cancel?: boolean;
1552
+ place?: boolean;
1553
+ }): Promise<any[]>;
1554
+ placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
1555
+ symbol: string;
1556
+ entry: number;
1557
+ stop: number;
1558
+ risk_reward: number;
1559
+ risk: number;
1560
+ place?: boolean;
1561
+ update_db?: boolean;
1562
+ raw?: boolean;
1563
+ use_current?: boolean;
1564
+ }): Promise<any>;
1565
+ getOrCreatePositionConfig(payload: {
1566
+ symbol: string;
1567
+ kind: "long" | "short";
1568
+ risk?: number;
1569
+ risk_reward?: number;
1570
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
1571
+ getPositionConfig(payload: {
1572
+ symbol: string;
1573
+ kind: "long" | "short";
1574
+ params?: {
1575
+ entry?: number;
1576
+ stop?: number;
1577
+ risk_reward?: number;
1578
+ risk?: number;
1579
+ profit_percent?: number;
1580
+ place_tp?: boolean;
1581
+ profit?: number;
1582
+ };
1583
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
1584
+ getCurrentPrice(symbol: string): Promise<any>;
1585
+ getAccountStrategy(payload: {
1586
+ symbol: string;
1587
+ }): Promise<AccountStrategy>;
1588
+ buildReduceConfig(payload: {
1589
+ symbol: string;
1590
+ kind?: "long" | "short";
1591
+ as_dict?: boolean;
1592
+ target_pnl?: number;
1593
+ trigger?: {
1594
+ long: boolean;
1595
+ short: boolean;
1596
+ };
1597
+ use_full?: boolean;
1598
+ }): Promise<{
1599
+ trigger_short: boolean;
1600
+ trigger_long: boolean;
1601
+ symbol: string;
1602
+ short_minimum_pnl: number;
1603
+ long_minimum_pnl: number;
1604
+ short_profit: any;
1605
+ long_profit: any;
1606
+ owner: string;
1607
+ exchange: string;
1608
+ not_reduce: boolean;
1609
+ reduce_ratio_long: any;
1610
+ reduce_ratio_short: any;
1611
+ use_full_long: any;
1612
+ use_full_short: any;
1613
+ } | {
1614
+ long: {
1615
+ minimum_pnl: number;
1616
+ max_size: number;
1617
+ profit: any;
1618
+ increase: boolean;
1619
+ not_reduce: boolean;
1620
+ ratio: any;
1621
+ use_full: boolean;
1622
+ sell_ratio: any;
1623
+ };
1624
+ short: {
1625
+ minimum_pnl: number;
1626
+ max_size: number;
1627
+ profit: any;
1628
+ increase: boolean;
1629
+ not_reduce: boolean;
1630
+ ratio: any;
1631
+ use_full: boolean;
1632
+ sell_ratio: any;
1633
+ };
1634
+ trigger: {
1635
+ long: boolean;
1636
+ short: boolean;
1637
+ };
1638
+ }>;
1639
+ getOriginalPlannedStop(payload: {
1640
+ symbol: string;
1641
+ kind: "long" | "short";
1642
+ }): Promise<any>;
1643
+ syncReduceClosePosition(payload?: {
1644
+ symbol: string;
1645
+ kind?: "long" | "short";
1646
+ trigger?: boolean;
1647
+ }): Promise<any>;
1648
+ reduceMajorPositionEntry(payload: {
1649
+ symbol: string;
1650
+ long: any;
1651
+ short: any;
1652
+ trigger: {
1653
+ long: boolean;
1654
+ short: boolean;
1655
+ };
1656
+ }): Promise<any>;
1657
+ placeProfitAndStop(payload: {
1658
+ symbol: string;
1659
+ trigger?: boolean;
1660
+ refresh?: boolean;
1661
+ kind?: "long" | "short";
1662
+ target_pnl?: number;
1663
+ }): Promise<any>;
1664
+ reEnterPositionOnEmpty(symbol: string): Promise<void>;
1665
+ generate_config_params(payload: {
1666
+ entry: number;
1667
+ stop: number;
1668
+ risk_reward: number;
1669
+ risk: number;
1670
+ symbol: string;
1671
+ with_trades?: boolean;
1672
+ }): Promise<any>;
1673
+ build_short_order(payload: {
1674
+ symbol: string;
1675
+ kind: "long" | "short";
1676
+ }): Promise<any>;
1677
+ extrapolateShortConfig(payload: {
1678
+ kind: "long" | "short";
1679
+ symbol: string;
1680
+ risk_reward?: number;
1681
+ risk?: number;
1682
+ }): Promise<any>;
1683
+ placeMarketOrder(payload: {
1684
+ symbol: string;
1685
+ kind: "long" | "short";
1686
+ quantity: number;
1687
+ }): Promise<void>;
1688
+ placeSingleOrder(payload: {
1689
+ symbol: string;
1690
+ kind: "long" | "short";
1691
+ }): Promise<string>;
1692
+ triggerTradeFromConfig(payload: {
1693
+ symbol: string;
1694
+ kind: "long" | "short";
1695
+ place?: boolean;
1696
+ raw?: boolean;
1697
+ tp?: boolean;
1698
+ stop?: boolean;
1699
+ use_current?: boolean;
1700
+ ignore_config?: boolean;
1701
+ }): Promise<any>;
1702
+ verifyStopLoss(payload: {
1703
+ symbol: string;
1704
+ kind: "long" | "short";
1705
+ revert?: boolean;
1706
+ }): Promise<void | Order[]>;
1707
+ windDownSymbol(payload: {
1708
+ symbol: string;
1709
+ risk_reward?: number;
1710
+ risk?: number;
1711
+ }): Promise<void>;
1712
+ updateTargetPnl(payload: {
1713
+ symbol: string;
1714
+ kind: "long" | "short";
1715
+ }): Promise<number>;
1716
+ placeOppositeTradeAction(payload: {
1717
+ symbol: string;
1718
+ kind: "long" | "short";
1719
+ data: {
1720
+ avg: {
1721
+ quantity: number;
1722
+ price: number;
1723
+ };
1724
+ entry: number;
1725
+ stop: number;
1726
+ risk_per_trade: number;
1727
+ profit_percent: number;
1728
+ risk_reward: number;
1729
+ };
1730
+ }): Promise<void>;
1731
+ buildOppositeTrades(payload: {
1732
+ symbol: string;
1733
+ kind: "long" | "short";
1734
+ place?: boolean;
1735
+ place_symbol?: string;
1736
+ }): Promise<{
1737
+ avg: {
1738
+ entry: number;
1739
+ price: number;
1740
+ quantity: number;
1741
+ };
1742
+ loss: number;
1743
+ profit_percent: number;
1744
+ fee: number;
1745
+ risk_per_trade: number;
1746
+ risk_reward: number;
1747
+ symbol?: string;
1748
+ focus: number;
1749
+ budget: number;
1750
+ support: number;
1751
+ resistance: number;
1752
+ percent_change: number;
1753
+ tradeSplit?: number;
1754
+ take_profit?: number;
1755
+ kind: "long" | "short";
1756
+ entry: number;
1757
+ stop: number;
487
1758
  min_size: number;
1759
+ price_places?: string;
1760
+ strategy?: "quantity" | "entry";
1761
+ as_array?: boolean;
1762
+ decimal_places?: string;
1763
+ min_profit?: number;
1764
+ raw?: boolean;
1765
+ gap?: number;
1766
+ rr?: number;
1767
+ max_size?: number;
1768
+ }>;
1769
+ runSimulation(payload: {
488
1770
  symbol: string;
489
- }, place?: boolean, skip_stop?: boolean): Promise<{
490
- entry_orders: {
491
- orders: {
492
- entry: any;
493
- quantity: any;
494
- reverse_avg_entry: any;
495
- reverse_avg_quantity: any;
496
- avg_entry: any;
497
- avg_size: any;
498
- }[];
499
- kind: "long" | "short";
1771
+ kind: "long" | "short";
1772
+ iterations?: number;
1773
+ raw?: boolean;
1774
+ }): Promise<Strategy | {
1775
+ last_entry: any;
1776
+ first_entry: any;
1777
+ threshold: any;
1778
+ risk: number;
1779
+ risk_reward: number;
1780
+ spread: number;
1781
+ gap_loss: number;
1782
+ net_profit: number;
1783
+ long: {
1784
+ avg_entry: number;
1785
+ avg_size: number;
1786
+ loss: number;
1787
+ stop: number;
1788
+ stop_quantity: number;
1789
+ re_entry_quantity: number;
1790
+ initial_pnl: number;
1791
+ tp: number;
1792
+ incurred_loss: number;
1793
+ pnl: number;
1794
+ remaining_quantity: number;
500
1795
  };
501
- stop_orders: {
1796
+ short: {
1797
+ avg_entry: number;
1798
+ avg_size: number;
1799
+ loss: number;
502
1800
  stop: number;
503
- final_stop: number;
504
- kind: "long" | "short";
505
- quantity: any;
506
- is_limit: boolean;
1801
+ stop_quantity: number;
1802
+ re_entry_quantity: number;
1803
+ initial_pnl: number;
1804
+ tp: number;
1805
+ incurred_loss: number;
1806
+ pnl: number;
1807
+ remaining_quantity: number;
507
1808
  };
508
- trades: any[];
1809
+ }[]>;
1810
+ getCurrentRun(payload: {
1811
+ symbol: string;
1812
+ kind?: "long" | "short";
1813
+ pnl?: number;
1814
+ }): Promise<true | import("pocketbase").RecordModel>;
1815
+ recomputeSymbolConfig(payload: {
1816
+ symbol: string;
1817
+ refresh?: boolean;
1818
+ }): Promise<SymbolConfig>;
1819
+ /**
1820
+ * This function builds a config for a symbol
1821
+ * @param payload
1822
+ * @returns
1823
+ */
1824
+ buildConfigForSymbol(payload: {
1825
+ symbol: string;
1826
+ risk: number;
1827
+ kind?: "long" | "short";
1828
+ risk_reward?: number;
1829
+ as_config?: boolean;
1830
+ with_trades?: boolean;
1831
+ }): Promise<any>;
1832
+ triggerBullishMarket(payload: {
1833
+ symbol: string;
1834
+ profit_percent?: number;
1835
+ risk_reward?: number;
1836
+ }): Promise<any>;
1837
+ updateAllActiveSymbols(payload: {
1838
+ interval?: number;
1839
+ }): Promise<void>;
1840
+ updateAllPositionsWithNoConfig(payload: {
1841
+ kind: "long" | "short";
1842
+ }): Promise<void>;
1843
+ getSymbolsForPositions(): Promise<any[]>;
1844
+ getNonEssentialSymbols(): Promise<any[]>;
1845
+ _terminatePositions(payload: {
1846
+ symbol: string;
1847
+ }): Promise<void>;
1848
+ getOrders(payload: {
1849
+ symbol: string;
1850
+ kind: "long" | "short";
1851
+ type: "limit" | "stop" | "tp";
1852
+ }): Promise<Order[]>;
1853
+ syncPositionConfigs(payload: {
1854
+ symbol: string;
1855
+ kind: "long" | "short";
1856
+ refresh?: boolean;
1857
+ }): Promise<void>;
1858
+ terminatePositions(payload: {
1859
+ symbol: string;
1860
+ }): Promise<void>;
1861
+ fetchAndUpdateTopMovers(): Promise<{
1862
+ updated_bullish: BullishMarket[];
1863
+ moved_to_winding: WindingDownMarket[];
509
1864
  }>;
510
- placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
1865
+ computeTargetPnl(payload: {
511
1866
  symbol: string;
512
- entry: number;
1867
+ kind: "long" | "short";
1868
+ }): Promise<number>;
1869
+ placeStopLimit(payload: {
1870
+ symbol: string;
1871
+ kind: "long" | "short";
1872
+ place?: boolean;
513
1873
  stop: number;
514
- risk_reward: number;
515
- risk: number;
1874
+ quantity?: number;
1875
+ }): Promise<any>;
1876
+ placeTrade(payload: {
1877
+ symbol: string;
1878
+ kind: "long" | "short";
516
1879
  place?: boolean;
517
- update_db?: boolean;
1880
+ limit?: boolean;
1881
+ tp?: boolean;
1882
+ stop?: boolean;
1883
+ raw?: boolean;
1884
+ cancel?: boolean;
1885
+ ignore_config?: boolean;
1886
+ target_pnl?: number;
518
1887
  }): Promise<any>;
519
- getPositionConfig(payload: {
1888
+ updateConfigPnl(payload: {
520
1889
  symbol: string;
521
1890
  kind: "long" | "short";
522
- params?: {
1891
+ }): Promise<void>;
1892
+ determineReduceTp(payload: {
1893
+ symbol: string;
1894
+ factor: number;
1895
+ }): Promise<{
1896
+ long_diff: number;
1897
+ short_diff: number;
1898
+ gap: number;
1899
+ gap_cost: number;
1900
+ long_tp: number;
1901
+ short_tp: number;
1902
+ long_percent: number;
1903
+ short_percent: number;
1904
+ }>;
1905
+ profitWithinGapStrategy(payload: {
1906
+ symbol: string;
1907
+ }): Promise<{
1908
+ reverse_config: any;
1909
+ reverse_action: {
1910
+ avg: {
1911
+ entry: number;
1912
+ price: number;
1913
+ quantity: number;
1914
+ };
1915
+ loss: number;
1916
+ profit_percent: number;
1917
+ fee: number;
1918
+ risk_per_trade: number;
1919
+ risk_reward: number;
1920
+ symbol?: string;
1921
+ focus: number;
1922
+ budget: number;
1923
+ support: number;
1924
+ resistance: number;
1925
+ percent_change: number;
1926
+ tradeSplit?: number;
1927
+ take_profit?: number;
1928
+ kind: "long" | "short";
523
1929
  entry: number;
524
1930
  stop: number;
525
- risk_reward: number;
526
- risk: number;
527
- profit_percent?: number;
1931
+ min_size: number;
1932
+ price_places?: string;
1933
+ strategy?: "quantity" | "entry";
1934
+ as_array?: boolean;
1935
+ decimal_places?: string;
1936
+ min_profit?: number;
1937
+ raw?: boolean;
1938
+ gap?: number;
1939
+ rr?: number;
1940
+ max_size?: number;
1941
+ };
1942
+ reverse_orders_to_buy: any;
1943
+ positions: {
1944
+ long: PositionsView & {
1945
+ expand?: {
1946
+ account_strategy?: AccountStrategy;
1947
+ };
1948
+ };
1949
+ short: PositionsView & {
1950
+ expand?: {
1951
+ account_strategy?: AccountStrategy;
1952
+ };
1953
+ };
1954
+ };
1955
+ orders_to_place: any;
1956
+ config_details: {
1957
+ app_config: {
1958
+ fee: number;
1959
+ risk_per_trade: number;
1960
+ risk_reward: number;
1961
+ symbol?: string;
1962
+ focus: number;
1963
+ budget: number;
1964
+ support: number;
1965
+ resistance: number;
1966
+ percent_change: number;
1967
+ tradeSplit?: number;
1968
+ take_profit?: number;
1969
+ kind: "long" | "short";
1970
+ entry: number;
1971
+ stop: number;
1972
+ min_size: number;
1973
+ price_places?: string;
1974
+ strategy?: "quantity" | "entry";
1975
+ as_array?: boolean;
1976
+ decimal_places?: string;
1977
+ min_profit?: number;
1978
+ raw?: boolean;
1979
+ gap?: number;
1980
+ rr?: number;
1981
+ max_size?: number;
1982
+ };
1983
+ last_value: any;
1984
+ config: {
1985
+ entry: number;
1986
+ stop: number;
1987
+ risk: number;
1988
+ risk_reward: number | {
1989
+ result: any[];
1990
+ value: number;
1991
+ total: number;
1992
+ risk_per_trade: number;
1993
+ max: number;
1994
+ min: number;
1995
+ neg_pnl: any;
1996
+ entry: any;
1997
+ };
1998
+ profit_percent: number;
1999
+ };
2000
+ pnl: number;
528
2001
  };
529
- }): Promise<import("pocketbase").RecordModel>;
530
- getCurrentPrice(symbol: string): Promise<any>;
531
- getPositionStrategy(): Promise<{
532
- strategy_instance: Strategy;
533
- focus_account: ExchangeAccount;
534
2002
  }>;
535
- getOriginalPlannedStop(payload: {
2003
+ generateGapTp(payload: {
536
2004
  symbol: string;
537
- kind: "long" | "short";
538
- }): Promise<any>;
539
- syncReduceClosePosition(symbol: string, payload?: {
540
- kind?: "long" | "short";
541
- long?: CodeNode;
542
- short?: CodeNode;
543
- trigger?: {
544
- long: boolean;
545
- short: boolean;
2005
+ factor?: number;
2006
+ }): Promise<{
2007
+ profit_percent: {
2008
+ long: number;
2009
+ short: number;
546
2010
  };
547
- }): Promise<any>;
2011
+ risk: {
2012
+ short: number;
2013
+ long: number;
2014
+ };
2015
+ take_profit: {
2016
+ long: number;
2017
+ short: number;
2018
+ };
2019
+ to_reduce: {
2020
+ short: number;
2021
+ long: number;
2022
+ };
2023
+ full_reduce: {
2024
+ short: number;
2025
+ long: number;
2026
+ };
2027
+ sell_quantity: {
2028
+ short: number;
2029
+ long: number;
2030
+ };
2031
+ gap: number;
2032
+ gap_loss: number;
2033
+ }>;
2034
+ getSellPriceFromStrategy(payload: {
2035
+ symbol: string;
2036
+ reduce_position: PositionsView;
2037
+ }): Promise<{
2038
+ pnl: number;
2039
+ loss: number;
2040
+ original_pnl: number;
2041
+ reward_factor: number;
2042
+ profit_percent: number;
2043
+ kind: "long" | "short";
2044
+ sell_price: number;
2045
+ quantity: number;
2046
+ price_places: string;
2047
+ decimal_places: string;
2048
+ }>;
548
2049
  }
2050
+ declare function getExchangeAccount(payload: {
2051
+ account: ExchangeType;
2052
+ app_db: AppDatabase;
2053
+ getCredentials: (account: string, exchange: string) => {
2054
+ api_key: string;
2055
+ api_secret: string;
2056
+ email: string;
2057
+ };
2058
+ proxyOptions?: {
2059
+ proxy?: any;
2060
+ ignore_proxy?: boolean;
2061
+ };
2062
+ canWithdraw?: boolean;
2063
+ }): Promise<ExchangeAccount$1>;
549
2064
  declare class App {
550
- private app_db;
2065
+ app_db: AppDatabase;
2066
+ proxyOptions?: {
2067
+ proxy?: any;
2068
+ ignore_proxy?: boolean;
2069
+ canWithdraw?: boolean;
2070
+ };
551
2071
  private getCredentials;
552
- constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
2072
+ constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => {
553
2073
  api_key: string;
554
2074
  api_secret: string;
555
- }>);
2075
+ email: string;
2076
+ }, proxyOptions?: {
2077
+ proxy?: any;
2078
+ ignore_proxy?: boolean;
2079
+ canWithdraw?: boolean;
2080
+ });
556
2081
  getExchangeAccount(account: ExchangeType): Promise<ExchangeAccount$1>;
557
2082
  syncAccount(payload: {
558
2083
  account: ExchangeType;
@@ -560,13 +2085,10 @@ declare class App {
560
2085
  kind?: "long" | "short";
561
2086
  update?: boolean;
562
2087
  as_view?: boolean;
563
- }): Promise<(PositionsView & {
564
- expand?: {
565
- config: ScheduledTrade;
566
- };
567
- }) | (PositionsView & {
2088
+ }): Promise<PositionsView | (PositionsView & {
568
2089
  expand?: {
569
2090
  config: ScheduledTrade;
2091
+ account: ExchangeAccount;
570
2092
  };
571
2093
  })[]>;
572
2094
  syncOrders(payload: {
@@ -581,7 +2103,7 @@ declare class App {
581
2103
  price?: number;
582
2104
  all?: boolean;
583
2105
  stop?: boolean;
584
- }): Promise<{
2106
+ }): Promise<void | {
585
2107
  success: boolean;
586
2108
  message: string;
587
2109
  exchange_result?: undefined;
@@ -597,83 +2119,6 @@ declare class App {
597
2119
  message?: undefined;
598
2120
  exchange_result?: undefined;
599
2121
  }>;
600
- triggerTradeFromConfig(payload: {
601
- account: ExchangeType;
602
- symbol: string;
603
- kind: "long" | "short";
604
- }): Promise<any>;
605
- toggleStopBuying(payload: {
606
- account: ExchangeType;
607
- symbol: string;
608
- kind: "long" | "short";
609
- should_stop?: boolean;
610
- }): Promise<import("pocketbase").RecordModel>;
611
- generate_config_params(exchange_account: ExchangeAccount$1, payload: {
612
- entry: number;
613
- stop: number;
614
- risk_reward: number;
615
- risk: number;
616
- symbol: string;
617
- }): Promise<{
618
- place_stop: boolean;
619
- profit_percent: number;
620
- entry: number;
621
- stop: number;
622
- avg_size: any;
623
- avg_entry: any;
624
- risk_reward: number;
625
- neg_pnl: any;
626
- risk: number;
627
- }>;
628
- generateConfig(payload: {
629
- account: ExchangeType;
630
- symbol: string;
631
- kind: "long" | "short";
632
- update_orders?: boolean;
633
- place_orders?: boolean;
634
- }): Promise<any>;
635
- updateReduceRatio(payload: {
636
- account: ExchangeType;
637
- symbol: string;
638
- }): Promise<{
639
- long_position: any;
640
- short_position: any;
641
- long_db_position: any;
642
- short_db_position: any;
643
- balance: any;
644
- }>;
645
- extrapolateShortConfig(payload: {
646
- account: ExchangeType;
647
- kind: "long" | "short";
648
- symbol: string;
649
- risk_reward?: number;
650
- }): Promise<PositionsView | {
651
- place_stop: boolean;
652
- profit_percent: number;
653
- entry: number;
654
- stop: number;
655
- avg_size: any;
656
- avg_entry: any;
657
- risk_reward: number;
658
- neg_pnl: any;
659
- risk: number;
660
- }>;
661
- verifyStopLoss(payload: {
662
- account: ExchangeType;
663
- symbol: string;
664
- kind: "long" | "short";
665
- revert?: boolean;
666
- }): Promise<import("pocketbase").RecordModel[]>;
667
- updateTopMovers(payload?: {
668
- new_markets: {
669
- symbol: string;
670
- percent: number;
671
- }[];
672
- totalRisk: number;
673
- }): Promise<{
674
- updated_bullish: BullishMarket[];
675
- moved_to_winding: WindingDownMarket[];
676
- }>;
677
2122
  getWindingDownMarkets(): Promise<WindingDownMarket[]>;
678
2123
  updateSymbolConfigs(payload: {
679
2124
  configs: {
@@ -690,6 +2135,150 @@ declare class App {
690
2135
  created: number;
691
2136
  }>;
692
2137
  updateAllAccountWithSymbols(with_positions?: boolean): Promise<void>;
2138
+ windDownSymbol(payload: {
2139
+ symbol: string;
2140
+ risk?: number;
2141
+ }): Promise<boolean>;
2142
+ getNonEssentialSymbols(): Promise<Set<any>>;
2143
+ refreshAllPositionsWithSymbol(payload: {
2144
+ symbol: string;
2145
+ }): Promise<void>;
2146
+ autoFollowPositions(): Promise<void>;
2147
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
2148
+ updateTpOnAllMarkets(): Promise<void>;
2149
+ triggerMoverTask(payload: {
2150
+ callback: (params: {
2151
+ symbol: string;
2152
+ account: ExchangeType;
2153
+ }) => Promise<any>;
2154
+ removeCallback?: (params: {
2155
+ symbol: string;
2156
+ account: ExchangeType;
2157
+ }) => Promise<any>;
2158
+ }): Promise<void>;
2159
+ placeTrade(payload: {
2160
+ account: ExchangeType;
2161
+ symbol: string;
2162
+ kind: "long" | "short";
2163
+ place?: boolean;
2164
+ tp?: boolean;
2165
+ cancel?: boolean;
2166
+ raw?: boolean;
2167
+ }): Promise<any>;
2168
+ runDbStrategyAccounts(callback: (params: {
2169
+ symbol: string;
2170
+ account: ExchangeType;
2171
+ }) => Promise<any>): Promise<void>;
2172
+ profitWithinGapStrategy(payload: {
2173
+ account: ExchangeType;
2174
+ symbol: string;
2175
+ }): Promise<{
2176
+ reverse_config: any;
2177
+ reverse_action: {
2178
+ avg: {
2179
+ entry: number;
2180
+ price: number;
2181
+ quantity: number;
2182
+ };
2183
+ loss: number;
2184
+ profit_percent: number;
2185
+ fee: number;
2186
+ risk_per_trade: number;
2187
+ risk_reward: number;
2188
+ symbol?: string;
2189
+ focus: number;
2190
+ budget: number;
2191
+ support: number;
2192
+ resistance: number;
2193
+ percent_change: number;
2194
+ tradeSplit?: number;
2195
+ take_profit?: number;
2196
+ kind: "long" | "short";
2197
+ entry: number;
2198
+ stop: number;
2199
+ min_size: number;
2200
+ price_places?: string;
2201
+ strategy?: "quantity" | "entry";
2202
+ as_array?: boolean;
2203
+ decimal_places?: string;
2204
+ min_profit?: number;
2205
+ raw?: boolean;
2206
+ gap?: number;
2207
+ rr?: number;
2208
+ max_size?: number;
2209
+ };
2210
+ reverse_orders_to_buy: any;
2211
+ positions: {
2212
+ long: PositionsView & {
2213
+ expand?: {
2214
+ account_strategy?: AccountStrategy;
2215
+ };
2216
+ };
2217
+ short: PositionsView & {
2218
+ expand?: {
2219
+ account_strategy?: AccountStrategy;
2220
+ };
2221
+ };
2222
+ };
2223
+ orders_to_place: any;
2224
+ config_details: {
2225
+ app_config: {
2226
+ fee: number;
2227
+ risk_per_trade: number;
2228
+ risk_reward: number;
2229
+ symbol?: string;
2230
+ focus: number;
2231
+ budget: number;
2232
+ support: number;
2233
+ resistance: number;
2234
+ percent_change: number;
2235
+ tradeSplit?: number;
2236
+ take_profit?: number;
2237
+ kind: "long" | "short";
2238
+ entry: number;
2239
+ stop: number;
2240
+ min_size: number;
2241
+ price_places?: string;
2242
+ strategy?: "quantity" | "entry";
2243
+ as_array?: boolean;
2244
+ decimal_places?: string;
2245
+ min_profit?: number;
2246
+ raw?: boolean;
2247
+ gap?: number;
2248
+ rr?: number;
2249
+ max_size?: number;
2250
+ };
2251
+ last_value: any;
2252
+ config: {
2253
+ entry: number;
2254
+ stop: number;
2255
+ risk: number;
2256
+ risk_reward: number | {
2257
+ result: any[];
2258
+ value: number;
2259
+ total: number;
2260
+ risk_per_trade: number;
2261
+ max: number;
2262
+ min: number;
2263
+ neg_pnl: any;
2264
+ entry: any;
2265
+ };
2266
+ profit_percent: number;
2267
+ };
2268
+ pnl: number;
2269
+ };
2270
+ }>;
2271
+ reduceExistingPosition(payload: {
2272
+ main_account: ExchangeType & {
2273
+ symbol: string;
2274
+ };
2275
+ reduce_account: ExchangeType & {
2276
+ symbol: string;
2277
+ };
2278
+ kind: "long" | "short";
2279
+ place?: boolean;
2280
+ increase?: boolean;
2281
+ }): Promise<any>;
693
2282
  }
694
2283
  export declare function initApp(payload: {
695
2284
  db: {
@@ -697,14 +2286,44 @@ export declare function initApp(payload: {
697
2286
  email: string;
698
2287
  password: string;
699
2288
  };
700
- getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
2289
+ password?: string;
2290
+ getCredentials: (account: string, exchange: string) => {
701
2291
  api_key: string;
702
2292
  api_secret: string;
703
- }>;
2293
+ email: string;
2294
+ };
2295
+ proxy?: any;
2296
+ ignore_proxy?: boolean;
2297
+ canWithdraw?: boolean;
2298
+ triggerToken?: string;
2299
+ }): Promise<App>;
2300
+ declare function getCredentials(account: string, exchange: string): {
2301
+ api_key: string;
2302
+ api_secret: string;
2303
+ email: string;
2304
+ };
2305
+ export declare function initialize(payload: {
2306
+ password?: string;
2307
+ proxy?: any;
2308
+ ignore_proxy?: boolean;
2309
+ canWithdraw?: boolean;
704
2310
  }): Promise<App>;
705
2311
 
2312
+ declare namespace database {
2313
+ export { AppDatabase, ExchangeType, initPocketBaseClient };
2314
+ }
2315
+ declare namespace exchange_account {
2316
+ export { ExchangeAccount$1 as ExchangeAccount, getExchangeAccount };
2317
+ }
2318
+ declare namespace app {
2319
+ export { App, getCredentials, initApp, initialize };
2320
+ }
2321
+
706
2322
  export {
707
2323
  ExchangeAccount$1 as ExchangeAccount,
2324
+ app,
2325
+ database,
2326
+ exchange_account,
708
2327
  };
709
2328
 
710
2329
  export {};