Spaces:
Paused
Paused
Deploy from GitHub Actions to nse-bot-backend
Browse files- .gitattributes +0 -5
- indicators.py +0 -76
.gitattributes
CHANGED
|
@@ -1,7 +1,2 @@
|
|
| 1 |
*.keras filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 3 |
-
fvg_replay/results/consec_spot_2026-07-01_2026-07-21_vwap-none_gap0.csv filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
fvg_replay/results/trades_month_all_lead.csv filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
nwe_rsi/trades_phase3b.csv filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
vwap_strategy/results/skips.csv filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
vwap_strategy/results_nograce/skips.csv filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 1 |
*.keras filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
indicators.py
DELETED
|
@@ -1,76 +0,0 @@
|
|
| 1 |
-
import numpy as np
|
| 2 |
-
import pandas as pd
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
def _wma(series: pd.Series, length: int) -> pd.Series:
|
| 6 |
-
weights = np.arange(1, length + 1)
|
| 7 |
-
return series.rolling(length).apply(
|
| 8 |
-
lambda x: np.dot(x, weights) / weights.sum(),
|
| 9 |
-
raw=True
|
| 10 |
-
)
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
def add_strategy_indicators(df: pd.DataFrame, ema_fast: int = 5, ema_slow: int = 9) -> pd.DataFrame:
|
| 14 |
-
out = df.copy().sort_values("timestamp").reset_index(drop=True)
|
| 15 |
-
|
| 16 |
-
# Indicator 2. Column names stay ema5/ema9 (fast/slow roles) regardless of the
|
| 17 |
-
# configured span so existing NN feature names keep working when the period changes.
|
| 18 |
-
out["ema5"] = out["close"].ewm(span=ema_fast, adjust=False).mean()
|
| 19 |
-
out["ema9"] = out["close"].ewm(span=ema_slow, adjust=False).mean()
|
| 20 |
-
|
| 21 |
-
# Indicator 1: BB Stops using WMA(20) on OHLC4, mult=1.0
|
| 22 |
-
out["ohlc4"] = (out["open"] + out["high"] + out["low"] + out["close"]) / 4.0
|
| 23 |
-
out["bb_basis"] = _wma(out["ohlc4"], 20)
|
| 24 |
-
out["bb_dev"] = out["ohlc4"].rolling(20).std(ddof=0) * 1.0
|
| 25 |
-
out["bb_upper"] = out["bb_basis"] + out["bb_dev"]
|
| 26 |
-
out["bb_lower"] = out["bb_basis"] - out["bb_dev"]
|
| 27 |
-
|
| 28 |
-
up_flags = []
|
| 29 |
-
down_flags = []
|
| 30 |
-
phases = []
|
| 31 |
-
change_up = []
|
| 32 |
-
change_down = []
|
| 33 |
-
|
| 34 |
-
prev_up = False
|
| 35 |
-
prev_down = False
|
| 36 |
-
|
| 37 |
-
for i in range(len(out)):
|
| 38 |
-
curr_up = prev_up
|
| 39 |
-
curr_down = prev_down
|
| 40 |
-
|
| 41 |
-
if i > 0:
|
| 42 |
-
prev_src = out.loc[i - 1, "ohlc4"]
|
| 43 |
-
curr_src = out.loc[i, "ohlc4"]
|
| 44 |
-
prev_upper = out.loc[i - 1, "bb_upper"]
|
| 45 |
-
curr_upper = out.loc[i, "bb_upper"]
|
| 46 |
-
prev_lower = out.loc[i - 1, "bb_lower"]
|
| 47 |
-
curr_lower = out.loc[i, "bb_lower"]
|
| 48 |
-
|
| 49 |
-
if pd.notna(prev_upper) and pd.notna(curr_upper) and pd.notna(prev_lower) and pd.notna(curr_lower):
|
| 50 |
-
crossover = (prev_src <= prev_upper) and (curr_src > curr_upper)
|
| 51 |
-
crossunder = (prev_src >= prev_lower) and (curr_src < curr_lower)
|
| 52 |
-
|
| 53 |
-
if crossover:
|
| 54 |
-
curr_up = True
|
| 55 |
-
curr_down = False
|
| 56 |
-
|
| 57 |
-
if crossunder:
|
| 58 |
-
curr_up = False
|
| 59 |
-
curr_down = True
|
| 60 |
-
|
| 61 |
-
up_flags.append(curr_up)
|
| 62 |
-
down_flags.append(curr_down)
|
| 63 |
-
phases.append("green" if curr_up else "red" if curr_down else None)
|
| 64 |
-
change_up.append(prev_down and curr_up)
|
| 65 |
-
change_down.append(prev_up and curr_down)
|
| 66 |
-
|
| 67 |
-
prev_up = curr_up
|
| 68 |
-
prev_down = curr_down
|
| 69 |
-
|
| 70 |
-
out["bb_up"] = up_flags
|
| 71 |
-
out["bb_down"] = down_flags
|
| 72 |
-
out["bb_phase"] = phases
|
| 73 |
-
out["bb_change_up"] = change_up
|
| 74 |
-
out["bb_change_down"] = change_down
|
| 75 |
-
|
| 76 |
-
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|