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.

def getData():

totComms = 0

with open(fileName) as f:

f_csv = csv.reader(f)

for row in f_csv:

f.close

commName.append(row[0])

bigPtVal.append(float(row[1]))

minMove.append(float(row[2]))

totComms = totComms + 1

The function starts out by opening the file C:\PBS\dataMaster.csv and reading

its contents into three different lists: commName, bigPtVal, andminMove.

Here is a quick snapshot of the contents of this file:

"AD",100000,0.0001

"BP",125000,0.0001

"CL",1000,0.01

"C2",50,0.25

"CC",10,1

"CD",100000,0.0001

"CL",1000,0.01

"CT",500,0.01

"CU",125000,0.0001

"DX",1000,0.005

"ED",2500,0.005

"EM",100,0.1

"FC",500,0.025

"FV",1000,0.0078

"GC",100,0.1

"HG",250,0.05

"HO",42000,0.0001

"JY",125000,0.00005

As you can see, the data are separated by commas, and there are three data values

per line. The first data value is the string (enclosed in quotes) that will be assigned

to commName. The second is the value of a big point move (a single increment

of the number right before the decimal point (British pound is quoted as 1.5631,

so a move from 1.5631 to 2.5631 would equate to $125,000), and the third is

the minimum move of the market. The minimum move in stocks is 0.01 or one

penny. In the British pound, it is 0.0001. Just like the ESB, the PSB needs to know

this information ahead of time so it can properly calculate price-based values and

perform accurate trade accounting. This file is easily editable and you can customize

it to fit your own data and its format.

183

USING PYTHON TO BACKTEST YOUR ALGORITHM

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!