예제 #1
0
page.set_layout([
    html.H1(
        page.name,
        style={
            "margin-bottom": "10px",
            "margin-left": "4px",
        },
    ),
    html.Div(children='''
            Choose an asset to benchmark
        '''),
    html.Br(),
    generate_analysis_mode_dropdown(page.id),
    html.Br(),
    dcc.DatePickerRange(
        id='date-picker-range',
        # min_date_allowed = calendar_start_date,
        max_date_allowed=datetime.today(
        ),  # maximum date allowed on the DatePickerRange component
        initial_visible_month=datetime.today(
        ),  # the month initially presented when the user opens the calendar
        start_date=(datetime.today() - timedelta(30)).date(),
        end_date=datetime.today().date(),
        display_format='MMM Do, YY',
        persistence=True,
        persisted_props=['start_date'],
        updatemode='bothdates',
        className='date_picker',
    ),
    html.Br(),
    dcc.Graph(id='benchmark-comparison-graph')
])
예제 #2
0
sample_data = px.data.stocks()
sample_data = pd.DataFrame(sample_data)

page = Page("Diversification")
page.set_path('/analysis/diversification')
metrics = ['asset-list', 'number-of-shares']
page.set_storage(metrics)

page.set_layout([
    html.H1(
        page.name,
        style={
            "margin-bottom": "10px",
            "margin-left": "4px",
        },
    ),
    html.Br(),
    dcc.Graph(id='sunburst'),
    dcc.Graph(id='industry-pie-chart'),
    dcc.Graph(id='sector-pie-chart'),
    dcc.Graph(id='diversification-map'),
])


# TODO: speed up with caching and prevent initial call
@app.callback(
    [
        Output('diversification-map', 'figure'),
        Output('industry-pie-chart', 'figure'),
        Output('sector-pie-chart', 'figure'),
        Output('sunburst', 'figure')
    },
                 value=0,
                 mode="gauge+number+delta",
                 title={'text': "Gain to Pain ratio"},
                 gauge=default_gauge))

page.set_layout([
    html.H1(
        'Risk Adjusted Return',
        style={
            "margin-bottom": "10px",
            "margin-left": "4px",
        },
    ),
    html.Div(children='''
            Risk-adjusted metrics calculated on portfolio.
        '''),
    html.Br(),
    dcc.Graph(id='sharpe_ratio_indicator', figure=sharpe_ratio_fig),
    html.Br(),
    dcc.Graph(id='sortino_ratio_indicator', figure=sortino_ratio_fig),
    html.Br(),
    dcc.Graph(id='gain_to_pain_ratio_indicator',
              figure=gain_to_pain_ratio_fig),
])


@app.callback([
    Output('sharpe_ratio_indicator', 'figure'),
    Output('sortino_ratio_indicator', 'figure'),
    Output('gain_to_pain_ratio_indicator', 'figure')
        dbc.Col(
            html.Div([html.H3(id='profit-factor'),
                      html.P("Profit Factor")],
                     id='profit-factor',
                     className="mini_container")),
    ]),
    dcc.Graph(id='aggregate-value-close'),
])

page.set_layout([
    html.H1(
        page.name,
        style={
            "margin-bottom": "10px",
            "margin-left": "4px",
        },
    ),
    html.Div(children='''
            Trading activity overview.
        '''),
    metrics,
])


@app.callback([
    Output("p&l", "children"),
    Output('rate-of-return', 'children'),
    Output('profit-factor', 'children'),
    Output('total-amount-traded', 'children')
], [
    Input('overview-profit-list', 'modified_timestamp'),