Sept. 16, 2020

The automation of a stock trading strategy appears at first glance as a simple process. You program what you think you might have done on a discretionary basis, except your computer can do it much faster and more often. You try to transfer to a program your acquired knowledge, understanding, logic, and trading methods by first simulating the outcome of your procedures over past market data.

Sept. 10, 2020

*The following was posted in a Quantopian Forum expressing **my point of view on the highlighted stock trading strategy.*

No one seems to be much concerned by the stock selection process used when it has a major role to play over the long term. First, let's set “long term” as 15 years or more. I would prefer 20-30+ years, but we do not have that much data available.

Sept. 1, 2020

A lot of emphasis was put on a payoff matrix equation (see my **last article**) to represent a long-term rebalancing stock portfolio. From it, we could estimate the number of trades the rebalancing might generate over the life of the portfolio. However, that was still only half of the solution. What was also needed was an estimate on the profitability of such a trading strategy. That part of the equation is more complicated and has a lot more than just one solution, even though, it too has a simple formulation.

Aug. 17, 2020

You start a stock portfolio with the intention of using scheduled rebalancing, meaning that the stocks in your portfolio are readjusted to a fixed weight on a yearly, monthly, or weekly basis. This portfolio management decision is simple, however, it does have ramifications.

An equal weight is easy to determine, it can be made proportional to the number of stocks *j* in the portfolio *w* = 1 / *j*. It does not say which stocks will be in your portfolio, only that the actual number of stocks will tend to *j* or less: → ≤ *j*. Fixing the number of stocks to be traded will also set the initial bet size which will depend on the available initial trading capital.

Aug. 4, 2020

*The following was posted in a Quantopian forum on a trading strategy I greatly modified in order to have it follow its payoff matrix equation directives. It is also the fifth walk-forward performed on this trend-following trading strategy over the past 3.5 months. The strategy used a leveraged adaptive exponential betting allocation function to increase its long-term performance.*

July 13, 2020

The following was posted in a Quantopian forum dealing with “Quality Companies in an Uptrend”. The **original strategy template** is available free for anyone to copy and use as they see fit. The trading strategy itself is fairly basic: it selects a set of the highest momentum stocks from top quality companies that are estimated to be in an uptrend. The assumption is made that such a trend would continue forward. The portfolio is rebalanced at the end of each month. Thereby, continuously chasing the higher momentum stocks. Nothing unreasonable about that proposition.

June 29, 2020

The way you design your stock trading strategy can force it to react in very specific ways. Pointing toward the need to gain a long-term portfolio management perspective since the primary objective of any strategy designer should be to structure these automated trading strategies so that they can, not only survive but also generate above-average returns over 20+ years. If you cannot achieve that, it is very simple: you failed. All you might have to help you is your skills, some math, and the analysis of past history.

June 25, 2020

The more you look at the stock market game, the more you realize you need to play for the long term even when you are making short-term trades. Also, the more you trade over the short term, the more those trades will be faced with random-like outcomes, and the more trades you will need to reach your long-term goals whatever they are. As if there was a contradiction in purpose and means to achieve those goals. Nonetheless, most often, it remains quantifiable. The presented equations will govern it all for some planned and preset strategies.

June 22, 2020

My last article: **Stock Trading Game - Gambling It Out** was making the point that stock prices could be considered as having the number of up and down days close to the equivalent of a coin toss. There was no need to look at thousands of stocks to validate this hypothesis. Even a small sample over an extended period of time would be more than sufficient to make that point. Nonetheless, some 21 years of data (5,473 trading days) was used to assess the general direction of the daily price movements and their long-term outcomes.

June 15, 2020

If you knew that if you played the stock market game and that you would win no matter what, even if it took a long time, would you not find the time and resources to play your expected winning game if you could?

June 10, 2020

You want to win the stock trading game, even with all its uncertainty. However, it should not be just winning it. It should also be with a higher purpose. Maybe, something like building up your own retirement fund or help someone else build theirs. One thing you should want, no matter what you do in managing that stock portfolio is to make sure you will win and make it so you outperform the expected long-term averages.

Outperforming the long-term averages is the only reason for you to undertake such a tasking endeavor yourself. Otherwise, simply buy a market average surrogate (such as SPY or some equivalent), or find someone that could do better than you which would have been more productive moneywise and with a lot less work.

June 4, 2020

A stock trading strategy can often be simplified to its most basic components, and there are not that many of them. In fact, maybe just two. Those trading strategies cannot be considered that complicated either if whatever their outcomes, they will end up as being the result of two numbers, namely: the number of trades executed over the life of the portfolio and the average net profit per trade. Due to the continuous trading, it transforms the expected portfolio profit problem into a long-term statistically driven and dynamic inventory management problem under uncertainty.

May 30, 2020

In this third installment, I would like to concentrate on the second part of the equation presented in my **previous post**. It is also where you can find an explanation for a trading strategy's overall return.

But first, a point to be made again, if your stock trading strategy is not built to last, what is it good for? Why build something and see it blow up in your face after a number of years? Wasn't your goal to build your retirement fund or someone else's, or build a legacy fund for some reason or other, and that it would, at the very least, have a positive ending value?

May 24, 2020

My last article (**The Inner Workings Of A Stock Trading Program - Part I**) stated that a single line of code was dictating the long-term behavior of a stock trading strategy. And that this scheduled rebalancing was sufficient to explain the number of trades that would be carried out over the life of this portfolio. In that article, the first part of the presented equation provided this estimate of the number of trades that would be performed over the years.

Other important observations could be directly extracted from the same equation. Having a portfolio's payoff matrix equation to explain an automated trading strategy implied that the outcome did, in fact, answer to mathematical functions. And that it is these mathematical functions that are driving the show.

May 22, 2020

My **last article** admitted that the trading strategy used was effectively trading on market noise. Even under those conditions, it could win and win big. It is surprising that, after such a statement, system designers were not in an uproar and making all those points that could be made to rebuke the claims. The article went even further by providing a portfolio payoff matrix equation which enabled making long-term estimates of the portfolio's future value.

May 18, 2020

My last series of articles (**The Portfolio Rebalancing Gambit, I, II, III**) was about a trading strategy that dealt with its long-term payoff matrix as if playing a game where some randomness appeared to prevail, and a lot of it did. Even in that kind of trading environment, the strategy was doing more than quite well.

A stock trading strategy operates quite differently than a long-term investment strategy. The latter is awaiting capital appreciation from reasonable investments for periods of 20-30+ years. Doing so, almost assuring itself of winning simply by holding most of the stock positions for long periods of time. As an example, see Berkshire Hathaway.

May 6, 2020

In my **previous article**, the point was made that you could win the game relatively easily simply by prescheduling your future trading activity based on your portfolio's initial set up. The portfolio value equation was put on the table with a reachable long-term objective giving a purpose to the whole process. You did it for your own retirement account or as some legacy fund you might want to leave behind or build a generational fund with philanthropic views. Those are things for you to decide. All I can do is help you design your long-term portfolio for whatever reason you may have.

I will build scenarios based on the portfolio payoff matrix equation presented in the prior two articles of this series (see related articles below). The purpose is to show the range of what you can do based on your own portfolio settings and long-term objectives and also show where's the money. I hope that with the examples provided you will be able to build your own and know what to expect based on your numbers.

May 3, 2020

Whatever your automated stock trading strategy, it needs a purpose, an objective. You need to plan for where you want to go and how you will get there. From my** previous article**, you can estimate how many trades will be executed without even writing a single line of code knowing you will be scheduling a periodic rebalancing procedure over your portfolio's life cycle.

This article continues in the same direction as the preceding ones (see related articles below), going from the endpoints and designing a trading strategy backward from the perspective of its long-term objectives. And then, redesign the trading strategy for going forward. All in the process of trying to answer the question:

**What does my trading strategy have to do to reach its long-term objectives?**

April 30, 2020

Often, we ignore the very structure we have given our automated stock trading strategies. We code them to behave in a certain way for as long as they will be executed. For example, in most Python programs showcased on Quantopian, we can find variants of the following line of code:

**schedule_function(rebalance, date_rules.month_start(), time_rules.market_open())**

It instructs the program to rebalance its portfolio the first trading day of each month as the market opens. That single line of code will execute, on its preset schedule, no matter what. Other programming languages would use a different syntax and wording to accomplish the same task.

April 24, 2020

We often design stock trading strategy simulations by first programming them on some economic notion and then observe the outcome. As if the trading procedures, over the long term, would resolve the appreciation problem all by themselves, when a more global view should be taken. The where you want to go and how far will it take you?

Most of it could be determined beforehand. More planning and a better outlook as to what you really want to do.

April 20, 2020

We design stock trading strategies simply to make money. The more the better. But it all has to be done within constraints of available capital and minimizing overall risks. Trading has a number of differences when compared to long-term investing in many regards. A trade, almost by definition, is seen as a short duration thing that can come out profitable or not. While in the long-term setting of investing, durability, appreciation and overall trends gain more importance. Short-term fluctuations are practically ignored while trading might live by them.

But whatever the trading strategy, it has some basic math to explain what it does. Not sophisticated math mind, as will be demonstrated here, but inherent structures nonetheless that are dependent on the how the trading is done. Most of the text that follows is about averages, and we can use these averages due to the large numbers that will be used. In all cases designing diversified portfolios with hundreds of stocks and thousands of other possibilities.

April 16, 2020

Usually, in designing automated stock trading portfolios, all the attention is put on the program's code. The trading procedures, the decision making, the gathering of relevant information that needs to be analyzed, interpreted, and acted upon. Often, our initial capital is a limiting factor just as our ability to extract a decent long-turn return.

Here, I will go about it in reverse. From the final objective, it will be to break down the trading strategy into what needs to be done to achieve these long-term returns. Something like starting from the end results and asking the question: how did we get here? Or more to the point: how could I get there? The “I” here is you.

April 13, 2020

The following is a post made on a Quantopian forum related to my recent articles on the subject of a portfolio's doubling time (see related files below).

I like the notion of doubling times for a portfolio. It indicates, on average, how much time was required for the portfolio to double in value. It is all a matter of the strategy's CAGR, its compounding rate.

April 9, 2020

I thought it might be an appropriate time to make a walk-forward test on the strategy presented in my January 8th article: **Financing Your Stock Trading Strategy** which showed a 16.9-year simulation with an ending date of 1919-11-29. It would make this new simulation a walk-forward, out-of-sample, test where the strategy would not have seen the last 3-month of market data.

March 31, 2020

My previous article dealt with **The Making Of A Stock Trading Strategy**'s mathematical backdrop. Designing automated trading strategies having for objective to prosper over the long term. There are a multitude of ways of doing so. A trading portfolio, even with its short-term vision, needs to view its final outcome in light of a long-term compounded return. This is where a portfolio's average doubling time takes some importance.

March 28, 2020

The making of an automated stock trading strategy is relatively simple. It is made of 3 distinct processes: selecting some stocks on some reasonable quantifiable assumptions, determining the logical trading rules and procedures that will be applied, and executing them. The trading process can be enclosed in a single do-while loop and be executed until reaching the end of the program, that it be up to a past or future date.

March 16, 2020

We can represent stock trading systems with equations and not necessarily know that much about their future market returns, except general expectations and/or educated guesses. However, with these equations we can determine what is needed, over the long term, to trade and win.

Jan. 24, 2020

This is a follow-up to my **last article**, an attempt to answer the question: can you do more?

Two of the most important traits of any stock trading strategy should be its durability and its scalability. The first so that the strategy does not blow up in your face during the entire trading interval, and the second so that a portfolio can grow big.

Jan. 8, 2020

In my **previous article** was shown 17 simulation results of a **stock trading strategy** as found on the Quantopian website. On that basic template, I added optional functions in order to increase and control performance.

This intermediary step is part of my analysis of the strategy's worthiness since I am still exploring its capabilities: limits, strengths, and weaknesses. I present 12 new simulations using 160 stocks.