Add script for generating swing trading signals based on TRIN Thrusts strategy

This commit is contained in:
moshferatu 2024-11-14 05:50:33 -08:00
parent 778c1c69a8
commit 48d3fa4975

View File

@ -0,0 +1,20 @@
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