move get_marketdata from get_assets and dont run get_assts if STOCK_EXCHANGE= is NONE

This commit is contained in:
olli 2024-02-07 11:11:24 +01:00
parent 183622d8ad
commit d9ce0ab7e2
4 changed files with 35 additions and 30 deletions

View File

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

View File

@ -16,6 +16,8 @@ function get_assets {
bitpanda-api-call GET "public/v1/market-ticker" || return 1 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 '.[] | 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 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 fi
cat ${g_tmp}/API_CMD_OUT >PRICETICKER cat ${g_tmp}/API_CMD_OUT >PRICETICKER
@ -44,13 +46,8 @@ function get_assets {
done done
mv ASSETS.tmp ASSETS mv ASSETS.tmp ASSETS
## write histfiles parallel
## 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/\|$//')
local f_ASSET local f_ASSET
local f_parallel_arg local f_parallel_arg
echo -n "parallel -j3 bash -c --" >/tmp/parallel echo -n "parallel -j3 bash -c --" >/tmp/parallel
for f_ASSET in $(cat ASSETS | egrep -v "${BLACKLIST}") for f_ASSET in $(cat ASSETS | egrep -v "${BLACKLIST}")
@ -63,26 +60,5 @@ function get_assets {
export csv_headline export csv_headline
. /tmp/parallel . /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 { 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_url="$1"
local f_name="$2" local f_name="$2"

View File

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