Skip to content

Instantly share code, notes, and snippets.

import yfinance as yf
import datetime as dt
import warnings
import talib
import pandas as pd
import time
from yahoo_fin import stock_info as si
from scipy.stats import zscore
import numpy as np
@shashankvemuri
shashankvemuri / end.py
Created August 3, 2020 01:32
End of code
prices = df['Adj Close'].tolist()
first_price = prices[0]
new_col = [current_price, current_price, current_price, current_price, current_price, current_price]
if hold > 0:
holding = [['Buy and Hold', hold, 1, first_price, np.nan, hold, np.nan, hold, np.nan, np.inf, 1]]
else:
holding = [['Buy and Hold', hold, 1, first_price, np.nan, np.nan, hold, np.nan, hold, 0, 0]]
for signal in signals:
if signal.lower() == 'moving average':
print ('-'*60)
print ('Simple Moving Average: ')
# Let's calulate Simple Moving Average(SMA)
short_sma= 20
long_sma = 50
SMAs=[short_sma, long_sma]
for i in SMAs:
@shashankvemuri
shashankvemuri / start.py
Last active August 3, 2020 01:12
Start of the code
import numpy as np
import pandas as pd
import yfinance as yf
import datetime as dt
import matplotlib.pyplot as plt
import mplfinance as mpf
from finta import TA
from pylab import rcParams
from yahoo_fin import stock_info as si
import talib
@shashankvemuri
shashankvemuri / code.py
Last active February 3, 2021 09:25
Backtest Strategies using Python
import numpy as np
import pandas as pd
import yfinance as yf
import datetime as dt
import matplotlib.pyplot as plt
import mplfinance as mpf
from finta import TA
from pylab import rcParams
from yahoo_fin import stock_info as si
import talib
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>TradeView - Balance Sheet</title>
<script src="sort-table.js"></script>
<link rel="stylesheet" href="sort-table.css">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/build/pure-min.css" integrity="sha384-cg6SkqEOCV1NbJoCu11+bm0NvBRc8IYLRGXkmNrqUBfTjmMYwNKPWBTIKyw9mHNJ" crossorigin="anonymous">
@shashankvemuri
shashankvemuri / python.py
Created August 2, 2020 15:46
Python Code
import requests
import yahoo_fin.stock_info as si
from flask import render_template
def get_balance_sheet(ticker):
try:
def get_symbol(symbol):
url = "http://d.yimg.com/autoc.finance.yahoo.com/autoc?query={}&region=1&lang=en".format(symbol)
result = requests.get(url).json()
for x in result['ResultSet']['Result']:
@shashankvemuri
shashankvemuri / all.py
Last active November 13, 2022 05:17
all the code for the project
import yfinance as yf
import streamlit as st
import datetime
import talib
import ta
import pandas as pd
import requests
yf.pdr_override()
st.write("""
@shashankvemuri
shashankvemuri / rest.py
Last active August 8, 2020 06:50
Rest of code
# Adjusted Close Price
st.header(f"Adjusted Close Price\n {company_name}")
st.line_chart(data['Adj Close'])
# ## SMA and EMA
#Simple Moving Average
data['SMA'] = talib.SMA(data['Adj Close'], timeperiod = 20)
# Exponential Moving Average
data['EMA'] = talib.EMA(data['Adj Close'], timeperiod = 20)
@shashankvemuri
shashankvemuri / intro.py
Last active August 8, 2020 06:52
Introduction to the web app
st.write("""
# Technical Analysis Web Application
Shown below are the **Moving Average Crossovers**, **Bollinger Bands**, **MACD's**, **Commodity Channel Indexes**, and **Relative Strength Indexes** of any stock!
""")
st.sidebar.header('User Input Parameters')
today = datetime.date.today()
def user_input_features():
ticker = st.sidebar.text_input("Ticker", 'AAPL')