Compare commits
2 Commits
dcf5336a75
...
c3e0060347
Author | SHA1 | Date | |
---|---|---|---|
c3e0060347 | |||
d71f344777 |
@ -33,7 +33,7 @@ function currency_converter {
|
|||||||
|
|
||||||
if [[ $f_currency_target =~ ^20.*-.*: ]]
|
if [[ $f_currency_target =~ ^20.*-.*: ]]
|
||||||
then
|
then
|
||||||
g_echo_warn "${FUNCNAME}: Invalid target $f_currency_target"
|
g_echo_warn "${FUNCNAME} $@: Invalid target"
|
||||||
g_traceback
|
g_traceback
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -80,6 +80,29 @@ function currency_converter {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# map EUR-Stablecoins to EUR
|
||||||
|
local f_stablecoins="EURC"
|
||||||
|
for f_stablecoin in $f_stablecoins
|
||||||
|
do
|
||||||
|
# Link EUR Stablecoin files to EUR
|
||||||
|
cd "$f_asset_histories"
|
||||||
|
find . -maxdepth 1 -mindepth 1 -name "*${f_stablecoin}.history.*.csv" | while read f_file
|
||||||
|
do
|
||||||
|
f_link_file=${f_file/${f_stablecoin}/EUR}
|
||||||
|
ln -sf "$f_file" "$f_link_file"
|
||||||
|
done
|
||||||
|
cd - >/dev/null
|
||||||
|
# use USD
|
||||||
|
if [[ $f_currency_target = $f_stablecoin ]]
|
||||||
|
then
|
||||||
|
f_currency_target=EUR
|
||||||
|
fi
|
||||||
|
if [[ $f_currency = $f_stablecoin ]]
|
||||||
|
then
|
||||||
|
f_currency=EUR
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# if there is no currency change (USD USD or USDT USD)
|
# if there is no currency change (USD USD or USDT USD)
|
||||||
if [[ $f_currency == $f_currency_target ]]
|
if [[ $f_currency == $f_currency_target ]]
|
||||||
then
|
then
|
||||||
@ -106,7 +129,7 @@ function currency_converter {
|
|||||||
for f_timeframe in 1d 1w
|
for f_timeframe in 1d 1w
|
||||||
do
|
do
|
||||||
[ "${f_currency}" = "USD" ] && get_marketdata_coinmarketcap "${f_currency_target}-${f_currency}" "${f_currency_target}${f_currency}" $f_timeframe
|
[ "${f_currency}" = "USD" ] && get_marketdata_coinmarketcap "${f_currency_target}-${f_currency}" "${f_currency_target}${f_currency}" $f_timeframe
|
||||||
[ "${f_currency_target}" = "USD" ] && get_marketdata_coinmarketcap "${f_currency}-${f_currency_target}" "${f_currency}${f_currency_target}"
|
[ "${f_currency_target}" = "USD" ] && get_marketdata_coinmarketcap "${f_currency}-${f_currency_target}" "${f_currency}${f_currency_target}" $f_timeframe
|
||||||
done
|
done
|
||||||
f_line=$(egrep "^$f_currency_date_minute" "$f_histfile"*m.csv 2>/dev/null | sort | tail -n1)
|
f_line=$(egrep "^$f_currency_date_minute" "$f_histfile"*m.csv 2>/dev/null | sort | tail -n1)
|
||||||
[ -z "$f_line" ] && f_line=$(egrep "^$f_currency_date_hour" "$f_histfile"*m.csv 2>/dev/null | sort | tail -n1)
|
[ -z "$f_line" ] && f_line=$(egrep "^$f_currency_date_hour" "$f_histfile"*m.csv 2>/dev/null | sort | tail -n1)
|
||||||
@ -123,24 +146,32 @@ function currency_converter {
|
|||||||
[[ $f_histfile =~ ${f_currency}${f_currency_target} ]] && f_reverse=true
|
[[ $f_histfile =~ ${f_currency}${f_currency_target} ]] && f_reverse=true
|
||||||
[ $f_currency_target = "USD" ] && f_reverse=true
|
[ $f_currency_target = "USD" ] && f_reverse=true
|
||||||
[ $f_currency = "USD" ] && f_reverse=false
|
[ $f_currency = "USD" ] && f_reverse=false
|
||||||
[ $f_currency_target = "EUR" ] && [ $f_currency = "USD" ] && f_reverse=true
|
[ $f_currency_target = "EUR" ] && [ $f_currency = "USD" ] && f_reverse=false
|
||||||
[[ $f_line =~ ^$f_currency_date_hour ]] && break
|
[[ $f_line =~ ^$f_currency_date_hour ]] && break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# end if no rate found
|
# if no rate found
|
||||||
if [ -z "$f_rate" ]
|
if [ -z "$f_rate" ]
|
||||||
then
|
then
|
||||||
# try workaround over USD if EUR
|
# if EUR spurce or traget try way over USD as workarount
|
||||||
if [[ ${f_currency_target} = EUR ]] && [[ $f_currency != USD ]]
|
if [[ ${f_currency_target} = EUR ]] && [[ $f_currency != USD ]] && [[ $f_currency != EUR ]]
|
||||||
then
|
then
|
||||||
#g_echo_note "trying way over USD (workaround)"
|
g_echo_note "trying way over USD (workaround) Target EUR"
|
||||||
if currency_converter $f_currency_amount $f_currency USD $f_currency_date
|
if currency_converter $f_currency_amount $f_currency USD "$f_currency_date"
|
||||||
then
|
then
|
||||||
f_currency_amount=$f_currency_converter_result
|
currency_converter $f_currency_converter_result USD EUR "$f_currency_date"
|
||||||
currency_converter $f_currency_amount USD EUR $f_currency_date
|
return $?
|
||||||
|
fi
|
||||||
|
elif [[ ${f_currency_target} != USD ]] && [[ ${f_currency_target} != EUR ]] && [[ $f_currency = EUR ]]
|
||||||
|
then
|
||||||
|
g_echo_note "trying way over USD (workaround) Source EUR"
|
||||||
|
if currency_converter $f_currency_amount EUR USD "$f_currency_date"
|
||||||
|
then
|
||||||
|
currency_converter $f_currency_converter_result USD ${f_currency_target} "$f_currency_date"
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
# end if no rate found
|
||||||
g_echo_error "didn't find rate for ${f_currency}-${f_currency_target} - '${FUNCNAME} $@'"
|
g_echo_error "didn't find rate for ${f_currency}-${f_currency_target} - '${FUNCNAME} $@'"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -151,7 +182,3 @@ function currency_converter {
|
|||||||
f_currency_converter_result=$g_calc_result
|
f_currency_converter_result=$g_calc_result
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ function get_marketdata_coinmarketcap {
|
|||||||
|
|
||||||
local f_id
|
local f_id
|
||||||
# get id -> If multiple take the one with the largest marketcap
|
# get id -> If multiple take the one with the largest marketcap
|
||||||
f_id=$(egrep "^${f_item},[1-9]" COINMARKETCAPIDS | sort -n -t, -k4 | tail -n1 | cut -d, -f2)
|
f_id=$(egrep "^${f_item},[1-9]" COINMARKETCAPIDS COINMARKETCAPIDS.tmp | sort -n -t, -k4 | tail -n1 | cut -d, -f2)
|
||||||
[[ $f_item = EURC ]] && f_id=20641
|
[[ $f_item = EURC ]] && f_id=20641
|
||||||
if [ -z "$f_id" ]
|
if [ -z "$f_id" ]
|
||||||
then
|
then
|
||||||
@ -91,7 +91,6 @@ function get_marketdata_coinmarketcap {
|
|||||||
# cleanup
|
# cleanup
|
||||||
rm -f "$f_targetcsvtmp" "${f_targetcsvtmp}".err ${f_targetjsontmp} "${f_targetjsontmp}".err
|
rm -f "$f_targetcsvtmp" "${f_targetcsvtmp}".err ${f_targetjsontmp} "${f_targetjsontmp}".err
|
||||||
|
|
||||||
|
|
||||||
if [ "$f_timeframe" = "1d" ] || [ "$f_timeframe" = "7d" ]
|
if [ "$f_timeframe" = "1d" ] || [ "$f_timeframe" = "7d" ]
|
||||||
then
|
then
|
||||||
# Download data from coinmarketcap
|
# Download data from coinmarketcap
|
||||||
|
@ -166,7 +166,7 @@ function webpage {
|
|||||||
f_sold=$(egrep "$f_exchange,.+,$f_asset" ALL_TRANSACTIONS_OVERVIEW.csv | tail -n1 | cut -d, -f22)
|
f_sold=$(egrep "$f_exchange,.+,$f_asset" ALL_TRANSACTIONS_OVERVIEW.csv | tail -n1 | cut -d, -f22)
|
||||||
if ! [ "$f_amount" = 0 ]
|
if ! [ "$f_amount" = 0 ]
|
||||||
then
|
then
|
||||||
currency_converter $f_amount $f_asset $TRANSFER_CURRENCY || continue
|
currency_converter "$f_amount" "$f_asset" "$TRANSFER_CURRENCY" || continue
|
||||||
f_currency_amount=$f_currency_converter_result
|
f_currency_amount=$f_currency_converter_result
|
||||||
g_calc "$f_currency_amount+($f_sold)"
|
g_calc "$f_currency_amount+($f_sold)"
|
||||||
#f_currency_amount=$g_calc_result
|
#f_currency_amount=$g_calc_result
|
||||||
|
Loading…
Reference in New Issue
Block a user