
With the continuous development of AI technology, its application areas have further expanded. Meanwhile, quantitative investment based on Forex APIs, Precious Metals APIs, and Stock APIs, with its scientific and systematic decision-making approach, is playing an increasingly important role in the financial field. QLib, as an open-source project focused on quantitative investment research, leverages AI technology combined with iTick’s free Forex API and Stock API data interfaces to provide researchers and practitioners with powerful quantitative investment tools.
Introduction to QLib
QLib is an open-source quantitative investment research platform developed by Microsoft, with its code repository available at https://github.com/microsoft/qlib. It aims to provide researchers and practitioners in the quantitative investment field with an efficient and convenient tool to help them build a complete quantitative research workflow and quickly validate their investment ideas.
The main purpose of QLib is to create value in the field of quantitative investment using artificial intelligence technology and empower research, covering the entire process from investment idea exploration to product implementation. Qlib supports various machine learning modeling paradigms, including supervised learning, market dynamics modeling, and reinforcement learning. QLib includes a complete machine learning pipeline for data processing, model training, and backtesting, covering the entire chain of quantitative investment, including alpha return discovery, risk modeling, portfolio optimization, and trade execution.
Introduction to iTick
iTick is a data agency that provides reliable data source APIs for fintech companies and developers. Its official website is https://itick.org. It offers Forex APIs, Stock APIs, Cryptocurrency APIs, Index APIs, etc., meeting the data needs of fintech companies and developers across different financial fields and helping to build innovative trading and analysis tools. Currently, it provides a free plan for individual quantitative developers, which can basically meet their daily usage needs, reducing development costs and data access barriers for individual developers. You can directly visit the official documentation at https://doc.itick.org.
Usage
Requesting K-Line Data
python -m pip install requests
"""
**iTick**: A data agency providing reliable data source APIs for fintech companies and developers, covering Forex API, Stock API, Cryptocurrency API, Index API, etc., helping to build innovative trading and analysis tools. They currently offer a free package that can meet the needs of individual quantitative developers.
Open-source stock data API address:
https://github.com/itick-org
Apply for a free API key at:
https://itick.org
"""
import requests
url = "https://api.itick.org/stock/kline?region=hk&code=700&kType=1"
headers = {
"accept": "application/json",
"token": "bb42e24746784dc0af821abdd1188861d945a07051c8414a8337697a752de1eb"
}
response = requests.get(url, headers=headers)
print(response.text)
Using QLib
QLib requires Python 3.8+ and recommends using Conda for environment management. Install the pyqlib library using pip:
pip install pyqlib
pip install numpy
pip install --upgrade cython
git clone https://github.com/microsoft/qlib.git && cd qlib
pip install . # `pip install -e .[dev]` is recommended for development. check details in docs/developer/code_standard_and_dev_guide.rst
After installation, you can start using the obtained data by running the following commands:
# get 1d data
python -m qlib.run.get_data qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
# get 1min data
python -m qlib.run.get_data qlib_data --target_dir ~/.qlib/qlib_data/cn_data_1min --region cn --interval 1min
Once the data is ready, you can run the Quant Research Workflow using the following command:
cd examples # Avoid running program under the directory contains `qlib`
qrun benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml
After running, you will get the following output, which is a preliminary analysis result of the investment data:
'The following are analysis results of the excess return without cost.'
risk
mean 0.000708
std 0.005626
annualized_return 0.178316
information_ratio 1.996555
max_drawdown -0.081806
'The following are analysis results of the excess return with cost.'
risk
mean 0.000512
std 0.005626
annualized_return 0.128982
information_ratio 1.444287
max_drawdown -0.091078
Summary
QLib, as a powerful quantitative investment research platform, provides rich functionalities and convenient tools for researchers and practitioners in the field of quantitative investment. Its flexibility and ease of use allow users to quickly build quantitative research workflows and validate their investment ideas
QLib can be widely applied to quantitative investment research in financial fields such as stocks, futures, and funds, helping investors with risk control, asset allocation, and investment decision-making. Meanwhile, with the continuous evolution of AI large model technologies, QLib will be able to offer increasingly strong capabilities in quantitative investment analysis and research.