This commit is contained in:
olli 2024-09-26 09:09:36 +02:00
parent 53861b2a8e
commit 335c1ee349
5 changed files with 55 additions and 17 deletions

View File

@ -391,7 +391,16 @@ function convert_ohlcv_1h_to_1d {
local f_today=$(TZ="$f_target_timezone" date "+%Y-%m-%d")
grep -A9999 -B24 "^$f_latestdate" "$f_input_file" | grep ':00:00,' | cut -d, -f1,2,3,4,5,6 | while read f_line
# check if there is a $f_latestdate
grep -A9999 -B24 "^$f_latestdate" "$f_input_file" >"$g_tmp/convert_ohlcv_1h_to_1d_nextlines"
if ! [ -s "$g_tmp/convert_ohlcv_1h_to_1d_nextlines" ]
then
cat "$f_input_file" >"$g_tmp/convert_ohlcv_1h_to_1d_nextlines"
f_nextdate=$(date -d "$(head -n1 "$g_tmp/convert_ohlcv_1h_to_1d_nextlines" | cut -d, -f1)" +%Y-%m-%d)
fi
# go through lines
cat "$g_tmp/convert_ohlcv_1h_to_1d_nextlines" | grep ':00:00,' | cut -d, -f1,2,3,4,5,6 | while read f_line
do
g_array "$f_line" g_line_array ,
# calculate day in target timezone
@ -456,6 +465,9 @@ function convert_ohlcv_1h_to_1d {
}
function convert_ohlcv_1d_to_1w {
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
local f_input_file=$1
local f_output_file=$2
@ -472,8 +484,15 @@ function convert_ohlcv_1d_to_1w {
# if not exists use first date as latest date
[ -z "$f_latestdate" ] && f_latestdate=$(date -d "$(head -n1 "$f_input_file" | cut -d, -f1)" +%Y-%m-%d)
# check if there is a $f_latestdate
grep -A9999 -B9 "^$f_latestdate" "$f_input_file" >"$g_tmp/convert_ohlcv_1d_to_1w_nextlines"
if ! [ -s "$g_tmp/convert_ohlcv_1d_to_1w_nextlines" ]
then
cat "$f_input_file" >"$g_tmp/convert_ohlcv_1d_to_1w_nextlines"
fi
# go through lines
for f_line in $(grep -A9999 -B9 "^$f_latestdate" "$f_input_file")
for f_line in $(cat "$g_tmp/convert_ohlcv_1d_to_1w_nextlines")
do
IFS=',' read -r f_date f_open f_high f_low f_close f_volume f_other <<< "$f_line"
IFS='-' read -r f_year f_month f_day <<< "$f_date"

View File

@ -120,7 +120,7 @@ function get_order_line_vars {
then
o[${f_asset}_present]=${f_type}
else
o[${f_asset}_present]=${o[${f_asset}_present]},${f_type}
o[${f_asset}_present]="${o[${f_asset}_present]} ${f_type}"
fi
o[${f_asset}_${f_type}_type]=${f_order_array[1]}
o[${f_asset}_${f_type}_side]=${f_order_array[2]}

View File

@ -91,9 +91,16 @@ function order {
# Add stoploos and take profit if available
if [ -n "$f_stoploss" ]
then
if g_num_is_higher_equal $f_stoploss $f_price
# check for long
if [[ $f_side = buy ]] && g_num_is_higher_equal $f_stoploss $f_price
then
g_echo_warn "Order not possible: Stoploss ($f_stoploss) higher then buy price ($f_price)"
g_echo_warn "Long Order not possible: Stoploss ($f_stoploss) higher then buy price ($f_price)"
return 1
fi
# check for short
if [[ $f_side = sell ]] && g_num_is_lower_equal $f_stoploss $f_price
then
g_echo_warn "Short Order not possible: Stoploss ($f_stoploss) lower then buy price ($f_price)"
return 1
fi
f_ccxt "print($STOCK_EXCHANGE.priceToPrecision('${f_symbol}', ${f_stoploss}))"
@ -102,11 +109,19 @@ function order {
fi
if [ -n "$f_takeprofit" ]
then
if g_num_is_lower_equal $f_takeprofit $f_price
# check for long
if [[ $f_side = buy ]] && g_num_is_lower_equal $f_takeprofit $f_price
then
g_echo_warn "Order not possible:TakeProfit ($f_takeprofit) lower then buy price ($f_price)"
g_echo_warn "Long Order not possible:TakeProfit ($f_takeprofit) lower then buy price ($f_price)"
return 1
fi
# check for short
if [[ $f_side = sell ]] && g_num_is_higher_equal $f_takeprofit $f_price
then
g_echo_warn "Short Order not possible:TakeProfit ($f_takeprofit) higher then buy price ($f_price)"
return 1
fi
f_ccxt "print($STOCK_EXCHANGE.priceToPrecision('${f_symbol}', ${f_takeprofit}))"
f_takeprofit=$f_ccxt_result
f_params="${f_params}'takeProfitPrice': '$f_takeprofit', "

View File

@ -105,20 +105,24 @@ function webpage {
echo '<h2>Open Orders</h2>' >>../index.html.tmp
echo "<table width='100%'><tr class=\"headline\"><td>Symbol</td><td>Amount</td><td>Entry Price</td><td>StopLoss</td><td>TakeProfit</td><td>Notes</td></tr>" >>../index.html.tmp
get_orders_array
local f_type
for f_symbol in ${f_symbols_array_trade[@]}
do
f_asset=${f_symbol//:$CURRENCY/}
f_asset=${f_asset//\//}
[ -z "${o[${f_asset}_entry_price]}" ] && continue
[ "${o[${f_asset}_entry_price]}" = "null" ] && continue
echo "<tr>
for f_type in ${o[${f_asset}_present]}
do
[ -z "${o[${f_asset}_${f_type}_entry_price]}" ] && continue
[ "${o[${f_asset}_${f_type}_entry_price]}" = "null" ] && continue
echo "<tr>
<td><a href=\"charts.html?symbol=${f_asset}&time=4h&symbol2=BTCUSDT\" target=\"_blank\" rel=\"noopener noreferrer\">$f_symbol</a></td>
<td>${o[${f_asset}_amount]}</td>
<td>${o[${f_asset}_entry_price]}</td>
<td>${o[${f_asset}_stoplossprice]}</td>
<td>${o[${f_asset}_takeprofitprice]}</td>
<td>${o[${f_asset}_type]} ${p[${f_asset}_side]}</td>
<td>${o[${f_asset}_${f_type}_amount]}</td>
<td>${o[${f_asset}_${f_type}_entry_price]}</td>
<td>${o[${f_asset}_${f_type}_stoplossprice]}</td>
<td>${o[${f_asset}_${f_type}_takeprofitprice]}</td>
<td>${o[${f_asset}_${f_type}_type]} ${p[${f_asset}_${f_type}_side]}</td>
</tr>" >>../index.html.tmp
done
done
echo "</table>" >>../index.html.tmp

View File

@ -47,7 +47,7 @@ function webpage_transactions {
local f_tax=$(cat ALL_TRANSACTIONS_OVERVIEW.csv | grep "^$f_tax_year-" | cut -d, -f 2,13,14 | egrep -v ',,0$' | grep "$f_exchange_tax_type" | cut -d, -f3 | awk "{ SUM += \$1} END { printf(\"%.2f\", SUM) }")
#echo "$f_exchange_tax_type: $f_tax"
#echo "$f_tax_type: $f_tax EUR<br>" >>${g_tmp}/tax_summary_$f_exchange-$f_tax_year
echo "$f_tax_type: $f_tax EUR<br>" >>${g_tmp}/tax_summary_$f_exchange-$f_tax_year
echo "<html>
<head>