@gbozee/ultimate 0.0.2-19 → 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 +153 -52
  2. package/dist/index.js +723 -231
  3. package/package.json +1 -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[];
@@ -128,6 +133,12 @@ export interface BaseExchange {
128
133
  checkDelistedMovers(payload: {
129
134
  movePercent: number;
130
135
  }): Promise<any>;
136
+ closePosition(payload: {
137
+ symbol: string;
138
+ kind: "long" | "short";
139
+ price_places?: string;
140
+ decimal_places?: string;
141
+ }): Promise<any>;
131
142
  }
132
143
  export interface BaseSystemFields {
133
144
  id: string;
@@ -142,6 +153,11 @@ export interface ExchangeAccount extends BaseSystemFields {
142
153
  usdt?: number;
143
154
  usdc?: number;
144
155
  proxy?: string;
156
+ bullish?: boolean;
157
+ bearish?: boolean;
158
+ movePercent?: number;
159
+ totalRisk?: number;
160
+ max_non_essential?: number;
145
161
  }
146
162
  export interface SymbolConfig extends BaseSystemFields {
147
163
  symbol: string;
@@ -153,6 +169,7 @@ export interface SymbolConfig extends BaseSystemFields {
153
169
  min_size?: number;
154
170
  weight?: number;
155
171
  leverage?: number;
172
+ candle_count?: number;
156
173
  }
157
174
  export interface ScheduledTrade extends BaseSystemFields {
158
175
  symbol: string;
@@ -233,6 +250,11 @@ export type ExchangeType = {
233
250
  export declare class AppDatabase {
234
251
  private pb;
235
252
  constructor(pb: PocketBase);
253
+ getAllSymbolsFromPositions(options?: {
254
+ no_position?: boolean;
255
+ kind?: "long" | "short";
256
+ custom_filter?: string;
257
+ }): Promise<any[]>;
236
258
  createOrUpdateLiveExchangeInstance(payload: {
237
259
  account: ExchangeType;
238
260
  symbol: string;
@@ -245,18 +267,24 @@ export declare class AppDatabase {
245
267
  }): Promise<import("pocketbase").RecordModel>;
246
268
  getProxyForAccount(account: ExchangeType): Promise<HttpsProxyAgent<`http://${string}`> | SocksProxyAgent>;
247
269
  getAccounts(): Promise<ExchangeAccount[]>;
248
- getAllSymbolConfigs(with_positions?: boolean): Promise<SymbolConfig[]>;
270
+ getAllSymbolConfigs(payload?: {
271
+ with_positions?: boolean;
272
+ custom_filter?: string;
273
+ }): Promise<SymbolConfig[]>;
249
274
  get_exchange_db_instance(account: ExchangeType): Promise<ExchangeAccount & {
250
275
  expand?: {
251
276
  proxy: Proxy$1;
252
277
  };
253
278
  }>;
254
- getPositions(account: ExchangeType, options: {
255
- symbol: string;
279
+ getPositions(options: {
280
+ account?: ExchangeType;
281
+ symbol?: string;
256
282
  as_view?: boolean;
283
+ custom_filter?: string;
257
284
  }): Promise<(PositionsView & {
258
285
  expand?: {
259
286
  config: ScheduledTrade;
287
+ account: ExchangeAccount;
260
288
  };
261
289
  })[]>;
262
290
  private _createOrUpdatePosition;
@@ -268,6 +296,7 @@ export declare class AppDatabase {
268
296
  }): Promise<(PositionsView & {
269
297
  expand?: {
270
298
  config: ScheduledTrade;
299
+ account: ExchangeAccount;
271
300
  };
272
301
  })[]>;
273
302
  update_db_position(position: any, payload: any): Promise<import("pocketbase").RecordModel>;
@@ -326,7 +355,7 @@ export declare class AppDatabase {
326
355
  risk_reward: number;
327
356
  risk: number;
328
357
  profit_percent?: number;
329
- }): Promise<void>;
358
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
330
359
  getPositionConfig(payload: {
331
360
  symbol: string;
332
361
  kind: "long" | "short";
@@ -345,6 +374,7 @@ export declare class AppDatabase {
345
374
  percent: number;
346
375
  }>;
347
376
  totalRisk: number;
377
+ max_count?: number;
348
378
  }): Promise<{
349
379
  updated_bullish: BullishMarket[];
350
380
  moved_to_winding: WindingDownMarket[];
@@ -369,16 +399,6 @@ export declare class AppDatabase {
369
399
  removePosition(position: any): Promise<void>;
370
400
  removePositionConfig(position: any): Promise<void>;
371
401
  }
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
402
  export type AppConfig = {
383
403
  fee: number;
384
404
  risk_per_trade: number;
@@ -421,10 +441,13 @@ declare class ExchangeAccount$1 {
421
441
  getLiveExchangeInstance(payload: {
422
442
  symbol: string;
423
443
  refresh?: boolean;
424
- price_places?: string;
425
- decimal_places?: string;
444
+ refresh_symbol_config?: boolean;
426
445
  }): Promise<import("pocketbase").RecordModel>;
427
- getActiveAccount(symbol: string, full?: boolean): Promise<Account | {
446
+ getActiveAccount(payload: {
447
+ symbol: string;
448
+ full?: boolean;
449
+ refresh?: boolean;
450
+ }): Promise<Account | {
428
451
  liquidation: {
429
452
  long: number;
430
453
  short: number;
@@ -439,9 +462,11 @@ declare class ExchangeAccount$1 {
439
462
  update?: boolean;
440
463
  as_view?: boolean;
441
464
  leverage?: number;
465
+ live_refresh?: boolean;
442
466
  }): Promise<PositionsView | (PositionsView & {
443
467
  expand?: {
444
468
  config: ScheduledTrade;
469
+ account: ExchangeAccount;
445
470
  };
446
471
  })[]>;
447
472
  getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
@@ -518,6 +543,7 @@ declare class ExchangeAccount$1 {
518
543
  kind: "long" | "short";
519
544
  quantity: any;
520
545
  is_limit: boolean;
546
+ neg_pnl: any;
521
547
  };
522
548
  trades: any[];
523
549
  }>;
@@ -540,25 +566,85 @@ declare class ExchangeAccount$1 {
540
566
  risk: number;
541
567
  profit_percent?: number;
542
568
  };
543
- }): Promise<ScheduledTrade>;
569
+ }): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
544
570
  getCurrentPrice(symbol: string): Promise<any>;
545
571
  getPositionStrategy(): Promise<{
546
572
  strategy_instance: Strategy;
547
573
  focus_account: ExchangeAccount;
548
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
+ }>;
549
623
  getOriginalPlannedStop(payload: {
550
624
  symbol: string;
551
625
  kind: "long" | "short";
552
626
  }): Promise<any>;
553
- syncReduceClosePosition(symbol: string, payload?: {
627
+ syncReduceClosePosition(payload?: {
628
+ symbol: string;
554
629
  kind?: "long" | "short";
555
- long?: CodeNode;
556
- short?: CodeNode;
557
- trigger?: {
630
+ trigger?: boolean;
631
+ }): Promise<any>;
632
+ reduceMajorPositionEntry(payload: {
633
+ symbol: string;
634
+ long: any;
635
+ short: any;
636
+ trigger: {
558
637
  long: boolean;
559
638
  short: boolean;
560
639
  };
561
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>;
562
648
  generate_config_params(payload: {
563
649
  entry: number;
564
650
  stop: number;
@@ -580,6 +666,7 @@ declare class ExchangeAccount$1 {
580
666
  kind: "long" | "short";
581
667
  symbol: string;
582
668
  risk_reward?: number;
669
+ risk?: number;
583
670
  }): Promise<{
584
671
  place_stop: boolean;
585
672
  profit_percent: number;
@@ -594,17 +681,47 @@ declare class ExchangeAccount$1 {
594
681
  triggerTradeFromConfig(payload: {
595
682
  symbol: string;
596
683
  kind: "long" | "short";
684
+ place?: boolean;
597
685
  }): Promise<any>;
598
686
  verifyStopLoss(payload: {
599
687
  symbol: string;
600
688
  kind: "long" | "short";
601
689
  revert?: boolean;
602
690
  }): Promise<import("pocketbase").RecordModel[]>;
603
- 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>;
604
704
  triggerBullishMarket(payload: {
605
705
  symbol: string;
606
706
  profit_percent?: number;
707
+ risk_reward?: number;
607
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>;
608
725
  }
609
726
  declare class App {
610
727
  private app_db;
@@ -623,6 +740,7 @@ declare class App {
623
740
  }): Promise<PositionsView | (PositionsView & {
624
741
  expand?: {
625
742
  config: ScheduledTrade;
743
+ account: ExchangeAccount;
626
744
  };
627
745
  })[]>;
628
746
  syncOrders(payload: {
@@ -670,22 +788,6 @@ declare class App {
670
788
  short_db_position: any;
671
789
  balance: any;
672
790
  }>;
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
791
  getWindingDownMarkets(): Promise<WindingDownMarket[]>;
690
792
  updateSymbolConfigs(payload: {
691
793
  configs: {
@@ -702,15 +804,14 @@ declare class App {
702
804
  created: number;
703
805
  }>;
704
806
  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
- }>;
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>;
714
815
  }
715
816
  export declare function initApp(payload: {
716
817
  db: {