@gbozee/ultimate 0.0.2-166 → 0.0.2-167

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.cjs CHANGED
@@ -60856,12 +60856,18 @@ class ExchangePosition {
60856
60856
  exchange_account;
60857
60857
  app_db;
60858
60858
  instance;
60859
+ orders;
60859
60860
  constructor(payload) {
60860
60861
  this.symbol_config = payload.symbol_config;
60861
60862
  this.exchange = payload.exchange;
60862
60863
  this.app_db = payload.app_db;
60863
60864
  this.instance = payload.instance;
60864
60865
  this.exchange_account = payload.exchange_account;
60866
+ this.orders = payload.orders || {
60867
+ entries: [],
60868
+ stop_orders: [],
60869
+ tp_orders: []
60870
+ };
60865
60871
  }
60866
60872
  async initialize() {
60867
60873
  const proxy = await this.getProxyForAccount();
@@ -61801,6 +61807,42 @@ class ExchangePosition {
61801
61807
  }
61802
61808
  return { profit_percent, take_profit, last_order };
61803
61809
  }
61810
+ getOrders(payload) {
61811
+ const { type = "limit" } = payload;
61812
+ if (type === "limit") {
61813
+ return this.orders.entries.map(convert_to_exchange_order);
61814
+ }
61815
+ if (type === "stop") {
61816
+ return this.orders.stop_orders.map(convert_to_exchange_order);
61817
+ }
61818
+ if (type === "tp") {
61819
+ return this.orders.tp_orders.map(convert_to_exchange_order);
61820
+ }
61821
+ }
61822
+ async cancelExchangeOrder(payload) {
61823
+ const { type, refresh = true } = payload;
61824
+ const orders = this.getOrders({ type });
61825
+ const result = await this.exchange.cancelOrders({
61826
+ symbol: this.symbol,
61827
+ orders: orders.map((x) => x.order_id)
61828
+ });
61829
+ if (refresh) {
61830
+ await this.refresh(true);
61831
+ }
61832
+ return result;
61833
+ }
61834
+ }
61835
+ function convert_to_exchange_order(order) {
61836
+ return {
61837
+ symbol: order.symbol,
61838
+ price: order.price,
61839
+ quantity: order.quantity,
61840
+ kind: order.kind,
61841
+ side: order.side,
61842
+ stop: order.stop,
61843
+ order_id: order.order_id,
61844
+ triggerPrice: order.triggerPrice
61845
+ };
61804
61846
  }
61805
61847
 
61806
61848
  // src/exchange-account.ts
@@ -61864,6 +61906,9 @@ class ExchangeAccount {
61864
61906
  const symbol_config = await this.recomputeSymbolConfig({
61865
61907
  symbol: payload.symbol
61866
61908
  });
61909
+ const active_account = await this.getActiveAccount({
61910
+ symbol: payload.symbol
61911
+ });
61867
61912
  const long_position = positions.find((x) => x.kind === "long");
61868
61913
  const short_position = positions.find((x) => x.kind === "short");
61869
61914
  this.long_position = new ExchangePosition({
@@ -61872,6 +61917,7 @@ class ExchangeAccount {
61872
61917
  exchange_account: this,
61873
61918
  instance: long_position,
61874
61919
  app_db: this.app_db,
61920
+ orders: active_account.orders.long,
61875
61921
  without_view: raw_positions.find((x) => x.kind === "long")
61876
61922
  });
61877
61923
  await this.long_position.initialize();
@@ -61881,6 +61927,7 @@ class ExchangeAccount {
61881
61927
  exchange_account: this,
61882
61928
  instance: short_position,
61883
61929
  app_db: this.app_db,
61930
+ orders: active_account.orders.short,
61884
61931
  without_view: raw_positions.find((x) => x.kind === "short")
61885
61932
  });
61886
61933
  await this.short_position.initialize();
package/dist/index.d.ts CHANGED
@@ -1706,12 +1706,27 @@ export declare function constructAppConfig(payload: {
1706
1706
  kelly_prediction_model: string;
1707
1707
  };
1708
1708
  }): AppConfig;
