Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Update Finance and ML docs #938

Merged
merged 6 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/apidocs/qiskit.finance.applications.ising.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _qiskit-finance-applications-ising:

.. automodule:: qiskit.finance.applications.ising
:no-members:
:no-inherited-members:
:no-special-members:
6 changes: 6 additions & 0 deletions docs/apidocs/qiskit.finance.applications.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _qiskit-finance-applications:

.. automodule:: qiskit.finance.applications
:no-members:
:no-inherited-members:
:no-special-members:
20 changes: 18 additions & 2 deletions qiskit/finance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,39 @@
===============================================
Qiskit's finance module (:mod:`qiskit.finance`)
===============================================
This is the finance domain logic....

.. currentmodule:: qiskit.finance

This is the Qiskit`s finance module. There is an initial set of function here that
will be built out over time. At present it has applications in the form of
Ising Hamiltonians. Some financial uncertainty problem components and data providers
which supply a source of financial data.

.. autosummary::
:toctree: ../stubs/
:nosignatures:

QiskitFinanceError

In addition to standard Python errors Qiskit's finance module will raise this error if
circumstances are that it cannot proceed to completion.

Submodules
==========

.. autosummary::
:toctree:

applications
components
data_providers

"""

from .exceptions import QiskitFinanceError
from ._logging import (get_qiskit_finance_logging,
set_qiskit_finance_logging)

__all__ = ['get_qiskit_finance_logging',
__all__ = ['QiskitFinanceError',
'get_qiskit_finance_logging',
'set_qiskit_finance_logging']
19 changes: 19 additions & 0 deletions qiskit/finance/applications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,22 @@
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""
Finance applications (:mod:`qiskit.finance.applications`)
=========================================================

.. currentmodule:: qiskit.finance.applications

Applications for Qiskit's finance module. The present set are in the form of
Ising Hamiltonians.

Submodules
==========

.. autosummary::
:toctree:

ising

"""
2 changes: 1 addition & 1 deletion qiskit/finance/applications/ising/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@


"""
=======================================================
Ising Models (:mod:`qiskit.finance.applications.ising`)
=======================================================

Ising models for finance problems

.. currentmodule:: qiskit.finance.applications.ising
Expand Down
7 changes: 4 additions & 3 deletions qiskit/finance/components/uncertainty_problems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This code is part of Qiskit.
#
# (C) Copyright IBM 2019.
# (C) Copyright IBM 2019, 2020
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -16,8 +16,9 @@
Uncertainty Problems (:mod:`qiskit.finance.components.uncertainty_problems`)
============================================================================
These are finance specific Aqua Uncertainty Problems where they inherit from
Aqua :class:`UncertaintyProblem`. As they rely on finance specific knowledge
and/or functions they live here rather than in Aqua.
Aqua :class:`~qiskit.aqua.components.uncertainty_problems.UncertaintyProblem`.
Because they rely on finance specific knowledge and/or functions they are
located here rather than in Aqua.

.. currentmodule:: qiskit.finance.components.uncertainty_problems

Expand Down
20 changes: 11 additions & 9 deletions qiskit/finance/data_providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2019.
# (C) Copyright IBM 2018, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -15,29 +15,31 @@
"""
Data Providers (:mod:`qiskit.finance.data_providers`)
=====================================================
Providers of financial data...

.. currentmodule:: qiskit.finance.data_providers

Data Providers Base Class
=========================
A selection of providers for financial data. These may be backed by
an external service that sources the actual data; please refer to the
specific provider class below, for more information in that regard.

Data Provider Base Class
========================

.. autosummary::
:toctree: ../stubs/
:nosignatures:

BaseDataProvider

Data Provider Utilities
=======================
Data Provider Types
===================

.. autosummary::
:toctree: ../stubs/
:nosignatures:

DataType
StockMarket
QiskitFinanceError

Data Providers
==============
Expand All @@ -53,13 +55,13 @@

"""

from ._base_data_provider import BaseDataProvider, DataType, StockMarket, QiskitFinanceError
from ._base_data_provider import BaseDataProvider, DataType, StockMarket
from .data_on_demand_provider import DataOnDemandProvider
from .exchange_data_provider import ExchangeDataProvider
from .wikipedia_data_provider import WikipediaDataProvider
from .random_data_provider import RandomDataProvider

__all__ = [
'BaseDataProvider', 'DataType', 'QiskitFinanceError', 'StockMarket', 'RandomDataProvider',
'BaseDataProvider', 'DataType', 'StockMarket', 'RandomDataProvider',
'DataOnDemandProvider', 'ExchangeDataProvider', 'WikipediaDataProvider'
]
7 changes: 1 addition & 6 deletions qiskit/finance/data_providers/_base_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@

import numpy as np
import fastdtw
from qiskit.aqua import AquaError
from ..exceptions import QiskitFinanceError

logger = logging.getLogger(__name__)


class QiskitFinanceError(AquaError):
""" Qiskit Finance Error """
pass


# Note: Not all DataProviders support all stock markets.
# Check the DataProvider before use.
class StockMarket(Enum):
Expand Down
10 changes: 5 additions & 5 deletions qiskit/finance/data_providers/data_on_demand_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

""" data on demand provider """
""" NASDAQ Data on demand data provider. """

from typing import Optional, Union, List
import datetime
Expand All @@ -22,15 +22,15 @@
import certifi
import urllib3

from qiskit.finance.data_providers import (BaseDataProvider,
StockMarket, QiskitFinanceError)
from ._base_data_provider import BaseDataProvider, StockMarket
from ..exceptions import QiskitFinanceError

logger = logging.getLogger(__name__)


class DataOnDemandProvider(BaseDataProvider):
"""
Python implementation of an NASDAQ Data on Demand data provider.
"""NASDAQ Data on Demand data provider.

Please see:
https://github.com/Qiskit/qiskit-tutorials/qiskit/finance/data_providers/time_series.ipynb
for instructions on use, which involve obtaining a NASDAQ DOD access token.
Expand Down
9 changes: 5 additions & 4 deletions qiskit/finance/data_providers/exchange_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

""" exchange data provider """
""" Exchange data provider. """

from typing import Union, List
import datetime
import importlib
import logging

from qiskit.finance.data_providers import (BaseDataProvider,
StockMarket, QiskitFinanceError)
from ._base_data_provider import BaseDataProvider, StockMarket
from ..exceptions import QiskitFinanceError

logger = logging.getLogger(__name__)


class ExchangeDataProvider(BaseDataProvider):
"""Python implementation of an Exchange Data provider.
"""Exchange data provider.

Please see:
https://github.com/Qiskit/qiskit-tutorials/qiskit/finance/data_providers/time_series.ipynb
for instructions on use, which involve obtaining a Quandl access token.
Expand Down
13 changes: 4 additions & 9 deletions qiskit/finance/data_providers/random_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""
Python implementation of provider of mock stock-market data, which are generated pseudo-randomly.
"""
""" Pseudo-randomly generated mock stock-market data provider """

from typing import Optional, Union, List
import datetime
Expand All @@ -24,17 +22,14 @@
import numpy as np
import pandas as pd

from qiskit.finance.data_providers import (BaseDataProvider,
StockMarket,
QiskitFinanceError)
from ._base_data_provider import BaseDataProvider, StockMarket
from ..exceptions import QiskitFinanceError

logger = logging.getLogger(__name__)


class RandomDataProvider(BaseDataProvider):
"""
Python implementation of provider of mock stock-market data,
which are generated pseudo-randomly.
"""Pseudo-randomly generated mock stock-market data provider.
"""

def __init__(self,
Expand Down
12 changes: 7 additions & 5 deletions qiskit/finance/data_providers/wikipedia_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

""" wikipedia data provider """
""" Wikipedia data provider. """

from typing import Optional, Union, List
import datetime
Expand All @@ -22,17 +22,19 @@
import quandl
from quandl.errors.quandl_error import NotFoundError

from qiskit.finance.data_providers import (BaseDataProvider,
StockMarket, QiskitFinanceError)
from ._base_data_provider import BaseDataProvider, StockMarket
from ..exceptions import QiskitFinanceError

logger = logging.getLogger(__name__)


class WikipediaDataProvider(BaseDataProvider):
"""Python implementation of a Wikipedia data provider.
"""Wikipedia data provider.

Please see:
https://github.com/Qiskit/qiskit-tutorials/qiskit/finance/data_providers/time_series.ipynb
woodsp-ibm marked this conversation as resolved.
Show resolved Hide resolved
for instructions on use."""
for instructions on use.
"""

def __init__(self,
token: Optional[str] = None,
Expand Down
22 changes: 22 additions & 0 deletions qiskit/finance/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-

# This code is part of Qiskit.
#
# (C) Copyright IBM 2019, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

""" Finance Exception """

from qiskit.aqua.aqua_error import AquaError


class QiskitFinanceError(AquaError):
"""Class for errors returned by Qiskit's finance module."""
pass
5 changes: 4 additions & 1 deletion qiskit/ml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
===================================================
Qiskit's Machine Learning module (:mod:`qiskit.ml`)
===================================================
This is the machine learning domain logic....

.. currentmodule:: qiskit.ml

This is the Qiskit`s machine learning module. There is an initial set of function here that
will be built out over time. At present it has sample sets that can be used with
Aqua's :mod:`~qiskit.aqua.algorithms.classifiers`.

Submodules
==========

Expand Down
4 changes: 2 additions & 2 deletions qiskit/optimization/applications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# that they have been altered from the originals.

"""
Optimization applications (:mod:`qiskit.aqua.applications`)
===========================================================
Optimization applications (:mod:`qiskit.optimization.applications`)
===================================================================

.. currentmodule:: qiskit.optimization.applications

Expand Down
1 change: 1 addition & 0 deletions qiskit/optimization/applications/ising/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Ising Models (:mod:`qiskit.optimization.applications.ising`)
============================================================

Ising models for optimization application problems

.. currentmodule:: qiskit.optimization.applications.ising
Expand Down
2 changes: 1 addition & 1 deletion test/finance/test_data_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from test.finance import QiskitFinanceTestCase
import warnings
import numpy as np
from qiskit.finance import QiskitFinanceError
from qiskit.finance.data_providers import (RandomDataProvider,
QiskitFinanceError,
WikipediaDataProvider,
StockMarket,
DataOnDemandProvider,
Expand Down