@gbozee/ultimate 0.0.2-5 → 0.0.2-53

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
@@ -5,6 +5,129 @@ import PocketBase from 'pocketbase';
5
5
  import { RecordModel } from 'pocketbase';
6
6
  import { SocksProxyAgent } from 'socks-proxy-agent';
7
7
 
8
+ export interface BaseSystemFields {
9
+ id: string;
10
+ created: string;
11
+ updated: string;
12
+ }
13
+ export interface ExchangeAccount extends BaseSystemFields {
14
+ exchange: "binance" | "bybit";
15
+ owner: string;
16
+ email?: string;
17
+ user?: string;
18
+ usdt?: number;
19
+ usdc?: number;
20
+ proxy?: string;
21
+ bullish?: boolean;
22
+ bearish?: boolean;
23
+ movePercent?: number;
24
+ totalRisk?: number;
25
+ max_non_essential?: number;
26
+ profit_percent?: number;
27
+ risk_reward?: number;
28
+ exclude_coins?: {
29
+ bullish?: string[];
30
+ };
31
+ include_delisted?: boolean;
32
+ }
33
+ export interface SymbolConfig extends BaseSystemFields {
34
+ symbol: string;
35
+ support?: number;
36
+ resistance?: number;
37
+ stop_percent?: number;
38
+ price_places?: string;
39
+ decimal_places?: string;
40
+ min_size?: number;
41
+ weight?: number;
42
+ leverage?: number;
43
+ candle_count?: number;
44
+ interval?: any;
45
+ }
46
+ export interface ScheduledTrade extends BaseSystemFields {
47
+ symbol: string;
48
+ account: string;
49
+ profit?: number;
50
+ risk?: number;
51
+ entry?: number;
52
+ stop?: number;
53
+ risk_reward?: number;
54
+ profit_percent?: number;
55
+ place_tp?: boolean;
56
+ kind?: "long" | "short";
57
+ current_price?: number;
58
+ }
59
+ export interface AccountStrategy extends BaseSystemFields {
60
+ account: string;
61
+ symbol: string;
62
+ tp_percent: number;
63
+ short_tp_factor: number;
64
+ fee_percent: number;
65
+ budget: number;
66
+ }
67
+ interface Proxy$1 extends BaseSystemFields {
68
+ ip_address?: string;
69
+ type?: "http" | "socks5";
70
+ }
71
+ export interface TradeBlockTracking extends BaseSystemFields {
72
+ account?: string;
73
+ symbol?: string;
74
+ running?: boolean;
75
+ }
76
+ export interface PositionsView {
77
+ id: string;
78
+ symbol?: any;
79
+ entry?: any;
80
+ quantity?: any;
81
+ take_profit?: any;
82
+ account?: any;
83
+ kind?: any;
84
+ target_pnl?: number;
85
+ liquidation?: number;
86
+ avg_price?: number;
87
+ avg_qty?: number;
88
+ next_order?: number;
89
+ last_order?: number;
90
+ config?: any;
91
+ stop_loss?: {
92
+ price: number;
93
+ quantity: number;
94
+ };
95
+ stop_pnl?: any;
96
+ leverage?: any;
97
+ avg_liquidation?: any;
98
+ balance?: any;
99
+ }
100
+ export interface BullishMarket extends RecordModel {
101
+ id: string;
102
+ symbol: string;
103
+ risk: number;
104
+ }
105
+ export interface WindingDownMarket extends RecordModel {
106
+ id: string;
107
+ symbol: string;
108
+ risk_reward: number;
109
+ }
110
+ export type GlobalConfig = {
111
+ profit_percent: number;
112
+ symbol: string;
113
+ profit: number;
114
+ risk: number;
115
+ stop_percent: number;
116
+ kind: "long" | "short";
117
+ reduce_percent: number;
118
+ support: number;
119
+ resistance: number;
120
+ price_places: string;
121
+ decimal_places: string;
122
+ min_size: number;
123
+ accounts: {
124
+ owner: string;
125
+ exchange?: string;
126
+ }[];
127
+ risk_reward: number;
128
+ reverse_factor: number;
129
+ leverage?: number;
130
+ };
8
131
  interface Position$1 {
9
132
  id: number;
10
133
  kind: "long" | "short";
@@ -85,10 +208,15 @@ export interface BaseExchange {
85
208
  count: number;
86
209
  raw?: boolean;
87
210
  }): Promise<any>;
