def get_core_selection_data(username, password):
    degiro = degiroapi.DeGiro()
    degiro.login(username, password)

    data_set = {}
    print("Prepare dictionary..")
    for symbol in tqdm(isin):
        try:
            searcher = degiro.search_products(symbol)
            data_set[f"{searcher[0]['symbol']}.{isin[symbol]}"] = {}
            data_set[f"{searcher[0]['symbol']}.{isin[symbol]}"][
                'name'] = searcher[0]['name']
            data_set[f"{searcher[0]['symbol']}.{isin[symbol]}"][
                'ISIN'] = symbol
        except Exception as e:
            print(f"Error for {symbol} dictionary preparing: {e}")

    data_set_with_data = {}
    print("Collecting data..")
    for symbol in tqdm(data_set):
        try:
            data_set_with_data[symbol] = get_json(
                "https://finance.yahoo.com/quote/" + symbol)
            data_set_with_data[symbol]['ISIN'] = data_set[symbol]['ISIN']
        except Exception as e:
            print(f"Error for {symbol} data collection: {e}")

    dump_pickle(data_set_with_data, 'core_selection_degiro.pickle')

    return data_set_with_data
예제 #2
0
def main():
    st.set_page_config(layout='wide')
    state = _get_state()

    placeholder = st.empty()
    if state.degiro is None:
        with placeholder.form('2FA'):
            username = st.text_input('Username', '')
            password = st.text_input('Password', '', type='password')
            totp = st.text_input('2FA - Leave empty if not needed', '')
            if st.form_submit_button('Submit'):
                state.degiro = degiroapi.DeGiro()
                try:
                    state.degiro.login(username, password, totp)
                except Exception:
                    st.warning('Wrong credentials')
                    state.degiro = None
                    st.stop()

    if state.degiro and state.products is None:
        placeholder.empty()
        process.get_data(state)

    if state.products is not None:
        show_page(state)

    state.sync()
예제 #3
0
 def login(self, request_body):
     try:
         degiro = degiroapi.DeGiro()
         resp = degiro.login(request_body.get("username"),
                             request_body.get("password"))
         return resp
     except Exception as exc:
         return str(exc), 401
예제 #4
0
 def get_portfolio(self):
     try:
         degiro = degiroapi.DeGiro()
         resp = degiro.login(*self.parse_basic_auth_creds())
         portfolio = degiro.getdata(degiroapi.Data.Type.PORTFOLIO)
         return portfolio, 200
     except Exception as exc:
         return str(exc), 401
예제 #5
0
 def get_cash_funds(self):
     try:
         degiro = degiroapi.DeGiro()
         resp = degiro.login(*self.parse_basic_auth_creds())
         cachfunds = degiro.getdata(degiroapi.Data.Type.CASHFUNDS)
         return cachfunds, 200
     except Exception as exc:
         return str(exc), 401
예제 #6
0
def connect_degiro():
    """Creates a degiro connection"""
    logger.info("Connecting to DeGiro...")
    degiro = degiroapi.DeGiro()
    with open(DEGIRO_PATH) as f:
        d = json.load(f)
        degiro.login(d['username'], d['password'])

    return degiro
예제 #7
0
import requests
import yfinance as yf
from degiroapi.product import Product
from degiroapi.order import Order
from degiroapi.utils import pretty_json
import credentials
import etfs

import pandas as pd
from datetime import datetime, timedelta

requests.get('http://charting.vwdservices.com', verify=False)

# start the session

degiro = degiroapi.DeGiro()
degiro.login(credentials.username, credentials.password)

# Log the session details
session = {}
cashfunds = degiro.getdata(degiroapi.Data.Type.CASHFUNDS)
portfolio = degiro.getdata(degiroapi.Data.Type.PORTFOLIO, True)

# Get the products from the ETFsx
for etf_name, tickr in etfs.list.items():
    product = yf.Ticker(tickr)
    data = yf.download(tickr, period="2m")
    print(product.info['shortName'])
    print(product.history(period="max"))

#try: