@gbozee/ultimate 0.0.2-19 → 0.0.2-21

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +249 -78
  2. package/dist/index.js +1496 -391
  3. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -85,10 +85,15 @@ export interface BaseExchange {
85
85
  count: number;
86
86
  raw?: boolean;
87
87
  }): Promise<any>;
88
- getExchangeAccountInfo(account: {
89
- owner: string;
90
- exchange: string;
91
- }, symbol: string): Promise<any>;
88
+ getExchangeAccountInfo(options: {
89
+ price_places?: string;
90
+ decimal_places?: string;
91
+ account: {
92
+ owner: string;
93
+ exchange: string;
94
+ };
95
+ symbol: string;
96
+ }): Promise<any>;
92
97
  cancelOrders(payload: {
93
98
  symbol: string;
94
99
  orders: number[];
@@ -123,11 +128,27 @@ export interface BaseExchange {
123
128
  }): Promise<any>;
124
129
  generateConfig(payload: {
125
130
  symbol: string;
131
+ interval?: any;
126
132
  limit?: number;
127
133
  }): Promise<any>;
128
134
  checkDelistedMovers(payload: {
129
135
  movePercent: number;
130
136
  }): Promise<any>;
137
+ closePosition(payload: {
138
+ symbol: string;
139
+ kind: "long" | "short";
140
+ price_places?: string;
141
+ decimal_places?: string;
142
+ }): Promise<any>;
143
+ getAllOpenSymbols(): Promise<string[]>;
144
+ createLimitPurchaseOrders(payload: {
145
+ orders: any[];
146
+ kind: "long" | "short";
147
+ decimal_places?: string;
148
+ price_places?: string;
149
+ symbol: string;
150
+ }): Promise<any>;
151
+ getDelistedSpotSymbols(): Promise<any>;
131
152
  }
