add Bank of Japan
This commit is contained in:
parent
73e258c3d9
commit
e372a5e0bf
|
@ -0,0 +1,52 @@
|
||||||
|
import requests
|
||||||
|
import pandas as pd
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
url = {
|
||||||
|
"BOJ": "https://www.stat-search.boj.or.jp"
|
||||||
|
}
|
||||||
|
|
||||||
|
class BOJData(object):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def toc(self):
|
||||||
|
tmp_url = url["BOJ"] + "/index_en.html"
|
||||||
|
r = requests.get(tmp_url)
|
||||||
|
main_statistics_table = BeautifulSoup(r.text, "html.parser").find_all('div', {"class": "clearfix"})[1]
|
||||||
|
uls = main_statistics_table.find_all("ul")
|
||||||
|
lis = [li for ul in uls for li in ul.find_all("li", {"class": "icoSimpleRightArrowForMainTime-series mainTimeSeriesName"})]
|
||||||
|
li_text = [li.text.strip() for li in lis]
|
||||||
|
li_urls = [url["BOJ"] + li.a.get("href") for li in lis]
|
||||||
|
toc = pd.DataFrame({"title": li_text, "url":li_urls})
|
||||||
|
return toc
|
||||||
|
|
||||||
|
def _download(self, down_url:str=None):
|
||||||
|
r = requests.get(down_url)
|
||||||
|
table = BeautifulSoup(r.text, "html.parser").find_all("table")
|
||||||
|
data = pd.read_html(str(table))[0]
|
||||||
|
header = ["time"] + list(data.loc[0][1:])
|
||||||
|
data.columns = header
|
||||||
|
data = data[1:]
|
||||||
|
return data
|
||||||
|
|
||||||
|
def download_data(self, query:str=None):
|
||||||
|
toc = self.toc()
|
||||||
|
if query == None:
|
||||||
|
return ValueError("rex is invalid.")
|
||||||
|
else:
|
||||||
|
data = toc[toc["title"].str.contains(query)].reset_index(drop=True)
|
||||||
|
if data.empty:
|
||||||
|
return ValueError("No related dataset, check the query again")
|
||||||
|
else:
|
||||||
|
output = []
|
||||||
|
for i in range(0, len(data)):
|
||||||
|
output.append(self._download(down_url=data.loc[i]["url"]))
|
||||||
|
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
,name,url
|
||||||
|
0,Basic Loan Rate[Daily] [Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/ir01_d_1_en.html
|
||||||
|
1,Average Interest Rates Posted at Financial Institutions by Type of Deposit[Weekly(Monday Base)],https://www.stat-search.boj.or.jp/ssi/mtshtml/ir02_w1_1_en.html
|
||||||
|
2,Average Contracted Interest Rates on Loans and Discounts[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/ir04_m_1_en.html
|
||||||
|
3,Call Rates[Daily] [Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/fm01_d_1_en.html
|
||||||
|
4,Foreign Exchange Rate(Tokyo Market Interbank Rates)[Daily] [Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/fm08_d_1_en.html
|
||||||
|
5,Effective Exchange Rates[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/fm09_m_1_en.html
|
||||||
|
6,Monetary Base/Average Amounts Outstanding[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/md01_m_1_en.html
|
||||||
|
7,Money Stock[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/md02_m_1_en.html
|
||||||
|
8,"Deposits, Vault Cash, and Loans and Bills Discounted[Monthly]",https://www.stat-search.boj.or.jp/ssi/mtshtml/md11_m_1_en.html
|
||||||
|
9,Principal Figures of Financial Institutions[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/md13_m_1_en.html
|
||||||
|
10,Principal Accounts/percentage changes from the previous year(Domestically Licensed Banks)[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/bs02_m_1_en.html
|
||||||
|
11,Households Financial Assets(Flow of Funds Accounts)[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/ff_q_1_en.html
|
||||||
|
12,TANKAN/Judgement Survey/Business Conditions[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_1_en.html
|
||||||
|
13,TANKAN/Judgement Survey/Domestic Supply & Demand Conditions[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_2_en.html
|
||||||
|
14,TANKAN/Judgement Survey/Change in Output Prices[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_3_en.html
|
||||||
|
15,TANKAN/Judgement Survey/Change in Input Prices[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_4_en.html
|
||||||
|
16,TANKAN/Judgement Survey/Production Capacity[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_5_en.html
|
||||||
|
17,TANKAN/Judgement Survey/Employment Conditions[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_6_en.html
|
||||||
|
18,TANKAN/Judgement Survey/Financial Position[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_7_en.html
|
||||||
|
19,TANKAN/Judgement Survey/Lending Attitude[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_8_en.html
|
||||||
|
20,TANKAN/Annual Projections/Fixed Investment[Fiscal Year],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_fy_1_en.html
|
||||||
|
21,TANKAN/Annual Projections/Current Profits[Fiscal Year],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_fy_2_en.html
|
||||||
|
22,Corporate Goods Price Index(CGPI)[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/pr01_m_1_en.html
|
||||||
|
23,Services Producer Price Index(SPPI)[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/pr02_m_1_en.html
|
||||||
|
24,Balance of Payments[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/bp01_m_1_en.html
|
||||||
|
25,Basic Loan Rate[Daily] [Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/ir01_d_1_en.html
|
||||||
|
26,Average Interest Rates Posted at Financial Institutions by Type of Deposit[Weekly(Monday Base)],https://www.stat-search.boj.or.jp/ssi/mtshtml/ir02_w1_1_en.html
|
||||||
|
27,Average Contracted Interest Rates on Loans and Discounts[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/ir04_m_1_en.html
|
||||||
|
28,Call Rates[Daily] [Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/fm01_d_1_en.html
|
||||||
|
29,Foreign Exchange Rate(Tokyo Market Interbank Rates)[Daily] [Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/fm08_d_1_en.html
|
||||||
|
30,Effective Exchange Rates[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/fm09_m_1_en.html
|
||||||
|
31,Monetary Base/Average Amounts Outstanding[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/md01_m_1_en.html
|
||||||
|
32,Money Stock[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/md02_m_1_en.html
|
||||||
|
33,"Deposits, Vault Cash, and Loans and Bills Discounted[Monthly]",https://www.stat-search.boj.or.jp/ssi/mtshtml/md11_m_1_en.html
|
||||||
|
34,Principal Figures of Financial Institutions[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/md13_m_1_en.html
|
||||||
|
35,Principal Accounts/percentage changes from the previous year(Domestically Licensed Banks)[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/bs02_m_1_en.html
|
||||||
|
36,Households Financial Assets(Flow of Funds Accounts)[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/ff_q_1_en.html
|
||||||
|
37,TANKAN/Judgement Survey/Business Conditions[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_1_en.html
|
||||||
|
38,TANKAN/Judgement Survey/Domestic Supply & Demand Conditions[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_2_en.html
|
||||||
|
39,TANKAN/Judgement Survey/Change in Output Prices[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_3_en.html
|
||||||
|
40,TANKAN/Judgement Survey/Change in Input Prices[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_4_en.html
|
||||||
|
41,TANKAN/Judgement Survey/Production Capacity[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_5_en.html
|
||||||
|
42,TANKAN/Judgement Survey/Employment Conditions[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_6_en.html
|
||||||
|
43,TANKAN/Judgement Survey/Financial Position[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_7_en.html
|
||||||
|
44,TANKAN/Judgement Survey/Lending Attitude[Quarterly],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_q_8_en.html
|
||||||
|
45,TANKAN/Annual Projections/Fixed Investment[Fiscal Year],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_fy_1_en.html
|
||||||
|
46,TANKAN/Annual Projections/Current Profits[Fiscal Year],https://www.stat-search.boj.or.jp/ssi/mtshtml/co_fy_2_en.html
|
||||||
|
47,Corporate Goods Price Index(CGPI)[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/pr01_m_1_en.html
|
||||||
|
48,Services Producer Price Index(SPPI)[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/pr02_m_1_en.html
|
||||||
|
49,Balance of Payments[Monthly],https://www.stat-search.boj.or.jp/ssi/mtshtml/bp01_m_1_en.html
|
|
Loading…
Reference in New Issue