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.

algorithms. I usually open SystemTester.py and save as immediately. If I am working

on a Donchian type of algorithm, I will use a name like DonchianSys1.py. Instead

of listing the program in its entirety, let’s break it up section by section.

Import Section

#------------------------------------------------------------

#Import section - inlcude functions, classes, variabels

#form externam modules

#------------------------------------------------------------

import csv

import tkinter as tk

import os.path

from getData import getData

from dataLists import myDate,myTime,myOpen,myHigh,myLow,

myClose

from tradeClass import tradeInfo

from equityDataClass import equityClass

from trade import trade

from systemMarket import systemMarketClass

from portfolio import portfolioClass

from indicators import highest,lowest,rsiClass,stochClass,

sAverage,bollingerBands

from systemAnalytics import calcSystemResults

from tkinter.filedialog import askopenfilenames

The hash sign (#) at the beginning of any text informs the interpreter to ignore

whatever follows up to the end of the line. Use this symbol for comments in your

Python code—just like we did with the single quote (‘) in VBA. You can also use it

to temporarily hide a line of code from the interpreter. All of the external files and

functions/classes are pulled into the main program by using the keywords from

and import. This is similar to C’s include statement—on the surface, anyway.

For all intents and purposes, we will use it simply to import external code. The

name of the external module follows from and the function/class name follows the

import keyword. Look at the line that starts, from indicators import … You

will see a good portion of the indicator functions and classes that were defined in

indicator.py.

Some of the imports are strictly Python related:

179

USING PYTHON TO BACKTEST YOUR ALGORITHM

import csv

import tkinter as tk

import os.path

from tkinter.filedialog import askopenfilenames

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!