132
153
  export interface BaseSystemFields {
133
154
  id: string;
@@ -142,6 +163,15 @@ export interface ExchangeAccount extends BaseSystemFields {
142
163
  usdt?: number;
143
164
  usdc?: number;
144
165
  proxy?: string;
166
+ bullish?: boolean;
167
+ bearish?: boolean;
168
+ movePercent?: number;
169
+ totalRisk?: number;
170
+ max_non_essential?: number;
171
+ profit_percent?: number;
172
+ exclude_coins?: {
173
+ bullish?: string[];
174
+ };
145
175
  }
146
176
  export interface SymbolConfig extends BaseSystemFields {
147
177
  symbol: string;
@@ -153,6 +183,8 @@ export interface SymbolConfig extends BaseSystemFields {
153
183
  min_size?: number;
154
184
  weight?: number;
155
185
  leverage?: number;
186
+ candle_count?: number;
187
+ interval?: any;
156
188
  }
157
189
  export interface ScheduledTrade extends BaseSystemFields {
158
190
  symbol: string;
@@ -233,6 +265,11 @@ export type ExchangeType = {
233
265
  export declare class AppDatabase {
234
266
  private pb;
235
267
  constructor(pb: PocketBase);
268
+ getAllSymbolsFromPositions(options?: {
269
+ no_position?: boolean;
270
+ kind?: "long" | "short";
271
+ custom_filter?: string;
272
+ }): Promise<any[]>;
236
273
  createOrUpdateLiveExchangeInstance(payload: {
237
274
  account: ExchangeType;
238
275
  symbol: string;
@@ -245,18 +282,24 @@ export declare class AppDatabase {
245
282
  }): Promise<import("pocketbase").RecordModel>;
246
283
  getProxyForAccount(account: ExchangeType): Promise<HttpsProxyAgent<`http://${string}`> | SocksProxyAgent>;
247
284
  getAccounts(): Promise<ExchangeAccount[]>;
248
- getAllSymbolConfigs(with_positions?: boolean): Promise<SymbolConfig[]>;
285
+ getAllSymbolConfigs(payload?: {
286
+ with_positions?: boolean;
287
+ custom_filter?: string;
288
+ }): Promise<SymbolConfig[]>;
249
289
  get_exchange_db_instance(account: ExchangeType): Promise<ExchangeAccount & {
250
290
  expand?: {
251
291
  proxy: Proxy$1;
252
292
  };
253
293
  }>;
254
- getPositions(account: ExchangeType, options: {
255
- symbol: string;
294
+ getPositions(options: {
295
+ account?: ExchangeType;
296
+ symbol?: string;
256
297
  as_view?: boolean;
298
+ custom_filter?: string;
257
299
  }): Promise<(PositionsView & {
258
300
  expand?: {
259
301
  config: ScheduledTrade;
302
+ account: ExchangeAccount;
260
303
  };
261
304
  })[]>;
262
305
  private _createOrUpdatePosition;
@@ -268,6 +311,7 @@ export declare class AppDatabase {
268
311
  }): Promise<(PositionsView & {
269
312
  expand?: {
270
313
  config: ScheduledTrade;
314
+ account: ExchangeAccount;
271
315
  };
272
316
  })[]>;
273
317
  update_db_position(position: any, payload: any): Promise<import("pocketbase").RecordModel>;
@@ -320,13 +364,17 @@ export declare class AppDatabase {
320
364
  message?: undefined;
321
365
  exchange_result?: undefined;
322
366
  }>;
367
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
368
+ updateScheduledTrade(id: string, payload: any): Promise<import("pocketbase").RecordModel>;
323
369
  createOrUpdatePositionConfig(db_position: any, payload: {
324
370
  entry: number;
325
371
  stop: number;
326
372
  risk_reward: number;
327
373
  risk: number;
328
374
  profit_percent?: number;
329
- }): Promise<void>;
375
+ place_tp?: boolean;
376
+ profit?: number;
377
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
330
378
  getPositionConfig(payload: {
331
379
  symbol: string;
332
380
  kind: "long" | "short";
@@ -345,6 +393,7 @@ export declare class AppDatabase {
345
393
  percent: number;
346
394
  }>;
347
395
  totalRisk: number;
396
+ max_count?: number;
348
397
  }): Promise<{
349
398
  updated_bullish: BullishMarket[];
350
399
  moved_to_winding: WindingDownMarket[];
@@ -365,20 +414,11 @@ export declare class AppDatabase {
365
414
  } | SymbolConfig[]>;
366
415
  unwindSymbolFromDB(symbol: string): Promise<boolean>;
367
416
  hasExistingPosition(symbol: string): Promise<import("pocketbase").RecordModel[]>;
417
+ hasExistingOrders(symbol: string): Promise<import("pocketbase").RecordModel[]>;
368
418
  removeSymbolFromUnwindingMarkets(symbol: string): Promise<boolean>;
369
419
  removePosition(position: any): Promise<void>;
370
420
  removePositionConfig(position: any): Promise<void>;
371
421
  }
372
- export interface CodeNode {
373
- minimum_pnl: number;
374
- max_size: number;
375
- profit: number;
376
- ratio?: number;
377
- increase: boolean;
378
- not_reduce?: boolean;
379
- reduce_ratio?: number;
380
- use_full?: boolean;
381
- }
382
422
  export type AppConfig = {
383
423
  fee: number;
384
424
  risk_per_trade: number;
@@ -404,14 +444,18 @@ export type AppConfig = {
404
444
  gap?: number;
405
445
  rr?: number;
406
446
  max_size?: number;
447
+ last_value?: any;
448
+ entries?: any[];
407
449
  };
408
450
  declare class ExchangeAccount$1 {
409
451
  private instance;
410
452
  exchange: BaseExchange;
453
+ main_exchange?: BaseExchange;
411
454
  private app_db;
412
455
  constructor(payload: ExchangeType, options: {
413
456
  exchange: BaseExchange;
414
457
  app_db: AppDatabase;
458
+ main_exchange?: BaseExchange;
415
459
  });
416
460
  /**
417
461
  *In order to avoid rate limiting issues, we cache the live exchange
@@ -421,10 +465,13 @@ declare class ExchangeAccount$1 {
421
465
  getLiveExchangeInstance(payload: {
422
466
  symbol: string;
423
467
  refresh?: boolean;
424
- price_places?: string;
425
- decimal_places?: string;
468
+ refresh_symbol_config?: boolean;
426
469
  }): Promise<import("pocketbase").RecordModel>;
427
- getActiveAccount(symbol: string, full?: boolean): Promise<Account | {
470
+ getActiveAccount(payload: {
471
+ symbol: string;
472
+ full?: boolean;
473
+ refresh?: boolean;
474
+ }): Promise<Account | {
428
475
  liquidation: {
429
476
  long: number;
430
477
  short: number;
@@ -439,9 +486,11 @@ declare class ExchangeAccount$1 {
439
486
  update?: boolean;
440
487
  as_view?: boolean;
441
488
  leverage?: number;
489
+ live_refresh?: boolean;
442
490
  }): Promise<PositionsView | (PositionsView & {
443
491
  expand?: {
444
492
  config: ScheduledTrade;
493
+ account: ExchangeAccount;
445
494
  };
446
495
  })[]>;
447
496
  getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
@@ -518,9 +567,18 @@ declare class ExchangeAccount$1 {
518
567
  kind: "long" | "short";
519
568
  quantity: any;
520
569
  is_limit: boolean;
570
+ neg_pnl: any;
521
571
  };
522
572
  trades: any[];
523
573
  }>;
574
+ determineAmountToBuy(payload: {
575
+ orders: any[];
576
+ kind: "long" | "short";
577
+ decimal_places?: string;
578
+ price_places?: string;
579
+ symbol: string;
580
+ place?: boolean;
581
+ }): Promise<any[]>;
524
582
  placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
525
583
  symbol: string;
526
584
  entry: number;
@@ -529,81 +587,198 @@ declare class ExchangeAccount$1 {
529
587
  risk: number;
530
588
  place?: boolean;
531
589
  update_db?: boolean;
590
+ raw?: boolean;
532
591
  }): Promise<any>;
533
592
  getPositionConfig(payload: {
534
593
  symbol: string;
535
594
  kind: "long" | "short";
536
595
  params?: {
537
- entry: number;
538
- stop: number;
539
- risk_reward: number;
540
- risk: number;
596
+ entry?: number;
597
+ stop?: number;
598
+ risk_reward?: number;
599
+ risk?: number;
541
600
  profit_percent?: number;
601
+ place_tp?: boolean;
602
+ profit?: number;
542
603
  };
543
- }): Promise<ScheduledTrade>;
604
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
544
605
  getCurrentPrice(symbol: string): Promise<any>;
545
606
  getPositionStrategy(): Promise<{
546
607
  strategy_instance: Strategy;
547
608
  focus_account: ExchangeAccount;
548
609
  }>;
610
+ buildReduceConfig(payload: {
611
+ symbol: string;
612
+ kind?: "long" | "short";
613
+ as_dict?: boolean;
614
+ trigger?: {
615
+ long: boolean;
616
+ short: boolean;
617
+ };
618
+ use_full?: boolean;
619
+ }): Promise<{
620
+ trigger_short: boolean;
621
+ trigger_long: boolean;
622
+ symbol: string;
623
+ short_minimum_pnl: number;
624
+ long_minimum_pnl: number;
625
+ short_profit: any;
626
+ long_profit: any;
627
+ owner: string;
628
+ exchange: string;
629
+ not_reduce: boolean;
630
+ reduce_ratio_long: any;
631
+ reduce_ratio_short: any;
632
+ use_full_long: any;
633
+ use_full_short: any;
634
+ } | {
635
+ long: {
636
+ minimum_pnl: number;
637
+ max_size: number;
638
+ profit: any;
639
+ increase: boolean;
640
+ not_reduce: boolean;
641
+ ratio: any;
642
+ use_full: boolean;
643
+ };
644
+ short: {
645
+ minimum_pnl: number;
646
+ max_size: number;
647
+ profit: any;
648
+ increase: boolean;
649
+ not_reduce: boolean;
650
+ ratio: any;
651
+ use_full: boolean;
652
+ };
653
+ trigger: {
654
+ long: boolean;
655
+ short: boolean;
656
+ };
657
+ }>;
549
658
  getOriginalPlannedStop(payload: {
550
659
  symbol: string;
551
660
  kind: "long" | "short";
552
661
  }): Promise<any>;
553
- syncReduceClosePosition(symbol: string, payload?: {
662
+ syncReduceClosePosition(payload?: {
663
+ symbol: string;
554
664
  kind?: "long" | "short";
555
- long?: CodeNode;
556
- short?: CodeNode;
557
- trigger?: {
665
+ trigger?: boolean;
666
+ }): Promise<any>;
667
+ reduceMajorPositionEntry(payload: {
668
+ symbol: string;
669
+ long: any;
670
+ short: any;
671
+ trigger: {
558
672
  long: boolean;
559
673
  short: boolean;
560
674
  };
561
675
  }): Promise<any>;
676
+ placeProfitAndStop(payload: {
677
+ symbol: string;
678
+ trigger?: boolean;
679
+ refresh?: boolean;
680
+ kind?: "long" | "short";
681
+ }): Promise<any>;
682
+ reEnterPositionOnEmpty(symbol: string): Promise<void>;
562
683
  generate_config_params(payload: {
563
684
  entry: number;
564
685
  stop: number;
565
686
  risk_reward: number;
566
687
  risk: number;
567
688
  symbol: string;
568
- }): Promise<{
569
- place_stop: boolean;
570
- profit_percent: number;
571
- entry: number;
572
- stop: number;
573
- avg_size: any;
574
- avg_entry: any;
575
- risk_reward: number;
576
- neg_pnl: any;
577
- risk: number;
578
- }>;
689
+ with_trades?: boolean;
690
+ }): Promise<any>;
691
+ build_short_order(payload: {
692
+ symbol: string;
693
+ kind: "long" | "short";
694
+ }): Promise<any>;
579
695
  extrapolateShortConfig(payload: {
580
696
  kind: "long" | "short";
581
697
  symbol: string;
582
698
  risk_reward?: number;
583
- }): Promise<{
584
- place_stop: boolean;
585
- profit_percent: number;
586
- entry: number;
587
- stop: number;
588
- avg_size: any;
589
- avg_entry: any;
590
- risk_reward: number;
591
- neg_pnl: any;
592
- risk: number;
593
- }>;
699
+ risk?: number;
700
+ }): Promise<any>;
594
701
  triggerTradeFromConfig(payload: {
595
702
  symbol: string;
596
703
  kind: "long" | "short";
704
+ place?: boolean;
705
+ raw?: boolean;
706
+ tp?: boolean;
597
707
  }): Promise<any>;
598
708
  verifyStopLoss(payload: {
599
709
  symbol: string;
600
710
  kind: "long" | "short";
601
711
  revert?: boolean;
602
712
  }): Promise<import("pocketbase").RecordModel[]>;
603
- windDownSymbol(symbol: string, risk_reward?: number): Promise<void>;
713
+ windDownSymbol(payload: {
714
+ symbol: string;
715
+ risk_reward?: number;
716
+ risk?: number;
717
+ }): Promise<void>;
718
+ updateTargetPnl(payload: {
719
+ symbol: string;
720
+ kind: "long" | "short";
721
+ }): Promise<number>;
722
+ recomputeSymbolConfig(payload: {
723
+ symbol: string;
724
+ refresh?: boolean;
725
+ }): Promise<SymbolConfig>;
726
+ /**
727
+ * This function builds a config for a symbol
728
+ * @param payload
729
+ * @returns
730
+ */
731
+ buildConfigForSymbol(payload: {
732
+ symbol: string;
733
+ risk: number;
734
+ kind?: "long" | "short";
735
+ risk_reward?: number;
736
+ as_config?: boolean;
737
+ with_trades?: boolean;
738
+ }): Promise<any>;
604
739
  triggerBullishMarket(payload: {
605
740
  symbol: string;
606
741
  profit_percent?: number;
742
+ risk_reward?: number;
743
+ }): Promise<any>;
744
+ updateAllActiveSymbols(payload: {
745
+ interval?: number;
746
+ }): Promise<void>;
747
+ updateAllPositionsWithNoConfig(payload: {
748
+ kind: "long" | "short";
749
+ }): Promise<void>;
750
+ getSymbolsForPositions(): Promise<any[]>;
751
+ getNonEssentialSymbols(): Promise<any[]>;
752
+ _terminatePositions(payload: {
753
+ symbol: string;
754
+ }): Promise<void>;
755
+ getOrders(payload: {
756
+ symbol: string;
757
+ kind: "long" | "short";
758
+ type: "limit" | "stop" | "tp";
759
+ refresh?: boolean;
760
+ }): Promise<import("pocketbase").RecordModel[]>;
761
+ syncPositionConfigs(payload: {
762
+ symbol: string;
763
+ kind: "long" | "short";
764
+ refresh?: boolean;
765
+ }): Promise<void>;
766
+ terminatePositions(payload: {
767
+ symbol: string;
768
+ }): Promise<void>;
769
+ fetchAndUpdateTopMovers(): Promise<{
770
+ updated_bullish: BullishMarket[];
771
+ moved_to_winding: WindingDownMarket[];
772
+ }>;
773
+ computeTargetPnl(payload: {
774
+ symbol: string;
775
+ kind: "long" | "short";
776
+ }): Promise<number>;
777
+ placeTrade(payload: {
778
+ symbol: string;
779
+ kind: "long" | "short";
780
+ place?: boolean;
781
+ tp?: boolean;
607
782
  }): Promise<any>;
608
783
  }
609
784
  declare class App {
@@ -623,6 +798,7 @@ declare class App {
623
798
  }): Promise<PositionsView | (PositionsView & {
624
799
  expand?: {
625
800
  config: ScheduledTrade;
801
+ account: ExchangeAccount;
626
802
  };
627
803
  })[]>;
628
804
  syncOrders(payload: {
@@ -670,22 +846,6 @@ declare class App {
670
846
  short_db_position: any;
671
847
  balance: any;
672
848
  }>;
673
- verifyStopLoss(payload: {
674
- account: ExchangeType;
675
- symbol: string;
676
- kind: "long" | "short";
677
- revert?: boolean;
678
- }): Promise<import("pocketbase").RecordModel[]>;
679
- updateTopMovers(payload?: {
680
- new_markets: {
681
- symbol: string;
682
- percent: number;
683
- }[];
684
- totalRisk: number;
685
- }): Promise<{
686
- updated_bullish: BullishMarket[];
687
- moved_to_winding: WindingDownMarket[];
688
- }>;
689
849
  getWindingDownMarkets(): Promise<WindingDownMarket[]>;
690
850
  updateSymbolConfigs(payload: {
691
851
  configs: {
@@ -702,15 +862,26 @@ declare class App {
702
862
  created: number;
703
863
  }>;
704
864
  updateAllAccountWithSymbols(with_positions?: boolean): Promise<void>;
705
- windDownSymbol(symbol: string): Promise<boolean>;
706
- fetchAndUpdateTopMovers(payload: {
707
- movePercent: number;
708
- account: ExchangeType;
709
- totalRisk: number;
710
- }): Promise<{
711
- updated_bullish: BullishMarket[];
712
- moved_to_winding: WindingDownMarket[];
713
- }>;
865
+ windDownSymbol(payload: {
866
+ symbol: string;
867
+ risk?: number;
868
+ }): Promise<boolean>;
869
+ getNonEssentialSymbols(): Promise<Set<any>>;
870
+ refreshAllPositionsWithSymbol(payload: {
871
+ symbol: string;
872
+ }): Promise<void>;
873
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
874
+ updateTpOnAllMarkets(): Promise<void>;
875
+ triggerMoverTask(payload: {
876
+ callback: (params: {
877
+ symbol: string;
878
+ account: ExchangeType;
879
+ }) => Promise<any>;
880
+ removeCallback?: (params: {
881
+ symbol: string;
882
+ account: ExchangeType;
883
+ }) => Promise<any>;
884
+ }): Promise<void>;
714
885
  }
715
886
  export declare function initApp(payload: {
716
887
  db: {