Beth  Nabimanya

Beth Nabimanya

1622491200

Algorithmic Trading Models — Cyclical Methods

If you enjoyed this content, I’m launching a new algorithmic finance newsletter, called Algo Fin, that you might be interested in. This newsletter will explore the connection between data science and finance, with an initial focus on the currency markets, but I hope to build many more avenues in the future. The newsletter is free to join currently as I am still planning a launch for paid subscribers, so if this sounds like something you might be interested in, its definitely worth checking out here!.

In the fourth article of this series, we will continue to summarise a collection of commonly used technical analysis trading models that will steadily increase in mathematical and computational complexity. Typically, these models are likely to be most effective around fluctuating or periodic instruments, such as forex pairs or commodities, which is what I have backtested them on. The aim behind each of these models is that they should be objective and systematic i.e. we should be able to translate them into a trading bot that will check some conditions at the start of each time period and make a decision if a buy or sell order should be posted or whether an already open trade should be closed.

Please note that not all of these trading models are successful. In fact, a large number of them were unsuccessful. This summaries series has the sole objective of describing the theory behind different types of trading models and is not financial advice as to how you should trade. If you do take some inspiration from these articles, however, and do decide to build a trading bot of your own, make sure that you properly backtest your strategies, on both in and out of sample data and also in dummy accounts with live data. I will cover these definitions and my testing strategies in a later article.

TheoryIn signal processing, a filter is a device that removes “unwanted” components from a signal. It removes certain frequencies from the signal that are considered background noise in order to paint a clearer picture of the true underlying signal.The are four broad types of filters and they are defined by the types of frequencies they allow to pass through and those that they therefore exclude.

  • low pass filter will, as the name suggests, allow low frequencies to pass through and reduce the significance of the higher frequenciesA high pass filter will do the opposite, allowing high frequencies to pass through and reducing low-frequency impactA bandpass filter will allow frequencies to pass through that are within a pre-defined band. We supply a minimum and maximum frequency value to our filter and it will only keep those values that fall withinA band stop filter also requires a minimum and maximum value, but will pass all frequencies that are either greater than the maximum or lower than the minimum, essentially all the frequencies a bandpass filter would not allow

_There are, of course, more sophisticated types such as notch filters (filters than reject a specific frequency) or comb filters (a series of regularly spaced band filters), but for the purpose of introducing this topic, we will stick to the fundamental concepts._ApplicationThe Butterworth filter was first introduced by the physicist Stephen Butterworth in 1930. I won’t go into all the technicals of how this filter works, but the most important feature about it is that it is a low pass filter. The Butterworth filter aims to produce an output that is as flat as possible, ignoring the high frequencies and returning the lower ones. It has been found that this filter is an ideal one for use in the world of forex trading because we want to see the general underlying “low frequency” cycles. We want to remove the high-frequency movements, as this is what we might consider as just noise.

_When we look at a chart, we start to see the scope for where this might have an application. As you can see, in the GBP/USD closing prices for the last 18 years, we see a lot of minor fluctuations around general price trends. If we were long or medium-term traders, we wouldn’t be interested in these fluctuations occurring around the trend, but we want the trend itself. One method to see the underlying trend is to use a moving average, which is useful, but is also a lagging indicator. The benefit of a filter is that it removes frequencies in real-time. We can see trend continuations and reversals immediately, making it easier for us to make trading decisions as close to these changes as possible.Python’s SciPy package has an option for us to easily run a Butterworth filter. You can find the documentation _here, but if you don’t come from a Physics background, you can look at the unknown values as parameters that we have the option to tune.

Naturally, our frequency cutoff must be less than our frequency value, but it is these two values and the order of the filter (the first argument to the signal.butter() method) that we have the opportunity to tweak. To find the best set of frequencies, cutoffs and order is simply a case of testing different values and finding the one that best follows our data. Plotting the output against the closing price will our visual measurement for how well our model performs. If we wanted a more mathematical evaluation, we could look at the correlation or R² value between our two variables.

#algorithms #forex #algorithmic-trading

What is GEEK

Buddha Community

Algorithmic Trading Models — Cyclical Methods

