finalni instant indikatory + save do arch
This commit is contained in:
@ -24,13 +24,19 @@ def populate_dynamic_RSI_indicator(data, state: StrategyState, name):
|
||||
req_source = safe_get(options, 'source', 'vwap')
|
||||
rsi_length = int(safe_get(options, "length",14))
|
||||
rsi_MA_length = safe_get(options, "MA_length", None)
|
||||
start = safe_get(options, "start","linear") #linear/sharp
|
||||
|
||||
|
||||
if on_confirmed_only is False or (on_confirmed_only is True and data['confirmed']==1):
|
||||
try:
|
||||
#source = state.bars[req_source]
|
||||
source = get_source_series(state, req_source)
|
||||
#cekame na dostatek dat
|
||||
if len(source) > rsi_length:
|
||||
delka = len(source)
|
||||
if delka > rsi_length or start == "linear":
|
||||
if delka <= rsi_length and start == "linear":
|
||||
rsi_length = delka
|
||||
|
||||
rsi_res = rsi(source, rsi_length)
|
||||
rsi_value = round(rsi_res[-1],4)
|
||||
state.indicators[name][-1]=rsi_value
|
||||
|
||||
@ -54,5 +54,6 @@ def conditional(state, params):
|
||||
|
||||
return 0, 0
|
||||
except Exception as e:
|
||||
printanyway(str(e)+format_exc())
|
||||
return -2, str(e)+format_exc()
|
||||
|
||||
|
||||
@ -17,17 +17,16 @@ def expression(state: StrategyState, params):
|
||||
if operation is None :
|
||||
return -2, "required param missing"
|
||||
|
||||
state.ilog(lvl=1,e=f"BEFORE {funcName} {operation=}", **params)
|
||||
state.ilog(lvl=0,e=f"BEFORE {funcName} {operation=}", **params)
|
||||
|
||||
#pro zacatek eval
|
||||
val = eval(operation, {'state': state}, state.ind_mapping)
|
||||
|
||||
val = eval(operation, {'state': state, 'np': np}, state.ind_mapping)
|
||||
|
||||
if not np.isfinite(val):
|
||||
val = 0
|
||||
#val = ne.evaluate(operation, state.ind_mapping)
|
||||
|
||||
state.ilog(lvl=1,e=f"AFTER {funcName} {operation=} res:{val}", **params)
|
||||
state.ilog(lvl=1,e=f"IND {funcName} {operation=} res:{val}", **params)
|
||||
return 0, val
|
||||
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ def ma(state, params):
|
||||
type = safe_get(params, "type", "ema")
|
||||
source = safe_get(params, "source", None)
|
||||
lookback = safe_get(params, "lookback",14)
|
||||
start = safe_get(params, "start","linear") #linear/sharp
|
||||
|
||||
#lookback muze byt odkaz na indikator, pak berem jeho hodnotu
|
||||
lookback = int(value_or_indicator(state, lookback))
|
||||
@ -23,8 +24,11 @@ def ma(state, params):
|
||||
source_series = get_source_series(state, source)
|
||||
|
||||
#pokud je mene elementu, pracujeme s tim co je
|
||||
if len(source_series) > lookback:
|
||||
source_series = source_series[-lookback:]
|
||||
akt_pocet = len(source_series)
|
||||
if akt_pocet < lookback and start == "linear":
|
||||
lookback = akt_pocet
|
||||
|
||||
#source_series = source_series[-lookback:]
|
||||
|
||||
type = "mi."+type
|
||||
ma_function = eval(type)
|
||||
|
||||
@ -20,6 +20,7 @@ from traceback import format_exc
|
||||
|
||||
def initialize_dynamic_indicators(state):
|
||||
#pro vsechny indikatory, ktere maji ve svych stratvars TYPE inicializujeme
|
||||
##ßprintanyway(state.vars, state)
|
||||
dict_copy = state.vars.indicators.copy()
|
||||
for indname, indsettings in dict_copy.items():
|
||||
for option,value in list(indsettings.items()):
|
||||
|
||||
Reference in New Issue
Block a user