Zorro

Posted on Jun 01, 2020 by Kris Longmore
1 Comment.
0 Views

Anyone that's been around the markets knows that the monthly release of the United States Department of Labor's Non-Farm Payrolls (NFP) data can have a tremendous impact, especially in the short term. NFP is a snapshot of the state of the employment situation in the US, representing the total number of paid workers, excluding farm employees and public servants. We know your barn is hiding a giant mining station, Rick The release of the monthly NFP data typically causes large swings in the currency markets, even when the results are in line with estimates. Here, we are interested in exploring potential seasonal effects around the release of this data. For example, does price tend to drift prior to the release? If so, which way?   For this analysis, we'll explore the EUR/USD exchange rate. To set up this research problem, we need to know that NFP is released on the first Friday of the month at 8:30am ET - usually. If the first Friday is a holiday, NFP is released the following Friday. These sorts of details can make seasonal analysis...

Posted on Apr 16, 2020 by Kris Longmore
3 comments.
0 Views

One of the keys to running a successful systematic trading business is a relentless focus on high return-on-investment activities. High ROI activities include: Implementing new trading strategies within a proven framework. An example might be to implement a portfolio of pairs trades in the equity market. Scaling existing strategies to new instruments or markets. For example, porting the pair trading setup to a different international equity market. Well planned iterative research, set up in such a way that you can test and invalidate ideas quickly. This is the kind of research we show in our Bootcamps. Low ROI activities include: Large scale data mining exercises or any research that requires significant effort be expended before the idea can be invalidated. Looking for unique alpha ideas when you could be implementing simple trades within a proven framework. Building your own backtesting platform[footnote]You probably think you’ll learn a ton doing this and you’re not wrong about that – but it’s going to suck a huge amount of your time on something that you can buy in cost-effectively.[/footnote] Building your own execution platform[footnote]Ditto.[/footnote]...

Posted on Oct 16, 2019 by Kris Longmore
2 comments.
0 Views

In the first three posts of this mini-series on pairs trading with Zorro and R, we: Implemented a Kalman filter in R Implemented a simple pairs trading algorithm in Zorro Connected Zorro and R and exchanged data between the two platforms In this fourth and final post, we're going to put it all together and develop a pairs trading script that uses Zorro for all the simulation aspects (data handling, position tracking, performance reporting and the like) and our Kalman implementation for updating the hedge ratio in real-time. You can download the exact script used in this post for free down at the very bottom. Let's go! Step 1: Encapsulate our Kalman routine in a function Encapsulating our Kalman routine in a function makes it easy to call from our Zorro script - it reduces the call to a single line of code. Save the following R script, which implements the iterative Kalman operations using data sent from Zorro, in your Zorro strategy folder: ###### KALMAN FILTER ####### delta <- 0.0001 Vw <- delta/(1-delta)*diag(2) Ve <- 0.01 R <- matrix(rep(0,...

Posted on Oct 03, 2019 by Kris Longmore
2 comments.
0 Views

In the last two posts, we implemented a Kalman filter in R for calculating a dynamic hedge ratio, and presented a Zorro script for backtesting and trading price-based spreads using a static hedge ratio. The goal is to get the best of both worlds and use our dynamic hedge ratio within the Zorro script. Rather than implement the Kalman filter in Lite-C, it's much easier to make use of Zorro's R bridge, which facilitates easy communication between the two applications. In this post, we'll provide a walk-through of configuring Zorro and R to exchange data with one another. Why integrate Zorro and R? While Zorro and R are useful as standalone tools, they have different strengths and weaknesses. Zorro was built to simulate trading strategies, and it does this very well. It’s fast and accurate. It lets you focus on your strategies by handling the nuts and bolts of simulation behind the scenes. It implements various tools of interest to traders, such as portfolio optimization and walk-forward analysis, and was designed to prevent common bugs, like lookahead bias. Zorro does...

Posted on Sep 25, 2019 by Kris Longmore
3 comments.
0 Views

In our previous post, we looked into implementing a Kalman filter in R for calculating the hedge ratio in a pairs trading strategy. You know, light reading... We saw that while R makes it easy to implement a relatively advanced algorithm like the Kalman filter, there are drawbacks to using it as a backtesting tool. Setting up anything more advanced than the simplest possible vectorised backtesting framework is tough going and error-prone. Plus, it certainly isn't simple to experiment with strategy design - for instance, incorporating costs, trading at multiple levels, using a timed exit, or incorporating other trade filters. To be fair, there are good native R backtesting solutions, such as Quantstrat. But in my experience none of them let you experiment as efficiently as the Zorro platform. And as an independent trader, the ability to move fast - writing proof of concept backtests, invalidating bad ideas, exploring good ones in detail, and ultimately moving to production efficiently - is quite literally a superpower. I've already invalidated 3 ideas since starting this post The downside with Zorro is that...

