@gbozee/ultimate 0.0.2-1 → 0.0.2-100

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