From 47b2ce1476f70e1c2a2ef7ca7dd231cf182778d2 Mon Sep 17 00:00:00 2001 From: Sam Fredrickson Date: Sat, 16 Nov 2024 14:07:24 -0800 Subject: [PATCH] Use ruff linter. --- justfile | 3 +++ model.py | 14 ++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/justfile b/justfile index d7ea2da..2924b35 100644 --- a/justfile +++ b/justfile @@ -10,5 +10,8 @@ run *name: fmt: black ./*.py +lint: + ruff check ./model.py + clean: rm -f bitcoin_*.png bitcoin_*.txt diff --git a/model.py b/model.py index bfd4abc..6e25075 100644 --- a/model.py +++ b/model.py @@ -1,11 +1,9 @@ import pandas as pd import numpy as np -from datetime import datetime, timedelta +from datetime import timedelta import matplotlib.pyplot as plt import seaborn as sns -from scipy.stats import norm -from scipy.signal import savgol_filter -from multiprocessing import Process, Pool +from multiprocessing import Pool # Utility functions @@ -455,7 +453,7 @@ def create_plots(df, start=None, end=None, project_days=365): plt.style.use("seaborn-v0_8") # Create figure with adjusted size for additional subplot - fig = plt.figure(figsize=(15, 15)) # Increased height to accommodate new subplot + _ = plt.figure(figsize=(15, 15)) # Increased height to accommodate new subplot # Date range for titles hist_date_range = f" ({plot_df['Date'].min().strftime('%Y-%m-%d')} to {plot_df['Date'].max().strftime('%Y-%m-%d')})" @@ -850,7 +848,7 @@ def create_backtest_plot( # Set up the plot plt.style.use("seaborn-v0_8") - fig, ax = plt.figure(figsize=(15, 10)), plt.gca() + _, ax = plt.figure(figsize=(15, 10)), plt.gca() # Plot training data heading_label = f'Historical Price (Training: {start_date.strftime("%Y-%m-%d")} to {backtest_date.strftime("%Y-%m-%d")})' @@ -1015,7 +1013,7 @@ def create_backtest_plot( def run_projection(args): df, start = args - projections = create_plots(df, start=start, project_days=365 * 4) + _ = create_plots(df, start=start, project_days=365 * 4) def run_projections(df): @@ -1205,7 +1203,7 @@ def run_systematic_backtests(df, validation_years=1, min_training_years=8): # Sort periods by backtest date for clearer analysis unique_periods.sort(key=lambda x: pd.Timestamp(x["backtest_date"])) - print(f"\nRunning backtests with:") + print("\nRunning backtests with:") print( f"- Start dates range: {unique_periods[0]['start_date']} to {unique_periods[-1]['start_date']}" )