Please indicate the public number: Jiedan notebook, after attention to get more lazy investment tools.

Abstract

When we look at certain indexes, the first step is to pick the corresponding index fund. So how do we know which ETF funds, enhancement funds and other public funds track the index? Furthermore, if you have information about the fund’s manager, size, annualization, Alpha and Beta, error rate, etc., can you use Excel filtering to make quick decisions? This article does this in 20 lines of code, with data files and code attached at the end.

Data sample

How to use

Filter index code

Filter IndexTicker and IndexName

Screen for larger funds

Screen funds with smaller tracking errors

View Fund Types

Typically we see ETFs, enhancement and traditional index funds, and you can sort through them to find what you like

Code implementation

Akshare library is mainly used to extract index list, and fundSmart interface is borrowed to get matching

import requests import json import csv from multiprocessing.dummy import Pool as ThreadPool from tqdm import tqdm import  akshare as ak FUND_URL = "http://www.fundsmart.com.cn/api/fund.list.data.php?d=&t=3&i={}" stock_df = ak.stock_zh_index_spot() funds = [x[2:] for x in stock_df['symbol'].to_list()] def getCoFunds(code): return requests.get(FUND_URL.format(code)).json()['list'] with ThreadPool(5) as p: R = list(TQDM (p.imap(getCoFunds, funds), total=len(funds))) with open(CSV ', 'w+') as f: fieldnames = list(r[0][0].keys()) writer = csv.DictWriter(f, fieldnames=fieldnames) writer.writeheader() for funds in r: for fund in funds: fund['indexTicker'] = "'" + fund['indexTicker'].zfill(6) writer.writerow(fund)Copy the code

If you like this article, please click on the lower right corner to share this article is one of my public account about quantitative tools, welcome to check out other tools and analysis methods

This article is published by OpenWrite, a blogging tool platform