@gbozee/ultimate 0.0.2-3 → 0.0.2-31

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,26 @@ import PocketBase from 'pocketbase';
5
5
  import { RecordModel } from 'pocketbase';
6
6
  import { SocksProxyAgent } from 'socks-proxy-agent';
7
7
 
8
+ export type GlobalConfig = {
9
+ profit_percent: number;
10
+ symbol: string;
11
+ profit: number;
12
+ risk: number;
13
+ stop_percent: number;
14
+ kind: "long" | "short";
15
+ reduce_percent: number;
16
+ support: number;
17
+ resistance: number;
18
+ price_places: string;
19
+ decimal_places: string;
20
+ min_size: number;
21
+ accounts: {
22
+ owner: string;
23
+ exchange?: string;
24
+ }[];
25
+ risk_reward: number;
26
+ reverse_factor: number;
27
+ };
8
28
  interface Position$1 {
9
29
  id: number;
10
30
  kind: "long" | "short";
@@ -85,10 +105,15 @@ export interface BaseExchange {
85
105
  count: number;
86
106
  raw?: boolean;
87
107
  }): Promise<any>;
88
- getExchangeAccountInfo(account: {
89
- owner: string;
90
- exchange: string;
91
- }, symbol: string): Promise<any>;
108
+ getExchangeAccountInfo(options: {
109
+ price_places?: string;
110
+ decimal_places?: string;
111
+ account: {
112
+ owner: string;
113
+ exchange: string;
114
+ };
115
+ symbol: string;
116
+ }): Promise<any>;
92
117
  cancelOrders(payload: {
93
118
  symbol: string;
94
119
  orders: number[];
@@ -117,6 +142,47 @@ export interface BaseExchange {
117
142
  price_places?: string;
118
143
  decimal_places?: string;
119
144
  }): Promise<any>;
145
+ setLeverage(payload: {
146
+ symbol: string;
147
+ leverage: number;
148
+ }): Promise<any>;
149
+ generateConfig(payload: {
150
+ symbol: string;
151
+ interval?: any;
152
+ limit?: number;
153
+ }): Promise<any>;
154
+ checkDelistedMovers(payload: {
155
+ movePercent: number;
156
+ include_delisted?: boolean;
157
+ }): Promise<any>;
158
+ closePosition(payload: {
159
+ symbol: string;
160
+ kind: "long" | "short";
161
+ price_places?: string;
162
+ decimal_places?: string;
163
+ }): Promise<any>;
164
+ getAllOpenSymbols(): Promise<string[]>;
165
+ createLimitPurchaseOrders(payload: {
166
+ orders: any[];
167
+ kind: "long" | "short";
168
+ decimal_places?: string;
169
+ price_places?: string;
170
+ symbol: string;
171
+ }): Promise<any>;
172
+ getDelistedSpotSymbols(): Promise<any>;
173
+ getOpenPositions(): Promise<any>;
174
+ crossAccountTransfer(payload: {
175
+ from: {
176
+ owner: string;
177
+ wallet: string;
178
+ };
179
+ to: {
180
+ owner: string;
181
+ wallet: string;
182
+ };
183
+ asset: string;
184
+ amount: number;
185
+ }): Promise<any>;
120
186
  }
