From 48d3fa497568d5b7c5e6dbcba228932660374939 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Thu, 14 Nov 2024 05:50:33 -0800 Subject: [PATCH] Add script for generating swing trading signals based on TRIN Thrusts strategy --- strategies/trin_thrusts.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 strategies/trin_thrusts.py diff --git a/strategies/trin_thrusts.py b/strategies/trin_thrusts.py new file mode 100644 index 0000000..b0178ea --- /dev/null +++ b/strategies/trin_thrusts.py @@ -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 \ No newline at end of file