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.

It works well on both Unix and Windows platforms. It includes a Python shell

window, which gives you access to the Python interactive mode. Before we can

start looking at the PSB, we need to learn a little bit about IDLE. So go ahead and

launch it through your Apps screen or Start menu. The Python Shell should now be

in front of you. Doesn’t look that special; it’s barebones in fact. This is by design to

keep the Python learning curve as a gradual incline.

A prompt, preceded by >>>, should now be blinking at you. Currently, the

Shell is in interactive mode—meaning that it wants you to give it a command. Type

4 + 6 and hit enter. The prompt now comes back with the answer—10. Now

type print(‘‘Hello World’’) and hit enter. The prompt comes back with Hello

World. Now type 100 ** 0.5 and hit enter. You should get the number 10.Now

type import this and hit enter. Your screen should be filled with the following:

170

USING PYTHON TO BACKTEST YOUR ALGORITHM

The Zen of Python, by Tim Peters

Beautiful is better than ugly.

Explicit is better than implicit.

Simple is better than complex.

Complex is better than complicated.

Flat is better than nested.

Sparse is better than dense.

Readability counts.

Special cases aren’t special enough to break the rules.

Although practicality beats purity.

Errors should never pass silently.

Unless explicitly silenced.

In the face of ambiguity, refuse the temptation to guess.

There should be one—and preferably only one—obvious way to do it.

Although that way may not be obvious at first unless you’re Dutch.

Now is better than never.

Although never is often better than *right* now.

If the implementation is hard to explain, it’s a bad idea.

If the implementation is easy to explain, it may be a good idea.

Namespaces are one honking great idea—let’s do more of those!

This is an ‘‘Easter egg’’ of a poem created by Python pioneer Tim Peters. Pretty cool,

huh? Some people live, eat, and breathe Python. You don’t need to go overboard to

get the benefits of learning a programming language such as Python.

You can now see why they call it an ‘‘interactive’’ shell. Let’s switch gears and

use IDLE as an IDE. Go under the File menu and select Open … and then navigate

your way to the PSB folder and open PSBBollinger. The file that opens is a trading

algorithm based once again on Bollinger Bands.

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!