Exemplo n.º 1
0
    def loadDates(self, dates=None):
        ''' 
        get data for all symbols as wide panel
        provide a dates list. If no dates list is provided, common dates are used.
        '''
        if dates is None: dates = self.commonDates

        tmp = {}

        for k, v in self.csv.iteritems():
            tmp[k] = v.loadDates(dates)

        return pd.WidePanel(tmp)
Exemplo n.º 2
0
import pandas as pd

from pybloqs.block.text import Span, Raw
from pybloqs.block.layout import Flow, HStack, VStack, Grid
from .generation_framework import assert_report_generated


colors = ["Red", "Green", "Blue", "Magenta", "Orange", "Yellow", "Teal"]

frame = pd.DataFrame({"a": [1.11111111, 2.22222222, 3.33333333], "b": ["foo", "baz", "bar"]}, index=[1, 2, 3])
panel = pd.WidePanel({"a": frame, "b": frame})


def _construct_style_inheritance(cls, **kwargs):
    return cls([Raw(color, background_color=color) for color in colors], text_align="right", title="Layout", **kwargs)


def _construct_nested_layout(cls, **kwargs):
    sub_flow = test_flow()
    sub_hstack = test_hstack()
    sub_vstack = test_vstack()
    sub_grid = test_grid()

    return cls([sub_flow, sub_hstack, sub_vstack, sub_grid], **kwargs)


@assert_report_generated
def test_flow():
    return Flow([Span(color, background_color=color) for color in colors], title="Flow Layout")

Exemplo n.º 3
0
 def construct_panel(self):
     self.panel = pandas.WidePanel(self.data_frames)
Exemplo n.º 4
0
import pandas as pd

from pybloqs.block.convenience import Block
from .generation_framework import assert_report_generated

series = pd.Series([1, 2, 3])
df = pd.DataFrame({"a": series, "b": series})
panel = pd.WidePanel({1: df, 2: df})


@assert_report_generated
def test_string():
    return Block("Hello World!", title="Salutations")


@assert_report_generated
def test_block():
    return Block(test_string(), title="Wrapped Block")


@assert_report_generated
def test_none():
    return Block(None, title="Empty Block")


@assert_report_generated
def test_matplotlib():
    return Block(series.plot(), title="Matplotlib Block")


@assert_report_generated
Exemplo n.º 5
0
import os
import pandas as pd
import pybloqs.plot as pbp

from .generation_framework import assert_report_generated


script_dir = os.path.dirname(__file__)

df = pd.read_csv(os.path.join(script_dir, "test_plot_df1.csv"), index_col=0, parse_dates=True)
df1 = pd.read_csv(os.path.join(script_dir, "test_plot_df2.csv"), index_col=0, parse_dates=True)
df2 = pd.read_csv(os.path.join(script_dir, "test_plot_df3.csv"), index_col=0, parse_dates=True)

wp = pd.WidePanel({1: df, 2: df1, 3: df2}).ix[:, :30, :2]

df_cr = (df + 1).cumprod()

a = df_cr.A
b = df_cr.B
c = df_cr.C
c.name = "C"


@assert_report_generated
def test_series():
    return pbp.Plot(a)


@assert_report_generated
def test_dataframe():
    return pbp.Plot(df)