Skip to content

The Magic of Subspells

Hey there, QuantMage enthusiasts!

Ever heard of a Subspell in the realm of QuantMage? It’s not just any term - it’s our special way of referring to an incantation used within another, needing its own spotlight (evaluating in isolation). Think of it as a supporting actor who steals the show! Subspells work within parent incantations like Filtered, Weighted(with inverse volatility weighting), If/Else, Enter/Exit, or Mixed. For the former two, any non-Ticker child of them is considered as a subspell. For the latter three, a subspell is introduced when you specify a subspell in place of an indicator symbol in one of its conditions. Sounds a bit like wizardry? Let’s dive into some real-world magic!

🚀 Quick Heads Up! Just a friendly reminder: everything we share here is for informational purposes. We’re not dishing out investment advice or nudging you to trade specific stocks. It’s always a great idea to do your research and maybe chat with a financial pro before you leap. Now, onto the fun stuff!

Volatility Subspell Rotator

Here’s a cool one. It uses Filtered with subspells to pick between two based on their 200-day volatility. To calculate this, each subspell is treated like its own entity. The two subspell incantations, both of which happen to be of If/Else in this case, are evaluated for trading as if each is its own spell. The aim? To potentially outperform simple diversification or sticking to a single spell. It’s like having a dynamic duo where you get the best of both worlds!

Subspell 60/40 Portfolio

This twist on the classic 60/40 Portfolio is something else. We’ve got Enter/Exit holding a subspell of Weighted, containing the 60/40 mix. The cool part? This subspell steps in as an indicator in both the entry and exit conditions as you can see from Subspell "Enter" used as an indicator symbol. Here the subspell is evaluated for trading in isolation, too, so that its prices and moving averages are obtained and used for the condition evaluation. It’s like having a secret escape route to a safer asset, aiming for a smoother ride in your investment journey. Enter/Exit can additionally use Subspell "Exit" and If/Else similarly supports Subspell "Then" and Subspell "Else". Subspell "From" and Subspell "To" also exist for Mixed.

Magic and Nuances

Subspells let you leverage a child incantation as if it’s a standalone spell. This brings a whole new layer of strategy, such as for sorting in Filtered or deciding when to hop in or out in Enter/Exit. But, there are some intricate details to keep in mind. First, daily trading is assumed for subspell evaluation, regardless of the spell’s trade setting. Second, they are always simulated, even in live trading. In other words, even if the spell is invested for live trading, its subspells are simulated (since they cannot be separately live-traded) and can deviate from hypothetical live results (if they were actually live-traded) in the same way a spell trading result can deviate from its backtest simulation. The last point is about the Enter/Exit incantation. It’s special in the sense that it requires a trading history, more specifically where the logic landed last time so that it can evaluate either entry condition or exit condition accordingly. When it’s used as part of a spell, but not as a subspell, which branches were visited last time is global in the scope of the whole spell. For instance, it’s possible that the relevant Enter/Exit is totally skipped by an upper logic last time, which is regarded as being in the “not entered” state when it comes to which condition of Enter/Exit should be checked for today. But, when it’s used as a subspell, last visited branches become local (i.e. only its entry branch and exit branch are considered) since it’s being evaluated in isolation. This can definitely incur a different behavior compared to when it’s used just as part of the whole spell. Please note that we’re talking about using it as a subspell itself, not as a parent of a subspell (like the second example above). Yes, it’s a bit meta and might seem like a brain-teaser, but as you play around with subspells, it’ll all start to click.

So, there you have it! Whether you’re just starting or you’re a seasoned QuantMage wizard, subspells open up a world of possibilities. Dive in, experiment, and who knows? You might just discover your next winning strategy. Happy spell-casting! 🧙📈