added charts, fixes,...
This commit is contained in:
parent
a5a8134b02
commit
c1ce1f3ca7
@ -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 "<div id='${file}'>
|
||||
<table class='charts-css line show-data-on-hover show-heading'><caption> $file </caption>"
|
||||
for mark in $(cat "${file}")
|
||||
do
|
||||
echo "<tr><td style='--color: $color; --start: calc( ($lastmark + $lowest) / $divideby ); --end: calc( ( $mark + $lowest) / $divideby );'> <span class='tooltip'> ${mark} % </span> </td></tr>"
|
||||
lastmark=${mark}
|
||||
done
|
||||
echo "</table></div>"
|
||||
}
|
||||
|
||||
function webpage {
|
||||
|
||||
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
|
||||
@ -27,17 +7,18 @@ function webpage {
|
||||
[ -e ../charts.min.css ] || wget -q https://raw.githubusercontent.com/ChartsCSS/charts.css/main/dist/charts.min.css -O ../charts.min.css
|
||||
|
||||
# create status webpage
|
||||
echo '<html><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="refresh" content="60" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="/browser.css">
|
||||
<link rel="stylesheet" type="text/css" href="/charts.min.css">' >../index.html.tmp
|
||||
echo "<title>Dabo! on ${STOCK_EXCHANGE} - ${URL}</title>
|
||||
</head><body>" >>../index.html.tmp
|
||||
echo "<h1>State of Dabo-Bot! on ${STOCK_EXCHANGE} - ${URL} (ReadOnly)</h1>
|
||||
<h1>Last update $(date "+%F %T")</h1>" >>../index.html.tmp
|
||||
|
||||
echo "<html>
|
||||
<head>
|
||||
<meta charset='UTF-8'>
|
||||
<meta http-equiv='refresh' content='${INTERVAL}'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
<link rel='stylesheet' type='text/css' href='/browser.css'>
|
||||
<link rel='stylesheet' type='text/css' href='/charts.min.css'>
|
||||
<title>Dabo! on ${STOCK_EXCHANGE} - ${URL}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>State of Dabo-Bot! on ${STOCK_EXCHANGE} - ${URL} (ReadOnly)</h1>
|
||||
<h1>Last update $(date '+%F %T')</h1>" >../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)
|
||||
@ -103,7 +84,7 @@ function webpage {
|
||||
|
||||
|
||||
echo '<h2>Open Trades (Invested Assets)</h2>' >>../index.html.tmp
|
||||
echo "<table>" >>../index.html.tmp
|
||||
echo "<table width='100%'>" >>../index.html.tmp
|
||||
local line
|
||||
cat EXCHANGE_GET_BALANCES_CMD_OUT | grep -v ${CURRENCY} | sort | while read line
|
||||
do
|
||||
@ -117,7 +98,19 @@ function webpage {
|
||||
echo "</table>" >>../index.html.tmp
|
||||
|
||||
echo "<h2>Market Performance ( $(cat MARKET_PERFORMANCE_LATEST)%)</h2>" >>../index.html.tmp
|
||||
echo "<table>" >>../index.html.tmp
|
||||
#echo "<table width='100%'><tr><td><details><summary>Charts</summary>" >>../index.html.tmp
|
||||
echo "<details><summary>Charts</summary>" >>../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 "</details></td></tr></table>" >>../index.html.tmp
|
||||
echo "</details>" >>../index.html.tmp
|
||||
echo "<details><summary>Table</summary><table width='100%'>" >>../index.html.tmp
|
||||
echo "<tr>" >>../index.html.tmp
|
||||
head -n1 MARKET_PERFORMANCE.csv | perl -pe 's/,/\n/g' | tr [:lower:] [:upper:] | while read f_mperfcol
|
||||
do
|
||||
@ -142,35 +135,20 @@ function webpage {
|
||||
echo "</tr>" >>../index.html.tmp
|
||||
done
|
||||
|
||||
echo "</table>" >>../index.html.tmp
|
||||
echo "</table></details>" >>../index.html.tmp
|
||||
echo "<a href=\"botdata/MARKET_PERFORMANCE.csv\">Complete list</a>" >>../index.html.tmp
|
||||
|
||||
|
||||
echo "<h2>Top/Flop</h2>" >>../index.html.tmp
|
||||
ls -1 trade-histories/*.result | cut -d . -f3-6 | sort -u | while read f_asset_results
|
||||
do
|
||||
f_asset=$(echo ${f_asset_results} | cut -d\- -f1)
|
||||
echo $(cat trade-histories/*${f_asset_results} | awk "{ SUM += \$1} END { printf(\"%.2f\", SUM)}") >trade-histories/${f_asset}.complete_result
|
||||
done
|
||||
echo "<h3>Top 10</h3>" >>../index.html.tmp
|
||||
grep [0-9] trade-histories/*.complete_result | sort -t: -k2 -rn | head -n 10 | cut -d/ -f2 | perl -pe 's/\.complete_result:/ /; s/$/%<br>/' >>../index.html.tmp
|
||||
|
||||
echo "<h3>Flop 10</h3>" >>../index.html.tmp
|
||||
grep [0-9] trade-histories/*.complete_result | sort -t: -k2 -n | head -n 10 | cut -d/ -f2 | perl -pe 's/\.complete_result:/ /; s/$/%<br>/' >>../index.html.tmp
|
||||
|
||||
|
||||
echo '<h2>Latest trades</h2>' >>../index.html.tmp
|
||||
echo '<h3>Open</h3>' >>../index.html.tmp
|
||||
|
||||
echo "<table><tr>" >>../index.html.tmp
|
||||
echo "<table width='100%'><tr>" >>../index.html.tmp
|
||||
echo "<td>Date</td>
|
||||
<td>Asset</td>
|
||||
<td>Action</td>
|
||||
<td>${CURRENCY} Quantity</td>
|
||||
<td>${CURRENCY} Price</td>
|
||||
<td>Commission</td>
|
||||
<td>Comment</td>
|
||||
<td>Chart</td></tr>" >>../index.html.tmp
|
||||
<td>Comment</td></tr>" >>../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 {
|
||||
<td>$(echo ${tradeline} | cut -d, -f5)</td>
|
||||
<td>$(echo ${tradeline} | cut -d, -f6)</td>
|
||||
<td>$(echo ${tradeline} | cut -d, -f7,8,9,10,11,12,13,14,15)</td>
|
||||
<td width='800'>" >>../index.html.tmp
|
||||
</tr>" >>../index.html.tmp
|
||||
echo "<tr><td colspan='7'><details><summary>Chart</summary>" >>../index.html.tmp
|
||||
genchart "$interimfile" >>../index.html.tmp
|
||||
echo "</td>
|
||||
</tr>" >>../index.html.tmp
|
||||
echo "</details></td></tr>" >>../index.html.tmp
|
||||
done
|
||||
echo "</table>" >>../index.html.tmp
|
||||
|
||||
echo '<h3>Closed</h3>' >>../index.html.tmp
|
||||
|
||||
echo "<table><tr>" >>../index.html.tmp
|
||||
echo "<table width='100%'><tr>" >>../index.html.tmp
|
||||
echo "<td>Date</td>
|
||||
<td>Asset</td>
|
||||
<td>Action</td>
|
||||
<td>${CURRENCY} Quantity</td>
|
||||
<td>${CURRENCY} Price (result)</td>
|
||||
<td>Commission</td>
|
||||
<td>Comment</td>
|
||||
<td>Chart</td></tr>" >>../index.html.tmp
|
||||
<td>Comment</td></tr>" >>../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 "<td>$(echo ${tradeline} | cut -d, -f1)</td>
|
||||
echo "<td>${tradedate}</td>
|
||||
<td><a href=\"botdata/asset-histories/${asset}.history.csv\">${asset}</a> <a href=\"https://www.coingecko.com/de/munze/$(egrep -i ^$(echo ${asset} | sed "s/${CURRENCY}$//"), COINGECKO_IDS | cut -d, -f2 )\">🔗</a></td>
|
||||
<td>${f_action}</td>
|
||||
<td>$(echo ${tradeline} | cut -d, -f4)</td>
|
||||
<td>${f_price}</td>
|
||||
<td>$(echo ${tradeline} | cut -d, -f6)</td>
|
||||
<td>$(echo ${tradeline} | cut -d, -f7,8,9,10,11,12,13,14,15)</td>
|
||||
<td width='800'> ">>../index.html.tmp
|
||||
echo ${f_action} | grep -q sell && genchart "$interimfile" >>../index.html.tmp
|
||||
echo "</td>
|
||||
</tr>" >>../index.html.tmp
|
||||
<td>$(echo ${tradeline} | cut -d, -f7,8,9,10,11,12,13,14,15)</td> ">>../index.html.tmp
|
||||
if echo ${f_action} | grep -q sell
|
||||
then
|
||||
echo "<tr><td colspan='7'><details><summary>Charts</summary>" >>../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 "</details></td></tr>" >>../index.html.tmp
|
||||
else
|
||||
echo "</tr>" >>../index.html.tmp
|
||||
fi
|
||||
done
|
||||
done
|
||||
echo "</table>" >>../index.html.tmp
|
||||
|
||||
|
||||
|
||||
echo "<h2>Current config</h2>" >>../index.html.tmp
|
||||
echo "<pre>$(cat ../../dabo-bot.conf | perl -pe 's/\</</g; s/\>/>/g;')</pre>" >>../index.html.tmp
|
||||
#echo "<h2>Current config</h2>" >>../index.html.tmp
|
||||
#echo "<pre>$(cat ../../dabo-bot.conf | perl -pe 's/\</</g; s/\>/>/g;')</pre>" >>../index.html.tmp
|
||||
|
||||
|
||||
|
||||
echo '<h2>Available Assets and histories</h2>' >>../index.html.tmp
|
||||
echo "<table><tr>" >>../index.html.tmp
|
||||
echo "<table width='100%'><tr>" >>../index.html.tmp
|
||||
echo "<tr><td>Asset</td><td>Date</td><td>Price ${CURRENCY}</td><td>24h change (USD)</td></tr>" >>../index.html.tmp
|
||||
local asset
|
||||
cat ASSETS | egrep -v "${BLACKLIST}" | sort | while read asset
|
||||
@ -263,15 +255,36 @@ function webpage {
|
||||
echo "<td><a href=\"botdata/asset-histories/${asset}.history.csv\">${asset}</a> <a href=\"https://www.coingecko.com/de/munze/$(egrep -i ^$(echo ${asset} | sed "s/${CURRENCY}$//"), COINGECKO_IDS | cut -d, -f2 )\">🔗</a></td>" >>../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 "
|
||||
<td>${asset[0]} ${asset[1]}</td>
|
||||
<td>${CURRENCY} ${asset[2]}</td>
|
||||
local assetin=($(cat asset-histories/${asset}.history.csv | egrep -v "0.00000000$" | tail -n2 | head -n1 | sed 's/,/ /g'))
|
||||
echo "<td>${assetin[0]} ${assetin[1]}</td>
|
||||
<td>${CURRENCY} ${assetin[2]}</td>
|
||||
<td> $(grep "^$kcurrency," ASSET_PRICE_CHANGE_PERCENTAGE_24H | cut -d, -f2)%</td>
|
||||
</tr>" >>../index.html.tmp
|
||||
</tr><tr><td colspan='4'>" >>../index.html.tmp
|
||||
echo "<details><summary>${asset} Charts</summary>" >>../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 "</details></td></tr>" >>../index.html.tmp
|
||||
|
||||
done
|
||||
echo "</table>" >>../index.html.tmp
|
||||
|
||||
|
||||
echo "<h2>Top/Flop</h2>" >>../index.html.tmp
|
||||
ls -1 trade-histories/*.result | cut -d . -f3-6 | sort -u | while read f_asset_results
|
||||
do
|
||||
f_asset=$(echo ${f_asset_results} | cut -d\- -f1)
|
||||
echo $(cat trade-histories/*${f_asset_results} | awk "{ SUM += \$1} END { printf(\"%.2f\", SUM)}") >trade-histories/${f_asset}.complete_result
|
||||
done
|
||||
echo "<h3>Top 10</h3>" >>../index.html.tmp
|
||||
grep [0-9] trade-histories/*.complete_result | sort -t: -k2 -rn | head -n 10 | cut -d/ -f2 | perl -pe 's/\.complete_result:/ /; s/$/%<br>/' >>../index.html.tmp
|
||||
|
||||
echo "<h3>Flop 10</h3>" >>../index.html.tmp
|
||||
grep [0-9] trade-histories/*.complete_result | sort -t: -k2 -n | head -n 10 | cut -d/ -f2 | perl -pe 's/\.complete_result:/ /; s/$/%<br>/' >>../index.html.tmp
|
||||
|
||||
|
||||
echo '<h2>Complete trading histories</h2>' >>../index.html.tmp
|
||||
echo "<table>" >>../index.html.tmp
|
||||
find trade-histories -type f -name *.history.csv | cut -d/ -f2 | cut -d. -f1 | sort | while read asset
|
||||
@ -284,4 +297,8 @@ function webpage {
|
||||
# color magic
|
||||
cat ../index.html.tmp | perl -pe 's/ (\-[0-9]+\.[0-9]+\%)/<font color=red>$1<\/font>/g; s/ ([0-9]+\.[0-9]+\%)/<font color=green>$1<\/font>/g;' >../index.html
|
||||
#mv ../index.html.tmp ../index.html
|
||||
|
||||
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@ finished"
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user