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.

entryPrice,fileList,entryPrice,entryQuant,exitQuant =

([] for i in range(5))

#exitPrice = list()

currentPrice,totComms,barsSinceEntry = 0

numRuns,myBPV,allowPyra,curShares = 0

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

#End of Lists and Variables

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

alist, blist, clist, dlist, elist = ([] for i in range(5))

The first line of code creates five different lists using an implicit for loop, a one-liner

for loop. You are probably starting to see the magic of Python.

182

USING PYTHON TO BACKTEST YOUR ALGORITHM

Data Import and Configuration and Portfolio Setup The list of data class

objects are assigned whatever is returned by the function getData(). When the PSB

is launched, one of the first things it asks the user is to pick some data (commodity,

equities, or index prices). The getData function handles the creation of an Open

File dialog, the selection of data files, and determining the market specifications

for each file selected. The following is the complete listing of the function’s source

broken down into easily explainable components.

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

#Get the raw data and its associated attributes

[pointvalue,symbol,tickvalue]

#Read a csv file that has at least D,O,H,L,C - V and OpInt

are optional

#Set up a portfolio of multiple markets

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

dataClassList = getData()

numMarkets = len(dataClassList)

portfolio = portfolioClass()

import csv

import tkinter as tk

import os.path

from marketDataClass import marketDataClass

from dataMasterLists import commName, bigPtVal, minMove

from tkinter.filedialog import askopenfilenames

from equityDataClass import equityClassdataClassList = list()

fileName = "c:\PBS\dataMaster.csv"

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!