Hello, this is Gaoraz 🙂
Today I want to show you how to create a development environment to use the IBKR TWS API in Python.
The time required is about 10-15 minutes.
Prerequisite
- Windows 11 Pro/Home
Building a Development Environment
Install Anaconda
Anaconda is a distribution of Python and associated packages for scientific computing, data analysis, and machine learning. Very easy to use.
Download Anaconda from the link below.
Distribution | Anaconda
Anaconda's open-source Distribution is the easiest way to perform Python/R data science and machine learning on a single...
Install the program using the default settings.
Install Microsoft VS Code
Microsoft VS Code is the most popular programming editor for Python on Windows.
Visual Studio Code - Code Editing. Redefined
Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications...
After installing Microsoft VS Code, restart Windows.
Install VSCode Extension for Python
- Launch VS Code.
- Click Install in the screenshot below to add the extension for Python.
Setting path to python.exe & conda.exe (VS Code)
- Open VS Code setting (Shortcut: Ctrl + ,)
- Type ‘Python: Default Interpreter Path’ and search.
- Type “~\anaconda3\python.exe”
- Open VS Code setting (Shortcut: Ctrl + ,)
- Type ‘Python: Conda Path’ and search.
- Type “~\anaconda3\Scripts\conda.exe”
After doing all things, please relaunch VS Code.
Test your environment
- Create a new folder.
- Open the folder in VS Code.
- Create “test.py” as a new file.
- Write a test code shown as below.
- Execute the code. (Shortcut: F5)
This is test code.
# test.py
import numpy
x = [1, 2, 3 , 5]
print(numpy.sum(x))
The result should be as below.
11
If some errors occur
Check that the following Paths are in the Windows environment variables.
C:\Users\{YOUR USER NAME}\anaconda3\condabin
C:\Users\{YOUR USER NAME}\anaconda3\Scripts
* To add Windows environment variables, type 'environment variables' in the search box of Windows.
Comments