Download backend/debug_test.py from getpulsar/signals: direct link, hf CLI and curl.
- Browser
- Download file 849 Bytes
-
https://huggingface.co/spaces/getpulsar/signals/resolve/main/backend/debug_test.py
- Command line
-
hf download hf://spaces/getpulsar/signals/backend/debug_test.py
-
curl -L -o debug_test.py https://huggingface.co/spaces/getpulsar/signals/resolve/main/backend/debug_test.py
849 Bytes
| from dotenv import load_dotenv | |
| load_dotenv() | |
| import pandas as pd | |
| import numpy as np | |
| from indicators.technical import compute_indicators | |
| from signals.scorer import compute_signal | |
| import config | |
| # build synthetic data (sufficient length) | |
| N=400 | |
| rng = pd.date_range('2023-01-01', periods=N, freq='h') | |
| price = np.cumsum(np.random.randn(N))*2 + 100 | |
| high = price + np.random.rand(N)*2 | |
| low = price - np.random.rand(N)*2 | |
| openp = price + np.random.randn(N)*0.5 | |
| close = price | |
| volume = (np.random.rand(N)*1000).astype(int) | |
| df = pd.DataFrame({'open':openp,'high':high,'low':low,'close':close,'volume':volume}, index=rng) | |
| ind = compute_indicators(df) | |
| last = ind.iloc[-1] | |
| score,signal,reasons = compute_signal(last, config.INDICATOR_WEIGHTS, news_score=None) | |
| print('Signal:', signal, 'Score:', score) | |
| print('Top reasons:') | |
| for r in reasons[:8]: | |
| print('-', r) | |