88
- getExchangeAccountInfo(account: {
89
- owner: string;
90
- exchange: string;
91
- }, symbol: string): Promise<any>;
211
+ getExchangeAccountInfo(options: {
212
+ price_places?: string;
213
+ decimal_places?: string;
214
+ account: {
215
+ owner: string;
216
+ exchange: string;
217
+ };
218
+ symbol: string;
219
+ }): Promise<any>;
92
220
  cancelOrders(payload: {
93
221
  symbol: string;
94
222
  orders: number[];
@@ -117,122 +245,111 @@ export interface BaseExchange {
117
245
  price_places?: string;
118
246
  decimal_places?: string;
119
247
  }): Promise<any>;
120
- }
121
- export interface BaseSystemFields {
122
- id: string;
123
- created: string;
124
- updated: string;
125
- }
126
- export interface ExchangeAccount extends BaseSystemFields {
127
- exchange: "binance" | "bybit";
128
- owner: string;
129
- email?: string;
130
- user?: string;
131
- usdt?: number;
132
- usdc?: number;
133
- proxy?: string;
134
- }
135
- export interface SymbolConfig extends BaseSystemFields {
136
- symbol: string;
137
- support?: number;
138
- resistance?: number;
139
- stop_percent?: number;
140
- price_places?: string;
141
- decimal_places?: string;
142
- min_size?: number;
143
- weight?: number;
144
- leverage?: number;
145
- }
146
- export interface ScheduledTrade extends BaseSystemFields {
147
- symbol: string;
148
- account: string;
149
- profit?: number;
150
- risk?: number;
151
- entry?: number;
152
- stop?: number;
153
- risk_reward?: number;
154
- profit_percent?: number;
155
- place_tp?: boolean;
156
- kind?: "long" | "short";
157
- current_price?: number;
158
- }
159
- export interface Strategy extends BaseSystemFields {
160
- name: string;
161
- short_risk_factor?: number;
162
- long_risk_factor?: number;
163
- profit_percent?: number;
164
- cancel_short?: boolean;
165
- cancel_long?: boolean;
166
- recompute_short_config?: boolean;
167
- update_stop_loss?: boolean;
168
- liquidation_as_entry?: boolean;
169
- stop_as_entry?: boolean;
170
- tp_as_stop?: boolean;
171
- entry_as_stop?: boolean;
172
- place_stop?: boolean;
173
- save_config?: boolean;
174
- }
175
- interface Proxy$1 extends BaseSystemFields {
176
- ip_address?: string;
177
- type?: "http" | "socks5";
178
- }
179
- export interface TradeBlockTracking extends BaseSystemFields {
180
- account?: string;
181
- symbol?: string;
182
- running?: boolean;
183
- }
184
- export interface PositionsView {
185
- id: string;
186
- symbol?: any;
187
- entry?: any;
188
- quantity?: any;
189
- take_profit?: any;
190
- account?: any;
191
- kind?: any;
192
- target_pnl?: number;
193
- liquidation?: number;
194
- avg_price?: number;
195
- avg_qty?: number;
196
- next_order?: number;
197
- last_order?: number;
198
- config?: any;
199
- stop_loss?: {
200
- price: number;
248
+ setLeverage(payload: {
249
+ symbol: string;
250
+ leverage: number;
251
+ }): Promise<any>;
252
+ generateConfig(payload: {
253
+ symbol: string;
254
+ interval?: any;
255
+ limit?: number;
256
+ }): Promise<any>;
257
+ checkDelistedMovers(payload: {
258
+ movePercent: number;
259
+ include_delisted?: boolean;
260
+ }): Promise<any>;
261
+ closePosition(payload: {
262
+ symbol: string;
263
+ kind: "long" | "short";
264
+ price_places?: string;
265
+ decimal_places?: string;
266
+ }): Promise<any>;
267
+ getAllOpenSymbols(): Promise<string[]>;
268
+ createLimitPurchaseOrders(payload: {
269
+ orders: any[];
270
+ kind: "long" | "short";
271
+ decimal_places?: string;
272
+ price_places?: string;
273
+ symbol: string;
274
+ }): Promise<any>;
275
+ getDelistedSpotSymbols(): Promise<any>;
276
+ getOpenPositions(): Promise<any>;
277
+ crossAccountTransfer(payload: {
278
+ from: {
279
+ owner: string;
280
+ wallet: string;
281
+ };
282
+ to: {
283
+ owner: string;
284
+ wallet: string;
285
+ };
286
+ asset: string;
287
+ amount: number;
288
+ }): Promise<any>;
289
+ placeMarketOrder(payload: {
290
+ symbol: string;
291
+ kind: "long" | "short";
201
292
  quantity: number;
202
- };
203
- stop_pnl?: any;
204
- leverage?: any;
205
- avg_liquidation?: any;
206
- balance?: any;
207
- }
208
- export interface BullishMarket extends RecordModel {
209
- id: string;
210
- symbol: string;
211
- risk: number;
212
- }
213
- export interface WindingDownMarket extends RecordModel {
214
- id: string;
215
- symbol: string;
293
+ price_places?: string;
294
+ decimal_places?: string;
295
+ }): Promise<any>;
216
296
  }
297
+ declare function initPocketBaseClient(proxy_credentials: {
298
+ host: string;
299
+ email: string;
300
+ password: string;
301
+ auto_cancellation?: boolean;
302
+ }): Promise<PocketBase>;
217
303
  export type ExchangeType = {
218
304
  owner: string;
219
305
  exchange: string;
220
306
  };
221
307
  export declare class AppDatabase {
222
- private pb;
308
+ pb: PocketBase;
223
309
  constructor(pb: PocketBase);
310
+ getCredentials(password: string): any;
311
+ saveCredentials(password: string, credentials: any): Promise<void>;
312
+ addNewCredential(password: string, payload: {
313
+ name: string;
314
+ exchange: string;
315
+ api_key: string;
316
+ api_secret: string;
317
+ }): Promise<void>;
318
+ getAllSymbolsFromPositions(options?: {
319
+ no_position?: boolean;
320
+ kind?: "long" | "short";
321
+ custom_filter?: string;
322
+ }): Promise<any[]>;
323
+ createOrUpdateLiveExchangeInstance(payload: {
324
+ account: ExchangeType;
325
+ symbol: string;
326
+ data?: any;
327
+ }): Promise<import("pocketbase").RecordModel>;
328
+ getLiveExchangeInstance(payload: {
329
+ account: ExchangeType;
330
+ symbol: string;
331
+ data?: any;
332
+ }): Promise<import("pocketbase").RecordModel>;
224
333
  getProxyForAccount(account: ExchangeType): Promise<HttpsProxyAgent<`http://${string}`> | SocksProxyAgent>;
334
+ getAccounts(): Promise<ExchangeAccount[]>;
335
+ getAllSymbolConfigs(payload?: {
336
+ with_positions?: boolean;
337
+ custom_filter?: string;
338
+ }): Promise<SymbolConfig[]>;
225
339
  get_exchange_db_instance(account: ExchangeType): Promise<ExchangeAccount & {
226
340
  expand?: {
227
341
  proxy: Proxy$1;
228
342
  };
229
343
  }>;
230
- getPositions(account: ExchangeType, options: {
231
- symbol: string;
344
+ getPositions(options: {
345
+ account?: ExchangeType;
346
+ symbol?: string;
232
347
  as_view?: boolean;
348
+ custom_filter?: string;
233
349
  }): Promise<(PositionsView & {
234
350
  expand?: {
235
351
  config: ScheduledTrade;
352
+ account: ExchangeAccount;
236
353
  };
237
354
  })[]>;
238
355
  private _createOrUpdatePosition;
@@ -244,6 +361,7 @@ export declare class AppDatabase {
244
361
  }): Promise<(PositionsView & {
245
362
  expand?: {
246
363
  config: ScheduledTrade;
364
+ account: ExchangeAccount;
247
365
  };
248
366
  })[]>;
249
367
  update_db_position(position: any, payload: any): Promise<import("pocketbase").RecordModel>;
@@ -269,6 +387,31 @@ export declare class AppDatabase {
269
387
  order_id: string;
270
388
  triggerPrice?: number;
271
389
  }>): Promise<import("pocketbase").RecordModel[]>;
390
+ deleteAndBulCreateAllOrders(payload: {
391
+ account: ExchangeType & {
392
+ id: string;
393
+ };
394
+ symbol: string;
395
+ all_orders: Array<{
396
+ symbol: string;
397
+ price: number;
398
+ quantity: number;
399
+ kind: "long" | "short";
400
+ side: "buy" | "sell";
401
+ stop: number;
402
+ order_id: string;
403
+ triggerPrice?: number;
404
+ }>;
405
+ }): Promise<void>;
406
+ cancelLimitOrders(payload: {
407
+ symbol: string;
408
+ kind: "long" | "short";
409
+ account: ExchangeType;
410
+ cancelExchangeOrders: (payload: {
411
+ symbol: string;
412
+ orders: number[];
413
+ }) => Promise<any>;
414
+ }): Promise<void>;
272
415
  cancelOrders(payload: {
273
416
  cancelExchangeOrders: (payload: {
274
417
  symbol: string;
@@ -296,45 +439,204 @@ export declare class AppDatabase {
296
439
  message?: undefined;
297
440
  exchange_result?: undefined;
298
441
  }>;
442
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
443
+ updateScheduledTrade(id: string, payload: any): Promise<import("pocketbase").RecordModel>;
444
+ getPositionsToAutoFollow(): Promise<(Position$1 & {
445
+ expand: {
446
+ account: ExchangeAccount;
447
+ };
448
+ })[]>;
299
449
  createOrUpdatePositionConfig(db_position: any, payload: {
300
450
  entry: number;
301
451
  stop: number;
302
452
  risk_reward: number;
303
453
  risk: number;
304
454
  profit_percent?: number;
305
- }): Promise<void>;
455
+ place_tp?: boolean;
456
+ profit?: number;
457
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
306
458
  getPositionConfig(payload: {
307
459
  symbol: string;
308
460
  kind: "long" | "short";
309
461
  account: ExchangeType;
462
+ }): Promise<ScheduledTrade | null>;
463
+ getPositionStrategy(account: ExchangeType): Promise<AccountStrategy>;
464
+ createOrUpdateWindingDownMarket(payload: {
465
+ symbol: string;
466
+ risk_reward?: number;
310
467
  }): Promise<import("pocketbase").RecordModel>;
311
- getPositionStrategy(account: ExchangeType): Promise<{
312
- strategy_instance: Strategy;
313
- focus_account: ExchangeAccount;
314
- }>;
315
- createOrUpdateWindingDownMarket(symbol: string): Promise<import("pocketbase").RecordModel>;
316
- getWindingDownMarkets(): Promise<WindingDownMarket[]>;
468
+ getWindingDownMarkets(symbol?: string): Promise<WindingDownMarket[]>;
469
+ getBullishMarket(symbol: string): Promise<BullishMarket>;
317
470
  getBullishMarkets(options?: {
318
471
  new_markets: Array<{
319
472
  symbol: string;
320
473
  percent: number;
321
474
  }>;
322
475
  totalRisk: number;
476
+ max_count?: number;
323
477
  }): Promise<{
324
478
  updated_bullish: BullishMarket[];
325
479
  moved_to_winding: WindingDownMarket[];
326
480
  }>;
481
+ updateSymbolConfigs(payload?: {
482
+ configs: Array<{
483
+ symbol: string;
484
+ support: number;
485
+ leverage: number;
486
+ min_size: number;
487
+ resistance: number;
488
+ price_places: string;
489
+ decimal_places: string;
490
+ }>;
491
+ }): Promise<{
492
+ updated: number;
493
+ created: number;
494
+ } | SymbolConfig[]>;
495
+ unwindSymbolFromDB(symbol: string): Promise<boolean>;
496
+ hasExistingPosition(symbol: string): Promise<import("pocketbase").RecordModel[]>;
497
+ hasExistingOrders(symbol: string): Promise<import("pocketbase").RecordModel[]>;
498
+ removeSymbolFromUnwindingMarkets(symbol: string): Promise<boolean>;
499
+ removePosition(position: any): Promise<void>;
500
+ removePositionConfig(position: any): Promise<void>;
327
501
  }
328
- export interface CodeNode {
329
- minimum_pnl: number;
330
- max_size: number;
331
- profit: number;
332
- ratio?: number;
333
- increase: boolean;
334
- not_reduce?: boolean;
335
- reduce_ratio?: number;
336
- use_full?: boolean;
502
+ export type SignalConfigType = {
503
+ focus: number;
504
+ budget: number;
505
+ percent_change?: number;
506
+ price_places?: string;
507
+ decimal_places?: string;
508
+ zone_risk?: number;
509
+ fee?: number;
510
+ support?: number;
511
+ risk_reward?: number;
512
+ resistance?: number;
513
+ risk_per_trade?: number;
514
+ increase_size?: boolean;
515
+ additional_increase?: number;
516
+ minimum_pnl?: number;
517
+ take_profit?: number;
518
+ increase_position?: boolean;
519
+ minimum_size?: number;
520
+ first_order_size?: number;
521
+ gap?: number;
522
+ max_size?: number;
523
+ };
524
+ declare class Signal {
525
+ focus: number;
526
+ budget: number;
527
+ percent_change: number;
528
+ price_places: string;
529
+ decimal_places: string;
530
+ zone_risk: number;
531
+ fee: number;
532
+ support?: number;
533
+ risk_reward: number;
534
+ resistance?: number;
535
+ risk_per_trade?: number;
536
+ increase_size: boolean;
537
+ additional_increase: number;
538
+ minimum_pnl: number;
539
+ take_profit?: number;
540
+ increase_position: boolean;
541
+ minimum_size: any;
542
+ first_order_size: number;
543
+ gap: number;
544
+ max_size: number;
545
+ 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);
546
+ build_entry({ current_price, stop_loss, pnl, stop_percent, kind, risk, no_of_trades, take_profit, }: {
547
+ take_profit?: number;
548
+ no_of_trades?: number;
549
+ current_price: number;
550
+ stop_loss?: number;
551
+ kind?: "long" | "short";
552
+ risk: number;
553
+ stop_percent?: number;
554
+ pnl?: number;
555
+ }): any;
556
+ get risk(): number;
557
+ get min_trades(): number;
558
+ get min_price(): number;
559
+ build_opposite_order({ current_price, kind, }: {
560
+ current_price: number;
561
+ kind?: "long" | "short";
562
+ }): any;
563
+ special_build_orders({ current_price, kind, }: {
564
+ current_price: number;
565
+ kind?: "long" | "short";
566
+ }): any;
567
+ build_orders({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
568
+ current_price: number;
569
+ kind?: "long" | "short";
570
+ limit?: boolean;
571
+ replace_focus?: boolean;
572
+ max_index?: number;
573
+ min_index?: number;
574
+ }): any;
575
+ build_orders_old({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
576
+ current_price: number;
577
+ kind?: "long" | "short";
578
+ limit?: boolean;
579
+ replace_focus?: boolean;
580
+ max_index?: number;
581
+ min_index?: number;
582
+ }): any;
583
+ get_bulk_trade_zones({ current_price, kind, limit, }: {
584
+ current_price: number;
585
+ kind?: "long" | "short";
586
+ limit?: boolean;
587
+ }): any;
588
+ get_future_zones({ current_price, kind, raw, }: {
589
+ raw?: boolean;
590
+ current_price: number;
591
+ kind?: "long" | "short";
592
+ }): number[];
593
+ to_f(value: number, places?: string): number;
594
+ get_margin_zones({ current_price, kind, }: {
595
+ current_price: number;
596
+ kind?: "long" | "short";
597
+ }): number[][];
598
+ get_margin_range(current_price: number, kind?: string): number[];
599
+ process_orders({ current_price, stop_loss, trade_zones, kind, }: {
600
+ current_price: number;
601
+ stop_loss: number;
602
+ trade_zones: number[];
603
+ kind?: "long" | "short";
604
+ }): any[];
605
+ get_risk_per_trade(number_of_orders: number): number;
606
+ build_trade_dict({ entry, stop, risk, arr, index, new_fees, kind, start, take_profit, }: {
607
+ entry: number;
608
+ stop: number;
609
+ risk: number;
610
+ arr: number[];
611
+ index: number;
612
+ new_fees?: number;
613
+ kind?: "long" | "short";
614
+ start?: number;
615
+ take_profit?: number;
616
+ }): {
617
+ entry: number;
618
+ risk: number;
619
+ quantity: number;
620
+ sell_price: number;
621
+ risk_sell: number;
622
+ stop: number;
623
+ pnl: number;
624
+ fee: number;
625
+ net: number;
626
+ incurred: number;
627
+ stop_percent: number;
628
+ };
629
+ to_df(currentPrice: number, places?: string): number;
337
630
  }
631
+ export declare function determine_average_entry_and_size(orders: Array<{
632
+ price: number;
633
+ quantity: number;
634
+ }>, places?: string, price_places?: string): {
635
+ entry: number;
636
+ price: number;
637
+ quantity: number;
638
+ };
639
+ export declare const createArray: (start: number, stop: number, step: number) => number[];
338
640
  export type AppConfig = {
339
641
  fee: number;
340
642
  risk_per_trade: number;
@@ -360,16 +662,280 @@ export type AppConfig = {
360
662
  gap?: number;
361
663
  rr?: number;
362
664
  max_size?: number;
665
+ last_value?: any;
666
+ entries?: any[];
667
+ };
668
+ export type ExtendConfigType = {
669
+ take_profit?: number;
670
+ entry: number;
671
+ risk?: number;
672
+ stop?: number;
673
+ risk_reward?: number;
674
+ raw_instance?: boolean;
675
+ no_of_trades?: number;
676
+ increase?: boolean;
677
+ price_places?: string;
678
+ decimal_places?: string;
679
+ min_profit?: number;
680
+ kind?: "long" | "short";
681
+ gap?: number;
682
+ rr?: number;
363
683
  };
684
+ 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;
685
+ export declare function buildAvg({ _trades, kind, }: {
686
+ _trades: any[];
687
+ kind: "long" | "short";
688
+ }): any;
689
+ export declare function sortedBuildConfig(app_config: AppConfig, options: any): any[];
690
+ export declare function get_app_config_and_max_size(config: GlobalConfig, payload: {
691
+ entry: number;
692
+ stop: number;
693
+ kind: "long" | "short";
694
+ }): {
695
+ app_config: AppConfig;
696
+ max_size: any;
697
+ last_value: any;
698
+ entries: {
699
+ entry: any;
700
+ avg_entry: any;
701
+ avg_size: any;
702
+ neg_pnl: any;
703
+ quantity: any;
704
+ }[];
705
+ };
706
+ export declare function buildAppConfig(config: GlobalConfig, payload: {
707
+ entry: number;
708
+ stop: number;
709
+ risk_reward: number;
710
+ risk: number;
711
+ symbol: string;
712
+ profit?: number;
713
+ }): AppConfig;
714
+ export declare function getOptimumStopAndRisk(app_config: AppConfig, params: {
715
+ max_size: number;
716
+ target_stop: number;
717
+ highest_risk?: number;
718
+ }): {
719
+ optimal_stop: number;
720
+ optimal_risk: number;
721
+ avg_size: any;
722
+ avg_entry: any;
723
+ result: any[];
724
+ first_entry: any;
725
+ neg_pnl: any;
726
+ risk_reward: number;
727
+ size_diff: number;
728
+ entry_diff: number;
729
+ };
730
+ export declare function generate_config_params(app_config: AppConfig, payload: {
731
+ entry: number;
732
+ stop: number;
733
+ risk_reward: number;
734
+ risk: number;
735
+ symbol: string;
736
+ }): {
737
+ entry: number;
738
+ stop: number;
739
+ avg_size: any;
740
+ avg_entry: any;
741
+ risk_reward: number;
742
+ neg_pnl: any;
743
+ risk: number;
744
+ };
745
+ export declare function determine_break_even_price(payload: {
746
+ long_position: {
747
+ entry: number;
748
+ quantity: number;
749
+ };
750
+ short_position: {
751
+ entry: number;
752
+ quantity: number;
753
+ };
754
+ fee_percent?: number;
755
+ }): {
756
+ price: number;
757
+ direction: string;
758
+ };
759
+ export declare function determine_amount_to_buy(payload: {
760
+ orders: any[];
761
+ kind: "long" | "short";
762
+ decimal_places?: string;
763
+ price_places?: string;
764
+ place?: boolean;
765
+ position: any;
766
+ existingOrders: any[];
767
+ }): any[];
768
+ export declare function generateOptimumAppConfig(config: GlobalConfig, payload: {
769
+ entry: number;
770
+ stop: number;
771
+ risk_reward: number;
772
+ start_risk: number;
773
+ max_risk?: number;
774
+ }, position: {
775
+ entry: number;
776
+ quantity: number;
777
+ kind: "long" | "short";
778
+ }): AppConfig | null;
779
+ declare class ExchangePosition {
780
+ exchange: BaseExchange;
781
+ exchange_account: ExchangeAccount$1;
782
+ private app_db;
783
+ private instance;
784
+ constructor(payload: {
785
+ exchange: BaseExchange;
786
+ app_db: AppDatabase;
787
+ instance: PositionsView;
788
+ exchange_account: ExchangeAccount$1;
789
+ without_view?: PositionsView;
790
+ });
791
+ get symbol(): any;
792
+ get kind(): any;
793
+ get account(): any;
794
+ cancelOrders(payload: {
795
+ limit?: boolean;
796
+ price?: number;
797
+ }): Promise<void | {
798
+ success: boolean;
799
+ message: string;
800
+ exchange_result?: undefined;
801
+ error?: undefined;
802
+ } | {
803
+ success: boolean;
804
+ exchange_result: any;
805
+ message?: undefined;
806
+ error?: undefined;
807
+ } | {
808
+ success: boolean;
809
+ error: any;
810
+ message?: undefined;
811
+ exchange_result?: undefined;
812
+ }>;
813
+ getConfig(payload?: {
814
+ params?: {
815
+ entry?: number;
816
+ stop?: number;
817
+ risk_reward?: number;
818
+ risk?: number;
819
+ profit_percent?: number;
820
+ place_tp?: boolean;
821
+ profit?: number;
822
+ };
823
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
824
+ updateTargetPnl(): Promise<number>;
825
+ updateConfigPnl(): Promise<void>;
826
+ triggerTradeFromConfig(payload: {
827
+ place?: boolean;
828
+ raw?: boolean;
829
+ tp?: boolean;
830
+ stop?: boolean;
831
+ use_current?: boolean;
832
+ ignore_config?: boolean;
833
+ }): Promise<any>;
834
+ placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
835
+ entry: number;
836
+ stop: number;
837
+ risk_reward: number;
838
+ risk: number;
839
+ place?: boolean;
840
+ update_db?: boolean;
841
+ raw?: boolean;
842
+ use_current?: boolean;
843
+ }): Promise<any>;
844
+ buildAppConfig(payload: {
845
+ entry: number;
846
+ stop: number;
847
+ risk_reward: number;
848
+ risk: number;
849
+ profit?: number;
850
+ update_db?: boolean;
851
+ profit_percent?: number;
852
+ }): Promise<AppConfig>;
853
+ placeConfigOrders(app_config: AppConfig, solution: {
854
+ risk_reward: number;
855
+ entry: number;
856
+ stop: number;
857
+ risk_per_trade: number;
858
+ avg_size: number;
859
+ neg_pnl: number;
860
+ min_size: number;
861
+ symbol: string;
862
+ }, place?: boolean, skip_stop?: boolean): Promise<{
863
+ entry_orders: {
864
+ orders: {
865
+ entry: any;
866
+ quantity: any;
867
+ reverse_avg_entry: any;
868
+ reverse_avg_quantity: any;
869
+ avg_entry: any;
870
+ avg_size: any;
871
+ }[];
872
+ kind: "long" | "short";
873
+ };
874
+ stop_orders: {
875
+ stop: number;
876
+ final_stop: number;
877
+ kind: "long" | "short";
878
+ quantity: any;
879
+ is_limit: boolean;
880
+ neg_pnl: any;
881
+ };
882
+ trades: any[];
883
+ }>;
884
+ determineAmountToBuy(payload: {
885
+ orders: any[];
886
+ kind: "long" | "short";
887
+ refresh?: boolean;
888
+ decimal_places?: string;
889
+ price_places?: string;
890
+ cancel?: boolean;
891
+ place?: boolean;
892
+ }): Promise<any[]>;
893
+ refresh(live_refresh?: boolean): Promise<{
894
+ instance: PositionsView;
895
+ existingOrders: void | import("pocketbase").RecordModel[];
896
+ }>;
897
+ placeTrade(payload: {
898
+ place?: boolean;
899
+ tp?: boolean;
900
+ stop?: boolean;
901
+ raw?: boolean;
902
+ cancel?: boolean;
903
+ ignore_config?: boolean;
904
+ }): Promise<any>;
905
+ }
364
906
  declare class ExchangeAccount$1 {
365
907
  private instance;
366
- private exchange;
908
+ exchange: BaseExchange;
909
+ main_exchange?: BaseExchange;
367
910
  private app_db;
911
+ private long_position?;
912
+ private short_position?;
368
913
  constructor(payload: ExchangeType, options: {
369
914
  exchange: BaseExchange;
370
915
  app_db: AppDatabase;
916
+ main_exchange?: BaseExchange;
371
917
  });
372
- getActiveAccount(symbol: string, full?: boolean): Promise<Account | {
918
+ /**
919
+ *In order to avoid rate limiting issues, we cache the live exchange
920
+ details for each symbol for an account in the database with an option
921
+ to refresh.
922
+ */
923
+ getDBInstance(): AppDatabase;
924
+ getLiveExchangeInstance(payload: {
925
+ symbol: string;
926
+ refresh?: boolean;
927
+ refresh_symbol_config?: boolean;
928
+ }): Promise<import("pocketbase").RecordModel>;
929
+ initializePositions(payload: {
930
+ symbol: string;
931
+ as_view?: boolean;
932
+ kind: "long" | "short";
933
+ }): Promise<ExchangePosition>;
934
+ getActiveAccount(payload: {
935
+ symbol: string;
936
+ full?: boolean;
937
+ refresh?: boolean;
938
+ }): Promise<Account | {
373
939
  liquidation: {
374
940
  long: number;
375
941
  short: number;
@@ -378,33 +944,48 @@ declare class ExchangeAccount$1 {
378
944
  current_price: any;
379
945
  exchange: any;
380
946
  }>;
381
- syncAccount(options: {
947
+ refreshAccount(payload: {
382
948
  symbol: string;
383
- kind?: "long" | "short";
384
- update?: boolean;
385
- as_view?: boolean;
949
+ live_refresh?: boolean;
950
+ leverage?: number;
386
951
  }): Promise<(PositionsView & {
387
952
  expand?: {
388
953
  config: ScheduledTrade;
954
+ account: ExchangeAccount;
389
955
  };
390
- }) | (PositionsView & {
956
+ })[]>;
957
+ syncAccount(options: {
958
+ symbol: string;
959
+ kind?: "long" | "short";
960
+ update?: boolean;
961
+ as_view?: boolean;
962
+ leverage?: number;
963
+ live_refresh?: boolean;
964
+ }): Promise<PositionsView | (PositionsView & {
391
965
  expand?: {
392
966
  config: ScheduledTrade;
967
+ account: ExchangeAccount;
393
968
  };
394
969
  })[]>;
395
970
  getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
396
971
  syncOrders(options: {
397
972
  symbol: string;
398
- kind: "long" | "short";
973
+ kind?: "long" | "short";
399
974
  update?: boolean;
400
- }): Promise<import("pocketbase").RecordModel[]>;
975
+ }): Promise<void | import("pocketbase").RecordModel[]>;
976
+ toggleStopBuying(payload: {
977
+ symbol: string;
978
+ kind: "long" | "short";
979
+ should_stop?: boolean;
980
+ }): Promise<import("pocketbase").RecordModel>;
401
981
  cancelOrders(payload: {
402
982
  symbol: string;
403
983
  kind: "long" | "short";
404
984
  price?: number;
405
985
  all?: boolean;
406
986
  stop?: boolean;
407
- }): Promise<{
987
+ limit?: boolean;
988
+ }): Promise<void | {
408
989
  success: boolean;
409
990
  message: string;
410
991
  exchange_result?: undefined;
@@ -424,6 +1005,12 @@ declare class ExchangeAccount$1 {
424
1005
  symbol: string;
425
1006
  orders: number[];
426
1007
  }): Promise<any>;
1008
+ getBreakEvenPrice(payload: {
1009
+ symbol: string;
1010
+ }): Promise<{
1011
+ price: number;
1012
+ direction: string;
1013
+ }>;
427
1014
  buildAppConfig(payload: {
428
1015
  entry: number;
429
1016
  stop: number;
@@ -434,6 +1021,17 @@ declare class ExchangeAccount$1 {
434
1021
  update_db?: boolean;
435
1022
  profit_percent?: number;
436
1023
  }): Promise<AppConfig>;
1024
+ buildTrades(payload: {
1025
+ symbol: string;
1026
+ kind: "long" | "short";
1027
+ risk?: number;
1028
+ }): Promise<{
1029
+ trades: any[];
1030
+ max_size: any;
1031
+ last_price: any;
1032
+ total_size: number;
1033
+ avg_entry: number;
1034
+ }>;
437
1035
  placeConfigOrders(app_config: AppConfig, solution: {
438
1036
  risk_reward: number;
439
1037
  entry: number;
@@ -461,9 +1059,20 @@ declare class ExchangeAccount$1 {
461
1059
  kind: "long" | "short";
462
1060
  quantity: any;
463
1061
  is_limit: boolean;
1062
+ neg_pnl: any;
464
1063
  };
465
1064
  trades: any[];
466
1065
  }>;
1066
+ determineAmountToBuy(payload: {
1067
+ orders: any[];
1068
+ kind: "long" | "short";
1069
+ refresh?: boolean;
1070
+ decimal_places?: string;
1071
+ price_places?: string;
1072
+ symbol: string;
1073
+ cancel?: boolean;
1074
+ place?: boolean;
1075
+ }): Promise<any[]>;
467
1076
  placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
468
1077
  symbol: string;
469
1078
  entry: number;
@@ -472,44 +1081,259 @@ declare class ExchangeAccount$1 {
472
1081
  risk: number;
473
1082
  place?: boolean;
474
1083
  update_db?: boolean;
1084
+ raw?: boolean;
1085
+ use_current?: boolean;
475
1086
  }): Promise<any>;
1087
+ getOrCreatePositionConfig(payload: {
1088
+ symbol: string;
1089
+ kind: "long" | "short";
1090
+ risk?: number;
1091
+ risk_reward?: number;
1092
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
476
1093
  getPositionConfig(payload: {
477
1094
  symbol: string;
478
1095
  kind: "long" | "short";
479
1096
  params?: {
480
- entry: number;
481
- stop: number;
482
- risk_reward: number;
483
- risk: number;
1097
+ entry?: number;
1098
+ stop?: number;
1099
+ risk_reward?: number;
1100
+ risk?: number;
484
1101
  profit_percent?: number;
1102
+ place_tp?: boolean;
1103
+ profit?: number;
485
1104
  };
486
- }): Promise<import("pocketbase").RecordModel>;
1105
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
487
1106
  getCurrentPrice(symbol: string): Promise<any>;
488
- getPositionStrategy(): Promise<{
489
- strategy_instance: Strategy;
490
- focus_account: ExchangeAccount;
1107
+ getPositionStrategy(): Promise<AccountStrategy>;
1108
+ buildReduceConfig(payload: {
1109
+ symbol: string;
1110
+ kind?: "long" | "short";
1111
+ as_dict?: boolean;
1112
+ trigger?: {
1113
+ long: boolean;
1114
+ short: boolean;
1115
+ };
1116
+ use_full?: boolean;
1117
+ }): Promise<{
1118
+ trigger_short: boolean;
1119
+ trigger_long: boolean;
1120
+ symbol: string;
1121
+ short_minimum_pnl: number;
1122
+ long_minimum_pnl: number;
1123
+ short_profit: any;
1124
+ long_profit: any;
1125
+ owner: string;
1126
+ exchange: string;
1127
+ not_reduce: boolean;
1128
+ reduce_ratio_long: any;
1129
+ reduce_ratio_short: any;
1130
+ use_full_long: any;
1131
+ use_full_short: any;
1132
+ } | {
1133
+ long: {
1134
+ minimum_pnl: number;
1135
+ max_size: number;
1136
+ profit: any;
1137
+ increase: boolean;
1138
+ not_reduce: boolean;
1139
+ ratio: any;
1140
+ use_full: boolean;
1141
+ };
1142
+ short: {
1143
+ minimum_pnl: number;
1144
+ max_size: number;
1145
+ profit: any;
1146
+ increase: boolean;
1147
+ not_reduce: boolean;
1148
+ ratio: any;
1149
+ use_full: boolean;
1150
+ };
1151
+ trigger: {
1152
+ long: boolean;
1153
+ short: boolean;
1154
+ };
491
1155
  }>;
492
1156
  getOriginalPlannedStop(payload: {
493
1157
  symbol: string;
494
1158
  kind: "long" | "short";
495
1159
  }): Promise<any>;
496
- syncReduceClosePosition(symbol: string, payload?: {
1160
+ syncReduceClosePosition(payload?: {
1161
+ symbol: string;
497
1162
  kind?: "long" | "short";
498
- long?: CodeNode;
499
- short?: CodeNode;
500
- trigger?: {
1163
+ trigger?: boolean;
1164
+ }): Promise<any>;
1165
+ reduceMajorPositionEntry(payload: {
1166
+ symbol: string;
1167
+ long: any;
1168
+ short: any;
1169
+ trigger: {
501
1170
  long: boolean;
502
1171
  short: boolean;
503
1172
  };
504
1173
  }): Promise<any>;
1174
+ placeProfitAndStop(payload: {
1175
+ symbol: string;
1176
+ trigger?: boolean;
1177
+ refresh?: boolean;
1178
+ kind?: "long" | "short";
1179
+ }): Promise<any>;
1180
+ reEnterPositionOnEmpty(symbol: string): Promise<void>;
1181
+ generate_config_params(payload: {
1182
+ entry: number;
1183
+ stop: number;
1184
+ risk_reward: number;
1185
+ risk: number;
1186
+ symbol: string;
1187
+ with_trades?: boolean;
1188
+ }): Promise<any>;
1189
+ build_short_order(payload: {
1190
+ symbol: string;
1191
+ kind: "long" | "short";
1192
+ }): Promise<any>;
1193
+ extrapolateShortConfig(payload: {
1194
+ kind: "long" | "short";
1195
+ symbol: string;
1196
+ risk_reward?: number;
1197
+ risk?: number;
1198
+ }): Promise<any>;
1199
+ placeMarketOrder(payload: {
1200
+ symbol: string;
1201
+ kind: "long" | "short";
1202
+ quantity: number;
1203
+ }): Promise<void>;
1204
+ placeSingleOrder(payload: {
1205
+ symbol: string;
1206
+ kind: "long" | "short";
1207
+ }): Promise<string>;
1208
+ triggerTradeFromConfig(payload: {
1209
+ symbol: string;
1210
+ kind: "long" | "short";
1211
+ place?: boolean;
1212
+ raw?: boolean;
1213
+ tp?: boolean;
1214
+ stop?: boolean;
1215
+ use_current?: boolean;
1216
+ ignore_config?: boolean;
1217
+ }): Promise<any>;
1218
+ verifyStopLoss(payload: {
1219
+ symbol: string;
1220
+ kind: "long" | "short";
1221
+ revert?: boolean;
1222
+ }): Promise<void | import("pocketbase").RecordModel[]>;
1223
+ windDownSymbol(payload: {
1224
+ symbol: string;
1225
+ risk_reward?: number;
1226
+ risk?: number;
1227
+ }): Promise<void>;
1228
+ updateTargetPnl(payload: {
1229
+ symbol: string;
1230
+ kind: "long" | "short";
1231
+ }): Promise<number>;
1232
+ getCurrentRun(payload: {
1233
+ symbol: string;
1234
+ kind?: "long" | "short";
1235
+ pnl?: number;
1236
+ }): Promise<true | import("pocketbase").RecordModel>;
1237
+ recomputeSymbolConfig(payload: {
1238
+ symbol: string;
1239
+ refresh?: boolean;
1240
+ }): Promise<SymbolConfig>;
1241
+ /**
1242
+ * This function builds a config for a symbol
1243
+ * @param payload
1244
+ * @returns
1245
+ */
1246
+ buildConfigForSymbol(payload: {
1247
+ symbol: string;
1248
+ risk: number;
1249
+ kind?: "long" | "short";
1250
+ risk_reward?: number;
1251
+ as_config?: boolean;
1252
+ with_trades?: boolean;
1253
+ }): Promise<any>;
1254
+ triggerBullishMarket(payload: {
1255
+ symbol: string;
1256
+ profit_percent?: number;
1257
+ risk_reward?: number;
1258
+ }): Promise<any>;
1259
+ updateAllActiveSymbols(payload: {
1260
+ interval?: number;
1261
+ }): Promise<void>;
1262
+ updateAllPositionsWithNoConfig(payload: {
1263
+ kind: "long" | "short";
1264
+ }): Promise<void>;
1265
+ getSymbolsForPositions(): Promise<any[]>;
1266
+ getNonEssentialSymbols(): Promise<any[]>;
1267
+ _terminatePositions(payload: {
1268
+ symbol: string;
1269
+ }): Promise<void>;
1270
+ getOrders(payload: {
1271
+ symbol: string;
1272
+ kind: "long" | "short";
1273
+ type: "limit" | "stop" | "tp";
1274
+ }): Promise<import("pocketbase").RecordModel[]>;
1275
+ syncPositionConfigs(payload: {
1276
+ symbol: string;
1277
+ kind: "long" | "short";
1278
+ refresh?: boolean;
1279
+ }): Promise<void>;
1280
+ terminatePositions(payload: {
1281
+ symbol: string;
1282
+ }): Promise<void>;
1283
+ fetchAndUpdateTopMovers(): Promise<{
1284
+ updated_bullish: BullishMarket[];
1285
+ moved_to_winding: WindingDownMarket[];
1286
+ }>;
1287
+ computeTargetPnl(payload: {
1288
+ symbol: string;
1289
+ kind: "long" | "short";
1290
+ }): Promise<number>;
1291
+ placeTrade(payload: {
1292
+ symbol: string;
1293
+ kind: "long" | "short";
1294
+ place?: boolean;
1295
+ tp?: boolean;
1296
+ stop?: boolean;
1297
+ raw?: boolean;
1298
+ cancel?: boolean;
1299
+ ignore_config?: boolean;
1300
+ }): Promise<any>;
1301
+ updateConfigPnl(payload: {
1302
+ symbol: string;
1303
+ kind: "long" | "short";
1304
+ }): Promise<void>;
505
1305
  }
1306
+ declare function getExchangeAccount(payload: {
1307
+ account: ExchangeType;
1308
+ app_db: AppDatabase;
1309
+ getCredentials: (account: string, exchange: string) => {
1310
+ api_key: string;
1311
+ api_secret: string;
1312
+ email: string;
1313
+ };
1314
+ proxyOptions?: {
1315
+ proxy?: any;
1316
+ ignore_proxy?: boolean;
1317
+ };
1318
+ canWithdraw?: boolean;
1319
+ }): Promise<ExchangeAccount$1>;
506
1320
  declare class App {
507
- private app_db;
1321
+ app_db: AppDatabase;
1322
+ proxyOptions?: {
1323
+ proxy?: any;
1324
+ ignore_proxy?: boolean;
1325
+ canWithdraw?: boolean;
1326
+ };
508
1327
  private getCredentials;
509
- constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
1328
+ constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => {
510
1329
  api_key: string;
511
1330
  api_secret: string;
512
- }>);
1331
+ email: string;
1332
+ }, proxyOptions?: {
1333
+ proxy?: any;
1334
+ ignore_proxy?: boolean;
1335
+ canWithdraw?: boolean;
1336
+ });
513
1337
  getExchangeAccount(account: ExchangeType): Promise<ExchangeAccount$1>;
514
1338
  syncAccount(payload: {
515
1339
  account: ExchangeType;
@@ -517,13 +1341,10 @@ declare class App {
517
1341
  kind?: "long" | "short";
518
1342
  update?: boolean;
519
1343
  as_view?: boolean;
520
- }): Promise<(PositionsView & {
521
- expand?: {
522
- config: ScheduledTrade;
523
- };
524
- }) | (PositionsView & {
1344
+ }): Promise<PositionsView | (PositionsView & {
525
1345
  expand?: {
526
1346
  config: ScheduledTrade;
1347
+ account: ExchangeAccount;
527
1348
  };
528
1349
  })[]>;
529
1350
  syncOrders(payload: {
@@ -538,7 +1359,7 @@ declare class App {
538
1359
  price?: number;
539
1360
  all?: boolean;
540
1361
  stop?: boolean;
541
- }): Promise<{
1362
+ }): Promise<void | {
542
1363
  success: boolean;
543
1364
  message: string;
544
1365
  exchange_result?: undefined;
@@ -554,41 +1375,6 @@ declare class App {
554
1375
  message?: undefined;
555
1376
  exchange_result?: undefined;
556
1377
  }>;
557
- triggerTradeFromConfig(payload: {
558
- account: ExchangeType;
559
- symbol: string;
560
- kind: "long" | "short";
561
- }): Promise<any>;
562
- toggleStopBuying(payload: {
563
- account: ExchangeType;
564
- symbol: string;
565
- kind: "long" | "short";
566
- should_stop?: boolean;
567
- }): Promise<import("pocketbase").RecordModel>;
568
- generate_config_params(exchange_account: ExchangeAccount$1, payload: {
569
- entry: number;
570
- stop: number;
571
- risk_reward: number;
572
- risk: number;
573
- symbol: string;
574
- }): Promise<{
575
- place_stop: boolean;
576
- profit_percent: number;
577
- entry: number;
578
- stop: number;
579
- avg_size: any;
580
- avg_entry: any;
581
- risk_reward: number;
582
- neg_pnl: any;
583
- risk: number;
584
- }>;
585
- generateConfig(payload: {
586
- account: ExchangeType;
587
- symbol: string;
588
- kind: "long" | "short";
589
- update_orders?: boolean;
590
- place_orders?: boolean;
591
- }): Promise<any>;
592
1378
  updateReduceRatio(payload: {
593
1379
  account: ExchangeType;
594
1380
  symbol: string;
@@ -599,39 +1385,52 @@ declare class App {
599
1385
  short_db_position: any;
600
1386
  balance: any;
601
1387
  }>;
602
- extrapolateShortConfig(payload: {
603
- account: ExchangeType;
604
- kind: "long" | "short";
605
- symbol: string;
606
- risk_reward?: number;
607
- }): Promise<PositionsView | {
608
- place_stop: boolean;
609
- profit_percent: number;
610
- entry: number;
611
- stop: number;
612
- avg_size: any;
613
- avg_entry: any;
614
- risk_reward: number;
615
- neg_pnl: any;
616
- risk: number;
1388
+ getWindingDownMarkets(): Promise<WindingDownMarket[]>;
1389
+ updateSymbolConfigs(payload: {
1390
+ configs: {
1391
+ symbol: string;
1392
+ support: number;
1393
+ leverage: number;
1394
+ min_size: number;
1395
+ resistance: number;
1396
+ price_places: string;
1397
+ decimal_places: string;
1398
+ }[];
1399
+ }): Promise<SymbolConfig[] | {
1400
+ updated: number;
1401
+ created: number;
617
1402
  }>;
618
- verifyStopLoss(payload: {
1403
+ updateAllAccountWithSymbols(with_positions?: boolean): Promise<void>;
1404
+ windDownSymbol(payload: {
1405
+ symbol: string;
1406
+ risk?: number;
1407
+ }): Promise<boolean>;
1408
+ getNonEssentialSymbols(): Promise<Set<any>>;
1409
+ refreshAllPositionsWithSymbol(payload: {
1410
+ symbol: string;
1411
+ }): Promise<void>;
1412
+ autoFollowPositions(): Promise<void>;
1413
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
1414
+ updateTpOnAllMarkets(): Promise<void>;
1415
+ triggerMoverTask(payload: {
1416
+ callback: (params: {
1417
+ symbol: string;
1418
+ account: ExchangeType;
1419
+ }) => Promise<any>;
1420
+ removeCallback?: (params: {
1421
+ symbol: string;
1422
+ account: ExchangeType;
1423
+ }) => Promise<any>;
1424
+ }): Promise<void>;
1425
+ placeTrade(payload: {
619
1426
  account: ExchangeType;
620
1427
  symbol: string;
621
1428
  kind: "long" | "short";
622
- revert?: boolean;
623
- }): Promise<import("pocketbase").RecordModel[]>;
624
- updateTopMovers(payload?: {
625
- new_markets: {
626
- symbol: string;
627
- percent: number;
628
- }[];
629
- totalRisk: number;
630
- }): Promise<{
631
- updated_bullish: BullishMarket[];
632
- moved_to_winding: WindingDownMarket[];
633
- }>;
634
- getWindingDownMarkets(): Promise<WindingDownMarket[]>;
1429
+ place?: boolean;
1430
+ tp?: boolean;
1431
+ cancel?: boolean;
1432
+ raw?: boolean;
1433
+ }): Promise<any>;
635
1434
  }
636
1435
  export declare function initApp(payload: {
637
1436
  db: {
@@ -639,14 +1438,100 @@ export declare function initApp(payload: {
639
1438
  email: string;
640
1439
  password: string;
641
1440
  };
642
- getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
1441
+ password?: string;
1442
+ getCredentials: (account: string, exchange: string) => {
643
1443
  api_key: string;
644
1444
  api_secret: string;
645
- }>;
1445
+ email: string;
1446
+ };
1447
+ proxy?: any;
1448
+ ignore_proxy?: boolean;
1449
+ canWithdraw?: boolean;
1450
+ triggerToken?: string;
646
1451
  }): Promise<App>;
1452
+ declare function getCredentials(account: string, exchange: string): {
1453
+ api_key: string;
1454
+ api_secret: string;
1455
+ email: string;
1456
+ };
1457
+ export declare function initialize(payload: {
1458
+ password?: string;
1459
+ proxy?: any;
1460
+ ignore_proxy?: boolean;
1461
+ canWithdraw?: boolean;
1462
+ }): Promise<App>;
1463
+ export type StrategyPosition = {
1464
+ entry: number;
1465
+ quantity: number;
1466
+ };
1467
+ export type Config = {
1468
+ tp_percent: number;
1469
+ short_tp_factor: number;
1470
+ fee_percent?: number;
1471
+ budget: number;
1472
+ global_config: GlobalConfig;
1473
+ };
1474
+ export declare class Strategy {
1475
+ position: {
1476
+ long: StrategyPosition;
1477
+ short: StrategyPosition;
1478
+ };
1479
+ config: Config;
1480
+ constructor(payload: {
1481
+ long: StrategyPosition;
1482
+ short: StrategyPosition;
1483
+ config: Config;
1484
+ });
1485
+ get price_places(): string;
1486
+ get decimal_places(): string;
1487
+ to_f(price: number): number;
1488
+ to_df(quantity: number): number;
1489
+ pnl(kind: "long" | "short"): number;
1490
+ tp(kind: "long" | "short"): number;
1491
+ calculate_fee(position: {
1492
+ price: number;
1493
+ quantity: number;
1494
+ }): number;
1495
+ get long_tp(): number;
1496
+ get short_tp(): number;
1497
+ generateGapClosingAlgorithm(payload: {
1498
+ kind: "long" | "short";
1499
+ risk_reward?: number;
1500
+ }): {
1501
+ [x: string]: any;
1502
+ risk: number;
1503
+ last_entry: any;
1504
+ first_entry: any;
1505
+ threshold: any;
1506
+ };
1507
+ runIterations(payload: {
1508
+ kind: "long" | "short";
1509
+ iterations: number;
1510
+ risk_reward?: number;
1511
+ }): {
1512
+ [x: string]: any;
1513
+ risk: number;
1514
+ last_entry: any;
1515
+ first_entry: any;
1516
+ threshold: any;
1517
+ }[];
1518
+ }
1519
+
1520
+ declare namespace database {
1521
+ export { AppDatabase, ExchangeType, initPocketBaseClient };
1522
+ }
1523
+ declare namespace exchange_account {
1524
+ export { ExchangeAccount$1 as ExchangeAccount, getExchangeAccount };
1525
+ }
1526
+ declare namespace app {
1527
+ export { App, getCredentials, initApp, initialize };
1528
+ }
647
1529
 
648
1530
  export {
649
1531
  ExchangeAccount$1 as ExchangeAccount,
1532
+ app,
1533
+ database,
1534
+ exchange_account,
650
1535
  };
651
1536
 
652
1537
  export {};