Use ruff linter.

This commit is contained in:
sam
2024-11-16 14:07:24 -08:00
parent db45b14882
commit 47b2ce1476
2 changed files with 9 additions and 8 deletions
+3
View File
@@ -10,5 +10,8 @@ run *name:
fmt: fmt:
black ./*.py black ./*.py
lint:
ruff check ./model.py
clean: clean:
rm -f bitcoin_*.png bitcoin_*.txt rm -f bitcoin_*.png bitcoin_*.txt
+6 -8
View File
@@ -1,11 +1,9 @@
import pandas as pd import pandas as pd
import numpy as np import numpy as np
from datetime import datetime, timedelta from datetime import timedelta
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import seaborn as sns import seaborn as sns
from scipy.stats import norm from multiprocessing import Pool
from scipy.signal import savgol_filter
from multiprocessing import Process, Pool
# Utility functions # Utility functions
@@ -455,7 +453,7 @@ def create_plots(df, start=None, end=None, project_days=365):
plt.style.use("seaborn-v0_8") plt.style.use("seaborn-v0_8")
# Create figure with adjusted size for additional subplot # 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 # 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')})" 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 # Set up the plot
plt.style.use("seaborn-v0_8") 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 # Plot training data
heading_label = f'Historical Price (Training: {start_date.strftime("%Y-%m-%d")} to {backtest_date.strftime("%Y-%m-%d")})' 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): def run_projection(args):
df, start = 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): 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 # Sort periods by backtest date for clearer analysis
unique_periods.sort(key=lambda x: pd.Timestamp(x["backtest_date"])) unique_periods.sort(key=lambda x: pd.Timestamp(x["backtest_date"]))
print(f"\nRunning backtests with:") print("\nRunning backtests with:")
print( print(
f"- Start dates range: {unique_periods[0]['start_date']} to {unique_periods[-1]['start_date']}" f"- Start dates range: {unique_periods[0]['start_date']} to {unique_periods[-1]['start_date']}"
) )