Spaces:
Configuration error
Configuration error
Download technical.py from Alibar/README: direct link, hf CLI and curl.
- Browser
- Download file 460 Bytes
-
https://huggingface.co/spaces/Alibar/README/resolve/main/technical.py
- Command line
-
hf download hf://spaces/Alibar/README/technical.py
-
curl -L -o technical.py https://huggingface.co/spaces/Alibar/README/resolve/main/technical.py
460 Bytes
| # -*- coding: utf-8 -*- | |
| import pandas as pd | |
| import numpy as np | |
| def sma_signal(df: pd.DataFrame, fast: int = 10, slow: int = 20): | |
| df = df.copy() | |
| df['sma_fast'] = df['close'].rolling(fast).mean() | |
| df['sma_slow'] = df['close'].rolling(slow).mean() | |
| df['signal'] = 0 | |
| df.loc[df['sma_fast'] > df['sma_slow'], 'signal'] = 1 | |
| df.loc[df['sma_fast'] < df['sma_slow'], 'signal'] = -1 | |
| return df[['close','sma_fast','sma_slow','signal']].dropna() | |