31.07.2021 Views

Ultimate Algorithmic Trading System

Using automated systems for trading in stock markets

Using automated systems for trading in stock markets

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

your algorithm are each written on a separate piece of paper and all the pieces are

then placed in a bag. You create an alternative trade history by reaching into the bag

and randomly selecting trades and writing them down in a trade log in sequential

manner. You do this routine until you have recorded the same number of trades that

were initially generated by the backtest. One very important thing to remember

is to always return the piece of paper to the bag after you record the trade. This

process would be very time consuming and you might ask what’s the use. Don’t

worry about the time involved because the computer can do it very quickly and

recreating hundreds of alternative paths is well worth the effort. Will it help create

a better algorithm? Probably not but it will help you make a decision to allocate

real funds to an algorithm or not. Like I stated earlier, the robustness of a trading

algorithm will reveal itself through Monte Carlo simulation.

Implementation of Monte Carlo Simulation Using Python The concept of this

form of simulation is easy enough. And putting it into computer language is as easy.

The hardest part is getting the initial trade list. Once you have that the rest falls into

place relatively easily. Understanding how a computer implementation of a concept

works usually helps the understanding of how the concept works in general and how

it might be beneficial.

Imagine all the trades generated by a backtest are stored in a list. The list is

simply an ordered collection of the trade dates and trade profits. The list might look

something like this:

TradeList[0] = (20011015,−150)

TradeList[1] = (20011105,+200)

TradeList[2] = (20011202,−300)

TradeList[3] = (20011222,+500)

You could call this the source list. Now imagine you have another blank list that’s

called AlternateList1. The objective of the Monte Carlo simulation is to fill the

AlternateList1 with trades from the source list. If there are only four elements in

the list, you would need an RNG to generate random numbers from 0 to 3. Let’s

push the RNG button and start the process of filling up AlternateList1:

The RNG generates the number 3

AlternateList1[0] = TradeList[3]

RNG generates the number 0

AlternateList[1] = TradeList[0]

RNG generates the number 1

AlternateList[2] = TradeList[1]

RNG generates the number 3

AlternateList[3] = TradeList[3]

259

GENETIC OPTIMIZATION, WALK FORWARD

www.rasabourse.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!