Skip to content

Instantly share code, notes, and snippets.

View GrovesD2's full-sized avatar

Danny Groves GrovesD2

View GitHub Profile
import time
import random
import numba as nb
import numpy as np
import pandas as pd
from copy import deepcopy
# For type hinting
from typing import Tuple
import numpy as np
import pandas as pd
import yfinance as yf
from typing import Tuple
from copy import deepcopy
import plotly.io as pio
import plotly.graph_objects as go
pio.renderers.default='browser'
import numpy as np
import matplotlib.pyplot as plt
from scipy import sparse
from typing import Tuple
from copy import deepcopy
from scipy.ndimage import gaussian_filter
IMAGE = 'PATH_TO_JPG_IMAGE' # Include JPG image here!
import time
import random
import numba as nb
import numpy as np
import pandas as pd
import datetime as dt
from tqdm import tqdm
from copy import deepcopy
# For type hinting
'''
This code is a demonstration to show how you can accidentally slip in future
results to a time-series predicting neural network.
DO NOT USE THIS CODE FOR MAKING PREDICTIONS, IT'S FAULTY ON PURPOSE.
'''
import numba as nb
import numpy as np
import pandas as pd
'''
Simple Neural Network attempt for price prediction - it does not do a good job
at all and therefore SHOULD NOT BE USED FOR ANY REAL TRADING/INVESTING
'''
import numba as nb
import numpy as np
import pandas as pd
import yfinance as yf
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__':
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 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 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'
'''