@gbozee/ultimate 0.0.2-next.36 → 0.0.2-next.37

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
@@ -68731,21 +68731,29 @@ function determineNewPosition({
68731
68731
  }) {
68732
68732
  const kind = position2.kind;
68733
68733
  const placed = trades.filter((t2) => {
68734
- if (kind === "long") {
68735
- return t2.entry >= price;
68734
+ let _price = t2.entry || t2.price;
68735
+ let condition1 = kind === "long" ? _price >= price : _price <= price;
68736
+ return condition1;
68737
+ }).map((t2) => {
68738
+ let _price = t2.entry || t2.price;
68739
+ let condition2 = kind === "long" ? _price >= position2.entry : _price <= position2.entry;
68740
+ if (condition2) {
68741
+ return {
68742
+ ...t2,
68743
+ price: position2.entry,
68744
+ entry: position2.entry
68745
+ };
68736
68746
  }
68737
- return t2.entry <= price;
68747
+ return t2;
68738
68748
  });
68739
68749
  const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
68740
68750
  if (position2.quantity > 0) {
68741
68751
  const placed_less_than_entry = placed.filter((t2) => {
68742
- if (kind === "long") {
68743
- return t2.entry < position2.entry;
68744
- }
68745
- return t2.entry > position2.entry;
68752
+ let condition1 = kind === "long" ? t2.entry <= position2.entry : t2.entry >= position2.entry;
68753
+ return condition1;
68746
68754
  });
68747
68755
  const avg = determine_average_entry_and_size(placed_less_than_entry.map((o) => ({
68748
- price: o.entry,
68756
+ price: o.entry || o.price,
68749
68757
  quantity: o.quantity
68750
68758
  })).concat([{ price: position2.entry, quantity: position2.quantity }]), global_config.decimal_places, global_config.price_places);
68751
68759
  position2.entry = avg.price;
@@ -68771,16 +68779,14 @@ function positionAt({
68771
68779
  taker: 0.05
68772
68780
  };
68773
68781
  const placed = trades.filter((t2) => {
68774
- if (kind === "long") {
68775
- return t2.entry >= price;
68776
- }
68777
- return t2.entry <= price;
68782
+ let _price = t2.entry || t2.price;
68783
+ let condition1 = kind === "long" ? _price >= price : _price <= price;
68784
+ return condition1;
68778
68785
  });
68779
68786
  const not_placed = trades.filter((t2) => {
68780
- if (kind === "long") {
68781
- return t2.entry < price;
68782
- }
68783
- return t2.entry > price;
68787
+ let _price = t2.entry || t2.price;
68788
+ let condition1 = kind === "long" ? _price < price : _price > price;
68789
+ return condition1;
68784
68790
  });
68785
68791
  const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
68786
68792
  const takerFee = price * placeQty * fee_rate.taker / 100;
@@ -69903,7 +69909,30 @@ class PaperBinanceExchange extends BaseExchange {
69903
69909
  async _placeTpOrder(payload) {
69904
69910
  return await placeTpOrder3(this.client, payload);
69905
69911
  }
69906
- async placeLimitOrders(_payload) {}
69912
+ async placeLimitOrders(payload) {
69913
+ const { price_places = "%.1f", decimal_places = "%.3f", symbol } = payload;
69914
+ if (payload.cancel) {
69915
+ await cancelAllOrders3(this.client, symbol, {
69916
+ type: "limit",
69917
+ kind: payload.kind
69918
+ });
69919
+ }
69920
+ if (payload.orders) {
69921
+ const orders = payload.orders.map((x) => ({
69922
+ side: payload.kind === "long" ? "buy" : "sell",
69923
+ price: x.entry,
69924
+ quantity: x.quantity,
69925
+ kind: payload.kind
69926
+ }));
69927
+ return await createLimitPurchaseOrders2(this.client, {
69928
+ symbol,
69929
+ kind: payload.kind,
69930
+ price_places,
69931
+ decimal_places,
69932
+ orders
69933
+ });
69934
+ }
69935
+ }
69907
69936
  async _placeStopOrder(payload) {
69908
69937
  return await placeStopOrder3(this.client, payload);
69909
69938
  }
package/dist/index.js CHANGED
@@ -68644,21 +68644,29 @@ function determineNewPosition({
68644
68644
  }) {
68645
68645
  const kind = position2.kind;
68646
68646
  const placed = trades.filter((t2) => {
68647
- if (kind === "long") {
68648
- return t2.entry >= price;
68647
+ let _price = t2.entry || t2.price;
68648
+ let condition1 = kind === "long" ? _price >= price : _price <= price;
68649
+ return condition1;
68650
+ }).map((t2) => {
68651
+ let _price = t2.entry || t2.price;
68652
+ let condition2 = kind === "long" ? _price >= position2.entry : _price <= position2.entry;
68653
+ if (condition2) {
68654
+ return {
68655
+ ...t2,
68656
+ price: position2.entry,
68657
+ entry: position2.entry
68658
+ };
68649
68659
  }
68650
- return t2.entry <= price;
68660
+ return t2;
68651
68661
  });
68652
68662
  const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
68653
68663
  if (position2.quantity > 0) {
68654
68664
  const placed_less_than_entry = placed.filter((t2) => {
68655
- if (kind === "long") {
68656
- return t2.entry < position2.entry;
68657
- }
68658
- return t2.entry > position2.entry;
68665
+ let condition1 = kind === "long" ? t2.entry <= position2.entry : t2.entry >= position2.entry;
68666
+ return condition1;
68659
68667
  });
68660
68668
  const avg = determine_average_entry_and_size(placed_less_than_entry.map((o) => ({
68661
- price: o.entry,
68669
+ price: o.entry || o.price,
68662
68670
  quantity: o.quantity
68663
68671
  })).concat([{ price: position2.entry, quantity: position2.quantity }]), global_config.decimal_places, global_config.price_places);
68664
68672
  position2.entry = avg.price;
@@ -68684,16 +68692,14 @@ function positionAt({
68684
68692
  taker: 0.05
68685
68693
  };
68686
68694
  const placed = trades.filter((t2) => {
68687
- if (kind === "long") {
68688
- return t2.entry >= price;
68689
- }
68690
- return t2.entry <= price;
68695
+ let _price = t2.entry || t2.price;
68696
+ let condition1 = kind === "long" ? _price >= price : _price <= price;
68697
+ return condition1;
68691
68698
  });
68692
68699
  const not_placed = trades.filter((t2) => {
68693
- if (kind === "long") {
68694
- return t2.entry < price;
68695
- }
68696
- return t2.entry > price;
68700
+ let _price = t2.entry || t2.price;
68701
+ let condition1 = kind === "long" ? _price < price : _price > price;
68702
+ return condition1;
68697
68703
  });
68698
68704
  const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
68699
68705
  const takerFee = price * placeQty * fee_rate.taker / 100;
@@ -69816,7 +69822,30 @@ class PaperBinanceExchange extends BaseExchange {
69816
69822
  async _placeTpOrder(payload) {
69817
69823
  return await placeTpOrder3(this.client, payload);
69818
69824
  }
69819
- async placeLimitOrders(_payload) {}
69825
+ async placeLimitOrders(payload) {
69826
+ const { price_places = "%.1f", decimal_places = "%.3f", symbol } = payload;
69827
+ if (payload.cancel) {
69828
+ await cancelAllOrders3(this.client, symbol, {
69829
+ type: "limit",
69830
+ kind: payload.kind
69831
+ });
69832
+ }
69833
+ if (payload.orders) {
69834
+ const orders = payload.orders.map((x) => ({
69835
+ side: payload.kind === "long" ? "buy" : "sell",
69836
+ price: x.entry,
69837
+ quantity: x.quantity,
69838
+ kind: payload.kind
69839
+ }));
69840
+ return await createLimitPurchaseOrders2(this.client, {
69841
+ symbol,
69842
+ kind: payload.kind,
69843
+ price_places,
69844
+ decimal_places,
69845
+ orders
69846
+ });
69847
+ }
69848
+ }
69820
69849
  async _placeStopOrder(payload) {
69821
69850
  return await placeStopOrder3(this.client, payload);
69822
69851
  }
@@ -72454,21 +72454,29 @@ function determineNewPosition({
72454
72454
  }) {
72455
72455
  const kind = position2.kind;
72456
72456
  const placed = trades.filter((t2) => {
72457
- if (kind === "long") {
72458
- return t2.entry >= price;
72457
+ let _price = t2.entry || t2.price;
72458
+ let condition1 = kind === "long" ? _price >= price : _price <= price;
72459
+ return condition1;
72460
+ }).map((t2) => {
72461
+ let _price = t2.entry || t2.price;
72462
+ let condition2 = kind === "long" ? _price >= position2.entry : _price <= position2.entry;
72463
+ if (condition2) {
72464
+ return {
72465
+ ...t2,
72466
+ price: position2.entry,
72467
+ entry: position2.entry
72468
+ };
72459
72469
  }
72460
- return t2.entry <= price;
72470
+ return t2;
72461
72471
  });
72462
72472
  const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
72463
72473
  if (position2.quantity > 0) {
72464
72474
  const placed_less_than_entry = placed.filter((t2) => {
72465
- if (kind === "long") {
72466
- return t2.entry < position2.entry;
72467
- }
72468
- return t2.entry > position2.entry;
72475
+ let condition1 = kind === "long" ? t2.entry <= position2.entry : t2.entry >= position2.entry;
72476
+ return condition1;
72469
72477
  });
72470
72478
  const avg = determine_average_entry_and_size(placed_less_than_entry.map((o) => ({
72471
- price: o.entry,
72479
+ price: o.entry || o.price,
72472
72480
  quantity: o.quantity
72473
72481
  })).concat([{ price: position2.entry, quantity: position2.quantity }]), global_config.decimal_places, global_config.price_places);
72474
72482
  position2.entry = avg.price;
@@ -72494,16 +72502,14 @@ function positionAt({
72494
72502
  taker: 0.05
72495
72503
  };
72496
72504
  const placed = trades.filter((t2) => {
72497
- if (kind === "long") {
72498
- return t2.entry >= price;
72499
- }
72500
- return t2.entry <= price;
72505
+ let _price = t2.entry || t2.price;
72506
+ let condition1 = kind === "long" ? _price >= price : _price <= price;
72507
+ return condition1;
72501
72508
  });
72502
72509
  const not_placed = trades.filter((t2) => {
72503
- if (kind === "long") {
72504
- return t2.entry < price;
72505
- }
72506
- return t2.entry > price;
72510
+ let _price = t2.entry || t2.price;
72511
+ let condition1 = kind === "long" ? _price < price : _price > price;
72512
+ return condition1;
72507
72513
  });
72508
72514
  const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
72509
72515
  const takerFee = price * placeQty * fee_rate.taker / 100;
@@ -73626,7 +73632,30 @@ class PaperBinanceExchange extends BaseExchange {
73626
73632
  async _placeTpOrder(payload) {
73627
73633
  return await placeTpOrder3(this.client, payload);
73628
73634
  }
73629
- async placeLimitOrders(_payload) {}
73635
+ async placeLimitOrders(payload) {
73636
+ const { price_places = "%.1f", decimal_places = "%.3f", symbol } = payload;
73637
+ if (payload.cancel) {
73638
+ await cancelAllOrders3(this.client, symbol, {
73639
+ type: "limit",
73640
+ kind: payload.kind
73641
+ });
73642
+ }
73643
+ if (payload.orders) {
73644
+ const orders = payload.orders.map((x) => ({
73645
+ side: payload.kind === "long" ? "buy" : "sell",
73646
+ price: x.entry,
73647
+ quantity: x.quantity,
73648
+ kind: payload.kind
73649
+ }));
73650
+ return await createLimitPurchaseOrders2(this.client, {
73651
+ symbol,
73652
+ kind: payload.kind,
73653
+ price_places,
73654
+ decimal_places,
73655
+ orders
73656
+ });
73657
+ }
73658
+ }
73630
73659
  async _placeStopOrder(payload) {
73631
73660
  return await placeStopOrder3(this.client, payload);
73632
73661
  }
@@ -72427,21 +72427,29 @@ function determineNewPosition({
72427
72427
  }) {
72428
72428
  const kind = position2.kind;
72429
72429
  const placed = trades.filter((t2) => {
72430
- if (kind === "long") {
72431
- return t2.entry >= price;
72430
+ let _price = t2.entry || t2.price;
72431
+ let condition1 = kind === "long" ? _price >= price : _price <= price;
72432
+ return condition1;
72433
+ }).map((t2) => {
72434
+ let _price = t2.entry || t2.price;
72435
+ let condition2 = kind === "long" ? _price >= position2.entry : _price <= position2.entry;
72436
+ if (condition2) {
72437
+ return {
72438
+ ...t2,
72439
+ price: position2.entry,
72440
+ entry: position2.entry
72441
+ };
72432
72442
  }
72433
- return t2.entry <= price;
72443
+ return t2;
72434
72444
  });
72435
72445
  const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
72436
72446
  if (position2.quantity > 0) {
72437
72447
  const placed_less_than_entry = placed.filter((t2) => {
72438
- if (kind === "long") {
72439
- return t2.entry < position2.entry;
72440
- }
72441
- return t2.entry > position2.entry;
72448
+ let condition1 = kind === "long" ? t2.entry <= position2.entry : t2.entry >= position2.entry;
72449
+ return condition1;
72442
72450
  });
72443
72451
  const avg = determine_average_entry_and_size(placed_less_than_entry.map((o) => ({
72444
- price: o.entry,
72452
+ price: o.entry || o.price,
72445
72453
  quantity: o.quantity
72446
72454
  })).concat([{ price: position2.entry, quantity: position2.quantity }]), global_config.decimal_places, global_config.price_places);
72447
72455
  position2.entry = avg.price;
@@ -72467,16 +72475,14 @@ function positionAt({
72467
72475
  taker: 0.05
72468
72476
  };
72469
72477
  const placed = trades.filter((t2) => {
72470
- if (kind === "long") {
72471
- return t2.entry >= price;
72472
- }
72473
- return t2.entry <= price;
72478
+ let _price = t2.entry || t2.price;
72479
+ let condition1 = kind === "long" ? _price >= price : _price <= price;
72480
+ return condition1;
72474
72481
  });
72475
72482
  const not_placed = trades.filter((t2) => {
72476
- if (kind === "long") {
72477
- return t2.entry < price;
72478
- }
72479
- return t2.entry > price;
72483
+ let _price = t2.entry || t2.price;
72484
+ let condition1 = kind === "long" ? _price < price : _price > price;
72485
+ return condition1;
72480
72486
  });
72481
72487
  const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
72482
72488
  const takerFee = price * placeQty * fee_rate.taker / 100;
@@ -73599,7 +73605,30 @@ class PaperBinanceExchange extends BaseExchange {
73599
73605
  async _placeTpOrder(payload) {
73600
73606
  return await placeTpOrder3(this.client, payload);
73601
73607
  }
73602
- async placeLimitOrders(_payload) {}
73608
+ async placeLimitOrders(payload) {
73609
+ const { price_places = "%.1f", decimal_places = "%.3f", symbol } = payload;
73610
+ if (payload.cancel) {
73611
+ await cancelAllOrders3(this.client, symbol, {
73612
+ type: "limit",
73613
+ kind: payload.kind
73614
+ });
73615
+ }
73616
+ if (payload.orders) {
73617
+ const orders = payload.orders.map((x) => ({
73618
+ side: payload.kind === "long" ? "buy" : "sell",
73619
+ price: x.entry,
73620
+ quantity: x.quantity,
73621
+ kind: payload.kind
73622
+ }));
73623
+ return await createLimitPurchaseOrders2(this.client, {
73624
+ symbol,
73625
+ kind: payload.kind,
73626
+ price_places,
73627
+ decimal_places,
73628
+ orders
73629
+ });
73630
+ }
73631
+ }
73603
73632
  async _placeStopOrder(payload) {
73604
73633
  return await placeStopOrder3(this.client, payload);
73605
73634
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-next.36",
4
+ "version": "0.0.2-next.37",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",