How I Built A Robo Advisor From Scratch With Python

Ryan O'Connell, CFA, FRM · Advanced ·💰 FinTech & AI for Finance Professionals ·10:08 ·5y ago

Key Takeaways

Builds a robo advisor from scratch using Python

Full Transcript

hey guys today i'm going to be talking about one of my favorite personal projects which was building a portfolio builder robo advisor website from scratch um if you clicked on this video expecting some sort of coding tutorial on how to do this um then this is not the video for you but i will be happy to show you a general guideline but i don't want to give all my secrets away so let's take a quick look at the end result [Music] and here is the end result my website portfolio constructs.com so if i click here to generate the portfolio i'm going to be greeted with a few options so i decided to include three inputs so how many years of investment is this person going to take we'll say 10 years what's their starting portfolio value let's say they invest a hundred thousand dollars and i gave the option of a risk tolerance level very high high medium low and very low let's go right in the middle with a medium and then we'll hit submit so right now it's generating the portfolio and here's the outcome so it shows the person's inputs right here and then it shows what is the recommended etfs for them to put in this portfolio and the number of shares of each of these etfs and the total amount into each etf so if we add up all these values in the column to the right we'll actually end up with the 100 000 that was originally stated to be put in there you can see that the portfolio builder recommends a combination of equities bonds commodities real estate and cash and then also the person can see at the end what is their expected expense ratio and how much they would pay in total expenses over the course of the year if they did invest in this portfolio and what sort of dividend yield they could expect from this portfolio as well as the total amount of dividends that they might expect just based on the historicals and then it also aggregates and shows what was the what would this the return of this portfolio have been um if you had invested a week ago versus a month ago versus a year ago and versus five years ago and then finally the the etf builder shows what percentage of the portfolio was allocated to equities versus bonds versus commodities real estate and cash and one other thing i added that i think would be pretty useful is you can download a pdf report so i'm going to i'm going to show you and open this so and this is all totally free so the person can save this for the future i better fix that the person can save this for the future if they're wanting to see um what was the recommended portfolio at a later date i had some big decisions to mull over when i was writing the actual algorithm to build the etf portfolios one big classic computer science algorithm problem i ran into was when i'm building these model portfolios and then selecting the optimal portfolio how many portfolios should the algorithm actually build in the first place to choose from and so the more portfolios you build the better result you're likely going to have but also the more portfolios that you build the longer the process is going to take so i had to consider how long is someone going to be willing to sit behind a computer screen and watch their mouse spin before they click off so what i ultimately settled on was to have the algorithm make 100 different portfolios and then grade all the portfolios based on risk and return and then return the number one portfolio out of the 100 options that was the best for the person in question and so it kind of works by finding out three things about the person so i also had to decide about what inputs did i want to use and i kind of i went with a minimalist approach so i asked them how much money do they want to invest how many years do they want to invest and what's their risk tolerance on a scale of one to five five being the highest so i would decide which assets or the algorithm would decide which assets to allocate their money into based on what they said in the time horizon and the risk um tolerance metrics right so a longer time horizon you can take more risk a higher risk tolerance you can take more risk and so that's how i had the algorithm break up whether how much they're gonna have in equities versus bonds versus commodities versus real estate etc the first choice i had to make in this project was basically choosing which programming language i wanted to use for the actual portfolio builder and so i had three main options i was mulling over which was java python and c plus plus and i ultimately ended up going with python because it's the easiest and the quickest to actually write code in now it's supposed to have the slowest execution but for me i just wanted to get a product out there something that people could use as fast as possible and i sacrifice on execution speed um and i see the penalty of that because the program doesn't really handle portfolios over five million dollars so um i might have to go in and change some of this code in the future but it was quick and easy to set up by using python the next decision i had to make involved choosing the web framework so in python there's two main options which is the django and flask what i had read online was that django was actually better for handling large-scale projects so it was harder to set up in the first place but it had more capabilities and so i've really wanted a website that could handle a lot of different things and django was perfect because it allowed for easy integration with sql so the database management it allowed for an easy setup with blogs so i put some blogs out there and overall i would highly suggest django to anyone who's looking to build any sort of python based website or python based robo advisor product the next obstacle i had to face in this project was the front end now this was actually the toughest for me because up until this point most of my programming understanding was in the back end you know the more the math and algorithm side and so i wasn't totally sure what what to do with this so i started looking at some of these you know these like this dumbed down host like wix and i quickly realized that they weren't going to be able to handle a project like this that required an sql backend and they really limited me to all the plugins that they had so i i tried to start writing uh you know html and javascript and css from scratch and making a website from scratch and i quickly realized that this was going to be an insanely time consuming project so i know i said that i made this whole website from scratch i kind of cheated a little bit because i bought this uh template so there's some good websites out there that you can buy templates from that i would highly suggest buying a template instead of starting from scratch because it'll save you a ton of time and you can get one for like 10 the next big decision i was facing in this process was which data provider to use and i really learned that there are a lot of good data providers um for financial data that can be accessed relatively cheaply and i'll name a few of them off the top of my head that i like using one is iex cloud i made some videos on iex cloud on how to pull their live stock prices into uh both excel and python another one i like is yahoo finance with the in python it's got the the y finance package so so that's another good one and then there's a third one that i like which is a alpha vantage so they have their own api they can be accessed i believe for free um and so there's there's really a lot of options in this part of the process the final decision i had to make when all was said and done was to choose actual web hosting service provider so which service provider is going to put my website on the internet or and so i had a few choices i looked at bluehost as a traditional um you know hosting client and then i also looked at um ocean digital and aws as cloud hosts and ultimately i found that aws was probably the best i think there's a reason that almost everyone is now using aws and so when i was trying to launch my website on aws i found it incredibly confusing there's just so much going on with aws especially if you're wanting to integrate some sort of data pipeline into github so what i ultimately ended up doing was hiring an aws specialist on fiverr and and i would suggest anyone who's trying to launch their own website if there's something that's really taking you a ton of time and you're really getting stuck on you can probably find someone on like fiverr or freelancer.com that can do it for pretty cheap and it would be well worth it based on how much time you would spend like banging your head against the wall trying to figure it out but anyways if you enjoyed this video um please subscribe to the channel and maybe even check out my website with the etf portfolio builder letting me know what you think of it so thank you [Music] you

Original Description

How I Built A Robo Advisor From Scratch With Python by Ryan O'Connell, CFA, FRM *Columbia AI for Business & Finance ...
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related Reads

📰
This region wants to build Africa’s most connected fintech ecosystem
WAEMU aims to create Africa's most connected fintech ecosystem, addressing interoperability issues, and key stakeholders discuss the future of fintech in the region
TechCabal
📰
Why South African banks still charge for instant payments
South African banks' instant payment fees spark debate on customer transaction costs and pricing strategies
TechCabal
📰
Accrue targets African businesses with stablecoin-powered cross-border banking platform
Accrue's stablecoin-powered platform facilitates cross-border banking for African businesses, reflecting a shift in fintech approaches to international commerce
TechCabal
📰
Why “faster payments” is the wrong frame for stablecoins.
Learn why 'faster payments' is an outdated concept for stablecoins and how to reframe the conversation around risk management
Medium · Startup
Up next
Retirement Checklist: Check Off These 7 Things Before You Retire
Your Money, Your Wealth
Watch →