@gbozee/ultimate 0.0.2-next.21 → 0.0.2-next.23

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
@@ -60951,13 +60951,7 @@ async function getLeverage2(client, symbol) {
60951
60951
  const leverage = response[0]?.leverage;
60952
60952
  return leverage ? to_f(leverage, "%0f") : 0;
60953
60953
  }
60954
- async function savePaperDetails(client, payload, new_payload) {
60955
- const current_account_info = await fetchBinanceAccount2(client, {
60956
- symbol: payload.symbol
60957
- }, {
60958
- price_places: payload.price_places,
60959
- decimal_places: payload.decimal_places
60960
- });
60954
+ async function updateDbDetails(client, payload, current_account_info, new_payload) {
60961
60955
  const position2 = payload.kind === "long" ? current_account_info.long_position : current_account_info.short_position;
60962
60956
  const take_profit = new_payload.take_profit || (position2.tp_quantity > 0 ? {
60963
60957
  price: position2.take_profit,
@@ -60991,7 +60985,15 @@ async function savePaperDetails(client, payload, new_payload) {
60991
60985
  data: current_account_info
60992
60986
  });
60993
60987
  return current_account_info;
60994
- return as_exchange_orders;
60988
+ }
60989
+ async function savePaperDetails(client, payload, new_payload) {
60990
+ const current_account_info = await fetchBinanceAccount2(client, {
60991
+ symbol: payload.symbol
60992
+ }, {
60993
+ price_places: payload.price_places,
60994
+ decimal_places: payload.decimal_places
60995
+ });
60996
+ return await updateDbDetails(client, payload, current_account_info, new_payload);
60995
60997
  }
60996
60998
  async function fetchDBExchangeData(client, symbol) {
60997
60999
  const current_price = await getCurrentPrice3(client.client, symbol);
@@ -61021,6 +61023,9 @@ async function fetchDBExchangeData(client, symbol) {
61021
61023
  exchange: "paper"
61022
61024
  }
61023
61025
  });
61026
+ if (config2.long?.entry && config2.long.entry < current_price) {
61027
+ config2.long = null;
61028
+ }
61024
61029
  config2.short = await client.app_db.getPositionConfig({
61025
61030
  symbol,
61026
61031
  kind: "short",
@@ -61029,14 +61034,24 @@ async function fetchDBExchangeData(client, symbol) {
61029
61034
  exchange: "paper"
61030
61035
  }
61031
61036
  });
61037
+ if (config2.short?.entry && config2.short.entry > current_price) {
61038
+ config2.short = null;
61039
+ }
61032
61040
  const raw_data = live_exchange_details.data;
61033
61041
  orders = raw_data.config.trades.exchange_info.open_orders || [];
61034
61042
  positions = raw_data.config.trades.exchange_info.positions;
61035
61043
  }
61036
- return { orders, symbol_config, positions, current_price, config: config2 };
61044
+ return {
61045
+ orders,
61046
+ symbol_config,
61047
+ positions,
61048
+ current_price,
61049
+ config: config2,
61050
+ raw_data: live_exchange_details?.data
61051
+ };
61037
61052
  }
