Python installation for trading

UberMachine

Well-Known Member
#1
I am starting this thread for installing Python on Windows/Linux since most traders find it difficult to get running.

To begin with, I am just posting the necessary steps to get started. In case of any errors, post it along with your operating system and a screenshot of the error message so that it would be helpful in diagnosing the error.

Windows
  1. Download Anaconda. Download the correct version for your system. Download Python 3.6 version
  2. After download, right click and Run as Administrator
  3. Click Yes and proceed. Change directory to D:\anaconda3 or any other drive other than C:\
  4. Install for all users and ADD TO PATH
  5. After completing installation. Open command prompt and type conda list. This must show a list of libraries installed
  6. If this shows error, run command prompt as administrator
This is good to get going

Linux
  1. Download Anaconda. Download the correct version for your system. Download Python 3.6 version
  2. After downloading chmod +x {{download_file}} (Replace download_file with the file name)
  3. Open command prompt and ./{{download_file}}
  4. Install anywhere. /home/{{user}}/anaconda3 is preferable
  5. After completing installation. Open command prompt and type conda list. This must show a list of libraries installed
This is good to get started

Post any errors as already told.
Once installed, you can type jupyter notebook in your terminal or use anaconda navigator to open jupyter notebook
 

VJAY

Well-Known Member
#2
Dear ubermachine,
Thanks for sharing....
How we can use it for trading?explain with step by step procedure.....
 

UberMachine

Well-Known Member
#3
Thanks.
Would definitely post more in the coming days (after I standardise a couple of my scripts)
But I wanted to make sure that the installation goes correct since most Windows users experience difficulty in running anaconda (due to windows permissions settings) and ta-lib installation.
I also wanted to explore what other methods are used by the traders for installing python since python is fast becoming a useful tool for algo trading and evaluation
 

VJAY

Well-Known Member
#4
Thanks.
Would definitely post more in the coming days (after I standardise a couple of my scripts)
But I wanted to make sure that the installation goes correct since most Windows users experience difficulty in running anaconda (due to windows permissions settings) and ta-lib installation.
I also wanted to explore what other methods are used by the traders for installing python since python is fast becoming a useful tool for algo trading and evaluation
Dear ubermachine,
I allready installed python as per ncube thread .using for pairtrade.i think its version 3.7...so i can use it for anaconda?please tell more about anaconda....sorry for my dumb querries as am dumb in this tech things...
 

UberMachine

Well-Known Member
#5
Dear ubermachine,
I allready installed python as per ncube thread .using for pairtrade.i think its version 3.7...so i can use it for anaconda?please tell more about anaconda....sorry for my dumb querries as am dumb in this tech things...
Have you installed talib?
Its a technical analysis library (I am not a fan of technical analysis)
You can install by typing
Python:
pip install TA-Lib
in the command prompt.

And you can follow this link in case of troubleshooting.

Once done, you can use this as follows in a jupyter notebook
Python:
import talib
talib.SMA(data)
TA-lib is insanely fast (when compared to other solutions, I believe)
And nothing is dumb :)
Once you get running, you can automate a lot of strategies from Excel or any other software
 

UberMachine

Well-Known Member
#6
Dear ubermachine,
I allready installed python as per ncube thread .using for pairtrade.i think its version 3.7...so i can use it for anaconda?please tell more about anaconda....sorry for my dumb querries as am dumb in this tech things...
And I am also on the pair trade.
May take me 10-15 days before coming up with something useful in intraday
 

UberMachine

Well-Known Member
#7
Dear ubermachine,
I allready installed python as per ncube thread .using for pairtrade.i think its version 3.7...so i can use it for anaconda?please tell more about anaconda....sorry for my dumb querries as am dumb in this tech things...
Anaconda is a python system with batteries installed.
By batteries, I mean it includes all the frequently used libraries that includes time series analysis, web server, statistical analysis, data fetching, machine learning, plotting, notebooks and much more.
Installing it in Windows would also give you a nice shortcut menu.
It also provides a good update system where you could manage all your libraries with a single menu.
 

UberMachine

Well-Known Member
#8
TA-LIB installation

Once python is installed, the next step would be to install the talib package if you are using technical analysis.
If you are going to stick with just mean, median, moving averages, then it is not necessary.
Install this if you want indicators such as Bollinger Bands, MACD, RSI and more and you don't want to calculate it yourselves

Windows
  1. Download this file. If link is broken you can download it from here. This is the official download page.
  2. Unzip to c:\ta-lib
  3. Then pip install TA-Lib
Once this is done, you can then use
Python:
import talib
output = talib.SMA(close)
You can use other functions such as
Python:
talib.EMA
talib.DEMA
talib.RSI
Inside a python prompt type talib. and press TAB for all the indicators
or
Python:
print (talib.get_functions())
Note this is 32-bit version. If you require a 64-bit version, you need to build it.
You can follow the detailed instructions here


Linux
  1. Download ta-lib here
  2. untar and cd
  3. ./configure --prefix=/usr
  4. make
  5. sudo make install
 
Last edited:

UberMachine

Well-Known Member
#9
Why TA-Lib installation?

Warning: I don't know technical analysis

We are going to simulate charts in TA-lib so that machine can pick the patterns and generate trades (quite ambitious)
So, say you do trade on breakout. I believe you would be doing the following
  1. Watch a few charts
  2. Wait for the breakout signal
  3. Place a trade based on the signal
If this is the workflow, then this could be automated to find the patterns and generate trade signals.
It could also help us get an understanding of whether technical analysis really works
 

trendtrade

niftytrader12
#10
Why TA-Lib installation?

Warning: I don't know technical analysis

We are going to simulate charts in TA-lib so that machine can pick the patterns and generate trades (quite ambitious)
So, say you do trade on breakout. I believe you would be doing the following
  1. Watch a few charts
  2. Wait for the breakout signal
  3. Place a trade based on the signal
If this is the workflow, then this could be automated to find the patterns and generate trade signals.
It could also help us get an understanding of whether technical analysis really works
@ubermachine, thanks for this great initiative regarding Python. A lot of traderji members will benefit from this.

It seems as if you have a programming background. Could you please tell what kind of programming are you familiar with ?
Can we somehow use TA-lib with SQL server database as well ?

Best regards.