Skip to main content

PnL.ai Intro


Part of my covid project and part of my long obsession with prediction markets, I have created a web page that displays and allows to compare best and worst performing trading strategies.

TL;DR: best stocks + best strategies -> the list of top and bottom performing trading algorithms. 

Product

Typically, trading newsletters and stock-scanners display only price return for top market gainers and losers. I have forever been interested in inspecting top and bottom performing trading strategies for a given set of securities and could not find any websites that do that. So, I decided to create a tool of my own.

I wanted the tool that would help me to answer questions like if there is a better strategy than buy and hold, should I follow greed and fear indicator of the market or do the opposite.

Top and bottom performing securities do not tell you if a stock is going to go up or down, but they do alert you to rapidly changing market conditions, such as change in the competitive landscape, impending lawsuits, changes in the company's management and, at the very least, the stocks you should avoid in your programmatic trading.

Top strategies do all that, but they can also alert you to a change in the market regime. For example, MACD strategy, which is a variant of oscillator strategy, executed on Citibank stock returned 20% in the first half of 2020. In the same time period, the Citibank stock went down and "BuyAndHold" strategy, which is pretty much what it sounds, lost 45%. Now, compare that to the end of 2020 through spring of 2021, when MACD lost 1% and "BuyAndHold" gained 70%. This happened due to the change in the market due to the rally in financial stocks at the end of 2020. The market player who detect change in the market conditions first will reap most benefits.

Another example, TSLA since the beginning of 2021 until end of April lost 7%. The StopLoss strategy sells the position after abrupt price drop and waits until the price returns to the level before the drop. For the same time interval the StopLoss strategy gained 10%. In this particular example, StopLoss outperformed BuyAndHold. See the graph and table results below.

To me personally, the most important feature is the ability to quickly tweak and modify trading strategies and observe change in their performance. You can change strategies parameters on the fly and even design your own custom trading strategy.

In the end, I developed a tool I can use for myself but hope other investors who are experimenting with trading algorithms will find it useful as well. I called it "Profit and Loss AI", or PnL.ai for short.

PnL.ai Description

The web-tool in the link below allows you to customize parameters of existing strategies and essentially create your own strategy and seeing how it will compare to the set of original strategies.

http://ec2-54-185-19-38.us-west-2.compute.amazonaws.com:5006/srv

  • In the section above you can specify security and data range.
  • In the section below you can choose strategy to customize and modify it's parameters.
  • The strategy comparison table will automatically update and will display a newly created strategy side by side with the original strategies.

Technology

The tool is developed on bokeh and python and allows you to edit configuration parameters of each strategy all without programming knowledge.

The strategies are fully specified via key/value pairs in the format of ini files used to initialize programs. The strategy classes are autogenerated by reading the ini config files dynamically using "factory" pattern.

You can find a simplified code in this github repo: https://github.com/varturas/PnlAITk

Next Steps

In the future I want to give users ability to monitor their chosen strategy by receiving trading algo alerts whenever performance of their custom trading algo is changes significantly.

I'm going to be adding more strategies, some of standard technical analysis variety and some will be more custom and more advanced. I'll also be adding more columns to the performance table to give better information.

You can receive daily newsletter with the list of trading strategies generated by above-mentioned web-tool by registering on http://pnl.ai/ and checking subscribe checkmark.




Comments

Popular posts from this blog

The Importance of Feedback in Societal and Political Systems

  The Importance of Feedback in Societal and Political Systems Synapsis :  Feedback mechanism just means learning from your mistakes. Losing this ability impairs individuals, societies, and nations from adapting and improving, ultimately jeopardizing their survival. Prolog In a constantly evolving world, complex systems—from individuals to governments—must adapt to remain relevant and effective. Systems that can incorporate feedback mechanisms are better equipped to withstand environmental stresses and maintain stability. Feedback allows these systems to adjust dynamically, improving their resilience against external challenges. Without it, a system risks becoming obsolete, overwhelmed by the rapid changes around it. A lack of feedback mechanisms results in stagnation, as systems disconnected from evolving realities lose their utility and purpose. Conversely, environments that are static and unchanging can similarly foster inertia, causing systems to decline in relevance and f...
  Reality Without Spooky Action: How Relational Quantum Mechanics and Quantum Darwinism Reframe Bell’s Paradox** The 90-Year-Old Problem That Refuses to Die Quantum mechanics works spectacularly well. It predicts spectra, semiconductors, lasers, and quantum computers. Yet since the 1930s, physicists have argued bitterly about what it says about reality itself . The dispute began with Einstein, Podolsky, and Rosen (EPR) . Their concern was simple and deeply physical: If physics is about reality, then distant things should have their own real states, independent of what we do elsewhere. Quantum mechanics seemed to violate that idea. When two particles are entangled, measuring one lets you predict the outcome of the other instantly, no matter how far apart they are. Einstein famously called this “spooky action at a distance.” Einstein was not objecting to randomness. He was objecting to the idea that reality itself might not be locally well defined . Bohr’s Answer — and W...