-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (37 loc) · 1.22 KB
/
main.py
File metadata and controls
43 lines (37 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from polars_talis import TechnicalAnalyzer, SMA, EMA, MACD, RSI, BollingerBands
if __name__ == "__main__":
import polars as pl
import numpy as np
from datetime import datetime, timedelta
# Generar datos de ejemplo
np.random.seed(42)
start_date = datetime(2023, 1, 1)
end_date = datetime(2023, 12, 31)
num_days = (end_date - start_date).days + 1
dates = [start_date + timedelta(days=i) for i in range(num_days)]
prices = 100 + np.cumsum(np.random.randn(num_days) * 0.5)
df = pl.DataFrame({
"date": dates,
"close": prices,
"volume": np.random.randint(1000, 10000, len(dates))
})
# Crear analizador con múltiples indicadores
analyzer = TechnicalAnalyzer(max_workers=4)
analyzer.add_indicators([
SMA(20),
SMA(50),
EMA(12),
EMA(26),
MACD(),
RSI(14),
BollingerBands(20, 2.0)
])
# Calcular todos los indicadores
result = analyzer.calculate(df, parallel=True)
print("Columnas resultantes:")
print(result.columns)
print("\nResumen del analizador:")
print(analyzer.get_summary())
print(f"\nDatos procesados: {len(result)} filas")
print(result)
print(result.to_numpy().T)