Create rl_agent.py
Browse files- rl_agent.py +12 -0
rl_agent.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
def rl_signal(df):
|
| 4 |
+
|
| 5 |
+
returns = df["Close"].pct_change()
|
| 6 |
+
|
| 7 |
+
momentum = returns.rolling(10).mean().iloc[-1]
|
| 8 |
+
|
| 9 |
+
if momentum > 0:
|
| 10 |
+
return 1
|
| 11 |
+
else:
|
| 12 |
+
return -1
|