121
187
  export interface BaseSystemFields {
122
188
  id: string;
@@ -131,6 +197,17 @@ export interface ExchangeAccount extends BaseSystemFields {
131
197
  usdt?: number;
132
198
  usdc?: number;
133
199
  proxy?: string;
200
+ bullish?: boolean;
201
+ bearish?: boolean;
202
+ movePercent?: number;
203
+ totalRisk?: number;
204
+ max_non_essential?: number;
205
+ profit_percent?: number;
206
+ risk_reward?: number;
207
+ exclude_coins?: {
208
+ bullish?: string[];
209
+ };
210
+ include_delisted?: boolean;
134
211
  }
135
212
  export interface SymbolConfig extends BaseSystemFields {
136
213
  symbol: string;
@@ -142,6 +219,8 @@ export interface SymbolConfig extends BaseSystemFields {
142
219
  min_size?: number;
143
220
  weight?: number;
144
221
  leverage?: number;
222
+ candle_count?: number;
223
+ interval?: any;
145
224
  }
146
225
  export interface ScheduledTrade extends BaseSystemFields {
147
226
  symbol: string;
@@ -213,26 +292,58 @@ export interface BullishMarket extends RecordModel {
213
292
  export interface WindingDownMarket extends RecordModel {
214
293
  id: string;
215
294
  symbol: string;
295
+ risk_reward: number;
216
296
  }
217
297
  export type ExchangeType = {
218
298
  owner: string;
219
299
  exchange: string;
220
300
  };
221
301
  export declare class AppDatabase {
222
- private pb;
302
+ pb: PocketBase;
223
303
  constructor(pb: PocketBase);
304
+ getCredentials(password: string): any;
305
+ saveCredentials(password: string, credentials: any): Promise<void>;
306
+ addNewCredential(password: string, payload: {
307
+ name: string;
308
+ exchange: string;
309
+ api_key: string;
310
+ api_secret: string;
311
+ }): Promise<void>;
312
+ getAllSymbolsFromPositions(options?: {
313
+ no_position?: boolean;
314
+ kind?: "long" | "short";
315
+ custom_filter?: string;
316
+ }): Promise<any[]>;
317
+ createOrUpdateLiveExchangeInstance(payload: {
318
+ account: ExchangeType;
319
+ symbol: string;
320
+ data?: any;
321
+ }): Promise<import("pocketbase").RecordModel>;
322
+ getLiveExchangeInstance(payload: {
323
+ account: ExchangeType;
324
+ symbol: string;
325
+ data?: any;
326
+ }): Promise<import("pocketbase").RecordModel>;
224
327
  getProxyForAccount(account: ExchangeType): Promise<HttpsProxyAgent<`http://${string}`> | SocksProxyAgent>;
328
+ getAccounts(): Promise<ExchangeAccount[]>;
329
+ getAllSymbolConfigs(payload?: {
330
+ with_positions?: boolean;
331
+ custom_filter?: string;
332
+ }): Promise<SymbolConfig[]>;
225
333
  get_exchange_db_instance(account: ExchangeType): Promise<ExchangeAccount & {
226
334
  expand?: {
227
335
  proxy: Proxy$1;
228
336
  };
229
337
  }>;
230
- getPositions(account: ExchangeType, options: {
231
- symbol: string;
338
+ getPositions(options: {
339
+ account?: ExchangeType;
340
+ symbol?: string;
232
341
  as_view?: boolean;
342
+ custom_filter?: string;
233
343
  }): Promise<(PositionsView & {
234
344
  expand?: {
235
345
  config: ScheduledTrade;
346
+ account: ExchangeAccount;
236
347
  };
237
348
  })[]>;
238
349
  private _createOrUpdatePosition;
@@ -244,18 +355,19 @@ export declare class AppDatabase {
244
355
  }): Promise<(PositionsView & {
245
356
  expand?: {
246
357
  config: ScheduledTrade;
358
+ account: ExchangeAccount;
247
359
  };
248
360
  })[]>;
249
- update_db_position(position: any, payload: any): Promise<RecordModel>;
361
+ update_db_position(position: any, payload: any): Promise<import("pocketbase").RecordModel>;
250
362
  getSymbolConfigFromDB(symbol: string): Promise<SymbolConfig>;
251
363
  getRunningInstanceFromDB(account: ExchangeType, symbol: string, options?: {
252
364
  delay?: number;
253
365
  }): Promise<TradeBlockTracking>;
254
- updateRunningInstance(id: string, running: boolean): Promise<RecordModel>;
366
+ updateRunningInstance(id: string, running: boolean): Promise<import("pocketbase").RecordModel>;
255
367
  getOrders(account: ExchangeType, options: {
256
368
  symbol: string;
257
369
  kind: "long" | "short";
258
- }): Promise<RecordModel[]>;
370
+ }): Promise<import("pocketbase").RecordModel[]>;
259
371
  deleteAndRecreateOrders(account: ExchangeType, options: {
260
372
  symbol: string;
261
373
  kind: "long" | "short";
@@ -268,7 +380,7 @@ export declare class AppDatabase {
268
380
  stop: number;
269
381
  order_id: string;
270
382
  triggerPrice?: number;
271
- }>): Promise<RecordModel[]>;
383
+ }>): Promise<import("pocketbase").RecordModel[]>;
272
384
  cancelOrders(payload: {
273
385
  cancelExchangeOrders: (payload: {
274
386
  symbol: string;
@@ -296,45 +408,202 @@ export declare class AppDatabase {
296
408
  message?: undefined;
297
409
  exchange_result?: undefined;
298
410
  }>;
411
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
412
+ updateScheduledTrade(id: string, payload: any): Promise<import("pocketbase").RecordModel>;
299
413
  createOrUpdatePositionConfig(db_position: any, payload: {
300
414
  entry: number;
301
415
  stop: number;
302
416
  risk_reward: number;
303
417
  risk: number;
304
418
  profit_percent?: number;
305
- }): Promise<void>;
419
+ place_tp?: boolean;
420
+ profit?: number;
421
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
306
422
  getPositionConfig(payload: {
307
423
  symbol: string;
308
424
  kind: "long" | "short";
309
425
  account: ExchangeType;
310
- }): Promise<RecordModel>;
426
+ }): Promise<ScheduledTrade | null>;
311
427
  getPositionStrategy(account: ExchangeType): Promise<{
312
428
  strategy_instance: Strategy;
313
429
  focus_account: ExchangeAccount;
314
430
  }>;
315
- createOrUpdateWindingDownMarket(symbol: string): Promise<RecordModel>;
316
- getWindingDownMarkets(): Promise<WindingDownMarket[]>;
431
+ createOrUpdateWindingDownMarket(payload: {
432
+ symbol: string;
433
+ risk_reward?: number;
434
+ }): Promise<import("pocketbase").RecordModel>;
435
+ getWindingDownMarkets(symbol?: string): Promise<WindingDownMarket[]>;
436
+ getBullishMarket(symbol: string): Promise<BullishMarket>;
317
437
  getBullishMarkets(options?: {
318
438
  new_markets: Array<{
319
439
  symbol: string;
320
440
  percent: number;
321
441
  }>;
322
442
  totalRisk: number;
443
+ max_count?: number;
323
444
  }): Promise<{
324
445
  updated_bullish: BullishMarket[];
325
446
  moved_to_winding: WindingDownMarket[];
326
447
  }>;
448
+ updateSymbolConfigs(payload?: {
449
+ configs: Array<{
450
+ symbol: string;
451
+ support: number;
452
+ leverage: number;
453
+ min_size: number;
454
+ resistance: number;
455
+ price_places: string;
456
+ decimal_places: string;
457
+ }>;
458
+ }): Promise<{
459
+ updated: number;
460
+ created: number;
461
+ } | SymbolConfig[]>;
462
+ unwindSymbolFromDB(symbol: string): Promise<boolean>;
463
+ hasExistingPosition(symbol: string): Promise<import("pocketbase").RecordModel[]>;
464
+ hasExistingOrders(symbol: string): Promise<import("pocketbase").RecordModel[]>;
465
+ removeSymbolFromUnwindingMarkets(symbol: string): Promise<boolean>;
466
+ removePosition(position: any): Promise<void>;
467
+ removePositionConfig(position: any): Promise<void>;
327
468
  }
328
- export interface CodeNode {
469
+ export type SignalConfigType = {
470
+ focus: number;
471
+ budget: number;
472
+ percent_change?: number;
473
+ price_places?: string;
474
+ decimal_places?: string;
475
+ zone_risk?: number;
476
+ fee?: number;
477
+ support?: number;
478
+ risk_reward?: number;
479
+ resistance?: number;
480
+ risk_per_trade?: number;
481
+ increase_size?: boolean;
482
+ additional_increase?: number;
483
+ minimum_pnl?: number;
484
+ take_profit?: number;
485
+ increase_position?: boolean;
486
+ minimum_size?: number;
487
+ first_order_size?: number;
488
+ gap?: number;
489
+ max_size?: number;
490
+ };
491
+ declare class Signal {
492
+ focus: number;
493
+ budget: number;
494
+ percent_change: number;
495
+ price_places: string;
496
+ decimal_places: string;
497
+ zone_risk: number;
498
+ fee: number;
499
+ support?: number;
500
+ risk_reward: number;
501
+ resistance?: number;
502
+ risk_per_trade?: number;
503
+ increase_size: boolean;
504
+ additional_increase: number;
329
505
  minimum_pnl: number;
506
+ take_profit?: number;
507
+ increase_position: boolean;
508
+ minimum_size: any;
509
+ first_order_size: number;
510
+ gap: number;
330
511
  max_size: number;
331
- profit: number;
332
- ratio?: number;
333
- increase: boolean;
334
- not_reduce?: boolean;
335
- reduce_ratio?: number;
336
- use_full?: boolean;
512
+ 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);
513
+ build_entry({ current_price, stop_loss, pnl, stop_percent, kind, risk, no_of_trades, take_profit, }: {
514
+ take_profit?: number;
515
+ no_of_trades?: number;
516
+ current_price: number;
517
+ stop_loss?: number;
518
+ kind?: "long" | "short";
519
+ risk: number;
520
+ stop_percent?: number;
521
+ pnl?: number;
522
+ }): any;
523
+ get risk(): number;
524
+ get min_trades(): number;
525
+ get min_price(): number;
526
+ build_opposite_order({ current_price, kind, }: {
527
+ current_price: number;
528
+ kind?: "long" | "short";
529
+ }): any;
530
+ special_build_orders({ current_price, kind, }: {
531
+ current_price: number;
532
+ kind?: "long" | "short";
533
+ }): any;
534
+ build_orders({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
535
+ current_price: number;
536
+ kind?: "long" | "short";
537
+ limit?: boolean;
538
+ replace_focus?: boolean;
539
+ max_index?: number;
540
+ min_index?: number;
541
+ }): any;
542
+ build_orders_old({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
543
+ current_price: number;
544
+ kind?: "long" | "short";
545
+ limit?: boolean;
546
+ replace_focus?: boolean;
547
+ max_index?: number;
548
+ min_index?: number;
549
+ }): any;
550
+ get_bulk_trade_zones({ current_price, kind, limit, }: {
551
+ current_price: number;
552
+ kind?: "long" | "short";
553
+ limit?: boolean;
554
+ }): any;
555
+ get_future_zones({ current_price, kind, raw, }: {
556
+ raw?: boolean;
557
+ current_price: number;
558
+ kind?: "long" | "short";
559
+ }): number[];
560
+ to_f(value: number, places?: string): number;
561
+ get_margin_zones({ current_price, kind, }: {
562
+ current_price: number;
563
+ kind?: "long" | "short";
564
+ }): number[][];
565
+ get_margin_range(current_price: number, kind?: string): number[];
566
+ process_orders({ current_price, stop_loss, trade_zones, kind, }: {
567
+ current_price: number;
568
+ stop_loss: number;
569
+ trade_zones: number[];
570
+ kind?: "long" | "short";
571
+ }): any[];
572
+ get_risk_per_trade(number_of_orders: number): number;
573
+ build_trade_dict({ entry, stop, risk, arr, index, new_fees, kind, start, take_profit, }: {
574
+ entry: number;
575
+ stop: number;
576
+ risk: number;
577
+ arr: number[];
578
+ index: number;
579
+ new_fees?: number;
580
+ kind?: "long" | "short";
581
+ start?: number;
582
+ take_profit?: number;
583
+ }): {
584
+ entry: number;
585
+ risk: number;
586
+ quantity: number;
587
+ sell_price: number;
588
+ risk_sell: number;
589
+ stop: number;
590
+ pnl: number;
591
+ fee: number;
592
+ net: number;
593
+ incurred: number;
594
+ stop_percent: number;
595
+ };
596
+ to_df(currentPrice: number, places?: string): number;
337
597
  }
598
+ export declare function determine_average_entry_and_size(orders: Array<{
599
+ price: number;
600
+ quantity: number;
601
+ }>, places?: string, price_places?: string): {
602
+ entry: number;
603
+ price: number;
604
+ quantity: number;
605
+ };
606
+ export declare const createArray: (start: number, stop: number, step: number) => number[];
338
607
  export type AppConfig = {
339
608
  fee: number;
340
609
  risk_per_trade: number;
@@ -360,16 +629,112 @@ export type AppConfig = {
360
629
  gap?: number;
361
630
  rr?: number;
362
631
  max_size?: number;
632
+ last_value?: any;
633
+ entries?: any[];
634
+ };
635
+ export type ExtendConfigType = {
636
+ take_profit?: number;
637
+ entry: number;
638
+ risk?: number;
639
+ stop?: number;
640
+ risk_reward?: number;
641
+ raw_instance?: boolean;
642
+ no_of_trades?: number;
643
+ increase?: boolean;
644
+ price_places?: string;
645
+ decimal_places?: string;
646
+ min_profit?: number;
647
+ kind?: "long" | "short";
648
+ gap?: number;
649
+ rr?: number;
650
+ };
651
+ 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;
652
+ export declare function buildAvg({ _trades, kind, }: {
653
+ _trades: any[];
654
+ kind: "long" | "short";
655
+ }): any;
656
+ export declare function sortedBuildConfig(app_config: AppConfig, options: any): any[];
657
+ export declare function get_app_config_and_max_size(config: GlobalConfig, payload: {
658
+ entry: number;
659
+ stop: number;
660
+ kind: "long" | "short";
661
+ }): {
662
+ app_config: AppConfig;
663
+ max_size: any;
664
+ last_value: any;
665
+ entries: {
666
+ entry: any;
667
+ avg_entry: any;
668
+ avg_size: any;
669
+ neg_pnl: any;
670
+ quantity: any;
671
+ }[];
672
+ };
673
+ export declare function buildAppConfig(config: GlobalConfig, payload: {
674
+ entry: number;
675
+ stop: number;
676
+ risk_reward: number;
677
+ risk: number;
678
+ symbol: string;
679
+ profit?: number;
680
+ }): AppConfig;
681
+ export declare function getOptimumStopAndRisk(app_config: AppConfig, params: {
682
+ max_size: number;
683
+ target_stop: number;
684
+ highest_risk?: number;
685
+ }): {
686
+ optimal_stop: number;
687
+ optimal_risk: number;
688
+ avg_size: any;
689
+ avg_entry: any;
690
+ result: any[];
691
+ first_entry: any;
692
+ neg_pnl: any;
693
+ risk_reward: number;
694
+ size_diff: number;
695
+ entry_diff: number;
696
+ };
697
+ export declare function generate_config_params(app_config: AppConfig, payload: {
698
+ entry: number;
699
+ stop: number;
700
+ risk_reward: number;
701
+ risk: number;
702
+ symbol: string;
703
+ }): {
704
+ entry: number;
705
+ stop: number;
706
+ avg_size: any;
707
+ avg_entry: any;
708
+ risk_reward: number;
709
+ neg_pnl: any;
710
+ risk: number;
363
711
  };
364
712
  declare class ExchangeAccount$1 {
365
713
  private instance;
366
- private exchange;
714
+ exchange: BaseExchange;
715
+ main_exchange?: BaseExchange;
367
716
  private app_db;
368
717
  constructor(payload: ExchangeType, options: {
369
718
  exchange: BaseExchange;
370
719
  app_db: AppDatabase;
720
+ main_exchange?: BaseExchange;
371
721
  });
372
- getActiveAccount(symbol: string, full?: boolean): Promise<Account | {
722
+ /**
723
+ *In order to avoid rate limiting issues, we cache the live exchange
724
+ details for each symbol for an account in the database with an option
725
+ to refresh.
726
+ */
727
+ getDBInstance(): AppDatabase;
728
+ getLiveExchangeInstance(payload: {
729
+ symbol: string;
730
+ refresh?: boolean;
731
+ refresh_symbol_config?: boolean;
732
+ }): Promise<import("pocketbase").RecordModel>;
733
+ getActiveAccount(payload: {
734
+ symbol: string;
735
+ full?: boolean;
736
+ refresh?: boolean;
737
+ }): Promise<Account | {
373
738
  liquidation: {
374
739
  long: number;
375
740
  short: number;
@@ -383,13 +748,12 @@ declare class ExchangeAccount$1 {
383
748
  kind?: "long" | "short";
384
749
  update?: boolean;
385
750
  as_view?: boolean;
386
- }): Promise<(PositionsView & {
387
- expand?: {
388
- config: ScheduledTrade;
389
- };
390
- }) | (PositionsView & {
751
+ leverage?: number;
752
+ live_refresh?: boolean;
753
+ }): Promise<PositionsView | (PositionsView & {
391
754
  expand?: {
392
755
  config: ScheduledTrade;
756
+ account: ExchangeAccount;
393
757
  };
394
758
  })[]>;
395
759
  getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
@@ -398,6 +762,11 @@ declare class ExchangeAccount$1 {
398
762
  kind: "long" | "short";
399
763
  update?: boolean;
400
764
  }): Promise<import("pocketbase").RecordModel[]>;
765
+ toggleStopBuying(payload: {
766
+ symbol: string;
767
+ kind: "long" | "short";
768
+ should_stop?: boolean;
769
+ }): Promise<import("pocketbase").RecordModel>;
401
770
  cancelOrders(payload: {
402
771
  symbol: string;
403
772
  kind: "long" | "short";
@@ -461,9 +830,18 @@ declare class ExchangeAccount$1 {
461
830
  kind: "long" | "short";
462
831
  quantity: any;
463
832
  is_limit: boolean;
833
+ neg_pnl: any;
464
834
  };
465
835
  trades: any[];
466
836
  }>;
837
+ determineAmountToBuy(payload: {
838
+ orders: any[];
839
+ kind: "long" | "short";
840
+ decimal_places?: string;
841
+ price_places?: string;
842
+ symbol: string;
843
+ place?: boolean;
844
+ }): Promise<any[]>;
467
845
  placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
468
846
  symbol: string;
469
847
  entry: number;
@@ -472,44 +850,222 @@ declare class ExchangeAccount$1 {
472
850
  risk: number;
473
851
  place?: boolean;
474
852
  update_db?: boolean;
853
+ raw?: boolean;
854
+ use_current?: boolean;
475
855
  }): Promise<any>;
476
856
  getPositionConfig(payload: {
477
857
  symbol: string;
478
858
  kind: "long" | "short";
479
859
  params?: {
480
- entry: number;
481
- stop: number;
482
- risk_reward: number;
483
- risk: number;
860
+ entry?: number;
861
+ stop?: number;
862
+ risk_reward?: number;
863
+ risk?: number;
484
864
  profit_percent?: number;
865
+ place_tp?: boolean;
866
+ profit?: number;
485
867
  };
486
- }): Promise<import("pocketbase").RecordModel>;
868
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
487
869
  getCurrentPrice(symbol: string): Promise<any>;
488
870
  getPositionStrategy(): Promise<{
489
871
  strategy_instance: Strategy;
490
872
  focus_account: ExchangeAccount;
491
873
  }>;
874
+ buildReduceConfig(payload: {
875
+ symbol: string;
876
+ kind?: "long" | "short";
877
+ as_dict?: boolean;
878
+ trigger?: {
879
+ long: boolean;
880
+ short: boolean;
881
+ };
882
+ use_full?: boolean;
883
+ }): Promise<{
884
+ trigger_short: boolean;
885
+ trigger_long: boolean;
886
+ symbol: string;
887
+ short_minimum_pnl: number;
888
+ long_minimum_pnl: number;
889
+ short_profit: any;
890
+ long_profit: any;
891
+ owner: string;
892
+ exchange: string;
893
+ not_reduce: boolean;
894
+ reduce_ratio_long: any;
895
+ reduce_ratio_short: any;
896
+ use_full_long: any;
897
+ use_full_short: any;
898
+ } | {
899
+ long: {
900
+ minimum_pnl: number;
901
+ max_size: number;
902
+ profit: any;
903
+ increase: boolean;
904
+ not_reduce: boolean;
905
+ ratio: any;
906
+ use_full: boolean;
907
+ };
908
+ short: {
909
+ minimum_pnl: number;
910
+ max_size: number;
911
+ profit: any;
912
+ increase: boolean;
913
+ not_reduce: boolean;
914
+ ratio: any;
915
+ use_full: boolean;
916
+ };
917
+ trigger: {
918
+ long: boolean;
919
+ short: boolean;
920
+ };
921
+ }>;
492
922
  getOriginalPlannedStop(payload: {
493
923
  symbol: string;
494
924
  kind: "long" | "short";
495
925
  }): Promise<any>;
496
- syncReduceClosePosition(symbol: string, payload?: {
926
+ syncReduceClosePosition(payload?: {
927
+ symbol: string;
497
928
  kind?: "long" | "short";
498
- long?: CodeNode;
499
- short?: CodeNode;
500
- trigger?: {
929
+ trigger?: boolean;
930
+ }): Promise<any>;
931
+ reduceMajorPositionEntry(payload: {
932
+ symbol: string;
933
+ long: any;
934
+ short: any;
935
+ trigger: {
501
936
  long: boolean;
502
937
  short: boolean;
503
938
  };
504
939
  }): Promise<any>;
940
+ placeProfitAndStop(payload: {
941
+ symbol: string;
942
+ trigger?: boolean;
943
+ refresh?: boolean;
944
+ kind?: "long" | "short";
945
+ }): Promise<any>;
946
+ reEnterPositionOnEmpty(symbol: string): Promise<void>;
947
+ generate_config_params(payload: {
948
+ entry: number;
949
+ stop: number;
950
+ risk_reward: number;
951
+ risk: number;
952
+ symbol: string;
953
+ with_trades?: boolean;
954
+ }): Promise<any>;
955
+ build_short_order(payload: {
956
+ symbol: string;
957
+ kind: "long" | "short";
958
+ }): Promise<any>;
959
+ extrapolateShortConfig(payload: {
960
+ kind: "long" | "short";
961
+ symbol: string;
962
+ risk_reward?: number;
963
+ risk?: number;
964
+ }): Promise<any>;
965
+ triggerTradeFromConfig(payload: {
966
+ symbol: string;
967
+ kind: "long" | "short";
968
+ place?: boolean;
969
+ raw?: boolean;
970
+ tp?: boolean;
971
+ stop?: boolean;
972
+ }): Promise<any>;
973
+ verifyStopLoss(payload: {
974
+ symbol: string;
975
+ kind: "long" | "short";
976
+ revert?: boolean;
977
+ }): Promise<import("pocketbase").RecordModel[]>;
978
+ windDownSymbol(payload: {
979
+ symbol: string;
980
+ risk_reward?: number;
981
+ risk?: number;
982
+ }): Promise<void>;
983
+ updateTargetPnl(payload: {
984
+ symbol: string;
985
+ kind: "long" | "short";
986
+ }): Promise<number>;
987
+ recomputeSymbolConfig(payload: {
988
+ symbol: string;
989
+ refresh?: boolean;
990
+ }): Promise<SymbolConfig>;
991
+ /**
992
+ * This function builds a config for a symbol
993
+ * @param payload
994
+ * @returns
995
+ */
996
+ buildConfigForSymbol(payload: {
997
+ symbol: string;
998
+ risk: number;
999
+ kind?: "long" | "short";
1000
+ risk_reward?: number;
1001
+ as_config?: boolean;
1002
+ with_trades?: boolean;
1003
+ }): Promise<any>;
1004
+ triggerBullishMarket(payload: {
1005
+ symbol: string;
1006
+ profit_percent?: number;
1007
+ risk_reward?: number;
1008
+ }): Promise<any>;
1009
+ updateAllActiveSymbols(payload: {
1010
+ interval?: number;
1011
+ }): Promise<void>;
1012
+ updateAllPositionsWithNoConfig(payload: {
1013
+ kind: "long" | "short";
1014
+ }): Promise<void>;
1015
+ getSymbolsForPositions(): Promise<any[]>;
1016
+ getNonEssentialSymbols(): Promise<any[]>;
1017
+ _terminatePositions(payload: {
1018
+ symbol: string;
1019
+ }): Promise<void>;
1020
+ getOrders(payload: {
1021
+ symbol: string;
1022
+ kind: "long" | "short";
1023
+ type: "limit" | "stop" | "tp";
1024
+ refresh?: boolean;
1025
+ }): Promise<import("pocketbase").RecordModel[]>;
1026
+ syncPositionConfigs(payload: {
1027
+ symbol: string;
1028
+ kind: "long" | "short";
1029
+ refresh?: boolean;
1030
+ }): Promise<void>;
1031
+ terminatePositions(payload: {
1032
+ symbol: string;
1033
+ }): Promise<void>;
1034
+ fetchAndUpdateTopMovers(): Promise<{
1035
+ updated_bullish: BullishMarket[];
1036
+ moved_to_winding: WindingDownMarket[];
1037
+ }>;
1038
+ computeTargetPnl(payload: {
1039
+ symbol: string;
1040
+ kind: "long" | "short";
1041
+ }): Promise<number>;
1042
+ placeTrade(payload: {
1043
+ symbol: string;
1044
+ kind: "long" | "short";
1045
+ place?: boolean;
1046
+ tp?: boolean;
1047
+ stop?: boolean;
1048
+ raw?: boolean;
1049
+ cancel?: boolean;
1050
+ }): Promise<any>;
505
1051
  }
506
1052
  declare class App {
507
- private app_db;
1053
+ app_db: AppDatabase;
1054
+ proxyOptions?: {
1055
+ proxy?: any;
1056
+ ignore_proxy?: boolean;
1057
+ canWithdraw?: boolean;
1058
+ };
508
1059
  private getCredentials;
509
- constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
1060
+ constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => {
510
1061
  api_key: string;
511
1062
  api_secret: string;
512
- }>);
1063
+ email: string;
1064
+ }, proxyOptions?: {
1065
+ proxy?: any;
1066
+ ignore_proxy?: boolean;
1067
+ canWithdraw?: boolean;
1068
+ });
513
1069
  getExchangeAccount(account: ExchangeType): Promise<ExchangeAccount$1>;
514
1070
  syncAccount(payload: {
515
1071
  account: ExchangeType;
@@ -517,13 +1073,10 @@ declare class App {
517
1073
  kind?: "long" | "short";
518
1074
  update?: boolean;
519
1075
  as_view?: boolean;
520
- }): Promise<(PositionsView & {
521
- expand?: {
522
- config: ScheduledTrade;
523
- };
524
- }) | (PositionsView & {
1076
+ }): Promise<PositionsView | (PositionsView & {
525
1077
  expand?: {
526
1078
  config: ScheduledTrade;
1079
+ account: ExchangeAccount;
527
1080
  };
528
1081
  })[]>;
529
1082
  syncOrders(payload: {
@@ -554,34 +1107,6 @@ declare class App {
554
1107
  message?: undefined;
555
1108
  exchange_result?: undefined;
556
1109
  }>;
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
1110
  generateConfig(payload: {
586
1111
  account: ExchangeType;
587
1112
  symbol: string;
@@ -599,39 +1124,51 @@ declare class App {
599
1124
  short_db_position: any;
600
1125
  balance: any;
601
1126
  }>;
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;
1127
+ getWindingDownMarkets(): Promise<WindingDownMarket[]>;
1128
+ updateSymbolConfigs(payload: {
1129
+ configs: {
1130
+ symbol: string;
1131
+ support: number;
1132
+ leverage: number;
1133
+ min_size: number;
1134
+ resistance: number;
1135
+ price_places: string;
1136
+ decimal_places: string;
1137
+ }[];
1138
+ }): Promise<SymbolConfig[] | {
1139
+ updated: number;
1140
+ created: number;
617
1141
  }>;
618
- verifyStopLoss(payload: {
1142
+ updateAllAccountWithSymbols(with_positions?: boolean): Promise<void>;
1143
+ windDownSymbol(payload: {
1144
+ symbol: string;
1145
+ risk?: number;
1146
+ }): Promise<boolean>;
1147
+ getNonEssentialSymbols(): Promise<Set<any>>;
1148
+ refreshAllPositionsWithSymbol(payload: {
1149
+ symbol: string;
1150
+ }): Promise<void>;
1151
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
1152
+ updateTpOnAllMarkets(): Promise<void>;
1153
+ triggerMoverTask(payload: {
1154
+ callback: (params: {
1155
+ symbol: string;
1156
+ account: ExchangeType;
1157
+ }) => Promise<any>;
1158
+ removeCallback?: (params: {
1159
+ symbol: string;
1160
+ account: ExchangeType;
1161
+ }) => Promise<any>;
1162
+ }): Promise<void>;
1163
+ placeTrade(payload: {
619
1164
  account: ExchangeType;
620
1165
  symbol: string;
621
1166
  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[]>;
1167
+ place?: boolean;
1168
+ tp?: boolean;
1169
+ cancel?: boolean;
1170
+ raw?: boolean;
1171
+ }): Promise<any>;
635
1172
  }
636
1173
  export declare function initApp(payload: {
637
1174
  db: {
@@ -639,10 +1176,21 @@ export declare function initApp(payload: {
639
1176
  email: string;
640
1177
  password: string;
641
1178
  };
642
- getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
1179
+ password?: string;
1180
+ getCredentials: (account: string, exchange: string) => {
643
1181
  api_key: string;
644
1182
  api_secret: string;
645
- }>;
1183
+ email: string;
1184
+ };
1185
+ proxy?: any;
1186
+ ignore_proxy?: boolean;
1187
+ canWithdraw?: boolean;
1188
+ }): Promise<App>;
1189
+ export declare function initialize(payload: {
1190
+ password?: string;
1191
+ proxy?: any;
1192
+ ignore_proxy?: boolean;
1193
+ canWithdraw?: boolean;
646
1194
  }): Promise<App>;
647
1195
 
648
1196
  export {