fix targetema begining
This commit is contained in:
@ -824,7 +824,7 @@ def list_models():
|
||||
return {"error": "Models directory does not exist."}
|
||||
|
||||
# List all files in the directory
|
||||
model_files = os.listdir(models_directory)
|
||||
model_files = sorted(os.listdir(models_directory))
|
||||
return {"models": model_files}
|
||||
|
||||
@app.post("/model/upload-model", dependencies=[Depends(api_key_auth)])
|
||||
|
||||
@ -49,8 +49,8 @@
|
||||
}
|
||||
|
||||
.scrollable-div {
|
||||
width: 328px;
|
||||
height: 143px;
|
||||
width: 478px;
|
||||
height: 260px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #585858;
|
||||
padding: 10px;
|
||||
|
||||
@ -18,6 +18,7 @@ Where
|
||||
- end is the current position -1
|
||||
"""""
|
||||
def targetema(state, params, name):
|
||||
try:
|
||||
funcName = "targetema"
|
||||
window_length_value = safe_get(params, "window_length_value", None)
|
||||
window_length_unit= safe_get(params, "window_length_unit", "position")
|
||||
@ -39,7 +40,25 @@ def targetema(state, params, name):
|
||||
|
||||
# Finding first index where vwap is smaller than ema_slow (last cross)
|
||||
idx = np.where(source_series < ema_slow_series)[0]
|
||||
if idx.size > 0:
|
||||
|
||||
#there is no cross yet (beginning of the market)
|
||||
#TODO jeste to zbytecne protahuje tento signal az do doby protnuti (prvni signal je delsi a obcas zasahuje do konzolidace)
|
||||
if idx.size ==0:
|
||||
#if price exists lower than qualifying price
|
||||
idx = np.where(source_series*(1 + req_min_pct_chng/100) < source_series[-1])[0]
|
||||
|
||||
if idx.size == 0:
|
||||
pass
|
||||
else:
|
||||
#we are qualified, oznacime
|
||||
first_idx = -len(source_series) + idx[-1]
|
||||
#fill target list with 1 from crossed point until last
|
||||
target_list = get_source_series(state, name)
|
||||
target_list[first_idx:] = [uptrend] * abs(first_idx)
|
||||
params["last_pos"] = float(source_series[-1])
|
||||
return 0, notrend
|
||||
#idx.size > 0:
|
||||
else:
|
||||
#if the value on the cross has min_pct from current price to qualify
|
||||
qual_price = source_series[idx[-1]] * (1 + req_min_pct_chng/100)
|
||||
qualified = qual_price < source_series[-1]
|
||||
@ -54,7 +73,23 @@ def targetema(state, params, name):
|
||||
|
||||
# Finding first index where vwap is smaller than ema_slow (last cross) and price at cross must respect min PCT threshold
|
||||
idx = np.where(source_series > ema_slow_series)[0]
|
||||
if idx.size > 0:
|
||||
#there is no cross yet (beginning of the market),
|
||||
if idx.size ==0:
|
||||
#if price exists higher than qualifying price
|
||||
idx = np.where(source_series*(1 - req_min_pct_chng/100) > source_series[-1])[0]
|
||||
|
||||
if idx.size == 0:
|
||||
pass
|
||||
else:
|
||||
#we are qualified, oznacime
|
||||
first_idx = -len(source_series) + idx[-1]
|
||||
#fill target list with 1 from crossed point until last
|
||||
target_list = get_source_series(state, name)
|
||||
target_list[first_idx:] = [downtrend] * abs(first_idx)
|
||||
params["last_neg"] = float(source_series[-1])
|
||||
return 0, notrend
|
||||
#idx.size < 0:
|
||||
else:
|
||||
#porovname zda mezi aktualni cenou a cenou v crossu je dostatecna pro kvalifikaci
|
||||
qual_price = source_series[idx[-1]] * (1 - req_min_pct_chng/100)
|
||||
qualified = qual_price>source_series[-1]
|
||||
@ -77,6 +112,10 @@ def targetema(state, params, name):
|
||||
params["last_neg"] = 99999999
|
||||
|
||||
return 0, notrend
|
||||
#pri chybe vracime explciitne notrend (muze mit jinou hodnotu nez 0)
|
||||
except Exception as e:
|
||||
state.ilog(lvl=1,e=f"IND ERROR {name} necháváme původní", message=str(e)+format_exc())
|
||||
return 0, notrend
|
||||
|
||||
def add_pct(pct, value):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user