Mar 23, 2023 9 MIN

Meet Darren Lee

How I #LearnedToCode Using OpenBB: Follow Darren Lee's journey from being a complete nOOb to actively contributing code in less than two years! If this former carpenter and recovering musician can, #learntocode, anyone curious enough to get started with Python for finance can too.

blog hero

Hi, everybody! You might already know me, as Danglewood#1001, from the OpenBB Discord, or from replies to inbound support requests. My real name is, Darren Lee, and it's a pleasure to know you.

Troy McClure you might remember from...

What you may not know about me is that the only reason I know any Python code is from being an active user of the OpenBB products, getting a little help from our friends along the way. I went from being a complete nOOb to actively contributing code in less than two years. If this former carpenter and recovering musician can, #learntocode, anyone curious enough to get started with Python for finance can too. Today, I want to share a little bit about my journey, from working a hammer on movie sets, to hammering out Python scripts for equity market analysis.

Darren laying down in the grass with his vintage guitar

If you were to ask me two-or-more years ago what I would be doing today, I would never have guessed it. Participating in group efforts and just saying "yes" to opportunities can go long way in life. I am happy report that working from home is indeed a great luxury. No more rush-hour rat-race. No more spending two hours of my day commuting. No more filling up the gas tank every week. Being stuck in traffic is one of humanity's greatest time-sucks. Trust me, never take the subway in Gotham City if you need to be on time; the forklift driver may disappear at any moment.

Gotham City Subway

Two years ago, while looking for an alternative way to go about personal financial research, I came across the GameStonk Terminal. Being a child of the MS-DOS command-prompt era of computing, I was drawn in by the nostalgia of it. The experience of working twenty browser tabs across multiple sites - with ads galore - was not appealing to me, and Didier was on a mission to build away from all of that noise. I could identify with the problem he was trying to solve. After witnessing the inspiring, relentless, work ethic and dedication to the project, I could tell there was something unique happening. Back then, the only way for me to contribute was to use the product and evangelize it to those willing to listen; so that's what I did. I joined Reddit and started an organic karma farm, planting OpenBB seeds. It was a bumper crop year.

I spent a long while plowing through the hundreds of functions, staring at the code, and attempting to understand how all the parts came together. The more I used it and got to know it, the more I began to love it. Things started clicking with enough exposure to the variety of one-liner functions responsible for collecting and processing the data, and hunting bugs down across the Terminal. I started noticing the similarities, and because Python is based in natural language, it is digestible and readable as a human.

if x > y:
    perform_this_function()
else:
    print('Y is greater than x, enjoy your burrito.')

After some time, I advanced from knowing nothing about the problem at hand, to breaking it down into smaller pieces, and then determining whether or not I can resolve any items - which, in most cases, was no. I may not be able to resolve issues at this point; but, I have been empowered with the ability to describe errors or bugs more efficiently, and can now document the issue with some actionable information.

Necessity is the mother of invention, as the saying goes, so when a workflow gets interrupted by a bug or behavioural quirk, it may turn out to be easier than expected to fix. A bug can be as simple as a typo, a single character. If a non-critical issue from a deep-in-the-weeds function is broken, it will not be repaired with the same priority as a core function. This is just the reality of being a large project with only a small team of core engineers. The beautiful thing about open source is that anyone can step in and fix it.

When facing this dilemma, tackling the issue personally may become necessary - as in, dive in and learn to swim. This is where the real learning happens. The question was initially, why does this not work? Evolved, it became, how can I get this to work? Which grew up to be, what are the required steps in order to make this work?

Using this type of framework to dabble in Python takes a large, complex ,subject (the Python language), and reduces the focus to cover only the parts necessary to get the job done. There is a lot which you do not need to know about Python in order to work with and analyze data, so it was refreshing to encounter the Minimum Viable Python (MVP) approach being taught by, PyQuantNews. Only learn what you need to. There are a lot of Python tutorials out there, and some are even for finance, but it is surprisingly difficult to find relevant material that is copy/paste-friendly.

You can search StackOverflow for an answer and get ten different ways to do the same thing, where none of them are relatable to the task at hand. It's very easy to come away from the site being more confused than before. So finding immediately usable snippets of code turned out to be a game-changer.

Seeing it work in front of my eyes, with each code block explained, opened the door to putting two-and-two together. I didn't need to understand everything in order to get something out of it. Best of all, they are using OpenBB! As far as I was aware, there were not many - if any - formal instruction materials specifically using the OpenBB SDK as an integral library. I can learn Python for finance in context with OpenBB? Yes, please, I'm in.

# Sample code from: https://pyquantnews.com/use-kelly-criterion-optimal-position-sizing

%matplotlib inline
from openbb_terminal.sdk import openbb

import numpy as np

from scipy.optimize import minimize_scalar
from scipy.integrate import quad
from scipy.stats import norm

annual_returns = (
    openbb.economy.index(
        ["^GSPC"], 
        start_date="1950-01-01", 
        column="Close"
    )
    .resample("A")
    .last()
    .pct_change()
    .dropna()
)

return_params = (
    annual_returns["^GSPC"]
    .rolling(25)
    .agg(["mean", "std"])
    .dropna()
)

annual_returns.head(3)
Date^GSPC
1951-12-31 00:00:000.163485
1952-12-31 00:00:000.117796
1953-12-31 00:00:00-0.0662401

For a novice, there is a lot to take away from just this one snippet. Most importantly, it provided a framework for making it my own. It becomes a playground for experimentation through the alteration of variables and inputs, seeing the immediate impact of any change; a template to insert into any workflow.

The rise of the code-completion AI tools gives beginners an easier-than-ever on-ramp into the world of Python. Jupyter Notebooks are very powerful tools for shortening the learning curve. Hovering the mouse over a function reveals all its secrets, removing the guess-work from experimentation. I highly recommend using a workspace like Jupyter or VS Code and leaning on this functionality to accelerate the learning process.

Docstrings in VS

The library of code examples shared by PyQuantNews are an invaluable resource for anyone new to either, Python or finance. The communication is clear, concise, and it leaves you with the framework to begin answering your own questions. It was eye-opening because it explained complex subjects in a boiled-down format digestible by any level of user. The integration of OpenBB into the learning process won my heart, and I wanted more, so I signed up for the 30-day boot camp, Getting Started with Python for Quant Finance.

I wanted to take the course for a few reasons:

  • To up my skills.

  • To be better equipped to support developers and ML/Quants.

  • OpenBB SDK will be used throughout the course, I want to experience an outsider demonstrating the product and on-boarding users.

  • To get the notebooks.

  • Meet some like-minded individuals.

The course did not disappoint, and the surrounding community was one of the best unexpected benefits. Everyone was in it together, helpful, and kind to each other. It gave you a place to fail gracefully, to get help, and to improve so that you could build the confidence needed to share your code with the world.

The course covered a lot of ground, from basics all the way to complex backtesting strategies and risk analysis. In upcoming posts, I will dive into applying what was learned and demonstrate how to get started contributing code to the project. Every day the platform continues its rapid evolution I become even more passionate about spreading the gospel of OpenBB. I wake up #bullish every morning because of how inspiring it is. I take great joy in seeing all the derived creations that our community members create, be sure to tag OpenBB when you share them!

Click here to find out more about Getting Started with Python for Quant Finance.

Click here to see what people are building in public with OpenBB.

Explore the
Terminal Pro


We use cookies

This website uses cookies to meausure and improve your user experience.