Posts

Progress Update 13

Image
    It has been 4 months since the last progress update and I want to highlight what has happened since then since as of writing this I completed a major milestone in making a nice trading algorithm. Since writing the last update, I have: Completed my 3rd semester of college Met Scott Juds (author of the book I was talking about in previous blog posts: Conquering The Seven Faces of Risk ) and learned a lot about true sector rotation theory Read a lot of books on creating technical trading systems such as Quantitative Trading Strategies  by Lars Kestner Created a key part that can be applied to any strategy I would want to test: a RSI divergence model all in Python code     The main thing I want to talk about on this progress update is the RSI divergence model that I completed late last night. For those of you that don't know what a RSI divergence is, it is where the RSI (Relative Strength Index) diverges either positively or negatively from price action. RSI div...

Progress Update 12

Image
    If you have been following along with my progress, first off let me say: I am very grateful that you are interested in my learning process involved with trying to build this trading algorithm over this summer. By all means, this isn't the final progress report/blog post and there will be more to come. The reason I am saying this is that my progress will be significantly slowed due to me going back to college. My main focus will be shifted back to school work and pursuing a Bachelor's of Science degree in Economics and (hopefully...) an Undergraduate degree in Finance.     This doesn't mean that I am done or finished with this little project of mine. I will  make small progress on the algorithm whenever I have some downtime in my college life. But it won't be anything near the progress that I have made during the last 2 months. I will  shift focus to this project during school breaks (Spring break, Winter break, etc.) if those situations allow me. B...

Progress Update 11

Image
    Interesting progress was made this week. I fixed my coding problem with the interactions between all the algorithm models that I discussed in the last update which allowed me to see the results of importing my strategy I created in TradingView's PineScript way back in Progress Update 3 . I read a lot more of my book, Conquering The Seven Faces of Risk  by Scott Juds  learning about strategies like differential signal processing between multiple assets to pick the "fastest horse".     Starting with what I did in QuantConnect this week. I fixed my code to make my algorithm execute versus running into Python runtime errors where I couldn't even see if my trading strategy was working or not. Despite talking about my usage of several models in my previous blog update, I decided to eliminate the complicated multi-model setup to just do everything in one model mostly inside the OnData() method. I did this because I was taking way too long trying to figure out ...

Progress Update 10

Image
    I just got back from a weekend getaway yesterday so now I am back to work. During this getaway, I brought my laptop and book Conquering The Seven Faces of Risk  by Scott Juds  to get some work done while away from my desk. I did more reading than coding this weekend so I learned a lot more from reading this book than I did making progress on coding on QuantConnect. So let me share a few things.     To start off of what progress I made in my coding, I started to make less progress today as I run into some compatibility issues. These issues are mainly coding issues with me trying to figure out how all of my Python classes will communicate with each other. Let me explain.     According to QuantConnect, a good trading algorithm consists of 5 models (Python classes) which all handle different parts of the algorithm. The diagram below from QuantConnect shows how these 5 parts interact with each other to create a trading algorithm.    ...

Progress Update 9

Image
    This week I got a lot done towards my ultimate goal of creating my SPY trading algorithm. Last week I just started using QuantConnect and made myself try and complete their "Boot Camp" that they had which is used to showcase what Python functions and development tools they offer. Yesterday I completed QuantConnect's Boot Camp which went over a variety of different strategies. Today I started to build the framework of my algorithm in QuantConnect's IDE (Integrated Development Environment) and continued reading Conquering The Seven Faces of Risk  by Scott M. Juds  which I started reading this week as well.     Now I'll be real, I most likely won't use most of the strategies that the Boot Camp taught me because they still stem from the "diversify & rebalance" views of Modern Portfolio Theory (MPT) which I basically discussed the flaws of it in the last blog update. Instead, I mainly saw the Boot Camp as a way to familiarize myself with QuantConn...

Progress Update 8

Image
     So this week, I got a significant amount of work done. I completed the "Analyze Financial Data with Python Skill Path" on Codecademy earlier today. Adding the certificate for the skill to my LinkedIn feels like I am collecting these skills like trading cards.      Completing this skill course was easier and a lot faster since some of the lessons were overlapping with the basic Python 3 course that I took before. So they were auto-completed before I even started the course.       The one thing about this skill course that I was looking forward to was learning how to pull and use data from financial APIs. But once I actually got to that section of the course, I started to question what exactly I expected of it before-hand. I guess I was slightly disappointed because I saw the keyword: financial APIs and immediately assumed that that was the "one-size-fits-all" skill I needed to create my trading algorithm. But it only was creatin...

Progress Update 7

