Understand quantitative data efinance in one article

Introduction

  • efinance  is a free and open source Python library for obtaining stock, fund, futures, and bond data. As can be seen from the source code, it is mainly based on the API of Oriental Fortune Network to obtain data. Although it does not provide data services itself, it provides many functions, including supporting multiple stock requests at the same time, supporting daily k, weekly k, monthly k, 60 minutes, 30 minutes, 15 minutes, 5 minutes, and 1 minute. Line data, etc.

Install or update using pip:

pip install efinance

renew

pip install efinance --upgrade

After installation, run python -c "import efinance as ef" on the command line. If no error is reported, the installation is successful.

Common usage

Before use, you need to "import efinance as ef" to import the efinance library to use the various functions of the library normally.

Get stock data

  1. Get A-share historical daily K-line data. Supports obtaining multiple stock data at the same time, supporting daily K, weekly K, monthly K, 60 minutes, 30 minutes, 15 minutes, 5 minutes, 1 minute K line data, etc.

ef.stock.get_quote_history(stock_codes=['600519','300750'], beg='20220901', end='20221015', klt=60)
  1. Obtain stock K-line data of Hong Kong and US stocks (supports inputting stock name and code)

ef.stock.get_quote_history('AAPL')
ef.stock.get_quote_history('微软')
ef.stock.get_quote_history('腾讯')
  1. Obtain ETF K-line data, taking China Internet ETF as an example.

ef.stock.get_quote_history('513050')
  1. Latest status of A shares in Shanghai and Shenzhen markets

ef.stock.get_realtime_quotes()
  1. Stock Dragon and Tiger List

ef.stock.get_daily_billboard()
  1. Quarterly performance of Shanghai and Shenzhen A shares. The default is the latest quarter, you can also specify the quarter

ef.stock.get_all_company_performance()
  1. Stock historical order inflow data (day level)

>>> import efinance as ef
>>> ef.stock.get_history_bill('300750')
  1. Stock inflow data for the latest trading day (minute level)

>>> import efinance as ef
>>> ef.stock.get_today_bill('300750')

Get futures data

  • Get basic information about exchange futures: ef.futures.get_futures_base_info()

  • Get futures historical quotes: ef.futures.get_quote_history('115.ZCM')

Get fund data

  • Get fund historical net value information: ef.fund.get_quote_history('161725')

  • Get fund public position information: ef.fund.get_invest_position('161725')

  • Obtain basic information of multiple funds at the same time: ef.fund.get_base_info(['161725','005827'])

Get convertible bond data

  • Get the overall market price of convertible bonds:ef.bond.get_realtime_quotes()

  • Get all convertible bond information:ef.bond.get_all_base_info()

  • Get the K-line data of the specified convertible bond:ef.bond.get_quote_history('128053')

in conclusion

efinance is a free and open source Python library used to obtain stock, fund, futures, and bond data. Its functions are very powerful:

  • Support stock data acquisition. Multiple stock data can be obtained at the same time, supporting daily K-line, weekly K, monthly K-line, 60-minute, 30-minute, 15-minute, 5-minute, 1-minute K-line data, etc.; supports obtaining stock K-line data of Hong Kong and US stocks (supports input of stock name) and code); supports obtaining ETF K-line data; supports obtaining the latest status of A shares in Shanghai and Shenzhen markets, etc.

  • Support futures data acquisition. You can obtain basic information about futures on the exchange and historical futures prices.

  • Supports obtaining fund data. You can obtain fund historical net value information, fund public position information, etc.

  • Supports obtaining convertible bond data. You can obtain the overall market situation of convertible bonds, K-line data of convertible bonds, etc.

Of course, we can also modify efinance according to our own needs and add more useful functions.

comminicate

Follow the WeChat public account: Zhuge Shuo Talk for more related content. At the same time, you can also get an invitation to join the quantitative investment seminar group to communicate and discuss with many practitioners and technical experts. The number of places is limited, so don’t miss it.

Writing articles is not easy. If you think this article is helpful to you, please give it a thumbs up and forward it to give me the motivation to keep writing good articles.

reference

Guess you like

Origin blog.csdn.net/richardzhutalk/article/details/127353911