Spaces:
Runtime error
Runtime error
File size: 2,640 Bytes
976166f a77544c 976166f a77544c 976166f a77544c 976166f 588011f 976166f a77544c 976166f a77544c 976166f a77544c 976166f a77544c 976166f a77544c 976166f a77544c 976166f a77544c 976166f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
import panel as pn
import pandas as pd
from datetime import datetime, timedelta
import plotly.express as px
import holoviews as hv
import numpy as np
import random
import scipy.stats as stats
import hvplot.pandas # noqa
from sqlalchemy import create_engine
import api
# from backgroundTask import stocks_stream
from functools import partial
import plotly.graph_objects as go
from panel.viewable import Viewer
import processing
import appComponents
import param
import db_operation as db
# import warnings
pn.extension('mathjax')
# warnings.filterwarnings("ignore", category=pd.core.common.SettingWithCopyWarning)
pn.extension('plotly')
pn.extension('tabulator')
db_url = 'sqlite:///instance/local.db'
engine = create_engine(db_url)
analytic_p = db.get_portfolio_analytic_df()
analytic_b = db.get_benchmark_analytic_df()
# load benchmark stock
# with engine.connect() as connection:
# analytics_df = pd.read
# calculated_b_stock = pd.read_sql('calculated_b_stock', con=connection)
# calculated_p_stock = pd.read_sql('calculated_p_stock', con=connection)
# p_eval_df = pd.read_sql('p_eval_result', con=connection)
stock_overview = appComponents.BestAndWorstStocks(
analytic_df=analytic_p)
composation_card = appComponents.PortfolioComposationCard(
analytic_p)
monthly_return_card = appComponents.HistReturnCard(
calculated_p_stock=analytic_p, calculated_b_stock=analytic_b)
# total_return_card = appComponents.TotalReturnCard(name='Range', eval_df=p_eval_df,
# b_stock_df=calculated_b_stock,
# p_stock_df=calculated_p_stock,
# value=(0, 20))
# drawdown_card = appComponents.DrawDownCard(
# eval_df=p_eval_df, calculated_p_stock=calculated_p_stock, calculated_b_stock=calculated_b_stock)
# top_header = appComponents.TopHeader(
# eval_df=p_eval_df
# )
template = pn.template.FastListTemplate(
title="Portfolio一览",
# sidebar=[freq, phase],
)
template.main.extend([stock_overview, composation_card, monthly_return_card])
# template.main.extend(
# [pn.Row(top_header),
# pn.Row(
# pn.Column(monthly_return_card, stock_overview,
# width=500, margin=(10, 10, 10, 10)),
# pn.Column(total_return_card, drawdown_card, margin=(10, 10, 10, 10)),
# pn.Column(composation_card, margin=(10, 10, 10, 10)),
# )]
# )
template.servable()
# pn.Row(
# pn.Column(monthly_return_card, stock_overview, width=500),
# pn.Column(total_return_card),
# pn.Column(composation_card)
# ).servable()
|