@gbozee/ultimate 0.0.2-5 → 0.0.2-51

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