Micro-sheep / efinance

efinance 是一个可以快速获取基金、股票、债券、期货数据的 Python 库,回测以及量化交易的好帮手!🚀🚀🚀
MIT License
1.83k stars 463 forks source link

Enhancement on stock.get_quote_history API #161

Closed allen-li1231 closed 7 months ago

allen-li1231 commented 7 months ago

Resolves #128

This PR enhanced stock.get_quote_history API with the following aspects:

Feature examples:

import efinance as ef

ef.stock.get_quote_history("PG")
# unexpectedly returns AAPL's stock history

# get history of stock, whose symbol exactly matches "PG"
ef.stock.get_quote_history("PG", quote_symbol_mode=True, use_id_cache=False)  # do not use cache as it will still matches AAPL
# Correctly returns P&G stock history

# fuzzy search "PG" in A stock market
ef.stock.get_quote_history("PG", market_type=ef.utils.MarketType.A_stock, use_id_cache=False)
# returns 平高电气 stock history

# exact search "PG" in A stock market
ef.stock.get_quote_history("PG", market_type=ef.utils.MarketType.A_stock, quote_symbol_mode=True, use_id_cache=False)
# returns empty dataframe as none matches in reality
allen-li1231 commented 7 months ago

@Micro-sheep Let me know if there is any advice or improvements as this is my first pr.

Micro-sheep commented 7 months ago

@Micro-sheep Let me know if there is any advice or improvements as this is my first pr.

I will be reviewing the code in the next two week.

allen-li1231 commented 7 months ago

Improved code as suggested.