added contracts/asset-amount

This commit is contained in:
olli 2024-12-13 10:15:43 +01:00
parent 8f307438cf
commit 4328807975

View File

@ -42,7 +42,7 @@ function get_positions {
jq -r " jq -r "
.[] | .[] |
select(.entryPrice != 0) | select(.entryPrice != 0) |
.symbol + \",\" + (.collateral|tostring) + \",\" + (.entryPrice|tostring) + \",\" + .side + \",\" + (.leverage|tostring) + \",\" + (.liquidationPrice|tostring) + \",\" + (.stopLossPrice|tostring) + \",\" + (.takeProfitPrice|tostring) .symbol + \",\" + (.collateral|tostring) + \",\" + (.entryPrice|tostring) + \",\" + .side + \",\" + (.leverage|tostring) + \",\" + (.liquidationPrice|tostring) + \",\" + (.stopLossPrice|tostring) + \",\" + (.takeProfitPrice|tostring) + \",\" + (.contracts|tostring)
" CCXT_POSITIONS_RAW >CCXT_POSITIONS " CCXT_POSITIONS_RAW >CCXT_POSITIONS
# check for takeprofit/stoploss orders if not in CCXT output (needed for phememx and maybe more exchanges) # check for takeprofit/stoploss orders if not in CCXT output (needed for phememx and maybe more exchanges)
@ -61,7 +61,7 @@ select(.entryPrice != 0) |
[ "${p[${f_asset}_side]}" = "short" ] && f_action=buy [ "${p[${f_asset}_side]}" = "short" ] && f_action=buy
if [[ ${p[${f_asset}_side]} =~ long|short ]] if [[ ${p[${f_asset}_side]} =~ long|short ]]
then then
# search fpr stoploss and takeprofit # search for stoploss and takeprofit
f_stoploss=$(egrep "^$f_symbol,Stop,$f_action,null,0," CCXT_ORDERS | cut -d , -f9) f_stoploss=$(egrep "^$f_symbol,Stop,$f_action,null,0," CCXT_ORDERS | cut -d , -f9)
f_takeprofit=$(egrep "^$f_symbol,MarketIfTouched,$f_action,null,0," CCXT_ORDERS | cut -d , -f9) f_takeprofit=$(egrep "^$f_symbol,MarketIfTouched,$f_action,null,0," CCXT_ORDERS | cut -d , -f9)
# escape : and / for sed and edit CCXT_POSITIONS if stoploss or takeprofit order found # escape : and / for sed and edit CCXT_POSITIONS if stoploss or takeprofit order found
@ -145,6 +145,9 @@ function get_position_line_vars {
f_position_takeprofit_price=${f_position_array[7]} f_position_takeprofit_price=${f_position_array[7]}
fi fi
printf -v f_position_asset_amount %.2f ${f_position_array[8]}
p[${f_asset}_asset_amount]=$f_position_asset_amount
# calc pnl percentage # calc pnl percentage
if [[ $f_position_side = long ]] if [[ $f_position_side = long ]]
then then