Use ruff linter.
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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']}"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user