20 lines
621 B
Python
20 lines
621 B
Python
from pandas import DataFrame, Series
|
|
|
|
from daily_data import get_daily_data
|
|
|
|
def signals(data: DataFrame) -> Series:
|
|
"""
|
|
Generate long signals based on the TRIN Thrusts strategy.
|
|
|
|
Returns a Series with 'L' for long signals and 'N' for no signal.
|
|
"""
|
|
start_date = data['Date'].min()
|
|
end_date = data['Date'].max()
|
|
trin_data = get_daily_data(symbol = 'RINT.Z', start_date = start_date, end_date = end_date)
|
|
|
|
trin_change = trin_data['Close'].pct_change()
|
|
trin_30_below = trin_change <= -0.4
|
|
|
|
signals = Series('N', index = data.index)
|
|
signals[trin_30_below] = 'L'
|
|
return signals |