fix: dont run get_assts if STOCK_EXCHANGE is NONE
This commit is contained in:
parent
9d0e0b388c
commit
ae99194986
@ -81,54 +81,57 @@ do
|
||||
INTERVAL_MIN=$(echo "${INTERVAL}/60-1" | bc -l | sed -r 's/^(-?)\./\10./' | cut -d\. -f1)
|
||||
[ -z "${INTERVAL_MIN}" ] && INTERVAL_MIN=1
|
||||
|
||||
# stock data
|
||||
if [ "${STOCK_EXCHANGE}" = "BINANCE" ]
|
||||
then
|
||||
# command for current token infos (function for setting var QUANTITY_LOT_CUT
|
||||
TOKEN_INFO_CMD="binance_get_token_info"
|
||||
# command for buying/selling a token
|
||||
TRADE_CMD='binance-api-call POST /api/v3/order "&symbol=TOKEN"eOrderQty=QUANTITY&side=ACTION&type=MARKET"'
|
||||
elif [ "${STOCK_EXCHANGE}" = "BITPANDA" ]
|
||||
then
|
||||
TOKEN_INFO_CMD="bitpanda_get_token_info"
|
||||
TRADE_CMD='bitpanda-api-call POST public/v1/account/orders "--header \"Content-Type: application/json\" --data \"{\\\"instrument_code\\\":\\\"TOKEN\\\",\\\"side\\\":\\\"ACTION\\\",\\\"type\\\":\\\"MARKET\\\",\\\"amount\\\":\\\"QUANTITY\\\"}\""'
|
||||
fi
|
||||
|
||||
### get general market data
|
||||
# Get coingecko data
|
||||
get_coingecko_data
|
||||
|
||||
# watch some manual defined assets
|
||||
watch_assets
|
||||
|
||||
# Get current assets
|
||||
if [ "${STOCK_EXCHANGE}" != "NONE" ]
|
||||
then
|
||||
get_assets || continue
|
||||
fi
|
||||
|
||||
# Get current MarketData
|
||||
get_marketdata
|
||||
|
||||
##### Sell something? ####
|
||||
check_for_sell
|
||||
|
||||
# Get current balances
|
||||
get_balances || continue
|
||||
|
||||
# Check the situation on the market
|
||||
if ! market_performance
|
||||
then
|
||||
f_market_performance=$(cat MARKET_PERFORMANCE_LATEST)
|
||||
fi
|
||||
|
||||
# stop here if no full loop
|
||||
[ ${FULL_LOOP} == 0 ] && continue
|
||||
|
||||
##### Buy something? ####
|
||||
check_for_buy
|
||||
## watch some manual defined assets
|
||||
watch_assets
|
||||
|
||||
##### Update webpage
|
||||
if jobs | egrep -q "Running.+webpage"
|
||||
|
||||
## if STOCK_EXCHANGE is present
|
||||
if [ "${STOCK_EXCHANGE}" != "NONE" ]
|
||||
then
|
||||
|
||||
# stock data
|
||||
if [ "${STOCK_EXCHANGE}" = "BINANCE" ]
|
||||
then
|
||||
# command for current token infos (function for setting var QUANTITY_LOT_CUT
|
||||
TOKEN_INFO_CMD="binance_get_token_info"
|
||||
# command for buying/selling a token
|
||||
TRADE_CMD='binance-api-call POST /api/v3/order "&symbol=TOKEN"eOrderQty=QUANTITY&side=ACTION&type=MARKET"'
|
||||
elif [ "${STOCK_EXCHANGE}" = "BITPANDA" ]
|
||||
then
|
||||
TOKEN_INFO_CMD="bitpanda_get_token_info"
|
||||
TRADE_CMD='bitpanda-api-call POST public/v1/account/orders "--header \"Content-Type: application/json\" --data \"{\\\"instrument_code\\\":\\\"TOKEN\\\",\\\"side\\\":\\\"ACTION\\\",\\\"type\\\":\\\"MARKET\\\",\\\"amount\\\":\\\"QUANTITY\\\"}\""'
|
||||
fi
|
||||
|
||||
# Get current assets
|
||||
get_assets || continue
|
||||
|
||||
# Sell something?
|
||||
check_for_sell
|
||||
|
||||
# Get current balances
|
||||
[ ${FULL_LOOP} = 1 ] && get_balances || continue
|
||||
|
||||
# Buy something?
|
||||
[ ${FULL_LOOP} = 1 ] && check_for_buy
|
||||
|
||||
fi
|
||||
|
||||
## Update webpage
|
||||
if jobs | egrep -q "Running.+webpage" && [ ${FULL_LOOP} = 1 ]
|
||||
then
|
||||
g_echo_note "webpage already running"
|
||||
else
|
||||
|
@ -1,22 +1,22 @@
|
||||
function get_coingecko_data {
|
||||
# get data from coingecko
|
||||
local f_gecko_currencies="usd eur"
|
||||
if find COINGECKO_GET_ASSETS_CMD_OUT -mmin +5 | grep -q COINGECKO_GET_ASSETS_CMD_OUT
|
||||
if find COINGECKO_GET_ASSETS_CMD_OUT -mmin +5 2>/dev/null | grep -q COINGECKO_GET_ASSETS_CMD_OUT
|
||||
then
|
||||
for f_gecko_currency in ${f_gecko_currencies}
|
||||
do
|
||||
echo "curl -s -X 'GET' \"https://api.coingecko.com/api/v3/coins/markets?vs_currency=${f_gecko_currency}&order=market_cap_desc&per_page=250&page=1&sparkline=false&price_change_percentage=1h,24h,7d,14d,30d,1y\" -H 'accept: application/json'" >COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD
|
||||
g_runcmd g_retrycmd sh COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD >COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT_TMP || return 1
|
||||
local f_test_query=$(jq -r ".[] |select(.symbol==\"btc\")|\"\\(.current_price)\"" COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT_TMP)
|
||||
if g_num_valid_number ${f_test_query}
|
||||
then
|
||||
mv COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT_TMP COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT
|
||||
[[ ${f_gecko_currency} =~ ^usd ]] && cat COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT >COINGECKO_GET_ASSETS_CMD_OUT
|
||||
else
|
||||
find COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT -mmin +15 | grep -q COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT && g_echo_warn "Coingecko data older then 15min: $(ls -l COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT)"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
for f_gecko_currency in ${f_gecko_currencies}
|
||||
do
|
||||
echo "curl -s -X 'GET' \"https://api.coingecko.com/api/v3/coins/markets?vs_currency=${f_gecko_currency}&order=market_cap_desc&per_page=250&page=1&sparkline=false&price_change_percentage=1h,24h,7d,14d,30d,1y\" -H 'accept: application/json'" >COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD
|
||||
g_runcmd g_retrycmd sh COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD >COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT_TMP || return 1
|
||||
local f_test_query=$(jq -r ".[] |select(.symbol==\"btc\")|\"\\(.current_price)\"" COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT_TMP)
|
||||
if g_num_valid_number ${f_test_query}
|
||||
then
|
||||
mv COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT_TMP COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT
|
||||
[[ ${f_gecko_currency} =~ ^usd ]] && cat COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT >COINGECKO_GET_ASSETS_CMD_OUT
|
||||
else
|
||||
find COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT -mmin +15 | grep -q COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT && g_echo_warn "Coingecko data older then 15min: $(ls -l COINGECKO_GET_ASSETS_${f_gecko_currency}_CMD_OUT)"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
[ ${FULL_LOOP} == 0 ] && return 0
|
||||
|
@ -18,7 +18,7 @@ function get_marketdata {
|
||||
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
|
||||
find asset-histories/*INDEX* -type f -mtime +6 -delete
|
||||
}
|
||||
|
||||
function get_marketdata_from_url {
|
||||
@ -26,7 +26,7 @@ function get_marketdata_from_url {
|
||||
local f_name="$2"
|
||||
|
||||
## get data for analysis
|
||||
if find asset-histories/${f_name}.history.csv -mmin -${INTERVAL_MIN} | grep -q "asset-histories/${f_name}.history.csv"
|
||||
if find asset-histories/${f_name}.history.csv -mmin -${INTERVAL_MIN} 2>/dev/null | grep -q "asset-histories/${f_name}.history.csv"
|
||||
then
|
||||
g_echo_note "asset-histories/${f_name}.history.csv already downloaded in the last ${INTERVAL_MIN} minutes"
|
||||
f_get_marketdata_price=$(cat MARKET_DATA_CMD_OUT-${f_name})
|
||||
|
Loading…
Reference in New Issue
Block a user