@gbozee/ultimate 0.0.2-125 → 0.0.2-128

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
@@ -59960,7 +59960,7 @@ class ExchangeAccount {
59960
59960
  const focus_position = positions.find((k) => {
59961
59961
  let condition = Boolean(k.expand?.account_strategy);
59962
59962
  if (kind) {
59963
- condition = condition && k.kind === kind;
59963
+ condition = k.kind === kind;
59964
59964
  }
59965
59965
  return condition;
59966
59966
  });
@@ -59970,9 +59970,7 @@ class ExchangeAccount {
59970
59970
  const reverse_kind = focus_position.kind === "long" ? "short" : "long";
59971
59971
  const reverse_position = positions.find((k) => k.kind === reverse_kind);
59972
59972
  const strategy2 = focus_position?.expand?.account_strategy;
59973
- if (!strategy2) {
59974
- return;
59975
- }
59973
+ const target_pnl = Math.abs(focus_position.take_profit - focus_position.entry) * focus_position.quantity;
59976
59974
  return computeProfitDetail({
59977
59975
  focus_position: {
59978
59976
  kind: focus_position.kind,
@@ -59981,11 +59979,11 @@ class ExchangeAccount {
59981
59979
  avg_price: focus_position.avg_price,
59982
59980
  avg_qty: focus_position.avg_qty
59983
59981
  },
59984
- pnl: focus_position.target_pnl,
59982
+ pnl: target_pnl,
59985
59983
  strategy: {
59986
- reward_factor: strategy2.reward_factor,
59987
- risk: strategy2.risk,
59988
- max_reward_factor: strategy2.max_reward_factor
59984
+ reward_factor: strategy2?.reward_factor || 1,
59985
+ risk: strategy2?.risk || 1,
59986
+ max_reward_factor: strategy2?.max_reward_factor || 0
59989
59987
  },
59990
59988
  reduce_position: {
59991
59989
  kind: reduce_position.kind,
@@ -60355,6 +60353,7 @@ class App {
60355
60353
  } = payload;
60356
60354
  const main_exchange_account = await this.getExchangeAccount(main_account);
60357
60355
  const reduce_exchange_account = await this.getExchangeAccount(reduce_account);
60356
+ const reverse_kind = kind === "long" ? "short" : "long";
60358
60357
  const reduce_position = await reduce_exchange_account.syncAccount({
60359
60358
  symbol: reduce_account.symbol,
60360
60359
  kind,
@@ -60363,7 +60362,7 @@ class App {
60363
60362
  const result = await main_exchange_account.getSellPriceFromStrategy({
60364
60363
  symbol: main_account.symbol,
60365
60364
  reduce_position,
60366
- kind: main_account.kind
60365
+ kind: main_account.kind || reverse_kind
60367
60366
  });
60368
60367
  if (place) {
60369
60368
  if (cancel_limit) {
package/dist/index.js CHANGED
@@ -59910,7 +59910,7 @@ class ExchangeAccount {
59910
59910
  const focus_position = positions.find((k) => {
59911
59911
  let condition = Boolean(k.expand?.account_strategy);
59912
59912
  if (kind) {
59913
- condition = condition && k.kind === kind;
59913
+ condition = k.kind === kind;
59914
59914
  }
59915
59915
  return condition;
59916
59916
  });
@@ -59920,9 +59920,7 @@ class ExchangeAccount {
59920
59920
  const reverse_kind = focus_position.kind === "long" ? "short" : "long";
59921
59921
  const reverse_position = positions.find((k) => k.kind === reverse_kind);
59922
59922
  const strategy2 = focus_position?.expand?.account_strategy;
59923
- if (!strategy2) {
59924
- return;
59925
- }
59923
+ const target_pnl = Math.abs(focus_position.take_profit - focus_position.entry) * focus_position.quantity;
59926
59924
  return computeProfitDetail({
59927
59925
  focus_position: {
59928
59926
  kind: focus_position.kind,
@@ -59931,11 +59929,11 @@ class ExchangeAccount {
59931
59929
  avg_price: focus_position.avg_price,
59932
59930
  avg_qty: focus_position.avg_qty
59933
59931
  },
59934
- pnl: focus_position.target_pnl,
59932
+ pnl: target_pnl,
59935
59933
  strategy: {
59936
- reward_factor: strategy2.reward_factor,
59937
- risk: strategy2.risk,
59938
- max_reward_factor: strategy2.max_reward_factor
59934
+ reward_factor: strategy2?.reward_factor || 1,
59935
+ risk: strategy2?.risk || 1,
59936
+ max_reward_factor: strategy2?.max_reward_factor || 0
59939
59937
  },
59940
59938
  reduce_position: {
59941
59939
  kind: reduce_position.kind,
@@ -60305,6 +60303,7 @@ class App {
60305
60303
  } = payload;
60306
60304
  const main_exchange_account = await this.getExchangeAccount(main_account);
60307
60305
  const reduce_exchange_account = await this.getExchangeAccount(reduce_account);
60306
+ const reverse_kind = kind === "long" ? "short" : "long";
60308
60307
  const reduce_position = await reduce_exchange_account.syncAccount({
60309
60308
  symbol: reduce_account.symbol,
60310
60309
  kind,
@@ -60313,7 +60312,7 @@ class App {
60313
60312
  const result = await main_exchange_account.getSellPriceFromStrategy({
60314
60313
  symbol: main_account.symbol,
60315
60314
  reduce_position,
60316
- kind: main_account.kind
60315
+ kind: main_account.kind || reverse_kind
60317
60316
  });
60318
60317
  if (place) {
60319
60318
  if (cancel_limit) {
@@ -66638,7 +66638,7 @@ class ExchangeAccount {
66638
66638
  const focus_position = positions.find((k) => {
66639
66639
  let condition = Boolean(k.expand?.account_strategy);
66640
66640
  if (kind) {
66641
- condition = condition && k.kind === kind;
66641
+ condition = k.kind === kind;
66642
66642
  }
66643
66643
  return condition;
66644
66644
  });
@@ -66648,9 +66648,7 @@ class ExchangeAccount {
66648
66648
  const reverse_kind = focus_position.kind === "long" ? "short" : "long";
66649
66649
  const reverse_position = positions.find((k) => k.kind === reverse_kind);
66650
66650
  const strategy2 = focus_position?.expand?.account_strategy;
66651
- if (!strategy2) {
66652
- return;
66653
- }
66651
+ const target_pnl = Math.abs(focus_position.take_profit - focus_position.entry) * focus_position.quantity;
66654
66652
  return computeProfitDetail({
66655
66653
  focus_position: {
66656
66654
  kind: focus_position.kind,
@@ -66659,11 +66657,11 @@ class ExchangeAccount {
66659
66657
  avg_price: focus_position.avg_price,
66660
66658
  avg_qty: focus_position.avg_qty
66661
66659
  },
66662
- pnl: focus_position.target_pnl,
66660
+ pnl: target_pnl,
66663
66661
  strategy: {
66664
- reward_factor: strategy2.reward_factor,
66665
- risk: strategy2.risk,
66666
- max_reward_factor: strategy2.max_reward_factor
66662
+ reward_factor: strategy2?.reward_factor || 1,
66663
+ risk: strategy2?.risk || 1,
66664
+ max_reward_factor: strategy2?.max_reward_factor || 0
66667
66665
  },
66668
66666
  reduce_position: {
66669
66667
  kind: reduce_position.kind,
@@ -67033,6 +67031,7 @@ class App {
67033
67031
  } = payload;
67034
67032
  const main_exchange_account = await this.getExchangeAccount(main_account);
67035
67033
  const reduce_exchange_account = await this.getExchangeAccount(reduce_account);
67034
+ const reverse_kind = kind === "long" ? "short" : "long";
67036
67035
  const reduce_position = await reduce_exchange_account.syncAccount({
67037
67036
  symbol: reduce_account.symbol,
67038
67037
  kind,
@@ -67041,7 +67040,7 @@ class App {
67041
67040
  const result = await main_exchange_account.getSellPriceFromStrategy({
67042
67041
  symbol: main_account.symbol,
67043
67042
  reduce_position,
67044
- kind: main_account.kind
67043
+ kind: main_account.kind || reverse_kind
67045
67044
  });
67046
67045
  if (place) {
67047
67046
  if (cancel_limit) {
@@ -66615,7 +66615,7 @@ class ExchangeAccount {
66615
66615
  const focus_position = positions.find((k) => {
66616
66616
  let condition = Boolean(k.expand?.account_strategy);
66617
66617
  if (kind) {
66618
- condition = condition && k.kind === kind;
66618
+ condition = k.kind === kind;
66619
66619
  }
66620
66620
  return condition;
66621
66621
  });
@@ -66625,9 +66625,7 @@ class ExchangeAccount {
66625
66625
  const reverse_kind = focus_position.kind === "long" ? "short" : "long";
66626
66626
  const reverse_position = positions.find((k) => k.kind === reverse_kind);
66627
66627
  const strategy2 = focus_position?.expand?.account_strategy;
66628
- if (!strategy2) {
66629
- return;
66630
- }
66628
+ const target_pnl = Math.abs(focus_position.take_profit - focus_position.entry) * focus_position.quantity;
66631
66629
  return computeProfitDetail({
66632
66630
  focus_position: {
66633
66631
  kind: focus_position.kind,
@@ -66636,11 +66634,11 @@ class ExchangeAccount {
66636
66634
  avg_price: focus_position.avg_price,
66637
66635
  avg_qty: focus_position.avg_qty
66638
66636
  },
66639
- pnl: focus_position.target_pnl,
66637
+ pnl: target_pnl,
66640
66638
  strategy: {
66641
- reward_factor: strategy2.reward_factor,
66642
- risk: strategy2.risk,
66643
- max_reward_factor: strategy2.max_reward_factor
66639
+ reward_factor: strategy2?.reward_factor || 1,
66640
+ risk: strategy2?.risk || 1,
66641
+ max_reward_factor: strategy2?.max_reward_factor || 0
66644
66642
  },
66645
66643
  reduce_position: {
66646
66644
  kind: reduce_position.kind,
@@ -67010,6 +67008,7 @@ class App {
67010
67008
  } = payload;
67011
67009
  const main_exchange_account = await this.getExchangeAccount(main_account);
67012
67010
  const reduce_exchange_account = await this.getExchangeAccount(reduce_account);
67011
+ const reverse_kind = kind === "long" ? "short" : "long";
67013
67012
  const reduce_position = await reduce_exchange_account.syncAccount({
67014
67013
  symbol: reduce_account.symbol,
67015
67014
  kind,
@@ -67018,7 +67017,7 @@ class App {
67018
67017
  const result = await main_exchange_account.getSellPriceFromStrategy({
67019
67018
  symbol: main_account.symbol,
67020
67019
  reduce_position,
67021
- kind: main_account.kind
67020
+ kind: main_account.kind || reverse_kind
67022
67021
  });
67023
67022
  if (place) {
67024
67023
  if (cancel_limit) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-125",
4
+ "version": "0.0.2-128",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",