function webpage { g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@" # create status webpage echo ' Statuspage Crypto Bot ' >../index.html.tmp echo "

Statuspage Crypto Bot (ReadOnly)

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

" >>../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 echo "
Overall Balance: ${CURRENCY} ${f_COMPLETE_BALANCE}
SPOT Balance (invested): ${CURRENCY} $f_SPOT_BALANCE
Free Balance (not invested): ${CURRENCY} ${CURRENCY_BALANCE}
" >>../index.html.tmp echo "

Trade Performance (overall closed trades)

" >>../index.html.tmp echo "
Performance day (last 24 hours): $(find trade-histories -name "*-closed.history.csv.result" -mtime -1 -exec cat {} \; | awk '{ SUM += $1} END { printf("%.2f", SUM) }')%
Performance week (last 7 days): $(find trade-histories -name "*-closed.history.csv.result" -mtime -7 -exec cat {} \; | awk '{ SUM += $1} END { printf("%.2f", SUM) }')%
Performance month (last 30 days): $(find trade-histories -name "*-closed.history.csv.result" -mtime -31 -exec cat {} \; | awk '{ SUM += $1} END { printf("%.2f", SUM) }')%
Performance complete): $(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 "" >>../index.html.tmp local line cat EXCHANGE_GET_BALANCES_CMD_OUT | grep -v ${CURRENCY} | sort | while read line do local spot_balances=($(echo $line | sed 's/,/ /g')) echo "" >>../index.html.tmp done echo "
${spot_balances[0]} 🔗 ${spot_balances[1]} ${CURRENCY} ${spot_balances[2]} ( $(cat DIFF_BUY_PRICE_${spot_balances[0]}${CURRENCY})%)
" >>../index.html.tmp echo "

Market Performance ( $(cat MARKET_PERFORMANCE_LATEST)%)

" >>../index.html.tmp echo -e "
$(egrep ":00:" MARKET_PERFORMANCE | tail -n10)\n$(tail -n1 MARKET_PERFORMANCE)
" >>../index.html.tmp echo "Complete list" >>../index.html.tmp echo '

Latest trades

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

Open

' >>../index.html.tmp echo "" >>../index.html.tmp echo "" >>../index.html.tmp local f_trade_file for f_trade_file in $(ls -t trade-histories/trade-*-open.history.csv 2>/dev/null) do local tradeline=$(tail -n1 ${f_trade_file}) local asset=$(echo ${f_trade_file} | cut -d. -f3 | cut -d- -f1) echo "" >>../index.html.tmp done echo "
Date Asset Action ${CURRENCY} Quantity ${CURRENCY} Price Commission Comment
$(echo ${tradeline} | cut -d, -f1) ${asset} 🔗 $(echo ${tradeline} | cut -d, -f2) $(echo ${tradeline} | cut -d, -f4) $(echo ${tradeline} | cut -d, -f5) $(echo ${tradeline} | cut -d, -f6) $(echo ${tradeline} | cut -d, -f7,8,9,10,11,12,13,14,15)
" >>../index.html.tmp echo '

Closed

' >>../index.html.tmp echo "" >>../index.html.tmp echo "" >>../index.html.tmp for f_trade_file in $(ls -t trade-histories/trade-*-closed.history.csv 2>/dev/null | head -n 50) do local tradeline cat ${f_trade_file} | while read tradeline do local f_action=$(echo ${tradeline} | cut -d, -f2) local f_price=$(echo ${tradeline} | cut -d, -f5) if echo ${f_action} | grep -q buy then echo ${f_price} >${g_tmp}/buyprice fi if echo ${f_action} | grep -q sell then if [ -s "${f_trade_file}.result" ] then local f_profit=$(cat "${f_trade_file}.result") f_price="${f_price} ( ${f_profit}%)" else local f_profit=$(g_percentage-diff $(cat ${g_tmp}/buyprice) ${f_price}) f_price="${f_price} ( ${f_profit}%)" echo "${f_profit}" >"${f_trade_file}.result" fi fi local asset=$(echo ${f_trade_file} | cut -d. -f3 | cut -d- -f1) echo "" >>../index.html.tmp done done echo "
Date Asset Action ${CURRENCY} Quantity ${CURRENCY} Price (result) Commission Comment
$(echo ${tradeline} | cut -d, -f1) ${asset} 🔗 ${f_action} $(echo ${tradeline} | cut -d, -f4) ${f_price} $(echo ${tradeline} | cut -d, -f6) $(echo ${tradeline} | cut -d, -f7,8,9,10,11,12,13,14,15)
" >>../index.html.tmp # echo "" >>../index.html.tmp # echo " # # # # # # " >>../index.html.tmp # grep ^20 trade-histories/*history.csv | sed 's/\// /; s/\./ /; s/:/ /; s/,/ /g' | sort -r -k3 >${g_tmp}/trade-hist-complete # local tradeline # cat ${g_tmp}/trade-hist-complete | while read tradeline # do # # use array trade # local trade=($tradeline) # local f_trace_price=${trade[8]} # if [ ${trade[4]} = "sell" ] # then # local f_trade_date=${trade[3]} # local f_trade_currency=${trade[1]} # local f_trade_sell_for=${trade[6]} # local f_trade_buy_for=$(grep -B1 "^${f_trade_date},sell," "trade-histories/${f_trade_currency}.history.csv" | grep ",buy," | cut -d, -f4 | cut -d" " -f1) # local f_result=$(echo "scale=2; ${f_trade_sell_for}-$f_trade_buy_for" | bc -l | sed 's/^\./0./; s/^-\./-0./' | xargs printf "%.2f") # local f_result_percentage=$(g_percentage-diff $f_trade_buy_for ${f_trade_sell_for}) # f_trace_price="$f_trace_price ($f_result( ${f_result_percentage}%))" # #echo "${trade[1]} $f_trade_buy_for -- ${f_trade_sell_for} == $f_result(${f_result_percentage}%)" # fi # echo " # # # # # # # " >>../index.html.tmp # # done # echo "
DateAssetAction${CURRENCY} Quantity${CURRENCY} Price (profit/loss)CommissionComment
${trade[3]}${trade[1]} 🔗${trade[4]}${trade[6]}${f_trace_price}${trade[9]} ${trade[10]}${trade[@]:11:30}
" >>../index.html.tmp echo "

Current config

" >>../index.html.tmp echo "
$(cat ../../bot.conf | perl -pe 's/\/>/g;')
" >>../index.html.tmp echo '

Available Assets and histories

' >>../index.html.tmp echo "" >>../index.html.tmp echo "" >>../index.html.tmp local asset cat ASSETS | egrep -v "${BLACKLIST}" | sort | while read asset do [ -s asset-histories/${asset}.history.csv ] || continue echo "" >>../index.html.tmp kcurrency=$(echo ${asset} | sed "s/${CURRENCY}//") #get_rate_percentage_min_before_and_now ${kcurrency} ${CURRENCY} 1440 local asset=($(cat asset-histories/${asset}.history.csv | egrep -v "0.00000000$" | tail -n2 | head -n1 | sed 's/,/ /g')) echo " " >>../index.html.tmp done echo "
AssetDatePrice ${CURRENCY}24h change (USD)
${asset} 🔗${asset[0]} ${asset[1]} ${CURRENCY} ${asset[2]} $(grep "^$kcurrency," ASSET_PRICE_CHANGE_PERCENTAGE_24H | cut -d, -f2)%
" >>../index.html.tmp echo '

Complete trading histories

' >>../index.html.tmp echo "" >>../index.html.tmp find trade-histories -type f -name *.history.csv | cut -d/ -f2 | cut -d. -f1 | sort | while read asset do [ -s trade-histories/${asset}.history.csv ] || continue echo "" >>../index.html.tmp done echo "
${asset} 🔗
" >>../index.html.tmp # color magic cat ../index.html.tmp | perl -pe 's/ (\-[0-9]+\.[0-9]+\%)/$1<\/font>/g; s/ ([0-9]+\.[0-9]+\%)/$1<\/font>/g;' >../index.html #mv ../index.html.tmp ../index.html }