@gbozee/ultimate 0.0.2-18 → 0.0.2-20

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 +158 -45
  2. package/dist/index.js +833 -222
  3. package/package.json +3 -1
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[];
@@ -125,6 +130,15 @@ export interface BaseExchange {
125
130
  symbol: string;
126
131
  limit?: number;
127
132
  }): Promise<any>;
133
+ checkDelistedMovers(payload: {
134
+ movePercent: number;
135
+ }): Promise<any>;
136
+ closePosition(payload: {
137
+ symbol: string;
138
+ kind: "long" | "short";
139
+ price_places?: string;
140
+ decimal_places?: string;
141
+ }): Promise<any>;
128
142
  }
129
143
  export interface BaseSystemFields {
130
144
  id: string;
@@ -139,6 +153,11 @@ export interface ExchangeAccount extends BaseSystemFields {
139
153
  usdt?: number;
140
154
  usdc?: number;
141
155
  proxy?: string;
156
+ bullish?: boolean;
157
+ bearish?: boolean;
158
+ movePercent?: number;
159
+ totalRisk?: number;
160
+ max_non_essential?: number;
142
161
  }
143
162
  export interface SymbolConfig extends BaseSystemFields {
144
163
  symbol: string;
@@ -150,6 +169,7 @@ export interface SymbolConfig extends BaseSystemFields {
150
169
  min_size?: number;
151
170
  weight?: number;
152
171
  leverage?: number;
172
+ candle_count?: number;
153
173
  }
154
174
  export interface ScheduledTrade extends BaseSystemFields {
155
175
  symbol: string;
@@ -230,6 +250,11 @@ export type ExchangeType = {
230
250
  export declare class AppDatabase {
231
251
  private pb;
232
252
  constructor(pb: PocketBase);
253
+ getAllSymbolsFromPositions(options?: {
254
+ no_position?: boolean;
255
+ kind?: "long" | "short";
256
+ custom_filter?: string;
257
+ }): Promise<any[]>;
233
258
  createOrUpdateLiveExchangeInstance(payload: {
234
259
  account: ExchangeType;
235
260
  symbol: string;
@@ -242,18 +267,24 @@ export declare class AppDatabase {
242
267
  }): Promise<import("pocketbase").RecordModel>;
243
268
  getProxyForAccount(account: ExchangeType): Promise<HttpsProxyAgent<`http://${string}`> | SocksProxyAgent>;
244
269
  getAccounts(): Promise<ExchangeAccount[]>;
245
- getAllSymbolConfigs(with_positions?: boolean): Promise<SymbolConfig[]>;
270
+ getAllSymbolConfigs(payload?: {
271
+ with_positions?: boolean;
272
+ custom_filter?: string;
273
+ }): Promise<SymbolConfig[]>;
246
274
  get_exchange_db_instance(account: ExchangeType): Promise<ExchangeAccount & {
247
275
  expand?: {
248
276
  proxy: Proxy$1;
249
277
  };
250
278
  }>;
251
- getPositions(account: ExchangeType, options: {
252
- symbol: string;
279
+ getPositions(options: {
280
+ account?: ExchangeType;
281
+ symbol?: string;
253
282
  as_view?: boolean;
283
+ custom_filter?: string;
254
284
  }): Promise<(PositionsView & {
255
285
  expand?: {
256
286
  config: ScheduledTrade;
287
+ account: ExchangeAccount;
257
288
  };
258
289
  })[]>;
259
290
  private _createOrUpdatePosition;
@@ -265,6 +296,7 @@ export declare class AppDatabase {
265
296
  }): Promise<(PositionsView & {
266
297
  expand?: {
267
298
  config: ScheduledTrade;
299
+ account: ExchangeAccount;
268
300
  };
269
301
  })[]>;
270
302
  update_db_position(position: any, payload: any): Promise<import("pocketbase").RecordModel>;
@@ -323,7 +355,7 @@ export declare class AppDatabase {
323
355
  risk_reward: number;
324
356
  risk: number;
325
357
  profit_percent?: number;
326
- }): Promise<void>;
358
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
327
359
  getPositionConfig(payload: {
328
360
  symbol: string;
329
361
  kind: "long" | "short";
@@ -342,6 +374,7 @@ export declare class AppDatabase {
342
374
  percent: number;
343
375
  }>;
344
376
  totalRisk: number;
377
+ max_count?: number;
345
378
  }): Promise<{
346
379
  updated_bullish: BullishMarket[];
347
380
  moved_to_winding: WindingDownMarket[];
@@ -366,16 +399,6 @@ export declare class AppDatabase {
366
399
  removePosition(position: any): Promise<void>;
367
400
  removePositionConfig(position: any): Promise<void>;
368
401
  }
369
- export interface CodeNode {
370
- minimum_pnl: number;
371
- max_size: number;
372
- profit: number;
373
- ratio?: number;
374
- increase: boolean;
375
- not_reduce?: boolean;
376
- reduce_ratio?: number;
377
- use_full?: boolean;
378
- }
379
402
  export type AppConfig = {
380
403
  fee: number;
381
404
  risk_per_trade: number;
@@ -404,7 +427,7 @@ export type AppConfig = {
404
427
  };
405
428
  declare class ExchangeAccount$1 {
406
429
  private instance;
407
- private exchange;
430
+ exchange: BaseExchange;
408
431
  private app_db;
409
432
  constructor(payload: ExchangeType, options: {
410
433
  exchange: BaseExchange;
@@ -418,10 +441,13 @@ declare class ExchangeAccount$1 {
418
441
  getLiveExchangeInstance(payload: {
419
442
  symbol: string;
420
443
  refresh?: boolean;
421
- price_places?: string;
422
- decimal_places?: string;
444
+ refresh_symbol_config?: boolean;
423
445
  }): Promise<import("pocketbase").RecordModel>;
424
- getActiveAccount(symbol: string, full?: boolean): Promise<Account | {
446
+ getActiveAccount(payload: {
447
+ symbol: string;
448
+ full?: boolean;
449
+ refresh?: boolean;
450
+ }): Promise<Account | {
425
451
  liquidation: {
426
452
  long: number;
427
453
  short: number;
@@ -436,9 +462,11 @@ declare class ExchangeAccount$1 {
436
462
  update?: boolean;
437
463
  as_view?: boolean;
438
464
  leverage?: number;
465
+ live_refresh?: boolean;
439
466
  }): Promise<PositionsView | (PositionsView & {
440
467
  expand?: {
441
468
  config: ScheduledTrade;
469
+ account: ExchangeAccount;
442
470
  };
443
471
  })[]>;
444
472
  getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
@@ -515,6 +543,7 @@ declare class ExchangeAccount$1 {
515
543
  kind: "long" | "short";
516
544
  quantity: any;
517
545
  is_limit: boolean;
546
+ neg_pnl: any;
518
547
  };
519
548
  trades: any[];
520
549
  }>;
@@ -537,25 +566,85 @@ declare class ExchangeAccount$1 {
537
566
  risk: number;
538
567
  profit_percent?: number;
539
568
  };
540
- }): Promise<ScheduledTrade>;
569
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
541
570
  getCurrentPrice(symbol: string): Promise<any>;
542
571
  getPositionStrategy(): Promise<{
543
572
  strategy_instance: Strategy;
544
573
  focus_account: ExchangeAccount;
545
574
  }>;
575
+ buildReduceConfig(payload: {
576
+ symbol: string;
577
+ kind?: "long" | "short";
578
+ as_dict?: boolean;
579
+ trigger?: {
580
+ long: boolean;
581
+ short: boolean;
582
+ };
583
+ use_full?: boolean;
584
+ }): Promise<{
585
+ trigger_short: boolean;
586
+ trigger_long: boolean;
587
+ symbol: string;
588
+ short_minimum_pnl: number;
589
+ long_minimum_pnl: number;
590
+ short_profit: any;
591
+ long_profit: any;
592
+ owner: string;
593
+ exchange: string;
594
+ not_reduce: boolean;
595
+ reduce_ratio_long: any;
596
+ reduce_ratio_short: any;
597
+ use_full_long: any;
598
+ use_full_short: any;
599
+ } | {
600
+ long: {
601
+ minimum_pnl: number;
602
+ max_size: number;
603
+ profit: any;
604
+ increase: boolean;
605
+ not_reduce: boolean;
606
+ ratio: any;
607
+ use_full: boolean;
608
+ };
609
+ short: {
610
+ minimum_pnl: number;
611
+ max_size: number;
612
+ profit: any;
613
+ increase: boolean;
614
+ not_reduce: boolean;
615
+ ratio: any;
616
+ use_full: boolean;
617
+ };
618
+ trigger: {
619
+ long: boolean;
620
+ short: boolean;
621
+ };
622
+ }>;
546
623
  getOriginalPlannedStop(payload: {
547
624
  symbol: string;
548
625
  kind: "long" | "short";
549
626
  }): Promise<any>;
550
- syncReduceClosePosition(symbol: string, payload?: {
627
+ syncReduceClosePosition(payload?: {
628
+ symbol: string;
551
629
  kind?: "long" | "short";
552
- long?: CodeNode;
553
- short?: CodeNode;
554
- trigger?: {
630
+ trigger?: boolean;
631
+ }): Promise<any>;
632
+ reduceMajorPositionEntry(payload: {
633
+ symbol: string;
634
+ long: any;
635
+ short: any;
636
+ trigger: {
555
637
  long: boolean;
556
638
  short: boolean;
557
639
  };
558
640
  }): Promise<any>;
641
+ placeProfitAndStop(payload: {
642
+ symbol: string;
643
+ trigger?: boolean;
644
+ refresh?: boolean;
645
+ kind?: "long" | "short";
646
+ }): Promise<any>;
647
+ reEnterPositionOnEmpty(symbol: string): Promise<void>;
559
648
  generate_config_params(payload: {
560
649
  entry: number;
561
650
  stop: number;
@@ -577,6 +666,7 @@ declare class ExchangeAccount$1 {
577
666
  kind: "long" | "short";
578
667
  symbol: string;
579
668
  risk_reward?: number;
669
+ risk?: number;
580
670
  }): Promise<{
581
671
  place_stop: boolean;
582
672
  profit_percent: number;
@@ -591,17 +681,47 @@ declare class ExchangeAccount$1 {
591
681
  triggerTradeFromConfig(payload: {
592
682
  symbol: string;
593
683
  kind: "long" | "short";
684
+ place?: boolean;
594
685
  }): Promise<any>;
595
686
  verifyStopLoss(payload: {
596
687
  symbol: string;
597
688
  kind: "long" | "short";
598
689
  revert?: boolean;
599
690
  }): Promise<import("pocketbase").RecordModel[]>;
600
- windDownSymbol(symbol: string, risk_reward?: number): Promise<void>;
691
+ windDownSymbol(payload: {
692
+ symbol: string;
693
+ risk_reward?: number;
694
+ risk?: number;
695
+ }): Promise<void>;
696
+ updateTargetPnl(payload: {
697
+ symbol: string;
698
+ kind: "long" | "short";
699
+ }): Promise<number>;
700
+ recomputeSymbolConfig(payload: {
701
+ symbol: string;
702
+ refresh?: boolean;
703
+ }): Promise<SymbolConfig>;
601
704
  triggerBullishMarket(payload: {
602
705
  symbol: string;
603
706
  profit_percent?: number;
707
+ risk_reward?: number;
604
708
  }): Promise<any>;
709
+ updateAllActiveSymbols(): Promise<void>;
710
+ updateAllPositionsWithNoConfig(payload: {
711
+ kind: "long" | "short";
712
+ }): Promise<void>;
713
+ getNonEssentialSymbols(): Promise<any[]>;
714
+ terminatePositions(payload: {
715
+ symbol: string;
716
+ }): Promise<void>;
717
+ fetchAndUpdateTopMovers(): Promise<{
718
+ updated_bullish: BullishMarket[];
719
+ moved_to_winding: WindingDownMarket[];
720
+ }>;
721
+ computeTargetPnl(payload: {
722
+ symbol: string;
723
+ kind: "long" | "short";
724
+ }): Promise<number>;
605
725
  }
606
726
  declare class App {
607
727
  private app_db;
@@ -620,6 +740,7 @@ declare class App {
620
740
  }): Promise<PositionsView | (PositionsView & {
621
741
  expand?: {
622
742
  config: ScheduledTrade;
743
+ account: ExchangeAccount;
623
744
  };
624
745
  })[]>;
625
746
  syncOrders(payload: {
@@ -667,22 +788,6 @@ declare class App {
667
788
  short_db_position: any;
668
789
  balance: any;
669
790
  }>;
670
- verifyStopLoss(payload: {
671
- account: ExchangeType;
672
- symbol: string;
673
- kind: "long" | "short";
674
- revert?: boolean;
675
- }): Promise<import("pocketbase").RecordModel[]>;
676
- updateTopMovers(payload?: {
677
- new_markets: {
678
- symbol: string;
679
- percent: number;
680
- }[];
681
- totalRisk: number;
682
- }): Promise<{
683
- updated_bullish: BullishMarket[];
684
- moved_to_winding: WindingDownMarket[];
685
- }>;
686
791
  getWindingDownMarkets(): Promise<WindingDownMarket[]>;
687
792
  updateSymbolConfigs(payload: {
688
793
  configs: {
@@ -699,7 +804,14 @@ declare class App {
699
804
  created: number;
700
805
  }>;
701
806
  updateAllAccountWithSymbols(with_positions?: boolean): Promise<void>;
702
- windDownSymbol(symbol: string): Promise<boolean>;
807
+ windDownSymbol(payload: {
808
+ symbol: string;
809
+ risk?: number;
810
+ }): Promise<boolean>;
811
+ getNonEssentialSymbols(): Promise<Set<any>>;
812
+ refreshAllPositionsWithSymbol(payload: {
813
+ symbol: string;
814
+ }): Promise<void>;
703
815
  }
704
816
  export declare function initApp(payload: {
705
817
  db: {
@@ -712,6 +824,7 @@ export declare function initApp(payload: {
712
824
  api_secret: string;
713
825
  }>;
714
826
  }): Promise<App>;
827
+ export declare function initialize(): Promise<App>;
715
828
 
716
829
  export {
717
830
  ExchangeAccount$1 as ExchangeAccount,