The team teaches project proved to be a highly engaging and transformative experience, offering us the opportunity to not only explore our own research but also to draw inspiration and knowledge from our fellow students. It added a dynamic and exciting element to our traditional school routine.
In our role, we were tasked with teaching CB 3.9 and 3.15, where we delved deep into the fascinating realm of developing algorithms. This journey allowed us to blend together various elements we had encountered in our previous studies, including booleans, conditionals, and other fundamental programming concepts, to create sophisticated programs capable of tackling intricate tasks. The knowledge we acquired during this process wasn’t confined to theoretical understanding; we actively applied these newfound skills to our passion projects.
In particular, we harnessed the power of algorithms within our AI and optimizer projects. For our AI system, algorithms played a pivotal role in both training the AI and shaping its decision-making logic. We used these algorithms to analyze data and provide intelligent recommendations to users, based on a multitude of factors. Meanwhile, our optimizer project demonstrated the practical applications of algorithms in finance. It involved processing over 6000 possible weightings of stock portfolios to determine the most optimal investment choices. This complex task was made possible through the strategic implementation of algorithms.
# Example of Algorithms in the code that I created optiizer
# finding weights, return, volitilty, and sharpe ratio.
stocks = pd.concat([price['AAPL'], price['NVDA'], price['MSFT'], price['TSLA'], price['AMZN'], price['NFLX'], price['QCOM'], price['SBUX']], axis = 1)
log_ret = np.log(stocks/stocks.shift(1))
# setting up variables
np.random.seed(42)
num_ports = 6000
num_stocks = 8
all_weights = np.zeros((num_ports, len(stocks.columns)))
ret_arr = np.zeros(num_ports)
vol_arr = np.zeros(num_ports)
sharpe_arr = np.zeros(num_ports)
# going through all possible weights
for x in range(num_ports):
# Weights
weights = np.array(np.random.random(num_stocks))
weights = weights/np.sum(weights)
# Save weights
all_weights[x,:] = weights
# Expected return
ret_arr[x] = np.sum( (log_ret.mean() * weights * 252))
# Expected volatility
vol_arr[x] = np.sqrt(np.dot(weights.T, np.dot(log_ret.cov()*252, weights)))
# Sharpe Ratio
sharpe_arr[x] = ret_arr[x]/vol_arr[x]
Furthermore, the knowledge we gained from the other team teaches was invaluable and highly impactful. For example, the Boolean ‘if’ statement module served as a source of inspiration for our AI project. We employed ‘if’ statements to assess various technical indicators and determine whether it was advisable for individuals to invest in particular stocks.
# Example of Algorithms in the code that I created optiizer
# AI Code
priceCORR = price.corr()
colors = ['gold', 'red', 'blue', 'royalblue', 'black', 'purple', 'pink', 'green']
fig, ax = plt.subplots(figsize=(10, 6))
priceCORR.plot(kind='bar', stacked=True, ax=ax, color=colors)
ax.set_ylabel("Correlation", fontsize=12)
ax.set_xlabel("Stocks", fontsize=12)
ax.set_title("Correlation between Stocks", fontsize=16)
plt.legend(title='Stocks', loc='upper right')
plt.xticks(rotation=0) # Rotate x-axis labels if needed
plt.show()
# Finding average correlation to show profability of portfolio
averageCorr = price.corr()
averageCorrMean = averageCorr.mean()
averageCorrMean
column_sum = 0
# For loop to find the mean of the entire data table
for i in range(len(averageCorrMean)):
column_sum += averageCorrMean[i]
column_sum = column_sum/len(averageCorrMean)
column_sum
# Reading in the stocks of each stock and then creating a central data frame of each.
import numpy as np
import pandas as pd
import pandas_datareader.data as web
# Get stock data
all_data = {ticker: web.DataReader(ticker,'stooq')
for ticker in ['AAPL', 'NVDA', 'MSFT', 'TSLA', 'AMZN', 'NFLX', 'QCOM', 'SBUX']}
# Extract the 'Adjusted Closing Price'
price = pd.DataFrame({ticker: data['Close']
for ticker, data in all_data.items() })
The collaborative and multidisciplinary nature of the team teaches project allowed us to appreciate the interconnectedness of various concepts and disciplines, offering a unique and enriching learning experience that transcended traditional classroom boundaries. It not only enhanced our technical skills but also nurtured our ability to work as a team, share knowledge, and draw inspiration from our peers, making the project an unforgettable and transformative part of our educational journey.