@gbozee/ultimate 0.0.2-10 → 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,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,386 @@ 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
+ };
358
808
  }
359
- 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;
360
845
  minimum_pnl: number;
846
+ take_profit?: number;
847
+ increase_position: boolean;
848
+ minimum_size: any;
849
+ first_order_size: number;
850
+ gap: number;
361
851
  max_size: number;
362
- profit: number;
363
- ratio?: number;
364
- increase: boolean;
365
- not_reduce?: boolean;
366
- reduce_ratio?: number;
367
- 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;
368
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[];
369
947
  export type AppConfig = {
370
948
  fee: number;
371
949
  risk_per_trade: number;
@@ -391,63 +969,445 @@ export type AppConfig = {
391
969
  gap?: number;
392
970
  rr?: number;
393
971
  max_size?: number;
972
+ last_value?: any;
973
+ entries?: any[];
394
974
  };
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;
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;
418
1144
  };
419
- active_account: Account;
420
- current_price: any;
421
- exchange: any;
422
- }>;
423
- syncAccount(options: {
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: {
424
1352
  symbol: string;
425
- kind?: "long" | "short";
426
- update?: boolean;
427
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;
428
1372
  leverage?: number;
429
1373
  }): Promise<(PositionsView & {
430
1374
  expand?: {
431
1375
  config: ScheduledTrade;
1376
+ account: ExchangeAccount;
432
1377
  };
433
- }) | (PositionsView & {
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 & {
434
1387
  expand?: {
435
1388
  config: ScheduledTrade;
1389
+ account: ExchangeAccount;
436
1390
  };
437
1391
  })[]>;
438
1392
  getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
439
1393
  syncOrders(options: {
440
1394
  symbol: string;
441
- kind: "long" | "short";
1395
+ kind?: "long" | "short";
442
1396
  update?: boolean;
443
- }): Promise<import("pocketbase").RecordModel[]>;
1397
+ }): Promise<void | Order[]>;
1398
+ toggleStopBuying(payload: {
1399
+ symbol: string;
1400
+ kind: "long" | "short";
1401
+ should_stop?: boolean;
1402
+ }): Promise<import("pocketbase").RecordModel>;
444
1403
  cancelOrders(payload: {
445
1404
  symbol: string;
446
1405
  kind: "long" | "short";
447
1406
  price?: number;
448
1407
  all?: boolean;
449
1408
  stop?: boolean;
450
- }): Promise<{
1409
+ limit?: boolean;
1410
+ }): Promise<void | {
451
1411
  success: boolean;
452
1412
  message: string;
453
1413
  exchange_result?: undefined;
@@ -467,6 +1427,12 @@ declare class ExchangeAccount$1 {
467
1427
  symbol: string;
468
1428
  orders: number[];
469
1429
  }): Promise<any>;
