-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b662ab3
commit 95514a9
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import sys | ||
import os | ||
|
||
# Add src directory to the Python path | ||
src_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../src')) | ||
sys.path.append(src_path) | ||
|
||
import preprocessing as dp | ||
import indicat as ind | ||
import visual as vis | ||
|
||
# Example usage | ||
def main(): | ||
file_path = '../data/amazon.csv' | ||
data = dp.load_data(file_path) | ||
data = ind.calculate_indicators(data) | ||
vis.plot_moving_averages(data, 'Stock_price_moving_average.png') | ||
vis.plot_rsi(data, 'relative_strength_index.png') | ||
vis.plot_macd(data, 'macd_signals.png') | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pandas_ta as ta | ||
|
||
def calculate_indicators(data): | ||
"""Calculate technical indicators.""" | ||
data['SMA_50'] = ta.sma(data['Close'], length=50) | ||
data['SMA_200'] = ta.sma(data['Close'], length=200) | ||
data['RSI'] = ta.rsi(data['Close'], length=14) | ||
|
||
macd = ta.macd(data['Close'], fast=12, slow=26, signal=9) | ||
data['MACD'] = macd['MACD_12_26_9'] | ||
data['MACD_signal'] = macd['MACDs_12_26_9'] | ||
data['MACD_hist'] = macd['MACDh_12_26_9'] | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pandas_ta as ta | ||
|
||
def calculate_indicators(data): | ||
"""Calculate technical indicators.""" | ||
data['SMA_50'] = ta.sma(data['Close'], length=50) | ||
data['SMA_200'] = ta.sma(data['Close'], length=200) | ||
data['RSI'] = ta.rsi(data['Close'], length=14) | ||
|
||
macd = ta.macd(data['Close'], fast=12, slow=26, signal=9) | ||
data['MACD'] = macd['MACD_12_26_9'] | ||
data['MACD_signal'] = macd['MACDs_12_26_9'] | ||
data['MACD_hist'] = macd['MACDh_12_26_9'] | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pandas_ta as ta | ||
|
||
def calculate_indicators(data): | ||
"""Calculate technical indicators.""" | ||
data['SMA_50'] = ta.sma(data['Close'], length=50) | ||
data['SMA_200'] = ta.sma(data['Close'], length=200) | ||
data['RSI'] = ta.rsi(data['Close'], length=14) | ||
|
||
macd = ta.macd(data['Close'], fast=12, slow=26, signal=9) | ||
data['MACD'] = macd['MACD_12_26_9'] | ||
data['MACD_signal'] = macd['MACDs_12_26_9'] | ||
data['MACD_hist'] = macd['MACDh_12_26_9'] | ||
return data |