Compare commits

..

3 Commits

6 changed files with 39 additions and 33 deletions

View File

@ -12,6 +12,8 @@ rm -r /tmp/parallel-* /tmp/overall-result-* /tmp/g_analyze.sh-*
g_nice
export FULL_LOOP=1
function g_echo_note {
[ -z "$1" ] && return 0

View File

@ -101,7 +101,13 @@ do
watch_assets
# Get current assets
get_assets || continue
if ! [ STOCK_EXCHANGE -eq "NONE" ]
then
get_assets || continue
fi
# Get current MarketData
get_marketdata
##### Sell something? ####
check_for_sell

View File

@ -16,6 +16,8 @@ function get_assets {
bitpanda-api-call GET "public/v1/market-ticker" || return 1
#cat ${g_tmp}/API_CMD_OUT | jq -r '.[] | select(.state=="ACTIVE") | .instrument_code + "," + .last_price' | sed 's/_//' | grep "${CURRENCY}," | egrep -v "${TRANSFER_CURRENCY},|,0[\.][0]*$" >${f_filename}_OUT.tmp
cat ${g_tmp}/API_CMD_OUT | jq -r '.[] | .instrument_code + "," + .last_price' | sed 's/_//' | grep "${CURRENCY}," | egrep -v "${TRANSFER_CURRENCY},|,0[\.][0]*$" >${f_filename}_OUT.tmp
else
f_no_exchange=1
fi
cat ${g_tmp}/API_CMD_OUT >PRICETICKER
@ -44,13 +46,8 @@ function get_assets {
done
mv ASSETS.tmp ASSETS
## write histfiles by having a look on marketcap
#>ASSETS_HIGHEST.tmp
# get alread invested assets
#f_investedassets_regex=$(cat EXCHANGE_GET_BALANCES_CMD_OUT | cut -d, -f1 | perl -pe 's/^/\^/; s/\n/\|/' | perl -pe 's/\|$//')
## write histfiles parallel
local f_ASSET
local f_parallel_arg
echo -n "parallel -j3 bash -c --" >/tmp/parallel
for f_ASSET in $(cat ASSETS | egrep -v "${BLACKLIST}")
@ -63,26 +60,5 @@ function get_assets {
export csv_headline
. /tmp/parallel
get_marketdata https://www.boerse.de/indizes/Dow-Jones/US2605661048 DOW-JONES-INDEX
get_marketdata https://www.boerse.de/indizes/SundP-500/US78378X1072 SP500-INDEX
get_marketdata https://www.boerse.de/indizes/Nasdaq-100/US6311011026 NASDAQ-INDEX
get_marketdata https://www.investing.com/indices/msci-eafe MSCI-EAFE-INDEX
get_marketdata https://www.investing.com/indices/10-year-treasury-yield 10-YEAR-TREASURY-YIELD-INDEX
get_marketdata https://www.boerse.de/rohstoffe/WTI-Rohoelpreis/XD0015948363 OIL-INVERTED-INDEX
get_marketdata https://www.boerse.de/rohstoffe/Goldpreis/XC0009655157 GOLD-INDEX
#get_marketdata https://www.boerse.de/aktien/Nvidia-Aktie/US67066G1040 NVIDIA-INDEX
#get_marketdata https://www.boerse.de/aktien/Tesla-Aktie/US88160R1014 TESLA-INDEX
#get_marketdata https://www.boerse.de/aktien/Apple-Aktie/US0378331005 APPLE-INDEX
get_marketdata https://www.boerse.de/realtime-kurse/MSCI-World/XC0009692739 MSCI-WORLD-INDEX
get_marketdata https://www.boerse.de/indizes/DJ-AMER-OIL-und-GAS/XC0006886516 OIL-GAS-INVERTED-INDEX
get_marketdata https://www.boerse.de/fonds/SPDR-SundP-Regional-Banking-ETF/US78464A6982 KRE-BANKING-INDEX
#get_marketdata https://www.boerse.de/indizes/Dax/DE0008469008 DAX-INDEX
get_marketdata https://www.investing.com/indices/usdollar DXY-INVERTED-INDEX
get_marketdata https://www.investing.com/economic-calendar/unemployment-rate-300/ US-UNEMPLOYMENT-INDEX
get_marketdata https://www.investing.com/economic-calendar/cpi-733 US-CONSUMER-PRICE-INDEX
get_marketdata https://www.investing.com/indices/fed-funds-composite-interest-rate-opinion US-FED-FEDERAL-FUNDS-RATE-INVERTED-INDEX
# clear old stuff
find asset-histories/*INDEX* -type f -mtime +6 -delete
}

View File

@ -1,4 +1,27 @@
function get_marketdata {
get_marketdata_from_url https://www.boerse.de/indizes/Dow-Jones/US2605661048 DOW-JONES-INDEX
get_marketdata_from_url https://www.boerse.de/indizes/SundP-500/US78378X1072 SP500-INDEX
get_marketdata_from_url https://www.boerse.de/indizes/Nasdaq-100/US6311011026 NASDAQ-INDEX
get_marketdata_from_url https://www.investing.com/indices/msci-eafe MSCI-EAFE-INDEX
get_marketdata_from_url https://www.investing.com/indices/10-year-treasury-yield 10-YEAR-TREASURY-YIELD-INDEX
get_marketdata_from_url https://www.boerse.de/rohstoffe/WTI-Rohoelpreis/XD0015948363 OIL-INVERTED-INDEX
get_marketdata_from_url https://www.boerse.de/rohstoffe/Goldpreis/XC0009655157 GOLD-INDEX
#get_marketdata https://www.boerse.de/aktien/Nvidia-Aktie/US67066G1040 NVIDIA-INDEX
#get_marketdata https://www.boerse.de/aktien/Tesla-Aktie/US88160R1014 TESLA-INDEX
#get_marketdata https://www.boerse.de/aktien/Apple-Aktie/US0378331005 APPLE-INDEX
get_marketdata_from_url https://www.boerse.de/realtime-kurse/MSCI-World/XC0009692739 MSCI-WORLD-INDEX
get_marketdata_from_url https://www.boerse.de/indizes/DJ-AMER-OIL-und-GAS/XC0006886516 OIL-GAS-INVERTED-INDEX
get_marketdata_from_url https://www.boerse.de/fonds/SPDR-SundP-Regional-Banking-ETF/US78464A6982 KRE-BANKING-INDEX
#get_marketdata https://www.boerse.de/indizes/Dax/DE0008469008 DAX-INDEX
get_marketdata_from_url https://www.investing.com/indices/usdollar DXY-INVERTED-INDEX
get_marketdata_from_url https://www.investing.com/economic-calendar/unemployment-rate-300/ US-UNEMPLOYMENT-INDEX
get_marketdata_from_url https://www.investing.com/economic-calendar/cpi-733 US-CONSUMER-PRICE-INDEX
get_marketdata_from_url https://www.investing.com/indices/fed-funds-composite-interest-rate-opinion US-FED-FEDERAL-FUNDS-RATE-INVERTED-INDEX
# clear old stuff
find asset-histories/*INDEX* -type f -mtime +6 -delet
}
function get_marketdata_from_url {
local f_url="$1"
local f_name="$2"

View File

@ -41,11 +41,10 @@ function get_vars_from_csv {
get_var_from_line price 2
# get newest price from raw file if this is a non-full loop
# TODO: Nicer pure-bash code
if [ ${FULL_LOOP} == 0 ]
then
f_ASSET_HIST_FILE_RAW=$(echo ${f_ASSET_HIST_FILE} | sed 's/.csv$/-raw.csv/')
f_price=$(tail -n1 "${f_ASSET_HIST_FILE_RAW}" | cut -d, -f2)
readarray -d "," -t f_last_line_raw_array < <(tail -n1 "${f_ASSET_HIST_FILE/.csv/-raw.csv}")
f_price=${f_last_line_raw_array[1]}
fi
get_var_from_line price_change 3

View File

@ -45,8 +45,8 @@ function watch_assets {
f_price=""
if [[ ${f_asset} =~ ^https ]]
then
# get asset price from get_marketdata
get_marketdata ${f_asset}
# get asset price from get_marketdata_from_url
get_marketdata_from_url ${f_asset}
f_price=${f_get_marketdata_price}
readarray -d " " -t f_asset_array < <(echo -n "${f_asset}")
f_asset=${f_asset_array[1]}