diff --git a/dabo/functions/webpage.sh b/dabo/functions/webpage.sh index cc21ad4..306977c 100644 --- a/dabo/functions/webpage.sh +++ b/dabo/functions/webpage.sh @@ -1,24 +1,4 @@ -function genchart { - local lastmark=0 - local mark="" - local file="$1" - local highest=$(sort -n "${file}" | tail -n1 | sed s/^-//) - local lowest=$(sort -n "${file}" | head -n1 | sed s/^-//) - local divideby=$(echo "$highest+$lowest" | bc -l) - local color="green" - tail -n1 "${file}" | grep -q "^-" && color="red" - - echo "
${mark} % |
Charts" >>../index.html.tmp + echo "Charts" >>../index.html.tmp + echo "Krypto" >>../index.html.tmp + genchart MARKET_PERFORMANCE.csv 50 2,3,4,5,6,7 red-or-green,gold,royalblue,lightyellow,MediumSlateBlue,Sienna >>../index.html.tmp + echo "Commodities" >>../index.html.tmp + genchart MARKET_PERFORMANCE.csv 50 2,12,10,13 red-or-green,gold,SandyBrown,Sienna >>../index.html.tmp + echo "World Economic data" >>../index.html.tmp + genchart MARKET_PERFORMANCE.csv 50 2,11,15 red-or-green,Yellow,Sienna >>../index.html.tmp + echo "US Economic data" >>../index.html.tmp + genchart MARKET_PERFORMANCE.csv 50 2,8,17,16,18,19,20,21,14,9 red-or-green,OliveDrab,Yellow,Orange,DeepSkyBlue,DarkMagenta,PeachPuff,PaleTurquoise,Pink,PapayaWhip >>../index.html.tmp + #echo " |
Date | Asset | Action | ${CURRENCY} Quantity | ${CURRENCY} Price | Commission | -Comment | -Chart | Comment | " >>../index.html.tmp local f_trade_file for f_trade_file in $(ls -t trade-histories/trade-*-open.history.csv 2>/dev/null) @@ -185,24 +163,23 @@ function webpage {$(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 + " >>../index.html.tmp + echo " |
Chart" >>../index.html.tmp genchart "$interimfile" >>../index.html.tmp - echo " |
-
Date | Asset | Action | ${CURRENCY} Quantity | ${CURRENCY} Price (result) | Commission | -Comment | -Chart | Comment | " >>../index.html.tmp for f_trade_file in $(ls -t trade-histories/trade-*-closed.history.csv 2>/dev/null | head -n 50) do @@ -211,10 +188,12 @@ function webpage { do local f_action=$(echo ${tradeline} | cut -d, -f2) local f_price=$(echo ${tradeline} | cut -d, -f5) - + local tradedate=$(echo ${tradeline} | cut -d, -f1 | perl -pe 's/_([0-9][0-9])-([0-9][0-9])-([0-9][0-9])/ $1:$2/') + if echo ${f_action} | grep -q buy then echo ${f_price} >${g_tmp}/buyprice + local tradedatebuy=${tradedate} fi if echo ${f_action} | grep -q sell @@ -231,30 +210,43 @@ function webpage { fi local asset=$(echo ${f_trade_file} | cut -d. -f3 | cut -d- -f1) interimfile=$(echo ${f_trade_file} | sed 's/closed\.history\.csv/interim\.history\.csv/') - echo "$(echo ${tradeline} | cut -d, -f1) | + echo "${tradedate} | ${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 ${f_action} | grep -q sell && genchart "$interimfile" >>../index.html.tmp - echo " | - " >>../index.html.tmp +$(echo ${tradeline} | cut -d, -f7,8,9,10,11,12,13,14,15) | ">>../index.html.tmp + if echo ${f_action} | grep -q sell + then + echo "
Charts" >>../index.html.tmp + local tradeintervals=$(cat ${interimfile} | wc -l) + head -n1 asset-histories/${asset}.history.csv >${g_tmp}/trade.csv + grep -A ${tradeintervals} "${tradedatebuy}:" asset-histories/${asset}.history.csv >>${g_tmp}/trade.csv + echo "Price, EMA, Levels" >>../index.html.tmp + genchart "${g_tmp}/trade.csv" ${tradeintervals} 2,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39 >>../index.html.tmp + echo "MACD" >>../index.html.tmp + genchart "${g_tmp}/trade.csv" ${tradeintervals} 8,6,7 >>../index.html.tmp + echo "RSIs" >>../index.html.tmp + genchart "${g_tmp}/trade.csv" ${tradeintervals} 10,11,12,14,15,16,17,13 >>../index.html.tmp + + echo " |
$(cat ../../dabo-bot.conf | perl -pe 's/\</g; s/\>/>/g;')" >>../index.html.tmp + #echo "
$(cat ../../dabo-bot.conf | perl -pe 's/\</g; s/\>/>/g;')" >>../index.html.tmp echo '
Asset | Date | Price ${CURRENCY} | 24h change (USD) | ${asset} 🔗 | " >>../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 " -${asset[0]} ${asset[1]} | -${CURRENCY} ${asset[2]} | + local assetin=($(cat asset-histories/${asset}.history.csv | egrep -v "0.00000000$" | tail -n2 | head -n1 | sed 's/,/ /g')) + echo "${assetin[0]} ${assetin[1]} | +${CURRENCY} ${assetin[2]} | $(grep "^$kcurrency," ASSET_PRICE_CHANGE_PERCENTAGE_24H | cut -d, -f2)% | - " >>../index.html.tmp +
" >>../index.html.tmp
+ echo "${asset} Charts" >>../index.html.tmp + echo "Price, EMA, Levels" >>../index.html.tmp + genchart asset-histories/${asset}.history.csv 50 2,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39 >>../index.html.tmp + echo "MACD" >>../index.html.tmp + genchart asset-histories/${asset}.history.csv 50 8,6,7 >>../index.html.tmp + echo "RSIs" >>../index.html.tmp + genchart asset-histories/${asset}.history.csv 50 10,11,12,14,15,16,17,13 >>../index.html.tmp + echo " |