@gbozee/ultimate 0.0.2-150 → 0.0.2-152

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
@@ -136,6 +136,11 @@ export interface PositionsView {
136
136
  quantity: number;
137
137
  };
138
138
  next_risk?: number;
139
+ proxy?: string;
140
+ expand?: {
141
+ p_account?: ExchangeAccount;
142
+ b_config?: ScheduledTrade;
143
+ };
139
144
  }
140
145
  export interface BullishMarket extends RecordModel {
141
146
  id: string;
@@ -1121,6 +1126,15 @@ export declare class Strategy {
1121
1126
  quantity: number;
1122
1127
  };
1123
1128
  }
1129
+ export declare function determine_average_entry_and_size(orders: Array<{
1130
+ price: number;
1131
+ quantity: number;
1132
+ }>, places?: string, price_places?: string): {
1133
+ entry: number;
1134
+ price: number;
1135
+ quantity: number;
1136
+ };
1137
+ export declare const createArray: (start: number, stop: number, step: number) => number[];
1124
1138
  export type SignalConfigType = {
1125
1139
  focus: number;
1126
1140
  budget: number;
@@ -1260,15 +1274,6 @@ declare class Signal {
1260
1274
  };
1261
1275
  to_df(currentPrice: number, places?: string): number;
1262
1276
  }
