Preface
tqsdk is a Python library for futures users, but it provides stock quotes and can be used to monitor stocks, select stocks, view quotes, make conditional orders and stock trading strategies.
It is a simple and powerful tool that can build various types of quantitative trading strategy programs with a small amount of code. Even a novice can learn to use this library to select stocks and check market trends in just ten minutes.
At the same time, it provides functions such as historical data, real-time data, strategy backtesting and simulated trading,
If you have a lot of ideas about trading, then you can even use tqsdk directly to write trading strategies.
Usage documentation can be found on the official website,
https://www.shinnytech.com/tianqin/
The installation method is very simple:
pip install tqsdk -U
Let’s give a simple example of checking market prices:
from tqsdk2 import TqApi, TqAuth
api = TqApi(web_gui=True, auth=TqAuth("username", "password"))
quote = api.get_quote("SZSE.159841") // 获得行情
print(quote.ask_volume1, quote.ask_price1) // 打印卖盘一档手数和价格
print(quote.instrument_name) // 打印股票名称(示例中是 证券ETF)
while True:
api.wait_update() // 阻塞到行情更新
print(quote.datetime, quote.last_price) // 行情每次跳动都打印时间和最新价
It should be noted that tqsdk only supports futures trading, not stock trading. It is very suitable for doing market-based calculations, such as calculating indicators, selecting stocks that meet conditions, etc. You can add your own email notifications to help you implement functions such as grid, conditional orders, and stop-profit and stop-loss.
In addition, I think it is very important that they have also built their own community. There is also a way to join the community on the official website, which is full of trading masters!
About Python technical reserves
Learning Python well is good whether you are getting a job or doing a side job to make money, but you still need to have a learning plan to learn Python. Finally, we share a complete set of Python learning materials to give some help to those who want to learn Python!
1. Python learning route
2. Basic learning of Python
1. Development tools
We will prepare you with the necessary tools you need to use in the Python development process, including the latest version of PyCharm installation and permanent activation tool.
2. Study notes
3. Learning videos
3. Essential manual for Python beginners
4. Python practical cases
5. Python crawler tips
6. A complete set of resources for data analysis
7. Python interview highlights
2. Resume template
Data collection
The complete set of Python learning materials mentioned above has been uploaded to CSDN official. If you need it, you can scan the CSDN official certification QR code below on WeChat and enter "receive materials" to get it.