How I Made a 65% ROI with this Boeing Trading Algorithm

Since the market crashed in March of 2020 the rebound has been swift and irrational.

Boeing, for example, is in many ways worse off than it was in March.

It’s clear air travel has plummeted and that airlines will be impacted for

years. Where will airlines get the money to purchase planes?

An example of one headline in April: “Boeing customers cancel staggering 150 Max plane orders”.

Buy the dip?

One thing I’ve noticed is that since the end of March you can

basically just buy every dip and expect a pop, selling the next day. I

mentioned this to a friend on Friday and decided to backtest it.

Well, sure enough it works!

I’ll mention I made one modification. Originally I wrote the system like so:

1. Check if Boeing is down more than 3% 15 minutes from close

2. If yes, buy with 100% of portfolio

3. The next day, 15 minutes from open liquidate the portfolio.

This worked OK. Great actually! It returned about 25%. But want to know what really kicked it up a notch?

Instead of just selling the next day, I only sell if the position is

sitting at a realized gain. So e.g. if the next day its flat or drops

another 1%, don’t sell it, just keep holding on until its up and THEN

sell. Of course, this is completely insane and you would have to expect

the market to only go up, but that’s what has been happening.

Guess what? This simple system returned a whopping 65% in two-ish months. Yeah, I know, crazy.

Check out the backtest screenshot:

And here are the raw trading logs for those that want to see the dates the trades were made:

Here is the code!

Before we look at the code, I’ll just mention here are the details of the backtest:

  • start with 100k in cash

  • start at April first and go until last Friday (June 19th 2020)

  • end up with about 165k or a 65% return.

I wrote this little script on Quant Connect. The screenshot at the

top of the page is the backtest result, and the code below is everything you need to try this out.

Note the place I mentioned in the code you should comment if you want this to be a little bit less insane.

#algorithmic-trading #trading #python #algorithms #trading-algorithms

Beth  Nabimanya

Beth Nabimanya

1622491200

Algorithmic Trading Models — Cyclical Methods

If you enjoyed this content, I’m launching a new algorithmic finance newsletter, called Algo Fin, that you might be interested in. This newsletter will explore the connection between data science and finance, with an initial focus on the currency markets, but I hope to build many more avenues in the future. The newsletter is free to join currently as I am still planning a launch for paid subscribers, so if this sounds like something you might be interested in, its definitely worth checking out here!.

In the fourth article of this series, we will continue to summarise a collection of commonly used technical analysis trading models that will steadily increase in mathematical and computational complexity. Typically, these models are likely to be most effective around fluctuating or periodic instruments, such as forex pairs or commodities, which is what I have backtested them on. The aim behind each of these models is that they should be objective and systematic i.e. we should be able to translate them into a trading bot that will check some conditions at the start of each time period and make a decision if a buy or sell order should be posted or whether an already open trade should be closed.

Please note that not all of these trading models are successful. In fact, a large number of them were unsuccessful. This summaries series has the sole objective of describing the theory behind different types of trading models and is not financial advice as to how you should trade. If you do take some inspiration from these articles, however, and do decide to build a trading bot of your own, make sure that you properly backtest your strategies, on both in and out of sample data and also in dummy accounts with live data. I will cover these definitions and my testing strategies in a later article.

TheoryIn signal processing, a filter is a device that removes “unwanted” components from a signal. It removes certain frequencies from the signal that are considered background noise in order to paint a clearer picture of the true underlying signal.The are four broad types of filters and they are defined by the types of frequencies they allow to pass through and those that they therefore exclude.

  • low pass filter will, as the name suggests, allow low frequencies to pass through and reduce the significance of the higher frequenciesA high pass filter will do the opposite, allowing high frequencies to pass through and reducing low-frequency impactA bandpass filter will allow frequencies to pass through that are within a pre-defined band. We supply a minimum and maximum frequency value to our filter and it will only keep those values that fall withinA band stop filter also requires a minimum and maximum value, but will pass all frequencies that are either greater than the maximum or lower than the minimum, essentially all the frequencies a bandpass filter would not allow