1263
- export declare function determine_average_entry_and_size(orders: Array<{
1264
- price: number;
1265
- quantity: number;
1266
- }>, places?: string, price_places?: string): {
1267
- entry: number;
1268
- price: number;
1269
- quantity: number;
1270
- };
1271
- export declare const createArray: (start: number, stop: number, step: number) => number[];
1272
1277
  export type AppConfig = {
1273
1278
  fee: number;
1274
1279
  risk_per_trade: number;
@@ -1653,22 +1658,26 @@ export declare function determineCompoundLongTrade(payload: {
1653
1658
  };
1654
1659
  declare class ExchangePosition {
1655
1660
  exchange: BaseExchange;
1661
+ symbol_config: SymbolConfig;
1656
1662
  exchange_account: ExchangeAccount$1;
1657
1663
  private app_db;
1658
1664
  private instance;
1659
1665
  constructor(payload: {
1660
1666
  exchange: BaseExchange;
1661
1667
  app_db: AppDatabase;
1668
+ symbol_config: SymbolConfig;
1662
1669
  instance: PositionsView;
1663
1670
  exchange_account: ExchangeAccount$1;
1664
1671
  without_view?: PositionsView;
1665
1672
  });
1673
+ getInstance(): PositionsView;
1666
1674
  get symbol(): any;
1667
1675
  get kind(): any;
1668
- get account(): any;
1676
+ get account(): ExchangeAccount;
1669
1677
  cancelOrders(payload: {
1670
1678
  limit?: boolean;
1671
1679
  price?: number;
1680
+ raw?: boolean;
1672
1681
  }): Promise<any[] | {
1673
1682
  success: boolean;
1674
1683
  message: string;
@@ -1696,7 +1705,7 @@ declare class ExchangePosition {
1696
1705
  profit?: number;
1697
1706
  };
1698
1707
  }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
1699
- updateTargetPnl(): Promise<number>;
1708
+ updateTargetPnl(): Promise<any>;
1700
1709
  updateConfigPnl(): Promise<void>;
1701
1710
  triggerTradeFromConfig(payload: {
1702
1711
  place?: boolean;
@@ -1705,8 +1714,9 @@ declare class ExchangePosition {
1705
1714
  stop?: boolean;
1706
1715
  use_current?: boolean;
1707
1716
  ignore_config?: boolean;
1717
+ risky?: boolean;
1708
1718
  }): Promise<any>;
1709
- placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
1719
+ placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders" | "dangerous_entry_orders", payload: {
1710
1720
  entry: number;
1711
1721
  stop: number;
1712
1722
  risk_reward: number;
@@ -1715,6 +1725,7 @@ declare class ExchangePosition {
1715
1725
  update_db?: boolean;
1716
1726
  raw?: boolean;
1717
1727
  use_current?: boolean;
1728
+ stop_percent?: number;
1718
1729
  }): Promise<any>;
1719
1730
  buildAppConfig(payload: {
1720
1731
  entry: number;
@@ -1724,6 +1735,11 @@ declare class ExchangePosition {
1724
1735
  profit?: number;
1725
1736
  update_db?: boolean;
1726
1737
  profit_percent?: number;
1738
+ use_kelly?: boolean;
1739
+ kelly_confidence_factor?: number;
1740
+ kelly_minimum_risk?: number;
1741
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1742
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1727
1743
  }): Promise<AppConfig>;
1728
1744
  placeConfigOrders(app_config: AppConfig, solution: {
1729
1745
  risk_reward: number;
@@ -1734,6 +1750,12 @@ declare class ExchangePosition {
1734
1750
  neg_pnl: number;
1735
1751
  min_size: number;
1736
1752
  symbol: string;
1753
+ stop_percent?: number;
1754
+ use_kelly?: boolean;
1755
+ kelly_confidence_factor?: number;
1756
+ kelly_minimum_risk?: number;
1757
+ kelly_prediction_model?: "exponential" | "normal" | "uniform";
1758
+ kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1737
1759
  }, place?: boolean, skip_stop?: boolean): Promise<{
1738
1760
  entry_orders: {
1739
1761
  orders: {
@@ -1774,9 +1796,153 @@ declare class ExchangePosition {
1774
1796
  tp?: boolean;
1775
1797
  stop?: boolean;
1776
1798
  raw?: boolean;
1799
+ limit?: boolean;
1777
1800
  cancel?: boolean;
1778
1801
  ignore_config?: boolean;
1802
+ risky?: boolean;
1803
+ target_pnl?: number;
1779
1804
  }): Promise<any>;
1805
+ placeStopLimit(payload: {
1806
+ place?: boolean;
1807
+ stop: number;
1808
+ quantity?: number;
1809
+ }): Promise<any>;
1810
+ computeTargetPnl(payload: {
1811
+ secondary: ExchangePosition;
1812
+ }): Promise<number>;
1813
+ runSimulation(payload: {
1814
+ iterations?: number;
1815
+ long_position: ExchangePosition;
1816
+ short_position: ExchangePosition;
1817
+ raw?: boolean;
1818
+ }): Promise<Strategy | {
1819
+ last_entry: any;
1820
+ first_entry: any;
1821
+ threshold: any;
1822
+ risk: number;
1823
+ risk_reward: number;
1824
+ spread: number;
1825
+ gap_loss: number;
1826
+ net_profit: number;
1827
+ long: {
1828
+ avg_entry: number;
1829
+ avg_size: number;
1830
+ loss: number;
1831
+ stop: number;
1832
+ stop_quantity: number;
1833
+ re_entry_quantity: number;
1834
+ initial_pnl: number;
1835
+ tp: number;
1836
+ incurred_loss: number;
1837
+ pnl: number;
1838
+ remaining_quantity: number;
1839
+ };
1840
+ short: {
1841
+ avg_entry: number;
1842
+ avg_size: number;
1843
+ loss: number;
1844
+ stop: number;
1845
+ stop_quantity: number;
1846
+ re_entry_quantity: number;
1847
+ initial_pnl: number;
1848
+ tp: number;
1849
+ incurred_loss: number;
1850
+ pnl: number;
1851
+ remaining_quantity: number;
1852
+ };
1853
+ }[]>;
1854
+ /**
1855
+ * This method is used to place the opposite trade action
1856
+ */
1857
+ placeOppositeTradeAction(payload: {
1858
+ data: {
1859
+ avg: {
1860
+ quantity: number;
1861
+ price: number;
1862
+ };
1863
+ entry: number;
1864
+ stop: number;
1865
+ risk_per_trade: number;
1866
+ profit_percent: number;
1867
+ risk_reward: number;
1868
+ };
1869
+ }): Promise<void>;
1870
+ /**
1871
+ * Updates the risk configuration for an empty position using the next_risk value.
1872
+ * This implements progressive risk management where successful trades increase future risk tolerance.
1873
+ *
1874
+ * @param payload.symbol - The trading symbol (e.g., "BTCUSDT")
1875
+ * @param payload.kind - Position type: "long" or "short"
1876
+ * @returns Object indicating if update was successful with old/new risk values
1877
+ */
1878
+ updateRiskOnEmpty(): Promise<{
1879
+ updated: boolean;
1880
+ symbol: any;
1881
+ kind: any;
1882
+ old_risk: number;
1883
+ new_risk: number;
1884
+ reason?: undefined;
1885
+ } | {
1886
+ updated: boolean;
1887
+ symbol: any;
1888
+ kind: any;
1889
+ reason: string;
1890
+ old_risk?: undefined;
1891
+ new_risk?: undefined;
1892
+ }>;
1893
+ increasePositionAtStop(payload: {
1894
+ place?: boolean;
1895
+ price?: number;
1896
+ quantity?: number;
1897
+ increase?: boolean;
1898
+ }): Promise<any>;
1899
+ placeSingleOrder(payload: {
1900
+ long_position: ExchangePosition;
1901
+ short_position: ExchangePosition;
1902
+ }): Promise<string>;
1903
+ placeMarketOrder(payload: {
1904
+ quantity: number;
1905
+ }): Promise<void>;
1906
+ generate_config_params(payload: {
1907
+ entry: number;
1908
+ stop: number;
1909
+ risk_reward: number;
1910
+ risk: number;
1911
+ with_trades?: boolean;
1912
+ }): Promise<any>;
1913
+ extrapolateConfig(payload: {
1914
+ risk_reward?: number;
1915
+ risk?: number;
1916
+ kind?: "long" | "short";
1917
+ }): Promise<any>;
1918
+ build_short_order(): Promise<any>;
1919
+ /**
1920
+ * This function builds a config for a symbol
1921
+ * @param payload
1922
+ * @returns
1923
+ */
1924
+ buildConfigForSymbol(payload: {
1925
+ risk: number;
1926
+ risk_reward?: number;
1927
+ as_config?: boolean;
1928
+ with_trades?: boolean;
1929
+ }): Promise<any>;
1930
+ buildTrades(payload: {
1931
+ risk?: number;
1932
+ }): Promise<{
1933
+ trades: any[];
1934
+ max_size: any;
1935
+ last_price: any;
1936
+ total_size: number;
1937
+ avg_entry: number;
1938
+ }>;
1939
+ tradeConfig(payload: {
1940
+ override?: any;
1941
+ }): Promise<AppConfig>;
1942
+ getOrCreatePositionConfig(payload: {
1943
+ risk?: number;
1944
+ risk_reward?: number;
1945
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
1780
1946
  }
1781
1947
  declare class ExchangeAccount$1 {
1782
1948
  instance: {
@@ -1786,8 +1952,8 @@ declare class ExchangeAccount$1 {
1786
1952
  exchange: BaseExchange;
1787
1953
  main_exchange?: BaseExchange;
1788
1954
  private app_db;
1789
- private long_position?;
1790
- private short_position?;
1955
+ long_position?: ExchangePosition;
1956
+ short_position?: ExchangePosition;
1791
1957
  constructor(payload: ExchangeType, options: {
1792
1958
  exchange: BaseExchange;
1793
1959
  app_db: AppDatabase;
@@ -1806,8 +1972,8 @@ declare class ExchangeAccount$1 {
1806
1972
  }): Promise<import("pocketbase").RecordModel>;
1807
1973
  initializePositions(payload: {
1808
1974
  symbol: string;
1809
- as_view?: boolean;
1810
1975
  kind: "long" | "short";
1976
+ update?: boolean;
1811
1977
  }): Promise<ExchangePosition>;
1812
1978
  getActiveAccount(payload: {
1813
1979
  symbol: string;
@@ -1856,6 +2022,11 @@ declare class ExchangeAccount$1 {
1856
2022
  kind: "long" | "short";
1857
2023
  should_stop?: boolean;
1858
2024
  }): Promise<import("pocketbase").RecordModel>;
2025
+ getFocusPosition(payload: {
2026
+ symbol: string;
2027
+ kind: "long" | "short";
2028
+ update?: boolean;
2029
+ }): Promise<ExchangePosition>;
1859
2030
  cancelOrders(payload: {
1860
2031
  symbol: string;
1861
2032
  kind: "long" | "short";
@@ -1890,21 +2061,6 @@ declare class ExchangeAccount$1 {
1890
2061
  price: number;
1891
2062
  direction: string;
1892
2063
  }>;
1893
- buildAppConfig(payload: {
1894
- entry: number;
1895
- stop: number;
1896
- risk_reward: number;
1897
- risk: number;
1898
- symbol: string;
1899
- profit?: number;
1900
- update_db?: boolean;
1901
- profit_percent?: number;
1902
- use_kelly?: boolean;
1903
- kelly_confidence_factor?: number;
1904
- kelly_minimum_risk?: number;
1905
- kelly_prediction_model?: "exponential" | "normal" | "uniform";
1906
- kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1907
- }): Promise<AppConfig>;
1908
2064
  tradeConfig(payload: {
1909
2065
  symbol: string;
1910
2066
  kind: "long" | "short";
@@ -1936,55 +2092,6 @@ declare class ExchangeAccount$1 {
1936
2092
  total_size: number;
1937
2093
  avg_entry: number;
1938
2094
  }>;
1939
- placeConfigOrders(app_config: AppConfig, solution: {
1940
- risk_reward: number;
1941
- entry: number;
1942
- stop: number;
1943
- risk_per_trade: number;
1944
- avg_size: number;
1945
- neg_pnl: number;
1946
- min_size: number;
1947
- symbol: string;
1948
- stop_percent?: number;
1949
- use_kelly?: boolean;
1950
- kelly_confidence_factor?: number;
1951
- kelly_minimum_risk?: number;
1952
- kelly_prediction_model?: "exponential" | "normal" | "uniform";
1953
- kelly_func?: "theoretical" | "position_based" | "theoretical_fixed";
1954
- }, place?: boolean, skip_stop?: boolean): Promise<{
1955
- entry_orders: {
1956
- orders: {
1957
- entry: any;
1958
- quantity: any;
1959
- reverse_avg_entry: any;
1960
- reverse_avg_quantity: any;
1961
- avg_entry: any;
1962
- avg_size: any;
1963
- }[];
1964
- kind: "long" | "short";
1965
- };
1966
- stop_orders: {
1967
- stop: number;
1968
- final_stop: number;
1969
- kind: "long" | "short";
1970
- quantity: any;
1971
- is_limit: boolean;
1972
- neg_pnl: any;
1973
- original_stop: number;
1974
- last_entry: any;
1975
- };
1976
- trades: any[];
1977
- }>;
1978
- determineAmountToBuy(payload: {
1979
- orders: any[];
1980
- kind: "long" | "short";
1981
- refresh?: boolean;
1982
- decimal_places?: string;
1983
- price_places?: string;
1984
- symbol: string;
1985
- cancel?: boolean;
1986
- place?: boolean;
1987
- }): Promise<any[]>;
1988
2095
  placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders" | "dangerous_entry_orders", payload: {
1989
2096
  symbol: string;
1990
2097
  entry: number;
@@ -2097,14 +2204,6 @@ declare class ExchangeAccount$1 {
2097
2204
  target_pnl?: number;
2098
2205
  }): Promise<any>;
2099
2206
  reEnterPositionOnEmpty(symbol: string): Promise<void>;
2100
- generate_config_params(payload: {
2101
- entry: number;
2102
- stop: number;
2103
- risk_reward: number;
2104
- risk: number;
2105
- symbol: string;
2106
- with_trades?: boolean;
2107
- }): Promise<any>;
2108
2207
  build_short_order(payload: {
2109
2208
  symbol: string;
2110
2209
  kind: "long" | "short";
@@ -2156,29 +2255,21 @@ declare class ExchangeAccount$1 {
2156
2255
  updateTargetPnl(payload: {
2157
2256
  symbol: string;
2158
2257
  kind: "long" | "short";
2159
- }): Promise<number>;
2160
- /**
2161
- * Updates the risk configuration for an empty position using the next_risk value.
2162
- * This implements progressive risk management where successful trades increase future risk tolerance.
2163
- *
2164
- * @param payload.symbol - The trading symbol (e.g., "BTCUSDT")
2165
- * @param payload.kind - Position type: "long" or "short"
2166
- * @returns Object indicating if update was successful with old/new risk values
2167
- */
2258
+ }): Promise<any>;
2168
2259
  updateRiskOnEmpty(payload: {
2169
2260
  symbol: string;
2170
2261
  kind: "long" | "short";
2171
2262
  }): Promise<{
2172
2263
  updated: boolean;
2173
- symbol: string;
2174
- kind: "long" | "short";
2264
+ symbol: any;
2265
+ kind: any;
2175
2266
  old_risk: number;
2176
2267
  new_risk: number;
2177
2268
  reason?: undefined;
2178
2269
  } | {
2179
2270
  updated: boolean;
2180
- symbol: string;
2181
- kind: "long" | "short";
2271
+ symbol: any;
2272
+ kind: any;
2182
2273
  reason: string;
2183
2274
  old_risk?: undefined;
2184
2275
  new_risk?: undefined;
@@ -2405,18 +2496,6 @@ declare class ExchangeAccount$1 {
2405
2496
  profitWithinGapStrategy(payload: {
2406
2497
  symbol: string;
2407
2498
  }): Promise<{
2408
- positions: {
2409
- long: PositionsView & {
2410
- expand?: {
2411
- account_strategy?: AccountStrategy;
2412
- };
2413
- };
2414
- short: PositionsView & {
2415
- expand?: {
2416
- account_strategy?: AccountStrategy;
2417
- };
2418
- };
2419
- };
2420
2499
  config_details: {
2421
2500
  app_config: {
2422
2501
  fee: number;
@@ -2453,23 +2532,6 @@ declare class ExchangeAccount$1 {
2453
2532
  };
2454
2533
  };
2455
2534
  last_value: any;
2456
- config: {
2457
- entry: number;
2458
- stop: number;
2459
- risk: number;
2460
- risk_reward: number | {
2461
- result: any[];
2462
- value: number;
2463
- total: number;
2464
- risk_per_trade: number;
2465
- max: number;
2466
- min: number;
2467
- neg_pnl: any;
2468
- entry: any;
2469
- };
2470
- profit_percent: number;
2471
- };
2472
- pnl: number;
2473
2535
  };
2474
2536
  }>;
2475
2537
  generateGapTp(payload: {
@@ -2679,18 +2741,6 @@ declare class App {
2679
2741
  account: ExchangeType;
2680
2742
  symbol: string;
2681
2743
  }): Promise<{
2682
- positions: {
2683
- long: PositionsView & {
2684
- expand?: {
2685
- account_strategy?: AccountStrategy;
2686
- };
2687
- };
2688
- short: PositionsView & {
2689
- expand?: {
2690
- account_strategy?: AccountStrategy;
2691
- };
2692
- };
2693
- };
2694
2744
  config_details: {
2695
2745
  app_config: {
2696
2746
  fee: number;
@@ -2727,23 +2777,6 @@ declare class App {
2727
2777
  };
2728
2778
  };
2729
2779
  last_value: any;
2730
- config: {
2731
- entry: number;
2732
- stop: number;
2733
- risk: number;
2734
- risk_reward: number | {
2735
- result: any[];
2736
- value: number;
2737
- total: number;
2738
- risk_per_trade: number;
2739
- max: number;
2740
- min: number;
2741
- neg_pnl: any;
2742
- entry: any;
2743
- };
2744
- profit_percent: number;
2745
- };
2746
- pnl: number;
2747
2780
  };
2748
2781
  }>;
2749
2782
  compoundLongTrade(payload: {