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.

>>> c = a + b

>>> c

After you hit enter following the last c you will be presented with this:

[1, 2, 3, 4, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 10]

This is simply a concatenation of the two lists. It includes all values from both lists.

Now type this:

>>> c.sort()

>>> c

Hit enter after the last c, and the list is now sorted and stored back in the original

list.

[1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 8, 8, 9, 10]

This is how I created a master data list that included all the dates in the different

equity streams from each market. I then used a removeDuplicates function to

remove the duplicate list entries. The other cool thing in this class is this snippet

of code:

192

USING PYTHON TO BACKTEST YOUR ALGORITHM

def createMonthList(li):

myMonthList = list()

for i in range(0,len(li)):

if i != 0:

tempa = int(li[i]/100)

pMonth = int(li[i-1]/100) % 100

month = int(li[i]/100) % 100

if pMonth != month:

myMonthList.append(li[i-1])

if i == len(li)-1:

return myMonthList

myMonthList.append(li[i])

This code takes a large list of dates and extracts the beginning date of each month

in that list, and then creates a list with just the different months. This is how I was able

to create a monthly breakdown of the time period used in the testing of the system.

20110930 2249 2249

20111031 -2545 -296

20111130 0 -296

20111230 -913 -1209

20120131 0 -1209

20120229 0 -1209

20120330 0 -1209

20120430 -120 -1329

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!