1430
+ getBreakEvenPrice(payload: {
1431
+ symbol: string;
1432
+ }): Promise<{
1433
+ price: number;
1434
+ direction: string;
1435
+ }>;
470
1436
  buildAppConfig(payload: {
471
1437
  entry: number;
472
1438
  stop: number;
@@ -477,82 +1443,604 @@ declare class ExchangeAccount$1 {
477
1443
  update_db?: boolean;
478
1444
  profit_percent?: number;
479
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
+ }>;
480
1476
  placeConfigOrders(app_config: AppConfig, solution: {
481
1477
  risk_reward: number;
482
1478
  entry: number;
483
1479
  stop: number;
484
- risk_per_trade: number;
485
- avg_size: number;
486
- neg_pnl: 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: {
1680
+ symbol: string;
1681
+ kind: "long" | "short";
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: {
1695
+ symbol: string;
1696
+ kind: "long" | "short";
1697
+ place?: boolean;
1698
+ place_symbol?: string;
1699
+ }): Promise<{
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;
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";
1719
+ entry: number;
1720
+ stop: number;
487
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: {
488
1733
  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";
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;
500
1758
  };
501
- stop_orders: {
1759
+ short: {
1760
+ avg_entry: number;
1761
+ avg_size: number;
1762
+ loss: number;
502
1763
  stop: number;
503
- final_stop: number;
504
- kind: "long" | "short";
505
- quantity: any;
506
- 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;
507
1771
  };
508
- 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[];
509
1827
  }>;
510
- placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
1828
+ computeTargetPnl(payload: {
511
1829
  symbol: string;
512
- entry: number;
1830
+ kind: "long" | "short";
1831
+ }): Promise<number>;
1832
+ placeStopLimit(payload: {
1833
+ symbol: string;
1834
+ kind: "long" | "short";
1835
+ place?: boolean;
513
1836
  stop: number;
514
- risk_reward: number;
515
- risk: number;
1837
+ quantity?: number;
1838
+ }): Promise<any>;
1839
+ placeTrade(payload: {
1840
+ symbol: string;
1841
+ kind: "long" | "short";
516
1842
  place?: boolean;
517
- 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;
518
1850
  }): Promise<any>;
519
- getPositionConfig(payload: {
1851
+ updateConfigPnl(payload: {
520
1852
  symbol: string;
521
1853
  kind: "long" | "short";
522
- 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";
523
1892
  entry: number;
524
1893
  stop: number;
525
- risk_reward: number;
526
- risk: number;
527
- 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;
528
1964
  };
529
- }): Promise<import("pocketbase").RecordModel>;
530
- getCurrentPrice(symbol: string): Promise<any>;
531
- getPositionStrategy(): Promise<{
532
- strategy_instance: Strategy;
533
- focus_account: ExchangeAccount;
534
1965
  }>;
535
- getOriginalPlannedStop(payload: {
1966
+ generateGapTp(payload: {
536
1967
  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;
1968
+ factor?: number;
1969
+ }): Promise<{
1970
+ profit_percent: {
1971
+ long: number;
1972
+ short: number;
546
1973
  };
547
- }): 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
+ }>;
548
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>;
549
2027
  declare class App {
550
- private app_db;
2028
+ app_db: AppDatabase;
2029
+ proxyOptions?: {
2030
+ proxy?: any;
2031
+ ignore_proxy?: boolean;
2032
+ canWithdraw?: boolean;
2033
+ };
551
2034
  private getCredentials;
552
- constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
2035
+ constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => {
553
2036
  api_key: string;
554
2037
  api_secret: string;
555
- }>);
2038
+ email: string;
2039
+ }, proxyOptions?: {
2040
+ proxy?: any;
2041
+ ignore_proxy?: boolean;
2042
+ canWithdraw?: boolean;
2043
+ });
556
2044
  getExchangeAccount(account: ExchangeType): Promise<ExchangeAccount$1>;
557
2045
  syncAccount(payload: {
558
2046
  account: ExchangeType;
@@ -560,13 +2048,10 @@ declare class App {
560
2048
  kind?: "long" | "short";
561
2049
  update?: boolean;
562
2050
  as_view?: boolean;
563
- }): Promise<(PositionsView & {
564
- expand?: {
565
- config: ScheduledTrade;
566
- };
567
- }) | (PositionsView & {
2051
+ }): Promise<PositionsView | (PositionsView & {
568
2052
  expand?: {
569
2053
  config: ScheduledTrade;
2054
+ account: ExchangeAccount;
570
2055
  };
571
2056
  })[]>;
572
2057
  syncOrders(payload: {
@@ -581,7 +2066,7 @@ declare class App {
581
2066
  price?: number;
582
2067
  all?: boolean;
583
2068
  stop?: boolean;
584
- }): Promise<{
2069
+ }): Promise<void | {
585
2070
  success: boolean;
586
2071
  message: string;
587
2072
  exchange_result?: undefined;
@@ -597,83 +2082,6 @@ declare class App {
597
2082
  message?: undefined;
598
2083
  exchange_result?: undefined;
599
2084
  }>;
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
2085
  getWindingDownMarkets(): Promise<WindingDownMarket[]>;
678
2086
  updateSymbolConfigs(payload: {
679
2087
  configs: {
@@ -690,6 +2098,150 @@ declare class App {
690
2098
  created: number;
691
2099
  }>;
692
2100
  updateAllAccountWithSymbols(with_positions?: boolean): Promise<void>;
2101
+ windDownSymbol(payload: {
2102
+ symbol: string;
2103
+ risk?: number;
2104
+ }): Promise<boolean>;
2105
+ getNonEssentialSymbols(): Promise<Set<any>>;
2106
+ refreshAllPositionsWithSymbol(payload: {
2107
+ symbol: string;
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: {
2123
+ account: ExchangeType;
2124
+ symbol: string;
2125
+ kind: "long" | "short";
2126
+ place?: boolean;
2127
+ tp?: boolean;
2128
+ cancel?: boolean;
2129
+ raw?: boolean;
2130
+ }): Promise<any>;
2131
+ runDbStrategyAccounts(callback: (params: {
2132
+ symbol: string;
2133
+ account: ExchangeType;
2134
+ }) => Promise<any>): Promise<void>;
2135
+ profitWithinGapStrategy(payload: {
2136
+ account: ExchangeType;
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
+ };
2241
+ kind: "long" | "short";
2242
+ place?: boolean;
2243
+ increase?: boolean;
2244
+ }): Promise<any>;
693
2245
  }
694
2246
  export declare function initApp(payload: {
695
2247
  db: {
@@ -697,14 +2249,44 @@ export declare function initApp(payload: {
697
2249
  email: string;
698
2250
  password: string;
699
2251
  };
700
- getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
2252
+ password?: string;
2253
+ getCredentials: (account: string, exchange: string) => {
701
2254
  api_key: string;
702
2255
  api_secret: string;
703
- }>;
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;
704
2273
  }): Promise<App>;
705
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
+
706
2285
  export {
707
2286
  ExchangeAccount$1 as ExchangeAccount,
2287
+ app,
2288
+ database,
2289
+ exchange_account,
708
2290
  };
709
2291
 
710
2292
  export {};