Skip to content

Instantly share code, notes, and snippets.

View quantra-go-algo's full-sized avatar

Algorithmic Trading quantra-go-algo

View GitHub Profile
@quantra-go-algo
quantra-go-algo / Pulling the data.py
Last active June 15, 2025 02:20
Creating Heatmap Using Python Seaborn v2 - Pulling the data
# Define a list of the tickers we are interested to observe
ticker_list = ['RELIANCE.NS','ADANIPOWER.NS','TCS.NS', 'HDFCBANK.NS', 'WIPRO.NS', 'HCLTECH.NS', 'KOTAKBANK.NS','INFY.NS','M&M.NS', 'BAJFINANCE.NS','ICICIBANK.NS']
# Define function to pull data from yahoo
def get_prices(tickers,start):
prices = yf.download(tickers, start=start, auto_adjust=False)['Adj Close']
return prices
prices_df = get_prices(ticker_list,start)
prices_df.shape
@quantra-go-algo
quantra-go-algo / Import the packages 2.py
Last active June 15, 2025 02:20
Creating Heatmap Using Python Seaborn v2 - Import the packages 2
# To work with the date
import datetime
# We will be working with pandas
import pandas as pd
# To pull the data from yahoo
import yfinance as yf
# To visualize the results
import matplotlib.pyplot as plt
import seaborn as sns
# Download the GBPUSD data from 2003 to 2013
data = yf.download('GBPUSD=X', start='2003-12-01', end='2023-10-06', auto_adjust=True, group_by='ticker')['GBPUSD=X']
# Compute the log returns
data['returns'] = np.log(data['Close']/data['Close'].shift(1))
# Print the data
data
# !pip install pyfolio-reloaded
# For data manipulation
import numpy as np
import pandas as pd
import yfinance as yf
import pyfolio as pf
from hmmlearn import hmm
from sklearn.utils import check_random_state
# Set the for loop
for i in range(1,len(monthly_index)):
print('='*100)
# Set the current month-end variable
current_month_end = monthly_index[(i-1)]
# Set the next month-end variable
next_month_end = monthly_index[i]
# Set the span from the previous to the next month end
span = len(data.loc[current_month_end:next_month_end,:].index)
from statsmodels.tsa.arima.model import ARIMA
pip install pandas numpy matplotlib statsmodels yfinance
pip install pandas statsmodels matplotlib
@quantra-go-algo
quantra-go-algo / install_talib.sh
Created February 2, 2021 06:03
Install TA-lib dependencies and Python wrapper
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz \
&& sudo tar -xzf ta-lib-0.4.0-src.tar.gz \
&& sudo rm ta-lib-0.4.0-src.tar.gz \
&& cd ta-lib/ \
&& sudo ./configure --prefix=/usr \
&& sudo make \
&& sudo make install \
&& cd ~ \
&& sudo rm -rf ta-lib/ \
&& pip install ta-lib
@quantra-go-algo
quantra-go-algo / predict_gold_etf.py
Last active November 19, 2024 05:52
Predicting the Gold ETF prices
# Predicting the Gold ETF prices
predicted_price = linear.predict(X_test)
predicted_price = pd.DataFrame(
predicted_price, index=y_test.index, columns=['price'])
predicted_price.plot(figsize=(10, 7))
y_test.plot()
plt.legend(['predicted_price', 'actual_price'])
plt.ylabel("Gold ETF Price")
plt.show()