-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (28 loc) · 1.48 KB
/
Copy pathmain.py
File metadata and controls
35 lines (28 loc) · 1.48 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
import argparse
from stock_predictor import StockPredictor
def main():
parser = argparse.ArgumentParser(description='AI Stock Price Predictor')
parser.add_argument('--ticker', type=str, required=True, help='Stock ticker symbol')
parser.add_argument('--start_date', type=str, help='Start date (YYYY-MM-DD)')
parser.add_argument('--end_date', type=str, help='End date (YYYY-MM-DD)')
parser.add_argument('--prediction_days', type=int, default=60, help='Number of days to use for prediction')
parser.add_argument('--future_days', type=int, default=30, help='Number of days to predict into the future')
parser.add_argument('--epochs', type=int, default=25, help='Number of training epochs')
parser.add_argument('--batch_size', type=int, default=32, help='Batch size for training')
args = parser.parse_args()
# Create predictor
predictor = StockPredictor(
ticker=args.ticker,
start_date=args.start_date,
end_date=args.end_date,
prediction_days=args.prediction_days
)
print(f"Training model for {args.ticker}...")
predictor.train(epochs=args.epochs, batch_size=args.batch_size)
print(f"Predicting next {args.future_days} days...")
predictions, dates = predictor.plot_predictions(days=args.future_days)
print("\nPredicted prices for the next days:")
for date, price in zip(dates, predictions):
print(f"{date.strftime('%Y-%m-%d')}: ${price[0]:.2f}")
if __name__ == "__main__":
main()