investpy 项目教程
项目的目录结构及介绍
investpy 项目的目录结构如下:
investpy/
├── examples/
│ ├── example1.ipynb
│ ├── example2.ipynb
│ └── ...
├── investpy/
│ ├── __init__.py
│ ├── stocks.py
│ ├── funds.py
│ ├── etfs.py
│ ├── indices.py
│ ├── currency_crosses.py
│ ├── bonds.py
│ ├── commodities.py
│ ├── certificates.py
│ ├── crypto.py
│ ├── news.py
│ ├── technical.py
│ ├── search.py
│ └── ...
├── tests/
│ ├── test_stocks.py
│ ├── test_funds.py
│ ├── test_etfs.py
│ ├── test_indices.py
│ ├── test_currency_crosses.py
│ ├── test_bonds.py
│ ├── test_commodities.py
│ ├── test_certificates.py
│ ├── test_crypto.py
│ ├── test_news.py
│ ├── test_technical.py
│ ├── test_search.py
│ └── ...
├── .gitignore
├── LICENSE
├── README.md
├── requirements.txt
└── setup.py
目录结构介绍
examples/
:包含使用 investpy 的 Jupyter Notebook 示例。investpy/
:包含 investpy 的主要代码文件,每个文件对应一种金融产品的数据获取。tests/
:包含测试文件,用于测试 investpy 的各个功能。.gitignore
:Git 忽略文件。LICENSE
:项目许可证。README.md
:项目说明文档。requirements.txt
:项目依赖文件。setup.py
:项目安装文件。
项目的启动文件介绍
investpy 项目的启动文件是 investpy/__init__.py
。这个文件初始化了整个包,并导入了所有必要的模块和函数,使得用户可以直接通过 import investpy
来使用 investpy 的所有功能。
项目的配置文件介绍
investpy 项目没有专门的配置文件。所有的配置和参数都在代码中直接设置和使用。用户在使用时,可以通过函数参数来传递所需的配置信息。
例如,获取股票历史数据的函数 get_stock_historical_data
的参数包括股票代码、国家、开始日期和结束日期等。
import investpy
df = investpy.get_stock_historical_data(stock='AAPL', country='United States', from_date='01/01/2020', to_date='01/01/2021')
通过这种方式,用户可以根据需要灵活地配置和使用 investpy 的功能。