def on_button_click(n): if n is not None: positions = Account_Positions() df_puts = positions.get_put_positions() df_calls = positions.get_call_positions() df_stocks = positions.get_stock_positions() cash_required = formatter_currency(df_puts["COST"].sum()) calls_dt = (dash_tabulator.DashTabulator( id="call-table", columns=[{ "id": i, "title": i, "field": i } for i in df_calls.columns], data=df_calls.to_dict("records"), ), ) stocks_dt = (dash_tabulator.DashTabulator( id="put-table", columns=[{ "id": i, "title": i, "field": i } for i in df_stocks.columns], data=df_stocks.to_dict("records"), ), ) puts_dt = (dash_tabulator.DashTabulator( id="put-table", columns=[{ "id": i, "title": i, "field": i } for i in df_puts.columns], data=df_puts.to_dict("records"), ), ) return ( puts_dt, calls_dt, stocks_dt, True, f" Cash Required : {cash_required}", ) else: return None, None, None, None, None
def on_button_click(n, start_date, end_date, ticker, instrument_type, tran_type, is_group): if n is None: return None, False, "" else: df = retrive_transactions(start_date, end_date, ticker, instrument_type, tran_type) logging.info("instrument_type is %s ", instrument_type) if not df.empty: sumText = 'Grand Total = "{}"'.format(round(df["TOTAL_PRICE"].sum(), 2)) options = {"selectable": 1} # Padd groupBy option to the Tabulator component to group at Ticker level if is_group: options["groupBy"] = "TICKER" columns = [ {"title": "DATE", "field": "DATE"}, {"title": "TOTAL PRICE", "field": "TOTAL_PRICE", "topCalc":"sum", "topCalcParams":{"precision":2,}}, {"title": "SYMBOL", "field": "SYMBOL"}, {"title": "TRAN TYPE", "field": "TRAN_TYPE"}, {"title": "POSITION", "field": "POSITION"}, {"title": "QTY", "field": "QTY"}, {"title": "PRICE", "field": "PRICE"}, {"title": "TICKER", "field": "TICKER"}, {"title": "TYPE", "field": "TYPE"}, {"title": "OPTION TYPE", "field": "OPTION_TYPE"}, ] dt = ( dash_tabulator.DashTabulator( id="screener-table", columns=columns, data=df.to_dict("records"), options=options, ), ) return dt, True, sumText else: return None, True, "No Records found"
{"id":2, "name":"Mary May", "age":"1", "col":"blue", "dob":"14/05/1982"}, {"id":3, "name":"Christine Lobowski", "age":"42", "col":"green", "dob":"22/05/1982"}, {"id":4, "name":"Brendon Philips", "age":"125", "col":"orange", "dob":"01/08/1980"}, {"id":5, "name":"Margret Marmajuke", "age":"16", "col":"yellow", "dob":"31/01/1999"}, {"id":6, "name":"Fred Savage", "age":"16", "col":"yellow", "rating":"1", "dob":"31/01/1999"}, {"id":7, "name":"Brie Larson", "age":"30", "col":"blue", "rating":"1", "dob":"31/01/1999"}, ] options = { "groupBy": "col", "selectable":1} downloadButtonType = {"css": "btn btn-primary", "text":"Export", "type":"xlsx"} app.layout = html.Div([ dash_tabulator.DashTabulator( id='input', columns=[], data=[], options=options, downloadButtonType=downloadButtonType, ), html.Div(id='output'), dcc.Interval( id='interval-component-iu', interval=1*10, # in milliseconds n_intervals=0, max_intervals=0 ) ]) @app.callback([ Output('input', 'columns'), Output('input', 'data')],
downloadButtonType = { "css": "btn btn-primary", "text": "Export", "type": "xlsx" } clearFilterButtonType = { "css": "btn btn-outline-dark", "text": "Clear Filters" } initialHeaderFilter = [{"field": "col", "value": "blue"}] app.layout = html.Div([ dash_tabulator.DashTabulator( id='tabulator', theme="tabulator", options=options, downloadButtonType=downloadButtonType, clearFilterButtonType=clearFilterButtonType, ), html.Div(id='output'), dcc.Interval( id='interval-component-iu', interval=1 * 10, # in milliseconds n_intervals=0, max_intervals=0) ]) @app.callback([ Output('tabulator', 'columns'), Output('tabulator', 'data'),
config={"scrollZoom":True, "displayModeBar":False, "displaylogo":False}, figure=empty_cube_figure, ), ]), dbc.Col(width=4, children=[ dtb.DashTabulator( id="rubik-table-history", data=[], columns=[ { "title":"Move Sequence (Click to Revert)", "columns":[ {"title":"Index", "field":"i", "hozAlign":"center", "headerSort":False}, {"title":"Move", "field":"move", "hozAlign":"center", "headerSort":False}, ] }, ], options={ "placeholder":"None", "layout":"fitDataStretch", "height":"100vw", "minHeight":"100vh", "maxHeight":"100vh", "selectable":"false", }, ), ]), ]), ]), ]), dbc.Card([
dbc.Input( type="text", disabled=True, ), ], ), dtb.DashTabulator( id="tabulator-pivot-raw", data=[], columns=[{ "title": "", "field": "none", "hozAlign": "center", "headerSort": False, }], options={ "placeholder": "None", "layout": "fitDataStretch", "layoutColumnsOnNewData": False, "minHeight": "50vh", "maxHeight": "50vh", "height": "50vh", "pagination": "local", "selectable": False, }, ), ]), ]), dbc.Card([ dbc.CardHeader([ dcc.Markdown(""" ### The Pivot Table
{ "title": "School Enrollment", "field": "Enrollment", "hozAlign": "right", "formatter": "money", "formatterParams": { "precision": 0 }, # "topCalc":"sum", "topCalcParams":{"precision":0} }, ] select_city_tabulator = (dash_tabulator.DashTabulator( id="select_city_tabulator", columns=columns, data=df_to_data(Fin_GID[START_YR]), options=select_cities_options, downloadButtonType=downloadButtonType, ), ) ########## Tabulator - City summary report output city_columns = [ { "title": "State", "field": "ST", "hozAlign": "left", "headerFilter": True }, { "title": "City/District", "field": "ID name",
def on_button_click( n, contract_type, min_expiration_days, max_expiration_days, min_delta, max_delta, premium, moneyness, ticker, ticker_list, is_group, ): if n is None: return None, False, "" else: global df params = {} func = None if contract_type == "PUT": func = short_put else: func = short_call if min_expiration_days: params["min_expiration_days"] = int(min_expiration_days) if max_expiration_days: params["max_expiration_days"] = int(max_expiration_days) if min_delta: params["min_delta"] = float(min_delta) if max_delta: params["max_delta"] = float(max_delta) if premium: params["premium"] = premium if moneyness: params["moneyness"] = moneyness if ticker: tickers = [ticker] elif ticker_list: tickers = screener_list.get(ticker_list) else: return None, True, "Enter Ticker or Select Watchlist" df = watchlist_income(tickers, params, func) if not df.empty: options = { "selectable": 1, "pagination": "local", "paginationSize": 20, "responsiveLayout": "true", "movableRows": "true" } # add groupBy option to the Tabulator component to group at Ticker level if is_group: options["groupBy"] = "TICKER" dt = dash_tabulator.DashTabulator( id='screener-table', columns=[{ "id": i, "title": i, "field": i } for i in df.columns], data=df.to_dict("records"), options=options, ), return dt, False, "" else: return None, True, "No Results Found"