This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List of stocks | |
stock_list = ['FB.O', 'AAPL.O', 'AMZN.O', 'NFLX.O', 'GOOGL.O'] | |
# Start Date | |
start_date = datetime.datetime(2019,6,10) | |
# End Date | |
end_date = datetime.datetime(2021,10,20) | |
# Set number of equities to the number of stocks | |
num_assets = len(stock_list) | |
# Set the risk factor | |
risk_factor = 0.7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EikonDataProvider(BaseDataProvider): | |
""" | |
The abstract base class for Eikon data_provider. | |
""" | |
def __init__(self, stocks_list, start_date, end_date): | |
''' | |
stocks -> List of interested assets | |
start -> start date to fetch historical data | |
end -> end date to fetch historical data | |
''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import datetime | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
from qiskit import Aer | |
from qiskit_finance.data_providers._base_data_provider import BaseDataProvider | |
from qiskit.finance.applications.ising import portfolio | |
from qiskit.circuit.library import TwoLocal | |
from qiskit.aqua import QuantumInstance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eikon_key = open("eikon.txt","r") | |
ek.set_app_key(str(eikon_key.read())) | |
eikon_key.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eikon as ek | |
print("Eikon version: ", ek.__version__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! pip install eikon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qiskit import IBMQ | |
IBMQ.save_account('MY_API_TOKEN') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warnings | |
warnings.filterwarnings("ignore") | |
import qiskit.tools.jupyter | |
%qiskit_version_table |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! pip install qiskit qiskit-finance==0.2.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
streamlit run qrng_final.py |