financedatabase 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Jeroen Bouma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.1
2
+ Name: FinanceDatabase
3
+ Version: 0.1.0
4
+ Summary: This is a database of 180.000+ symbols containing Equities, ETFs, Funds, Indices, Futures, Options, Currencies, Cryptocurrencies and Money Markets.
5
+ Home-page: https://github.com/JerBouma/FinanceDatabase
6
+ Author: JerBouma
7
+ Author-email: jer.bouma@gmail.com
8
+ License: MIT
9
+ Keywords: finance,database,financials
10
+ Platform: UNKNOWN
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Financial and Insurance Industry
13
+ Classifier: Topic :: Office/Business :: Financial :: Investment
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Description-Content-Type: text/markdown
18
+
19
+ # Finance Database
20
+ As a private investor, the sheer amount of information that can be found on the internet is rather daunting. Trying to
21
+ understand what type of companies or ETFs are available is incredibly challenging with there being millions of
22
+ companies amd derivatives available on the market. Sure, the most traded companies and ETFs can quickly be found
23
+ simply because they are known to the public (for example, Microsoft, Tesla, S&P500 ETF or an All-World ETF). However,
24
+ what else is out there is often unknown.
25
+
26
+ **This database tries to solve that**. It features 180.000+ symbols containing Equities, ETFs, Funds, Indices, Futures,
27
+ Options, Currencies, Cryptocurrencies and Money Markets. It therefore allows you to obtain a broad overview of sectors,
28
+ industries, types of investments and much more.
29
+
30
+ The aim of this database is explicitly _not_ to provide up-to-date fundamentals or stock data as those can be obtained
31
+ with ease (with the help of this database) by using [FundamentalAnalysis](https://github.com/JerBouma/FundamentalAnalysis)
32
+ or [yfinance](https://github.com/ranaroussi/yfinance). Instead, it gives insights into the products that exist in each
33
+ country, industry and sector and gives the most essential information about each product. With this information, you
34
+ can analyse specific areas of the financial world and/or find that product that is hard to find. See for examples
35
+ on how you can combine this database and the earlier mentioned packages the section [Examples](#Examples).
36
+
37
+ Some key statistics of the database:
38
+
39
+ | Product | Quantity | Sectors | Industries | Countries | Exchanges |
40
+ | ----------------- | --------- | --------- | ------------- | --------- | --------- |
41
+ | Equities | 84.091 | 16 | 262 | 109 | 79 |
42
+ | ETFs | 15.892 | 268* | 88* | 100** | 44 |
43
+ | Funds | 34.947 | 857* | 416* | 100** | 25 |
44
+
45
+ | Product | Quantity | Exchanges |
46
+ | ----------------- | --------- | --------- |
47
+ | Indices | 24.548 | 62 |
48
+ | Currencies | 2.529 | 2 |
49
+ | Cryptocurrencies | 3.624 | 1 |
50
+ | Options | 13.819 | 1 |
51
+ | Futures | 1.173 | 7 |
52
+ | Money Markets | 1.384 | 2 |
53
+
54
+ \* These numbers refer to families (iShares, Vanguard) and categories (World Stock, Real Estate) respectively.
55
+ \** This is an estimation. Obtaining the country distribution can only be done by collecting data on the underlying
56
+ or by manual search.
57
+
58
+ ## Usage
59
+ To access the database you can download the entire repository but I strongly recommend making use of the package
60
+ closely attached to the database. It allows you to select specific json files as well as search through collected
61
+ data with a specific query.
62
+
63
+ You can install the package with the following steps:
64
+ 1. `pip install FinanceDatabase`
65
+ - Alternatively, download the 'Searcher' directory.
66
+ 2. (within Python) `import FinanceDatabase as fd`
67
+
68
+ The package has the following functions:
69
+ - `show_options(product)` - gives all available options from the below functions per product (i.e. Equities, Funds)
70
+ which then can be used to collect the data.
71
+ - `select_cryptocurrencies(cryptocurrency=None)` - with no input gives all cryptocurrencies, with input gives
72
+ the cryptocurrency of choice.
73
+ - `select_currencies(currency=None)` - with no input gives all currencies, with input gives
74
+ the currency of choice.
75
+ - `select_etfs(category=None)` - with no input gives all etfs, with input gives all etfs of a
76
+ specific category.
77
+ - `select_equities(country=None, sector=None, industry=None)` - with no input gives all equities, with input
78
+ gives all equities of a country, sector, industry or a combination of the three.
79
+ - `select_funds(category=None)` - with no input gives all funds, with input gives all funds of a
80
+ specific category.
81
+ - `def select_indices(market=None)` - with no input gives all indices, with input gives all funds of a
82
+ specific market which usually refers to indices in a specific country (like de_market gives DAX).
83
+ - `select_other(product)` - gives either all Futures, all Moneymarkets or all Options.
84
+ - `search_products(database, query, new_database=None)` - with input from the above functions, this function searching
85
+ for specific values in the summary of the product (i.e. the query 'sustainable')
86
+
87
+ ## Examples
88
+ This section gives a few examples of the possibilities with this package. These are merely a few of the things you
89
+ can do with the package and it only uses yfinance. **As you can obtain a wide range of symbols, pretty much any package
90
+ that requires symbols should work.**
91
+
92
+ ### United States' Airlines
93
+ If I wish to obtain all companies within the United States listed under 'Airlines' I can write the
94
+ following code:
95
+ ````
96
+ import FinanceDatabase as fd
97
+
98
+ airlines_us = fd.select_equities(country='United States', sector='Industrials', industry='Airlines')
99
+ ````
100
+ Then, I can use packages like [yfinance](https://github.com/ranaroussi/yfinance) to quickly collect data from
101
+ Yahoo Finance for each symbol in the industry like this:
102
+ ````
103
+ from yfinance.utils import get_json
104
+ from yfinance import download
105
+
106
+ airlines_us_fundamentals = {}
107
+ for symbol in airlines_us:
108
+ airlines_us_fundamentals[symbol] = get_json("https://finance.yahoo.com/quote/" + symbol)
109
+
110
+ airlines_us_stock_data = download(list(airlines_us))
111
+ ````
112
+ With a few lines of code, I have collected all data from a specific industry within the United States. From here on
113
+ you can compare pretty much any key statistic, fundamental data and stock data. For example, let's plot a simple bar
114
+ chart that gives insights in the Quick Ratios (indicator of the overall financial strength or weakness of a company):
115
+ ````
116
+ import matplotlib.pyplot as plt
117
+
118
+ for symbol in airlines_us_fundamentals:
119
+ quick_ratio = airlines_us_fundamentals[symbol]['financialData']['quickRatio']
120
+ long_name = airlines_us_fundamentals[symbol]['quoteType']['longName']
121
+
122
+ if quick_ratio is None:
123
+ continue
124
+
125
+ plt.barh(long_name, quick_ratio)
126
+
127
+ plt.tight_layout()
128
+ plt.show()
129
+ ``````
130
+ Which results in the graph displayed below (as of the 3rd of February 2021). From this graph you could identify
131
+ companies that currently lack enough assets to cover their liabilities (quick ratio < 1) and those that do have enough
132
+ assets (quick ratio > 1). Both too low and too high could make you wonder whether the company adequately manages
133
+ its assets.
134
+
135
+ ![FinanceDatabase](Examples/United_States_Airlines_QuickRatio.png)
136
+
137
+ ### Semiconductors ETFs
138
+ If I wish to obtain all ETFs that have something to do with 'semiconductors' I can use the search function which works
139
+ as follows:
140
+ ````
141
+ import FinanceDatabase as fd
142
+
143
+ all_etfs = fd.select_etfs()
144
+ semiconductor_etfs = search_products(all_etfs, 'semiconductor')
145
+ ````
146
+ The variable semiconductor_etfs returns all etfs that have the word 'semiconductor' in their summary which usually also
147
+ corresponds to the fact they are targeted around semiconductors. Next, I collect data:
148
+ ````
149
+ semiconductor_etfs_fundamentals = {}
150
+ for symbol in semiconductor_etfs:
151
+ semiconductor_etfs_fundamentals[symbol] = get_json("https://finance.yahoo.com/quote/" + symbol)
152
+ ````
153
+ And lastly, I have a look at the YTD returns (as of the 3rd of February 2021) of each ETF to understand which ones
154
+ might be worthwile to invest in:
155
+ ````
156
+ for symbol in semiconductor_etfs_fundamentals:
157
+ ytd_return = semiconductor_etfs_fundamentals[symbol]['fundPerformance']['trailingReturns']['ytd']
158
+ long_name = semiconductor_etfs_fundamentals[symbol]['quoteType']['longName']
159
+
160
+ if ytd_return is None:
161
+ continue
162
+
163
+ plt.barh(long_name, ytd_return)
164
+
165
+ plt.tight_layout()
166
+ plt.xticks([-1, -0.5, 0, 0.5, 1], ['-100%', '-50%', '0%', '50%', '100%'])
167
+ plt.show()
168
+ ````
169
+ This results in the following graph which gives _some_ insights in the available semiconductor ETFs. Then with the large amount of fundamentals data you can
170
+ figure out how each ETF differs and what might be worthwile to invest in.
171
+
172
+ ![FinanceDatabase](Examples/Semiconductors_ETFs_Returns.png)
173
+
174
+
175
+
@@ -0,0 +1,8 @@
1
+ Searcher/__init__.py,sha256=SQZsYUKL1Imdm8E3bzAq4s9yZBdND_9uZ-sAfgzFWtA,387
2
+ Searcher/json_options.py,sha256=K4vhI3sqwSf8NWI50OlpAH1mE53jYu3IEKnKXszEHA8,1159
3
+ Searcher/json_picker.py,sha256=4i6heSaxpaNLDAputUW9LomaYQHSkNria007nIdq2l4,6805
4
+ FinanceDatabase-0.1.0.dist-info/LICENSE,sha256=ZAOE27yAFlghnUI41yF3PcGqCAf00STEm7yIAjgb-j8,1090
5
+ FinanceDatabase-0.1.0.dist-info/METADATA,sha256=N1sy0ZaKQfzCOIoaomhcgs8jA9Qzjsoo-9RKt9PT_lY,8910
6
+ FinanceDatabase-0.1.0.dist-info/WHEEL,sha256=OqRkF0eY5GHssMorFjlbTIq072vpHpF60fIQA6lS9xA,92
7
+ FinanceDatabase-0.1.0.dist-info/top_level.txt,sha256=fcQge8j8kNtCcDPgmW1D6HEWo7a7cAQlq2quar7UEfc,9
8
+ FinanceDatabase-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.36.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ Searcher
Searcher/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ # Modules
2
+ from .json_picker import select_cryptocurrencies
3
+ from .json_picker import select_currencies
4
+ from .json_picker import select_etfs
5
+ from .json_picker import select_equities
6
+ from .json_picker import select_funds
7
+ from .json_picker import select_indices
8
+ from .json_picker import select_other
9
+ from .json_options import show_options
10
+ from .json_options import search_products
@@ -0,0 +1,33 @@
1
+ import requests
2
+ import json
3
+
4
+
5
+ def show_options(product):
6
+ URL = ("https://raw.githubusercontent.com/JerBouma/FinanceDatabase/master/"
7
+ "Database/Categories/")
8
+
9
+ if product.lower() not in ['cryptocurrencies', 'currencies', 'equities', 'etfs', 'funds']:
10
+ raise ValueError((product.lower() + " is not an available options. Please choose either 'cryptocurrencies', "
11
+ "'currencies', 'equities', 'etfs' or 'funds'"))
12
+ try:
13
+ json_file = URL + product.lower() + '_options.json'
14
+ request = requests.get(json_file)
15
+ json_data = json.loads(request.text)
16
+ except json.decoder.JSONDecodeError:
17
+ raise ValueError("Not able to find the options for " + product.lower())
18
+
19
+ return json_data
20
+
21
+
22
+ def search_products(database, query, new_database=None):
23
+ if new_database is None:
24
+ new_database = {}
25
+
26
+ for symbol in database:
27
+ try:
28
+ if query in database[symbol]['summary']:
29
+ new_database[symbol] = database[symbol]
30
+ except (TypeError, KeyError):
31
+ continue
32
+
33
+ return new_database
@@ -0,0 +1,181 @@
1
+ import requests
2
+ import json
3
+
4
+
5
+ def select_cryptocurrencies(cryptocurrency=None):
6
+ URL = ("https://raw.githubusercontent.com/JerBouma/FinanceDatabase/master/"
7
+ "Database/Cryptocurrencies/")
8
+
9
+ if cryptocurrency:
10
+ try:
11
+ json_file = URL + cryptocurrency + '.json'
12
+ request = requests.get(json_file)
13
+ json_data = json.loads(request.text)
14
+ except json.decoder.JSONDecodeError:
15
+ raise ValueError("Not able to find any data for {}".format(cryptocurrency))
16
+ else:
17
+ try:
18
+ json_file = URL + "_Cryptocurrencies.json"
19
+ request = requests.get(json_file)
20
+ json_data = json.loads(request.text)
21
+ except json.decoder.JSONDecodeError:
22
+ raise ValueError("Not able to find any data.")
23
+
24
+ return json_data
25
+
26
+
27
+ def select_currencies(currency=None):
28
+ URL = ("https://raw.githubusercontent.com/JerBouma/FinanceDatabase/master/"
29
+ "Database/Currencies/")
30
+
31
+ if currency:
32
+ try:
33
+ json_file = URL + currency + '.json'
34
+ request = requests.get(json_file)
35
+ json_data = json.loads(request.text)
36
+ except json.decoder.JSONDecodeError:
37
+ raise ValueError("Not able to find any data for {}".format(currency))
38
+ else:
39
+ try:
40
+ json_file = URL + "_Currencies.json"
41
+ request = requests.get(json_file)
42
+ json_data = json.loads(request.text)
43
+ except json.decoder.JSONDecodeError:
44
+ raise ValueError("Not able to find any data.")
45
+
46
+ return json_data
47
+
48
+
49
+ def select_etfs(category=None):
50
+ URL = ("https://raw.githubusercontent.com/JerBouma/FinanceDatabase/master/"
51
+ "Database/ETFs/")
52
+
53
+ if category:
54
+ category = category.replace(' ', '%20')
55
+ try:
56
+ json_file = URL + category + '.json'
57
+ request = requests.get(json_file)
58
+ json_data = json.loads(request.text)
59
+ except json.decoder.JSONDecodeError:
60
+ raise ValueError("Not able to find any data for {}".format(category))
61
+ else:
62
+ try:
63
+ json_file = URL + "_ETFs.json"
64
+ request = requests.get(json_file)
65
+ json_data = json.loads(request.text)
66
+ except json.decoder.JSONDecodeError:
67
+ raise ValueError("Not able to find any data.")
68
+
69
+ return json_data
70
+
71
+
72
+ def select_equities(country=None, sector=None, industry=None):
73
+ URL = ("https://raw.githubusercontent.com/JerBouma/FinanceDatabase/master/"
74
+ "Database/Equities/")
75
+
76
+ if country and sector and industry:
77
+ country = country.replace(' ', '%20')
78
+ sector = sector.replace(' ', '%20')
79
+ industry = industry.replace(' ', '%20')
80
+
81
+ try:
82
+ json_file = URL + 'Countries/' + country + '/' + sector + '/' + industry + ".json"
83
+ request = requests.get(json_file)
84
+ json_data = json.loads(request.text)
85
+ except json.decoder.JSONDecodeError:
86
+ raise ValueError("Not able to find any data with the combination of Country ({}), "
87
+ "Sector ({}), Industry ({}).".format(country, sector, industry))
88
+ elif sector and industry:
89
+ sector = sector.replace(' ', '%20')
90
+ industry = industry.replace(' ', '%20')
91
+
92
+ try:
93
+ json_file = URL + 'Sectors/' + sector + '/' + industry + ".json"
94
+ request = requests.get(json_file)
95
+ json_data = json.loads(request.text)
96
+ except json.decoder.JSONDecodeError:
97
+ raise ValueError("Not able to find any data with the combination of, "
98
+ "Sector ({}), Industry ({}).".format(sector, industry))
99
+ elif country:
100
+ country = country.replace(' ', '%20')
101
+
102
+ try:
103
+ json_file = URL + 'Countries/' + country + ".json"
104
+ request = requests.get(json_file)
105
+ json_data = json.loads(request.text)
106
+ except json.decoder.JSONDecodeError:
107
+ raise ValueError("Not able to find any data with the combination of "
108
+ "Country ({}).".format(country))
109
+ elif industry or (country and industry):
110
+ raise ValueError("Only selecting industry or country and industry results in no data.")
111
+ else:
112
+ try:
113
+ json_file = URL + "Equities.json"
114
+ request = requests.get(json_file)
115
+ json_data = json.loads(request.text)
116
+ except json.decoder.JSONDecodeError:
117
+ raise ValueError("Not able to find any data.")
118
+
119
+ return json_data
120
+
121
+
122
+ def select_funds(category=None):
123
+ URL = ("https://raw.githubusercontent.com/JerBouma/FinanceDatabase/master/"
124
+ "Database/Funds/")
125
+
126
+ if category:
127
+ category = category.replace(' ', '%20')
128
+ try:
129
+ json_file = URL + category + '.json'
130
+ request = requests.get(json_file)
131
+ json_data = json.loads(request.text)
132
+ except json.decoder.JSONDecodeError:
133
+ raise ValueError("Not able to find any data for {}".format(category))
134
+ else:
135
+ try:
136
+ json_file = URL + "_Funds.json"
137
+ request = requests.get(json_file)
138
+ json_data = json.loads(request.text)
139
+ except json.decoder.JSONDecodeError:
140
+ raise ValueError("Not able to find any data.")
141
+
142
+ return json_data
143
+
144
+
145
+ def select_indices(market=None):
146
+ URL = ("https://raw.githubusercontent.com/JerBouma/FinanceDatabase/master/"
147
+ "Database/Indices/")
148
+
149
+ if market:
150
+ try:
151
+ json_file = URL + market + '.json'
152
+ request = requests.get(json_file)
153
+ json_data = json.loads(request.text)
154
+ except json.decoder.JSONDecodeError:
155
+ raise ValueError("Not able to find any data for {}".format(market))
156
+ else:
157
+ try:
158
+ json_file = URL + "_Indices.json"
159
+ request = requests.get(json_file)
160
+ json_data = json.loads(request.text)
161
+ except json.decoder.JSONDecodeError:
162
+ raise ValueError("Not able to find any data.")
163
+
164
+ return json_data
165
+
166
+
167
+ def select_other(product):
168
+ URL = ("https://raw.githubusercontent.com/JerBouma/FinanceDatabase/master/"
169
+ "Database/Other/")
170
+
171
+ if product not in ['Futures', 'Moneymarkets', 'Options']:
172
+ raise ValueError("{} is not available. Only 'Futures', 'Moneymarkets' and 'Options'.")
173
+
174
+ try:
175
+ json_file = URL + product + ".json"
176
+ request = requests.get(json_file)
177
+ json_data = json.loads(request.text)
178
+ except json.decoder.JSONDecodeError:
179
+ raise ValueError("Not able to find any data with type {}.".format(product))
180
+
181
+ return json_data