Skip to content

Instantly share code, notes, and snippets.

View GrovesD2's full-sized avatar

Danny Groves GrovesD2

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@GrovesD2
GrovesD2 / trend_predictor.ipynb
Created October 29, 2023 17:01
A simple model for predicting today's trend in the SPY
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@GrovesD2
GrovesD2 / williams_r.ipynb
Created October 28, 2023 13:39
A backtest and parameter optimisation for the Williams %r strategy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import pandas as pd
import yfinance as yf
import matplotlib.pyplot as plt
def heat_smooth(
ts: np.array,
h: float,
k: float,
import numpy as np
import pandas as pd
import yfinance as yf
from dtaidistance import dtw
from plotly import graph_objects as go
from plotly.subplots import make_subplots
import plotly.io as pio
pio.renderers.default='svg'
import time
import numpy as np
import numba as nb
import pandas as pd
import yfinance as yf
import plotly.graph_objects as go
import plotly.io as pio
pio.renderers.default='svg'
import numpy as np
from scipy.optimize import minimize, LinearConstraint
def find_grad_intercept(case, x, y):
'''
Find the granient and intercept terms for the envelope trend line.
Note: case = 'above' or 'below'
'''
import numpy as np
import yfinance as yf
import scipy.stats as stats
from scipy.integrate import quad
from scipy.optimize import minimize
# Get the monthly price data for the SPY ticker
df = yf.download(
'SPY',
interval='1mo',
import streamlit as st
import streamlit.components.v1 as components
st.set_page_config(layout="wide")
def get_info_widget(
ticker: str = "AAPL",
theme: str = "dark",
):
import pandas as pd
import yfinance as yf
GROWTH_SINCE = '2021-12-01' # The lower date to calculate the stock performance
GROUPBY_COL = 'GICS Sector' # Use 'GICS Sector' or 'GICS Sub-Industry'
S_AND_P_URL = 'https://en.wikipedia.org/wiki/List_of_S%26P_500_companies'
NUM_PER_GROUP = 3 # The top n winning stocks per group
if __name__ == '__main__':