I'm trying to download the min initial investment for a mutual fund. I can find it on yahoo financials at
https://finance.yahoo.com/quote/QALTX/purchase-info?p=QALTX
I tried using the yahoofinancials module, but it only seems to be returning data for get_historical_price_data. the other extensions only seem to return None. does anyone know why the extension below is returning None? also do you know what extension I should use to get the min initial investment, or can you suggest how else to download it?
code:
import yahoofinancials
from yahoofinancials import YahooFinancials
import pandas as pd
print(YahooFinancials('QALTX').get_key_statistics_data())
output:
{'QALTX': None}
I've just tested this, and your code is returning data for me. However, the minimum initial investment does not seem like something that is gathered by this library in my review of the source code. I could be wrong, but I didn't find it.
The short code below will return the "Min Initial Investment" for this particular URL, but I'm not making any guarantee that this code will work for other mutual funds. It should work, but I leave that to someone else to test.
import decimal as dc
import requests
from bs4 import BeautifulSoup as bs
TICKER = 'QALTX'
URL = 'https://finance.yahoo.com/quote/{}/purchase-info?p={}'.format(TICKER,TICKER)
req = requests.get(URL)
soup = bs(req.text)
# this part is potentially very brittle depending on how often Yahoo Finance changes
elem = soup.select('span[class~="Fl(end)"]')[0]
# replace comma in `10,000` with the empty string
min_initial_investment = dc.Decimal(elem.text.replace(',',''))
Output:
In [90]: min_initial_investment
Out[90]: Decimal('10000')