def get_performance(resultset, from_date, to_date):
    df = pd.DataFrame.from_records(
        Performance(
            mock_src.MockSource(resultset, filename='client-demo.xlsx'),
            InMemoryBlockStore()).report(False, from_date, to_date, to_date))[[
                'date', 'mv', 'flows', 'inception'
            ]]

    return nicer(df)
Exemplo n.º 2
0
def test_volatility_example():
    # Test based upon the example here:
    # http://invest-made-easy.blogspot.com/2013/03/understanding-volatility-and-sharpe.html
    # The calculated standard deviation of the monthly returns should be 2.25%

    vol_fields = [DAY, VOL_INC, ANN_VOL_INC]

    df = pd.DataFrame.from_records(
        Performance(entity_scope="test",
                    entity_code="test_5yr_vol",
                    src=mock_src.MockSource(
                        'VolEx1',
                        filename=Path(__file__).parent.parent.joinpath(
                            "test-data.xlsx")),
                    block_store=InMemoryBlockStore()).report(
                        False,
                        '2019-12-31',
                        '2020-01-11',
                        '2020-01-11',
                        fields=vol_fields))[['date', 'mv'] + vol_fields]

    volatility = df[VOL_INC].values[-1]
    assert volatility == pytest.approx(0.0225, abs=0.00005)
from pathlib import Path
import pytest
import uuid

from pds import PerformanceDataSet
from performance_sources import mock_src
from misc import *
from block_stores.block_store_in_memory import InMemoryBlockStore
from block_stores.block_store_structured_results import BlockStoreStructuredResults

from tests.utilities.environment import test_scope
from tests.utilities.api_factory import api_factory
from interfaces import IBlockStore

src = mock_src.MockSource('Set1', filename=Path(__file__).parent.parent.joinpath("test-data.xlsx"))


def add_block(entity_scope: str, entity_code: str, bs: InMemoryBlockStore, sd, ed, ad) -> None:
    """
    Adds a block to a block store

    :param str entity_scope: The scope of the entity to add
    :param str entity_code: The code of the entity to add
    :param InMemoryBlockStore bs: The block store to add the block to
    :param sd: The effectiveAt start date
    :param ed: The effectiveAt end date
    :param ad: The asAt date

    :return: None
    """