import FinanceDatabase as fd

all_technology_companies = fd.select_equities(sector='Technology')
silicon_valley = fd.search_products(all_technology_companies,
                                    query='San Jose',
                                    search='city')

for ticker in silicon_valley.copy():
    if '.' in ticker:
        del silicon_valley[ticker]

import FundamentalAnalysis as fa

API_KEY = "YOUR_API_KEY_HERE"
data_set = {}
for ticker in silicon_valley:
    try:
        data_set[ticker] = fa.key_metrics(ticker, API_KEY, period='annual')
    except Exception:
        continue

import pandas as pd
import matplotlib.pyplot as plt

years = ['2016', '2017', '2018', '2019', '2020']
market_cap = pd.DataFrame(index=years)
for ticker in data_set:
    try:
        data_years = []
        for year in years:
            data_years.append(data_set[ticker].loc['marketCap'][year])
import FinanceDatabase as fd
import pandas as pd

core_selection = fd.select_etfs("core_selection_degiro_filtered")

tickers = pd.Series(core_selection.keys())
tickers.to_excel('core_selection_tickers.xlsx', index=None, header=None)
Exemplo n.º 3
0
import FinanceDatabase as fd
from yfinance.utils import get_json
from yfinance import download
import matplotlib.pyplot as plt

airlines_us = fd.select_equities(country='United States', industry='Airlines')

airlines_us_fundamentals = {}
for symbol in airlines_us:
    airlines_us_fundamentals[symbol] = get_json(
        "https://finance.yahoo.com/quote/" + symbol)

airlines_us_stock_data = download(list(airlines_us))

for symbol in airlines_us_fundamentals:
    quick_ratio = airlines_us_fundamentals[symbol]['financialData'][
        'quickRatio']
    long_name = airlines_us_fundamentals[symbol]['quoteType']['longName']

    if quick_ratio is None:
        continue

    plt.barh(long_name, quick_ratio)

plt.tight_layout()
plt.show()
Exemplo n.º 4
0
import FinanceDatabase as fd
import matplotlib.pyplot as plt
import pandas as pd
import yfinance as yf
from ta.volatility import BollingerBands

# Obtain all ETFs in the category health then filter based on biotech
health_etfs = fd.select_etfs(category='Health')
health_etfs_in_biotech = fd.search_products(health_etfs, 'biotech')

# Download stock data on the Biotech companies
stock_data_biotech = yf.download(list(health_etfs_in_biotech.keys()),
                                 start="2020-01-01",
                                 end="2020-06-01")['Adj Close']
stock_data_biotech = stock_data_biotech.dropna(axis='columns')

# Initalise the plot and row/column variables
figure, axis = plt.subplots(4, 3)
row = 0
column = 0

# Loop over the tickers
for ticker in stock_data_biotech.columns:
    # Initalise the DataFrame
    data_plot = pd.DataFrame(stock_data_biotech[ticker])

    # Initialize Bollinger Bands Indicator
    indicator_bb = BollingerBands(close=stock_data_biotech[ticker],
                                  window=20,
                                  window_dev=2)
import FinanceDatabase as fd
from yfinance.utils import get_json
import matplotlib.pyplot as plt

all_etfs = fd.select_etfs()

semiconductor_etfs = fd.search_products(all_etfs, 'semiconductor')

# Remove some unwanted ETFs
del semiconductor_etfs['DXSH.DE']
del semiconductor_etfs['DXSH.F']

semiconductor_etfs_fundamentals = {}
for symbol in semiconductor_etfs:
    semiconductor_etfs_fundamentals[symbol] = get_json(
        "https://finance.yahoo.com/quote/" + symbol)

for symbol in semiconductor_etfs_fundamentals:
    ytd_return = semiconductor_etfs_fundamentals[symbol]['fundPerformance'][
        'trailingReturns']['ytd']
    long_name = semiconductor_etfs_fundamentals[symbol]['quoteType'][
        'longName']

    if ytd_return is None:
        continue

    plt.barh(long_name, ytd_return)

plt.tight_layout()
plt.xticks([-1, -0.5, 0, 0.5, 1], ['-100%', '-50%', '0%', '50%', '100%'])
plt.show()
Exemplo n.º 6
0
import FinanceDatabase as fd
import matplotlib.pyplot as plt

# Obtain all countries from the database
equities_countries = fd.show_options('equities', 'countries')

# Obtain all sectors from the database
equities_sectors = fd.show_options('equities', 'sectors')

# Obtain all industries from the database
equities_industries = fd.show_options('equities', 'industries')

# Obtain all industries from the database
equities_all_categories = fd.show_options('equities')

equities_per_sector_netherlands = {}

for sector in equities_sectors[1:]:  # I skip the first sector since it means 'No Category'
    try:
        equities_per_sector_netherlands[sector] = len(fd.select_equities(country='Netherlands', sector=sector))
    except ValueError as error:
        print(error)

legend, values = zip(*equities_per_sector_netherlands.items())

colors = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'tab:blue', 'tab:orange', 'tab:gray',
          'lightcoral', 'yellow', 'saddlebrown', 'lightblue', 'olive']
plt.pie(values, labels=legend, colors=colors,
        wedgeprops={'linewidth': 0.5, 'edgecolor': 'white'})
plt.title('Companies per sector in the Netherlands')
plt.tight_layout()
Exemplo n.º 7
0
    def search_products(self, product):

        return fd.search_products()
Exemplo n.º 8
0
 def show_options(self, product):
     '''
         Can use this for initial tree of display options
     '''
     return fd.show_options(product)