1709
+ export type ExchangeOrder = {
1710
+ symbol: string;
1711
+ price: number;
1712
+ quantity: number;
1713
+ kind: "long" | "short";
1714
+ side: "buy" | "sell";
1715
+ stop: number;
1716
+ order_id: string;
1717
+ triggerPrice?: number;
1718
+ };
1709
1719
  export declare class ExchangePosition {
1710
1720
  exchange: BaseExchange;
1711
1721
  symbol_config: SymbolConfig;
1712
1722
  exchange_account: ExchangeAccount$1;
1713
1723
  private app_db;
1714
1724
  private instance;
1725
+ orders: {
1726
+ entries: ExchangeOrder[];
1727
+ stop_orders: ExchangeOrder[];
1728
+ tp_orders: ExchangeOrder[];
1729
+ };
1715
1730
  constructor(payload: {
1716
1731
  exchange: BaseExchange;
1717
1732
  app_db: AppDatabase;
@@ -1719,6 +1734,11 @@ export declare class ExchangePosition {
1719
1734
  instance: PositionsView;
1720
1735
  exchange_account: ExchangeAccount$1;
1721
1736
  without_view?: PositionsView;
1737
+ orders?: {
1738
+ entries: any[];
1739
+ stop_orders: any[];
1740
+ tp_orders: any[];
1741
+ };
1722
1742
  });
1723
1743
  initialize(): Promise<void>;
1724
1744
  getInstance(): PositionsView;
@@ -2032,6 +2052,22 @@ export declare class ExchangePosition {
2032
2052
  take_profit: any;
2033
2053
  last_order: number;
2034
2054
  }>;
2055
+ getOrders(payload: {
2056
+ type?: "limit" | "stop" | "tp";
2057
+ }): {
2058
+ symbol: any;
2059
+ price: any;
2060
+ quantity: any;
2061
+ kind: any;
2062
+ side: any;
2063
+ stop: any;
2064
+ order_id: any;
2065
+ triggerPrice: any;
2066
+ }[];
2067
+ cancelExchangeOrder(payload: {
2068
+ type: "limit" | "stop" | "tp";
2069
+ refresh?: boolean;
2070
+ }): Promise<any>;
2035
2071
  }
2036
2072
  declare class ExchangeAccount$1 {
2037
2073
  instance: {
package/dist/index.js CHANGED
@@ -60801,12 +60801,18 @@ class ExchangePosition {
60801
60801
  exchange_account;
60802
60802
  app_db;
60803
60803
  instance;
60804
+ orders;
60804
60805
  constructor(payload) {
60805
60806
  this.symbol_config = payload.symbol_config;
60806
60807
  this.exchange = payload.exchange;
60807
60808
  this.app_db = payload.app_db;
60808
60809
  this.instance = payload.instance;
60809
60810
  this.exchange_account = payload.exchange_account;
60811
+ this.orders = payload.orders || {
60812
+ entries: [],
60813
+ stop_orders: [],
60814
+ tp_orders: []
60815
+ };
60810
60816
  }
60811
60817
  async initialize() {
60812
60818
  const proxy = await this.getProxyForAccount();
@@ -61746,6 +61752,42 @@ class ExchangePosition {
61746
61752
  }
61747
61753
  return { profit_percent, take_profit, last_order };
61748
61754
  }
61755
+ getOrders(payload) {
61756
+ const { type = "limit" } = payload;
61757
+ if (type === "limit") {
61758
+ return this.orders.entries.map(convert_to_exchange_order);
61759
+ }
61760
+ if (type === "stop") {
61761
+ return this.orders.stop_orders.map(convert_to_exchange_order);
61762
+ }
61763
+ if (type === "tp") {
61764
+ return this.orders.tp_orders.map(convert_to_exchange_order);
61765
+ }
61766
+ }
61767
+ async cancelExchangeOrder(payload) {
61768
+ const { type, refresh = true } = payload;
61769
+ const orders = this.getOrders({ type });
61770
+ const result = await this.exchange.cancelOrders({
61771
+ symbol: this.symbol,
61772
+ orders: orders.map((x) => x.order_id)
61773
+ });
61774
+ if (refresh) {
61775
+ await this.refresh(true);
61776
+ }
61777
+ return result;
61778
+ }
61779
+ }
61780
+ function convert_to_exchange_order(order) {
61781
+ return {
61782
+ symbol: order.symbol,
61783
+ price: order.price,
61784
+ quantity: order.quantity,
61785
+ kind: order.kind,
61786
+ side: order.side,
61787
+ stop: order.stop,
61788
+ order_id: order.order_id,
61789
+ triggerPrice: order.triggerPrice
61790
+ };
61749
61791
  }
61750
61792
 
61751
61793
  // src/exchange-account.ts
@@ -61809,6 +61851,9 @@ class ExchangeAccount {
61809
61851
  const symbol_config = await this.recomputeSymbolConfig({
61810
61852
  symbol: payload.symbol
61811
61853
  });
61854
+ const active_account = await this.getActiveAccount({
61855
+ symbol: payload.symbol
61856
+ });
61812
61857
  const long_position = positions.find((x) => x.kind === "long");
61813
61858
  const short_position = positions.find((x) => x.kind === "short");
61814
61859
  this.long_position = new ExchangePosition({
@@ -61817,6 +61862,7 @@ class ExchangeAccount {
61817
61862
  exchange_account: this,
61818
61863
  instance: long_position,
61819
61864
  app_db: this.app_db,
61865
+ orders: active_account.orders.long,
61820
61866
  without_view: raw_positions.find((x) => x.kind === "long")
61821
61867
  });
61822
61868
  await this.long_position.initialize();
@@ -61826,6 +61872,7 @@ class ExchangeAccount {
61826
61872
  exchange_account: this,
61827
61873
  instance: short_position,
61828
61874
  app_db: this.app_db,
61875
+ orders: active_account.orders.short,
61829
61876
  without_view: raw_positions.find((x) => x.kind === "short")
61830
61877
  });
61831
61878
  await this.short_position.initialize();
@@ -67529,12 +67529,18 @@ class ExchangePosition {
67529
67529
  exchange_account;
67530
67530
  app_db;
67531
67531
  instance;
67532
+ orders;
67532
67533
  constructor(payload) {
67533
67534
  this.symbol_config = payload.symbol_config;
67534
67535
  this.exchange = payload.exchange;
67535
67536
  this.app_db = payload.app_db;
67536
67537
  this.instance = payload.instance;
67537
67538
  this.exchange_account = payload.exchange_account;
67539
+ this.orders = payload.orders || {
67540
+ entries: [],
67541
+ stop_orders: [],
67542
+ tp_orders: []
67543
+ };
67538
67544
  }
67539
67545
  async initialize() {
67540
67546
  const proxy = await this.getProxyForAccount();
@@ -68474,6 +68480,42 @@ class ExchangePosition {
68474
68480
  }
68475
68481
  return { profit_percent, take_profit, last_order };
68476
68482
  }
68483
+ getOrders(payload) {
68484
+ const { type = "limit" } = payload;
68485
+ if (type === "limit") {
68486
+ return this.orders.entries.map(convert_to_exchange_order);
68487
+ }
68488
+ if (type === "stop") {
68489
+ return this.orders.stop_orders.map(convert_to_exchange_order);
68490
+ }
68491
+ if (type === "tp") {
68492
+ return this.orders.tp_orders.map(convert_to_exchange_order);
68493
+ }
68494
+ }
68495
+ async cancelExchangeOrder(payload) {
68496
+ const { type, refresh = true } = payload;
68497
+ const orders = this.getOrders({ type });
68498
+ const result = await this.exchange.cancelOrders({
68499
+ symbol: this.symbol,
68500
+ orders: orders.map((x) => x.order_id)
68501
+ });
68502
+ if (refresh) {
68503
+ await this.refresh(true);
68504
+ }
68505
+ return result;
68506
+ }
68507
+ }
68508
+ function convert_to_exchange_order(order) {
68509
+ return {
68510
+ symbol: order.symbol,
68511
+ price: order.price,
68512
+ quantity: order.quantity,
68513
+ kind: order.kind,
68514
+ side: order.side,
68515
+ stop: order.stop,
68516
+ order_id: order.order_id,
68517
+ triggerPrice: order.triggerPrice
68518
+ };
68477
68519
  }
68478
68520
 
68479
68521
  // src/exchange-account.ts
@@ -68537,6 +68579,9 @@ class ExchangeAccount {
68537
68579
  const symbol_config = await this.recomputeSymbolConfig({
68538
68580
  symbol: payload.symbol
68539
68581
  });
68582
+ const active_account = await this.getActiveAccount({
68583
+ symbol: payload.symbol
68584
+ });
68540
68585
  const long_position = positions.find((x) => x.kind === "long");
68541
68586
  const short_position = positions.find((x) => x.kind === "short");
68542
68587
  this.long_position = new ExchangePosition({
@@ -68545,6 +68590,7 @@ class ExchangeAccount {
68545
68590
  exchange_account: this,
68546
68591
  instance: long_position,
68547
68592
  app_db: this.app_db,
68593
+ orders: active_account.orders.long,
68548
68594
  without_view: raw_positions.find((x) => x.kind === "long")
68549
68595
  });
68550
68596
  await this.long_position.initialize();
@@ -68554,6 +68600,7 @@ class ExchangeAccount {
68554
68600
  exchange_account: this,
68555
68601
  instance: short_position,
68556
68602
  app_db: this.app_db,
68603
+ orders: active_account.orders.short,
68557
68604
  without_view: raw_positions.find((x) => x.kind === "short")
68558
68605
  });
68559
68606
  await this.short_position.initialize();
@@ -67506,12 +67506,18 @@ class ExchangePosition {
67506
67506
  exchange_account;
67507
67507
  app_db;
67508
67508
  instance;
67509
+ orders;
67509
67510
  constructor(payload) {
67510
67511
  this.symbol_config = payload.symbol_config;
67511
67512
  this.exchange = payload.exchange;
67512
67513
  this.app_db = payload.app_db;
67513
67514
  this.instance = payload.instance;
67514
67515
  this.exchange_account = payload.exchange_account;
67516
+ this.orders = payload.orders || {
67517
+ entries: [],
67518
+ stop_orders: [],
67519
+ tp_orders: []
67520
+ };
67515
67521
  }
67516
67522
  async initialize() {
67517
67523
  const proxy = await this.getProxyForAccount();
@@ -68451,6 +68457,42 @@ class ExchangePosition {
68451
68457
  }
68452
68458
  return { profit_percent, take_profit, last_order };
68453
68459
  }
68460
+ getOrders(payload) {
68461
+ const { type = "limit" } = payload;
68462
+ if (type === "limit") {
68463
+ return this.orders.entries.map(convert_to_exchange_order);
68464
+ }
68465
+ if (type === "stop") {
68466
+ return this.orders.stop_orders.map(convert_to_exchange_order);
68467
+ }
68468
+ if (type === "tp") {
68469
+ return this.orders.tp_orders.map(convert_to_exchange_order);
68470
+ }
68471
+ }
68472
+ async cancelExchangeOrder(payload) {
68473
+ const { type, refresh = true } = payload;
68474
+ const orders = this.getOrders({ type });
68475
+ const result = await this.exchange.cancelOrders({
68476
+ symbol: this.symbol,
68477
+ orders: orders.map((x) => x.order_id)
68478
+ });
68479
+ if (refresh) {
68480
+ await this.refresh(true);
68481
+ }
68482
+ return result;
68483
+ }
68484
+ }
68485
+ function convert_to_exchange_order(order) {
68486
+ return {
68487
+ symbol: order.symbol,
68488
+ price: order.price,
68489
+ quantity: order.quantity,
68490
+ kind: order.kind,
68491
+ side: order.side,
68492
+ stop: order.stop,
68493
+ order_id: order.order_id,
68494
+ triggerPrice: order.triggerPrice
68495
+ };
68454
68496
  }
68455
68497
 
68456
68498
  // src/exchange-account.ts
@@ -68514,6 +68556,9 @@ class ExchangeAccount {
68514
68556
  const symbol_config = await this.recomputeSymbolConfig({
68515
68557
  symbol: payload.symbol
68516
68558
  });
68559
+ const active_account = await this.getActiveAccount({
68560
+ symbol: payload.symbol
68561
+ });
68517
68562
  const long_position = positions.find((x) => x.kind === "long");
68518
68563
  const short_position = positions.find((x) => x.kind === "short");
68519
68564
  this.long_position = new ExchangePosition({
@@ -68522,6 +68567,7 @@ class ExchangeAccount {
68522
68567
  exchange_account: this,
68523
68568
  instance: long_position,
68524
68569
  app_db: this.app_db,
68570
+ orders: active_account.orders.long,
68525
68571
  without_view: raw_positions.find((x) => x.kind === "long")
68526
68572
  });
68527
68573
  await this.long_position.initialize();
@@ -68531,6 +68577,7 @@ class ExchangeAccount {
68531
68577
  exchange_account: this,
68532
68578
  instance: short_position,
68533
68579
  app_db: this.app_db,
68580
+ orders: active_account.orders.short,
68534
68581
  without_view: raw_positions.find((x) => x.kind === "short")
68535
68582
  });
68536
68583
  await this.short_position.initialize();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-166",
4
+ "version": "0.0.2-167",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",