Image
    It has been a few days since posting an update on my progress because I was cramming for the sake of cramming. My personal goal that I put on myself was that I wanted to complete Codecademy's Python 3 course in 1 week. As of yesterday, I have completed that goal and basically have learned a whole new programming language in 7 days.         It sounds impressive, but in the grand scheme of things, It doesn't really matter how fast I completed it. It matters how much of it I comprehended. But since this isn't my first programming language (Java was), I understand all of the programming concepts that Codecademy gave me in that course. I just wanted to push myself to learn it quick so I can get back on track to coding and implementing my trading strategy. Completing these courses is a small detour in this process of learning how to create a trading bot since I should have learned it before, but it is still part of the learning process.     As ...

Progress Update 6

Image
    Today I continued my Code Academy Python course and read more of Chapter 2: Great Trend Followers in Michael Covel's book: Trend Following .      I completed the 4th Python learning module about lists and I'm one coding project away from completing the 5th Python learning module about loops. Despite getting through less modules today, I am now 45% complete with the entire Python course. This can start to slow as I get near the end with all the harder concepts, but I am still aiming to complete the course before my 7-day trial.     In between coding breaks, I continued reading chapter 2 of Trend Following  because I previously skipped to chapter 10 about successful trading systems when I encountered a problem with developing my own trading system and needed help.      Since all of chapter 2 is about great trend followers, I learned about a few people who have developed great trading systems to consistently make them mon...

Progress Update 5: Starting Python

Image
    Yesterday, I ran into some programming problems with TradingView's PineScript. I have ran into some problems with PineScript leading up to yesterday, but this was completely absurd. My main algorithmic problem that I was trying to solve was the negating orders problem that I described in the last blog post. If my trading algorithm was capping it's losing trades and getting bigger winning trades, I want to encourage that by minimizing the amount of useless orders that go through. $0.01/contract fee doesn't sound like a lot, but hundreds of negating orders being put through over a 10.5 year back-test implies a lot of useless trades in which I just eat fees.     In the last blog post, I figured out why the problem was occurring, but then the task was to solve it. I thought about it for a while yesterday and finally came up with an efficient solution. The first step was to find a way to see the pending orders that sit there waiting to execute at the close of the 4 ho...

Progress Update 4

    Today my day was mainly spent reading Chapter 10: Trading Systems in the book Trend Following  by Michael Covel . Reading all about what makes a trading system profitable was useful information and I learned of real-world examples of why the system of trend following is the most profitable long term.     This chapter went over a few topics that I learned in my summer ECON200 Microeconomics course such as expected value and game theory. Covel talked a bit about Nash Equilibrium which I was the most intrigued by when I took my microeconomics course. If you don't know what Nash Equilibrium is, it's a concept in game theory where if you are rational and your opponent is rational, there is one optimal strategy. Applying this general concept to investing, Covel points out: "If we own some stock, and there is a possibility of a price decline, we are at risk. The stock is not the risk, nor is the loss the risk. The possibility of loss is the risk. As long as we own ...

Progress Update 3: What Should I Name My Hedge Fund?

Image
    Today I wrote down the estimated returns for both versions of my trading algorithm: longs and shorts allowed and longs only. Let me start this blog post off with a question: What should I name my hedge fund? The year over year returns are spectacular! Here is the data I mapped out on the public Google Sheets comparing the two versions of the algorithm to the normal SPY returns:     This isn't saying that the algorithm is 100% perfect. There is one option I thought of today while I was skating to try to tighten stop losses to previous bar closes and opens instead of previous bar's lows or highs. There is also one more problem with the algorithm that I do not know how to fix yet. This problem is where the algorithm will quickly open and close a position in the middle of a "trend-catching" position. The reason this "bug" doesn't significantly show up in the returns is because it opens and closes a position so quick that the realized P/L will be less tha...

Progress Update 2

     Today I dove deeper into the RSI-based strategy that I stumbled on yesterday. I wrote down potential changes that I could make to the code to have it perform better and started work on it. I removed most of the barrier conditions and variables to isolate the profit-maximizing factors that I found out yesterday: RSI with a simple moving average on top of it.     Before every potential change, I first found the optimal values of the basic underlying strategy and mapped out possible returns on different time frames starting on a 4 hour chart with 18,304.95% net profit in a quick 10.5 years (first trade started in January 2010 for the sample data).     As I made changes, I would map out possible returns on each time frame I was looking at. So today I only went through 4 major changes that overall affects the performance of the strategy. One of the changes that made a significant increase in returns is a "pattern-based" stop-loss instead of a percent-b...

Progress Update 1

Image
          As the first post of this blog, I would like to say that the reason behind creating this blog and publicly sharing my learning process in attempting to create a trading bot is strictly for educational uses only. If I create a successful automated trading strategy devoid of emotions, then I can try to use my own capital to deploy and test out the strategy. If I fail in creating a successful automated trading strategy, I will still pick up useful insights and skills that other people my age will not have. It is a win-win-win scenario. I win whether I fail or not, and you the reader win through learning along with me.      Today I continued working on the SPY strategy that is based on using moving averages and volatility-based indicators. When I finished coding and planning out the strategy that I wanted to do, I had a hard time figuring out why the strategy wasn't placing any buy or sell orders. I eventually found out that my "genius"...