Posted on Sep 13, 2019 by Michael M
2 comments.
0 Views

Chart patterns have long been a favourite of the technical analysis community. Triangles, flags, pennants, cups, heads and shoulders.... Name a shape, someone somewhere is using it to predict market behaviour. But, we need to find out if there is a grain of truth or reliability in these patterns. Can attempts to objectively measure these patterns, such as with the Frechet distance, really give you a hint as to the future direction of the market? Or should you stick to an approach we know makes money? ah, I see a blue star pattern on my chart... a good omen. The problem is that such an approach is inherently subjective since price action almost never matches perfectly with the idealized version of price patterns you see in every beginner's guide to trading. It is up to you, the individual, to determine whether a particular chart formation matches closely enough with a particular pattern for it to be considered valid. This is quite tricky! It's very difficult to codify a trading system based on their use. By extension, it is difficult to test...

Posted on Sep 03, 2019 by Michael M
No Comments.
0 Views

In part 1 of this series, we talked about how a market-savvy systematic trader would approach a period of drawdown in a trading strategy. Specifically, they'd: do the best job possible of designing and building their trading strategy to be robust to a range of future market conditions chill out and let the strategy do its thing, understanding that drawdowns are business-as-usual go and look for other opportunities to trade. Of course, at some point, you have to retire strategies. Alpha doesn't persist forever. In our own trading, we don't systematise this decision process. We weigh up the evidence and make discretionary judgements. All things being equal we tend to allow things a lot of space to work out. However, in this post, we review a systematic approach which can aid this decision making... In particular, we concentrate on the following question: "what is the difference between the empirical distributions of live and backtested returns?" Let's dive in and explore The Cold Blood Index! Becoming Cold-Blooded.... Johan Lotter, the brains behind the Zorro development platform, proposed an empirical approach to...

Posted on Jun 19, 2019 by Kris Longmore
12 comments.
0 Views

Before you commit your precious time to read this post on Shannon Entropy, I need to warn you that this is one of those posts that market nerds like myself will get a kick out of, but which probably won't add much of practical value to your trading. The purpose of this post is to scratch the surface of the markets from an information theoretic perspective, using tools developed by none other than the father of the digital age, Claude Shannon. Specifically, we're going to tinker with the concept of Shannon Entropy. Shannon (the man, not the entropy) was one of those annoying people that excels at everything he touches. Most notably, he was the first to describe the theory of electrical circuit design (in his Master's thesis at the age of 21, no less). Later, around 1948, he discovered Information Theory, which leverages his unique-at-the-time understanding that computers could express numbers, words, pictures, even audio and video as strings of binary digits. Not being one to let his genius go to waste, he and his buddy Ed Thorpe secretly...

Posted on May 31, 2019 by Kris Longmore
1 Comment.
0 Views

If you've ever delved into the world of retail foreign exchange trading, you'll have come across the MetaTrader platform. Let's be clear. The platform has its drawbacks. If you've traded "grown-up" markets, some of the features will leave you scratching your head. But one thing's for sure - MetaTrader provides fast, convenient access to pretty much every retail forex broker on the planet. That's no small thing. If we had the choice, we'd rather trade directly with the broker through a dedicated API rather than through a third-party platform, but often that's not an option. One thing that my life as a trader has taught me is that it's better to move fast in order to get trading strategies into the market with a solution that's "good enough" rather than spending valuable R&D time on developing "optimal" solutions - which usually end up changing anyway. So we suck it up and make the best of the tools at our disposal. It's all about being smart with priorities. We do our Spot FX trading through Darwinex. Not only is their business...

Posted on Jul 10, 2018 by Kris Longmore
1 Comment.
0 Views

One of the ongoing research projects inside the Robot Wealth community involves an FX strategy with some multi-week hold periods. Such a strategy can be significantly impacted by the swap, or the cost of financing the position. These costs change over time, and we decided that for the sake of more accurate simulations, we would incorporate these changes into our backtests. This post shows you how to simulate variable FX swaps in both Python and the Zorro trading automation software platform. What is Swap? The swap (also called the roll) is the cost of financing an FX position. It is typically derived from the central bank interest rate differential of the two currencies in the exchange rate being traded, plus some additional fee for your broker. Most brokers apply it on a daily basis, and typically apply three times the regular amount on a Wednesday to account for the weekend. Swap can be both credited to and debited from a trader's account, depending on the actual position taken. Why is it Important? Swap can have a big impact on strategies...