This is a program that collects market data from TWS API. It is modified from the sample code of TWS API. The whole project initially designed for data extraction of different type of instrument. However, it only supports stock market at the current stage.
###1. Interactive Broker Pro account ###2. MariaDB / Mysql Database and client
git clone https://github.com/AlvinTheDeveloper/ib-market-data-collector.git
cd ib-market-data-collector
pip install -r requirements.txt
cd lib/pythonclient/
python3 setup.py sdist
python3 setup.py bdist_wheel
python3 -m pip install --user --upgrade dist/ibapi-9.76.1-py3-none-any.whl
mysql -u your_username --host=your_host -p < db_init.sql
mv ./config/keysAndConfig.demo.json ./config/keysAndConfig.json
Before the program starts receiving data from API, it fetches watchlist data from the database. You will have to set up the watchlist in the database. My way is to export the watchlist from TWS and import the watchlist data to the database's watchlist table.
3.1.a You can create a watchlist in TWS by following the steps mentioned in this video.
3.1.b Once you created a new watchlist, you have to edit the column by following the steps mentioned in this video
3.1.c Export your watchlist to the "data" directory. Watch this video to learn how to export a watchlist.
python3 CsvToDb.py
""" python3 DataCollector.py """