_There are, of course, more sophisticated types such as notch filters (filters than reject a specific frequency) or comb filters (a series of regularly spaced band filters), but for the purpose of introducing this topic, we will stick to the fundamental concepts._ApplicationThe Butterworth filter was first introduced by the physicist Stephen Butterworth in 1930. I won’t go into all the technicals of how this filter works, but the most important feature about it is that it is a low pass filter. The Butterworth filter aims to produce an output that is as flat as possible, ignoring the high frequencies and returning the lower ones. It has been found that this filter is an ideal one for use in the world of forex trading because we want to see the general underlying “low frequency” cycles. We want to remove the high-frequency movements, as this is what we might consider as just noise.

_When we look at a chart, we start to see the scope for where this might have an application. As you can see, in the GBP/USD closing prices for the last 18 years, we see a lot of minor fluctuations around general price trends. If we were long or medium-term traders, we wouldn’t be interested in these fluctuations occurring around the trend, but we want the trend itself. One method to see the underlying trend is to use a moving average, which is useful, but is also a lagging indicator. The benefit of a filter is that it removes frequencies in real-time. We can see trend continuations and reversals immediately, making it easier for us to make trading decisions as close to these changes as possible.Python’s SciPy package has an option for us to easily run a Butterworth filter. You can find the documentation _here, but if you don’t come from a Physics background, you can look at the unknown values as parameters that we have the option to tune.

Naturally, our frequency cutoff must be less than our frequency value, but it is these two values and the order of the filter (the first argument to the signal.butter() method) that we have the opportunity to tweak. To find the best set of frequencies, cutoffs and order is simply a case of testing different values and finding the one that best follows our data. Plotting the output against the closing price will our visual measurement for how well our model performs. If we wanted a more mathematical evaluation, we could look at the correlation or R² value between our two variables.

#algorithms #forex #algorithmic-trading

Beth  Nabimanya

Beth Nabimanya

1624867080

Algorithm trading backtest and optimization examples

Algorithm trading backtest and optimization examples

Algorithmic trading backtests

Algorithm trading backtest and optimization examples.

xbtusd-vanila-market-making-backtest-hedge

xbtusd-vanila-market-making-backtest-hedge

#algorithms #optimization examples #algorithm trading backtest #algorithm #trading backtest

August  Larson

August Larson

1624365480

Algorithmic Trading with the Keltner Channel in Python

A must-know indicator for all the traders out there

Introduction

While you’re studying technical indicators, you would definitely come across a list comprising curated indicators that are widely considered as ‘must-know’ indicators that need to be learned by you before getting your hands dirty in the real-world market. The indicator we are going to explore today adds to this list given its performance in the market. It’s none other than the Keltner Channel (KC).

In this article, we will first discuss what the Keltner Channel is all about, and the mathematics behind the indicator. Then, we will proceed to the programming part where we will use Python to build the indicator from scratch, construct a simple trading strategy based on the indicator, backtest the strategy on Intel stocks, and finally, compare the strategy returns with those of the SPY ETF (an ETF particularly designed to track the movements of the S&P 500 market index).

#finance #python #algorithmic trading with the keltner channel in python #algorithmic trading #the keltner channel #algorithmic trading with the keltner channel

August  Larson

August Larson

1624372980

Algorithmic Trading with Williams %R in Python

Learn to build a killer trading strategy with a powerful technical indicator in python

Introduction

While having a look at the list of most popular momentum indicators that consists of the Relative Strength Index, and the Stochastic Oscillator, the one we are going to discuss today also joins the list when considering its usage and efficiency in the real world market. It’s none other than the Williams %R.

In this article, we are going to explore what Williams %R is all about, the math behind this indicator, and how a trading strategy based on it can be built with the help of python. As a bonus step, we will compare the returns of our Williams %R strategy returns with the returns of SPY ETF (an ETF specifically designed to track the movement of the S&P 500 Index) to get an idea of how well our strategy performs in the real-world market and can be considered as a step to evaluate the strategy. Considering your curiosity piqued, let’s dive into the article!

#python #algorithmic trading with williams %r in python #algorithmic trading with williams %r #algorithmic trading #williams %r