From 2417df23175ebad6f231cc83fd205f873b2373b6 Mon Sep 17 00:00:00 2001 From: olli Date: Tue, 4 Jun 2024 15:16:40 +0200 Subject: [PATCH] fixes,.. --- .../get_bitpanda_api_transactions.sh | 2 +- dabo/functions/webpage.sh | 52 +++++++++++++++++-- dabo/transaction-history.sh | 2 - 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/dabo/functions/get_bitpanda_api_transactions.sh b/dabo/functions/get_bitpanda_api_transactions.sh index 9dd9c2f..4eb534b 100644 --- a/dabo/functions/get_bitpanda_api_transactions.sh +++ b/dabo/functions/get_bitpanda_api_transactions.sh @@ -39,7 +39,7 @@ function get_bitpanda_api_transactions { .time.date_iso8601 + ",leverage-" + .type + "," + .cryptocoin_symbol + "," + .amount_cryptocoin + ",EUR," + .amount_fiat + ",Bitpanda" ' BITPANDA_trades.json >>BITPANDA.csv.tmp # Workaround fpr staking-rewards (not availabpe per API yet (https://help.blockpit.io/hc/de-at/articles/360011790820-Wie-importiere-ich-Daten-mittels-Bitpanda-API-Key) - [ -s bitpanda-export.csv ] && cat bitpanda-export.csv | grep reward,incoming | awk -F, '{print $2",reward-staking,"$8","$9",EUR,"$5",Bitpanda"}' >>BITPANDA.csv.tmp + [ -s bitpanda-export.csv ] && cat bitpanda-export.csv | grep reward,incoming | awk -F, '{print $2",reward-staking,"$8","$7",EUR,"$5",Bitpanda"}' >>BITPANDA.csv.tmp cat BITPANDA.csv.tmp | grep -v ",reward.best," | sort >TRANSACTIONS-BITPANDA.csv rm -f BITPANDA.csv.tmp diff --git a/dabo/functions/webpage.sh b/dabo/functions/webpage.sh index 2fa5243..33378f3 100644 --- a/dabo/functions/webpage.sh +++ b/dabo/functions/webpage.sh @@ -1,8 +1,9 @@ - function webpage { - g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@" + g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@" + webpage_transactions + # Get charts.css [ -e ../charts.min.css ] || wget ${g_wget_opts} -q https://raw.githubusercontent.com/ChartsCSS/charts.css/main/dist/charts.min.css -O ../charts.min.css @@ -20,6 +21,9 @@ function webpage {

State of Dabo-Bot! on ${STOCK_EXCHANGE} - ${URL} (ReadOnly)

Last update $(date '+%F %T')

" >../index.html.tmp + # historic overview + echo '

Historic Overview

' >>../index.html.tmp + local f_SPOT_BALANCE=$(tail -n1 "asset-histories/BALANCESPOT${CURRENCY}.history.csv" | cut -d, -f2) local f_COMPLETE_BALANCE=$(tail -n1 "asset-histories/BALANCECOMPLETE${CURRENCY}.history.csv" | cut -d, -f2) echo '

Overview

' >>../index.html.tmp @@ -81,9 +85,8 @@ function webpage { $(find trade-histories -name "*-closed.history.csv.result" -exec cat {} \; | awk "{ SUM += \$1} END { printf(\"%.2f\", SUM)}")% " >>../index.html.tmp - - echo '

Open Trades (Invested Assets)

' >>../index.html.tmp + echo '

Open Positions

' >>../index.html.tmp echo "" >>../index.html.tmp local line cat EXCHANGE_GET_BALANCES_CMD_OUT | grep -v ${CURRENCY} | sort | while read line @@ -96,7 +99,46 @@ function webpage { " >>../index.html.tmp done echo "
" >>../index.html.tmp - + + ## Open Positions + echo "

Open Positions - From Trade Histories

" >>../index.html.tmp + echo "" >>../index.html.tmp + echo "" >>../index.html.tmp + rm -f ../index.html.tmp.tmp + cat ALL_TRANSACTIONS_OVERVIEW.csv | cut -d, -f2,4 | sort -u | while read f_asset_per_exchange + do + mapfile -d, -t f_asset_per_exchange_array < <(echo $f_asset_per_exchange) + f_asset=${f_asset_per_exchange_array[1]%$'\n'} + f_exchange=${f_asset_per_exchange_array[0]} + [[ "$f_exchange" =~ JustTrade|Bitpanda ]] || continue + f_amount=$(egrep "$f_exchange,.+,$f_asset" ALL_TRANSACTIONS_OVERVIEW.csv | tail -n1 | cut -d, -f18) + f_spent=$(egrep "$f_exchange,.+,$f_asset" ALL_TRANSACTIONS_OVERVIEW.csv | tail -n1 | cut -d, -f20) + f_sold=$(egrep "$f_exchange,.+,$f_asset" ALL_TRANSACTIONS_OVERVIEW.csv | tail -n1 | cut -d, -f22) + if ! [ "$f_amount" = 0 ] + then + currency_converter $f_amount $f_asset $TRANSFER_CURRENCY || continue + f_currency_amount=$f_currency_converter_result + g_calc "$f_currency_amount+($f_sold)" + f_currency_amount=$g_calc_result + g_calc "$f_spent-($f_sold)" + f_spent=$g_calc_result + + if [ "$f_spent" = 0 ] + then + f_result_percent=0 + else + g_percentage-diff $f_spent $f_currency_amount + f_result_percent=$g_percentage_diff_result + fi + g_calc "$f_currency_amount-($f_spent)" + f_result=$g_calc_result + echo "" >>../index.html.tmp.tmp + fi + done + sort -n -k3 -t'>' -r ../index.html.tmp.tmp >>../index.html.tmp + rm ../index.html.tmp.tmp + echo "
AmountSpent AmountSold AmountProfit/LossAsset AmountExchange
$f_currency_amount $TRANSFER_CURRENCY$f_spent $TRANSFER_CURRENCY$f_sold $TRANSFER_CURRENCY$f_result $TRANSFER_CURRENCY ( ${f_result_percent}%)$f_amount $f_asset$f_exchange
" >>../index.html.tmp + echo "

Market Performance ( $(cat MARKET_PERFORMANCE_LATEST)%)

" >>../index.html.tmp #echo "
Charts" >>../index.html.tmp echo "
Charts" >>../index.html.tmp diff --git a/dabo/transaction-history.sh b/dabo/transaction-history.sh index e29a73f..2ff96b0 100755 --- a/dabo/transaction-history.sh +++ b/dabo/transaction-history.sh @@ -4,9 +4,7 @@ while true do - get_transactions transactions_overview - transactions_summary sleep 3600 done