61038
61053
  async function getPositionInfo3(client, symbol) {
61039
- const { positions, symbol_config, current_price, orders, config: config2 } = await fetchDBExchangeData(client, symbol);
61054
+ const { positions, symbol_config, current_price, orders, config: config2, raw_data } = await fetchDBExchangeData(client, symbol);
61040
61055
  const long_generator = primitiveTradeGenerator({
61041
61056
  position: {
61042
61057
  kind: "long",
@@ -61065,6 +61080,22 @@ async function getPositionInfo3(client, symbol) {
61065
61080
  config: config2.short,
61066
61081
  price: current_price
61067
61082
  });
61083
+ if (raw_data) {
61084
+ await updateDbDetails(client, {
61085
+ kind: "long",
61086
+ symbol
61087
+ }, raw_data, {
61088
+ position: {},
61089
+ orders: long_state.newTrades()
61090
+ });
61091
+ await updateDbDetails(client, {
61092
+ kind: "short",
61093
+ symbol
61094
+ }, raw_data, {
61095
+ position: {},
61096
+ orders: short_state.newTrades()
61097
+ });
61098
+ }
61068
61099
  const long_position = long_state.position.get();
61069
61100
  const short_position = short_state.position.get();
61070
61101
  const long_quantity = long_position.quantity;
package/dist/index.js CHANGED
@@ -60888,13 +60888,7 @@ async function getLeverage2(client, symbol) {
60888
60888
  const leverage = response[0]?.leverage;
60889
60889
  return leverage ? to_f(leverage, "%0f") : 0;
60890
60890
  }
60891
- async function savePaperDetails(client, payload, new_payload) {
60892
- const current_account_info = await fetchBinanceAccount2(client, {
60893
- symbol: payload.symbol
60894
- }, {
60895
- price_places: payload.price_places,
60896
- decimal_places: payload.decimal_places
60897
- });
60891
+ async function updateDbDetails(client, payload, current_account_info, new_payload) {
60898
60892
  const position2 = payload.kind === "long" ? current_account_info.long_position : current_account_info.short_position;
60899
60893
  const take_profit = new_payload.take_profit || (position2.tp_quantity > 0 ? {
60900
60894
  price: position2.take_profit,
@@ -60928,7 +60922,15 @@ async function savePaperDetails(client, payload, new_payload) {
60928
60922
  data: current_account_info
60929
60923
  });
60930
60924
  return current_account_info;
60931
- return as_exchange_orders;
60925
+ }
60926
+ async function savePaperDetails(client, payload, new_payload) {
60927
+ const current_account_info = await fetchBinanceAccount2(client, {
60928
+ symbol: payload.symbol
60929
+ }, {
60930
+ price_places: payload.price_places,
60931
+ decimal_places: payload.decimal_places
60932
+ });
60933
+ return await updateDbDetails(client, payload, current_account_info, new_payload);
60932
60934
  }
60933
60935
  async function fetchDBExchangeData(client, symbol) {
60934
60936
  const current_price = await getCurrentPrice3(client.client, symbol);
@@ -60958,6 +60960,9 @@ async function fetchDBExchangeData(client, symbol) {
60958
60960
  exchange: "paper"
60959
60961
  }
60960
60962
  });
60963
+ if (config2.long?.entry && config2.long.entry < current_price) {
60964
+ config2.long = null;
60965
+ }
60961
60966
  config2.short = await client.app_db.getPositionConfig({
60962
60967
  symbol,
60963
60968
  kind: "short",
@@ -60966,14 +60971,24 @@ async function fetchDBExchangeData(client, symbol) {
60966
60971
  exchange: "paper"
60967
60972
  }
60968
60973
  });
60974
+ if (config2.short?.entry && config2.short.entry > current_price) {
60975
+ config2.short = null;
60976
+ }
60969
60977
  const raw_data = live_exchange_details.data;
60970
60978
  orders = raw_data.config.trades.exchange_info.open_orders || [];
60971
60979
  positions = raw_data.config.trades.exchange_info.positions;
60972
60980
  }
60973
- return { orders, symbol_config, positions, current_price, config: config2 };
60981
+ return {
60982
+ orders,
60983
+ symbol_config,
60984
+ positions,
60985
+ current_price,
60986
+ config: config2,
60987
+ raw_data: live_exchange_details?.data
60988
+ };
60974
60989
  }
60975
60990
  async function getPositionInfo3(client, symbol) {
60976
- const { positions, symbol_config, current_price, orders, config: config2 } = await fetchDBExchangeData(client, symbol);
60991
+ const { positions, symbol_config, current_price, orders, config: config2, raw_data } = await fetchDBExchangeData(client, symbol);
60977
60992
  const long_generator = primitiveTradeGenerator({
60978
60993
  position: {
60979
60994
  kind: "long",
@@ -61002,6 +61017,22 @@ async function getPositionInfo3(client, symbol) {
61002
61017
  config: config2.short,
61003
61018
  price: current_price
61004
61019
  });
61020
+ if (raw_data) {
61021
+ await updateDbDetails(client, {
61022
+ kind: "long",
61023
+ symbol
61024
+ }, raw_data, {
61025
+ position: {},
61026
+ orders: long_state.newTrades()
61027
+ });
61028
+ await updateDbDetails(client, {
61029
+ kind: "short",
61030
+ symbol
61031
+ }, raw_data, {
61032
+ position: {},
61033
+ orders: short_state.newTrades()
61034
+ });
61035
+ }
61005
61036
  const long_position = long_state.position.get();
61006
61037
  const short_position = short_state.position.get();
61007
61038
  const long_quantity = long_position.quantity;
@@ -73931,13 +73931,7 @@ async function getLeverage2(client, symbol) {
73931
73931
  const leverage = response[0]?.leverage;
73932
73932
  return leverage ? to_f(leverage, "%0f") : 0;
73933
73933
  }
73934
- async function savePaperDetails(client, payload, new_payload) {
73935
- const current_account_info = await fetchBinanceAccount2(client, {
73936
- symbol: payload.symbol
73937
- }, {
73938
- price_places: payload.price_places,
73939
- decimal_places: payload.decimal_places
73940
- });
73934
+ async function updateDbDetails(client, payload, current_account_info, new_payload) {
73941
73935
  const position2 = payload.kind === "long" ? current_account_info.long_position : current_account_info.short_position;
73942
73936
  const take_profit = new_payload.take_profit || (position2.tp_quantity > 0 ? {
73943
73937
  price: position2.take_profit,
@@ -73971,7 +73965,15 @@ async function savePaperDetails(client, payload, new_payload) {
73971
73965
  data: current_account_info
73972
73966
  });
73973
73967
  return current_account_info;
73974
- return as_exchange_orders;
73968
+ }
73969
+ async function savePaperDetails(client, payload, new_payload) {
73970
+ const current_account_info = await fetchBinanceAccount2(client, {
73971
+ symbol: payload.symbol
73972
+ }, {
73973
+ price_places: payload.price_places,
73974
+ decimal_places: payload.decimal_places
73975
+ });
73976
+ return await updateDbDetails(client, payload, current_account_info, new_payload);
73975
73977
  }
73976
73978
  async function fetchDBExchangeData(client, symbol) {
73977
73979
  const current_price = await getCurrentPrice3(client.client, symbol);
@@ -74001,6 +74003,9 @@ async function fetchDBExchangeData(client, symbol) {
74001
74003
  exchange: "paper"
74002
74004
  }
74003
74005
  });
74006
+ if (config2.long?.entry && config2.long.entry < current_price) {
74007
+ config2.long = null;
74008
+ }
74004
74009
  config2.short = await client.app_db.getPositionConfig({
74005
74010
  symbol,
74006
74011
  kind: "short",
@@ -74009,14 +74014,24 @@ async function fetchDBExchangeData(client, symbol) {
74009
74014
  exchange: "paper"
74010
74015
  }
74011
74016
  });
74017
+ if (config2.short?.entry && config2.short.entry > current_price) {
74018
+ config2.short = null;
74019
+ }
74012
74020
  const raw_data = live_exchange_details.data;
74013
74021
  orders = raw_data.config.trades.exchange_info.open_orders || [];
74014
74022
  positions = raw_data.config.trades.exchange_info.positions;
74015
74023
  }
74016
- return { orders, symbol_config, positions, current_price, config: config2 };
74024
+ return {
74025
+ orders,
74026
+ symbol_config,
74027
+ positions,
74028
+ current_price,
74029
+ config: config2,
74030
+ raw_data: live_exchange_details?.data
74031
+ };
74017
74032
  }
74018
74033
  async function getPositionInfo3(client, symbol) {
74019
- const { positions, symbol_config, current_price, orders, config: config2 } = await fetchDBExchangeData(client, symbol);
74034
+ const { positions, symbol_config, current_price, orders, config: config2, raw_data } = await fetchDBExchangeData(client, symbol);
74020
74035
  const long_generator = primitiveTradeGenerator({
74021
74036
  position: {
74022
74037
  kind: "long",
@@ -74045,6 +74060,22 @@ async function getPositionInfo3(client, symbol) {
74045
74060
  config: config2.short,
74046
74061
  price: current_price
74047
74062
  });
74063
+ if (raw_data) {
74064
+ await updateDbDetails(client, {
74065
+ kind: "long",
74066
+ symbol
74067
+ }, raw_data, {
74068
+ position: {},
74069
+ orders: long_state.newTrades()
74070
+ });
74071
+ await updateDbDetails(client, {
74072
+ kind: "short",
74073
+ symbol
74074
+ }, raw_data, {
74075
+ position: {},
74076
+ orders: short_state.newTrades()
74077
+ });
74078
+ }
74048
74079
  const long_position = long_state.position.get();
74049
74080
  const short_position = short_state.position.get();
74050
74081
  const long_quantity = long_position.quantity;
@@ -73904,13 +73904,7 @@ async function getLeverage2(client, symbol) {
73904
73904
  const leverage = response[0]?.leverage;
73905
73905
  return leverage ? to_f(leverage, "%0f") : 0;
73906
73906
  }
73907
- async function savePaperDetails(client, payload, new_payload) {
73908
- const current_account_info = await fetchBinanceAccount2(client, {
73909
- symbol: payload.symbol
73910
- }, {
73911
- price_places: payload.price_places,
73912
- decimal_places: payload.decimal_places
73913
- });
73907
+ async function updateDbDetails(client, payload, current_account_info, new_payload) {
73914
73908
  const position2 = payload.kind === "long" ? current_account_info.long_position : current_account_info.short_position;
73915
73909
  const take_profit = new_payload.take_profit || (position2.tp_quantity > 0 ? {
73916
73910
  price: position2.take_profit,
@@ -73944,7 +73938,15 @@ async function savePaperDetails(client, payload, new_payload) {
73944
73938
  data: current_account_info
73945
73939
  });
73946
73940
  return current_account_info;
73947
- return as_exchange_orders;
73941
+ }
73942
+ async function savePaperDetails(client, payload, new_payload) {
73943
+ const current_account_info = await fetchBinanceAccount2(client, {
73944
+ symbol: payload.symbol
73945
+ }, {
73946
+ price_places: payload.price_places,
73947
+ decimal_places: payload.decimal_places
73948
+ });
73949
+ return await updateDbDetails(client, payload, current_account_info, new_payload);
73948
73950
  }
73949
73951
  async function fetchDBExchangeData(client, symbol) {
73950
73952
  const current_price = await getCurrentPrice3(client.client, symbol);
@@ -73974,6 +73976,9 @@ async function fetchDBExchangeData(client, symbol) {
73974
73976
  exchange: "paper"
73975
73977
  }
73976
73978
  });
73979
+ if (config2.long?.entry && config2.long.entry < current_price) {
73980
+ config2.long = null;
73981
+ }
73977
73982
  config2.short = await client.app_db.getPositionConfig({
73978
73983
  symbol,
73979
73984
  kind: "short",
@@ -73982,14 +73987,24 @@ async function fetchDBExchangeData(client, symbol) {
73982
73987
  exchange: "paper"
73983
73988
  }
73984
73989
  });
73990
+ if (config2.short?.entry && config2.short.entry > current_price) {
73991
+ config2.short = null;
73992
+ }
73985
73993
  const raw_data = live_exchange_details.data;
73986
73994
  orders = raw_data.config.trades.exchange_info.open_orders || [];
73987
73995
  positions = raw_data.config.trades.exchange_info.positions;
73988
73996
  }
73989
- return { orders, symbol_config, positions, current_price, config: config2 };
73997
+ return {
73998
+ orders,
73999
+ symbol_config,
74000
+ positions,
74001
+ current_price,
74002
+ config: config2,
74003
+ raw_data: live_exchange_details?.data
74004
+ };
73990
74005
  }
73991
74006
  async function getPositionInfo3(client, symbol) {
73992
- const { positions, symbol_config, current_price, orders, config: config2 } = await fetchDBExchangeData(client, symbol);
74007
+ const { positions, symbol_config, current_price, orders, config: config2, raw_data } = await fetchDBExchangeData(client, symbol);
73993
74008
  const long_generator = primitiveTradeGenerator({
73994
74009
  position: {
73995
74010
  kind: "long",
@@ -74018,6 +74033,22 @@ async function getPositionInfo3(client, symbol) {
74018
74033
  config: config2.short,
74019
74034
  price: current_price
74020
74035
  });
74036
+ if (raw_data) {
74037
+ await updateDbDetails(client, {
74038
+ kind: "long",
74039
+ symbol
74040
+ }, raw_data, {
74041
+ position: {},
74042
+ orders: long_state.newTrades()
74043
+ });
74044
+ await updateDbDetails(client, {
74045
+ kind: "short",
74046
+ symbol
74047
+ }, raw_data, {
74048
+ position: {},
74049
+ orders: short_state.newTrades()
74050
+ });
74051
+ }
74021
74052
  const long_position = long_state.position.get();
74022
74053
  const short_position = short_state.position.get();
74023
74054
  const long_quantity = long_position.quantity;
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.21",
4
+ "version": "0.0.2-next.23",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",