1.code:
import tushare as ts
import requests
from bs4 import BeautifulSoup
import pandas as pd
import matplotlib
matplotlib.use(‘TkAgg’)
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
fontproperties=FontProperties(fname=’/System/Library/Fonts/PingFang.ttc’)
picture = [‘exchange’,‘pair’,‘mount’]

kw = {‘user-agent’:‘Mozilla/5.0’}
url = ‘https://tushare.pro/document/41?doc_id=66
r = requests.get(url,headers = kw)
soup = BeautifulSoup(r.text,‘html.parser’)

#获得国家名和简称
name_list = {}
trs = soup.find_all(‘tr’)
for tr in trs:
tds = tr.find_all(‘td’)
if len(tds) == 2:
short_name = ‘’.join(tds[0].contents)
name = ‘’.join(tds[1].contents)
name_list[short_name] = name

data = []
pro = ts.pro_api()
for country in name_list:
df = pro.coinexchanges(area_code = country)
data.append(df)

total_data = pd.concat(data)

#交易对最多的交易所
max_pair = total_data[total_data.pairs == total_data.pairs.max()]
max_name = max_pair[‘name’]

#交易对最少的交易所
min_pair = total_data[total_data.pairs == total_data.pairs.min()]
min_name = min_pair[‘name’]

#有期货交易的交易所个数
fut_yes = total_data[total_data[‘fut_trade’] ==‘Y’ ]
fut_num = len(fut_yes)
fut_ex_name = fut_yes[‘name’]

2.结果:

1.分布
用tushare上的数据分析数币交易所情况
2.费率用tushare上的数据分析数币交易所情况
用tushare上的数据分析数币交易所情况
1.详细分析见公众号文章

2.点击可以注册tushare

相关文章: