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

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);
@@ -61033,10 +61035,17 @@ async function fetchDBExchangeData(client, symbol) {
61033
61035
  orders = raw_data.config.trades.exchange_info.open_orders || [];
61034
61036
  positions = raw_data.config.trades.exchange_info.positions;
61035
61037
  }
61036
- return { orders, symbol_config, positions, current_price, config: config2 };
61038
+ return {
61039
+ orders,
61040
+ symbol_config,
61041
+ positions,
61042
+ current_price,
61043
+ config: config2,
61044
+ raw_data: live_exchange_details?.data
61045
+ };
61037
61046
  }
61038
61047
  async function getPositionInfo3(client, symbol) {
61039
- const { positions, symbol_config, current_price, orders, config: config2 } = await fetchDBExchangeData(client, symbol);
61048
+ const { positions, symbol_config, current_price, orders, config: config2, raw_data } = await fetchDBExchangeData(client, symbol);
61040
61049
  const long_generator = primitiveTradeGenerator({
61041
61050
  position: {
61042
61051
  kind: "long",
@@ -61065,6 +61074,22 @@ async function getPositionInfo3(client, symbol) {
61065
61074
  config: config2.short,
61066
61075
  price: current_price
61067
61076
  });
61077
+ if (raw_data) {
61078
+ await updateDbDetails(client, {
61079
+ kind: "long",
61080
+ symbol
61081
+ }, raw_data, {
61082
+ position: {},
61083
+ orders: long_state.newTrades()
61084
+ });
61085
+ await updateDbDetails(client, {
61086
+ kind: "short",
61087
+ symbol
61088
+ }, raw_data, {
61089
+ position: {},
61090
+ orders: short_state.newTrades()
61091
+ });
61092
+ }
61068
61093
  const long_position = long_state.position.get();
61069
61094
  const short_position = short_state.position.get();
61070
61095
  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);
@@ -60970,10 +60972,17 @@ async function fetchDBExchangeData(client, symbol) {
60970
60972
  orders = raw_data.config.trades.exchange_info.open_orders || [];
60971
60973
  positions = raw_data.config.trades.exchange_info.positions;
60972
60974
  }
60973
- return { orders, symbol_config, positions, current_price, config: config2 };
60975
+ return {
60976
+ orders,
60977
+ symbol_config,
60978
+ positions,
60979
+ current_price,
60980
+ config: config2,
60981
+ raw_data: live_exchange_details?.data
60982
+ };
60974
60983
  }
60975
60984
  async function getPositionInfo3(client, symbol) {
60976
- const { positions, symbol_config, current_price, orders, config: config2 } = await fetchDBExchangeData(client, symbol);
60985
+ const { positions, symbol_config, current_price, orders, config: config2, raw_data } = await fetchDBExchangeData(client, symbol);
60977
60986
  const long_generator = primitiveTradeGenerator({
60978
60987
  position: {
60979
60988
  kind: "long",
@@ -61002,6 +61011,22 @@ async function getPositionInfo3(client, symbol) {
61002
61011
  config: config2.short,
61003
61012
  price: current_price
61004
61013
  });
61014
+ if (raw_data) {
61015
+ await updateDbDetails(client, {
61016
+ kind: "long",
61017
+ symbol
61018
+ }, raw_data, {
61019
+ position: {},
61020
+ orders: long_state.newTrades()
61021
+ });
61022
+ await updateDbDetails(client, {
61023
+ kind: "short",
61024
+ symbol
61025
+ }, raw_data, {
61026
+ position: {},
61027
+ orders: short_state.newTrades()
61028
+ });
61029
+ }
61005
61030
  const long_position = long_state.position.get();
61006
61031
  const short_position = short_state.position.get();
61007
61032
  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);
@@ -74013,10 +74015,17 @@ async function fetchDBExchangeData(client, symbol) {
74013
74015
  orders = raw_data.config.trades.exchange_info.open_orders || [];
74014
74016
  positions = raw_data.config.trades.exchange_info.positions;
74015
74017
  }
74016
- return { orders, symbol_config, positions, current_price, config: config2 };
74018
+ return {
74019
+ orders,
74020
+ symbol_config,
74021
+ positions,
74022
+ current_price,
74023
+ config: config2,
74024
+ raw_data: live_exchange_details?.data
74025
+ };
74017
74026
  }
74018
74027
  async function getPositionInfo3(client, symbol) {
74019
- const { positions, symbol_config, current_price, orders, config: config2 } = await fetchDBExchangeData(client, symbol);
74028
+ const { positions, symbol_config, current_price, orders, config: config2, raw_data } = await fetchDBExchangeData(client, symbol);
74020
74029
  const long_generator = primitiveTradeGenerator({
74021
74030
  position: {
74022
74031
  kind: "long",
@@ -74045,6 +74054,22 @@ async function getPositionInfo3(client, symbol) {
74045
74054
  config: config2.short,
74046
74055
  price: current_price
74047
74056
  });
74057
+ if (raw_data) {
74058
+ await updateDbDetails(client, {
74059
+ kind: "long",
74060
+ symbol
74061
+ }, raw_data, {
74062
+ position: {},
74063
+ orders: long_state.newTrades()
74064
+ });
74065
+ await updateDbDetails(client, {
74066
+ kind: "short",
74067
+ symbol
74068
+ }, raw_data, {
74069
+ position: {},
74070
+ orders: short_state.newTrades()
74071
+ });
74072
+ }
74048
74073
  const long_position = long_state.position.get();
74049
74074
  const short_position = short_state.position.get();
74050
74075
  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);
@@ -73986,10 +73988,17 @@ async function fetchDBExchangeData(client, symbol) {
73986
73988
  orders = raw_data.config.trades.exchange_info.open_orders || [];
73987
73989
  positions = raw_data.config.trades.exchange_info.positions;
73988
73990
  }
73989
- return { orders, symbol_config, positions, current_price, config: config2 };
73991
+ return {
73992
+ orders,
73993
+ symbol_config,
73994
+ positions,
73995
+ current_price,
73996
+ config: config2,
73997
+ raw_data: live_exchange_details?.data
73998
+ };
73990
73999
  }
73991
74000
  async function getPositionInfo3(client, symbol) {
73992
- const { positions, symbol_config, current_price, orders, config: config2 } = await fetchDBExchangeData(client, symbol);
74001
+ const { positions, symbol_config, current_price, orders, config: config2, raw_data } = await fetchDBExchangeData(client, symbol);
73993
74002
  const long_generator = primitiveTradeGenerator({
73994
74003
  position: {
73995
74004
  kind: "long",
@@ -74018,6 +74027,22 @@ async function getPositionInfo3(client, symbol) {
74018
74027
  config: config2.short,
74019
74028
  price: current_price
74020
74029
  });
74030
+ if (raw_data) {
74031
+ await updateDbDetails(client, {
74032
+ kind: "long",
74033
+ symbol
74034
+ }, raw_data, {
74035
+ position: {},
74036
+ orders: long_state.newTrades()
74037
+ });
74038
+ await updateDbDetails(client, {
74039
+ kind: "short",
74040
+ symbol
74041
+ }, raw_data, {
74042
+ position: {},
74043
+ orders: short_state.newTrades()
74044
+ });
74045
+ }
74021
74046
  const long_position = long_state.position.get();
74022
74047
  const short_position = short_state.position.get();
74023
74048
  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.22",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",