update switching fr logic for expected alpha

This commit is contained in:
2026-05-07 20:59:47 +00:00
parent 1bbb4797ce
commit e4bdb3f6a0
6 changed files with 122 additions and 60 deletions

75
ng.py
View File

@@ -1,5 +1,5 @@
import os
from nicegui import ui, app
from nicegui import ui, app, html
from sqlalchemy import create_engine
# import requests
import json
@@ -127,7 +127,8 @@ def update_body_scroll(e=None, bool_override=False):
async def update_tv():
series_update_aster_tob = json.loads(VALKEY.get('fut_ticker_aster')) # ty:ignore[invalid-argument-type]
series_update_extend_tob = json.loads(VALKEY.get('fut_ticker_extended')) # ty:ignore[invalid-argument-type]
series_update_algo_status = json.loads(VALKEY.get('algo_status')) # ty:ignore[invalid-argument-type]
series_update_algo_status = json.loads(VALKEY.get('algo_status')) # ty:ignore[invalid-argument-type]
master_data = json.loads(VALKEY.get(name='fr_engine_best_fund_rate_master')) # ty:ignore[invalid-argument-type]
timestamp_aster_tob = round( ( series_update_aster_tob['timestamp_transaction'] / 1000 ) , 2)
timestamp_extend_tob = round( ( series_update_extend_tob['timestamp_msg'] / 1000 ) , 2)
@@ -172,18 +173,66 @@ async def rt_chart_page():
LOOKBACK = app.storage.user.get('lookback', LOOKBACK)
timer = ui.timer(REFRESH_INTERVAL_RT_SEC, update_tv)
with ui.row():
with ui.column():
ui.switch('☸︎', value=ALLOW_BODY_SCROLL, on_change=lambda e: update_body_scroll(e))
with ui.column():
ui.switch('▶️', value=True).bind_value_to(timer, 'active')
with ui.column().style('position: absolute; right: 20px; font-family: monospace; align-self: center;'):
ui.label('Atwater Trading - Funding Rate')
# ui.query('.q-page').classes('flex flex-col h-screen')
# with ui.row():
# with ui.column():
# ui.switch('☸︎', value=ALLOW_BODY_SCROLL, on_change=lambda e: update_body_scroll(e))
# with ui.column():
# ui.switch('▶️', value=True).bind_value_to(timer, 'active')
# with ui.column().style('position: absolute; right: 20px; font-family: monospace; align-self: center;'):
# ui.label('Atwater Trading - Funding Rate')
with ui.grid(columns=16).classes('w-full gap-0 auto-fit'):
with ui.card().tight().classes('w-full col-span-full no-shadow border border-black-200').style('overflow: auto;'):
ui.html('<div id="tv" style="width:100%; height:800px;"></div>', sanitize=False).classes('w-full')
ui.run_javascript(f'await create_tv(charts_list={CHARTS}, create_chart_options={CHARTS_OPTIONS});')
with ui.grid(columns=2, rows=2).classes('h-screen w-full flex-grow gap-2 auto-fit '):
aggrid = ui.aggrid({
'columnDefs': [
{'field': 'name', 'editable': True, 'sortable': True},
{'field': 'age', 'editable': True},
{'field': 'id'},
],
'rowData': [
{'id': 0, 'name': 'Alice', 'age': 18},
{'id': 1, 'name': 'Bob', 'age': 21},
{'id': 2, 'name': 'Carol', 'age': 20},
],
'rowSelection': {'mode': 'multiRow'},
'stopEditingWhenCellsLoseFocus': True,
}).classes('auto-fit flex-grow w-full col-span-2 md:col-span-1')
# with ui.element(tag='div').classes('auto-fit flex-grow w-full').style("height:100%; width: 100%;"):
# with ui.tabs().classes('w-full') as tabs:
# one = ui.tab('One').classes('auto-fit flex-grow w-full').style("height:100%; width: 100%;")
# two = ui.tab('Two').classes('auto-fit flex-grow w-full').style("height:100%; width: 100%;")
# with ui.tab_panels(tabs, value=two).classes('auto-fit flex-grow w-full').style("height:100%; width: 100%;"):
# with ui.tab_panel(one).classes('auto-fit flex-grow w-full').style("height:100%; width: 100%;"):
# ui.label('First tab')
# with ui.tab_panel(two).classes('auto-fit flex-grow w-full').style("height:100%; width: 100%;"):
ui.html('<div id="tv" style="height:100%; width: 100%;"></div>', sanitize=False).classes('auto-fit flex-grow w-full col-span-2 md:col-span-1')
ui.run_javascript(f'await create_tv(charts_list={CHARTS}, create_chart_options={CHARTS_OPTIONS});')
with ui.element(tag='div').classes('col-span-2').style("height:100%; width: 100%;"):
with ui.tabs().classes('w-full') as tabs:
one = ui.tab('One')
two = ui.tab('Two')
with ui.tab_panels(tabs, value=two).classes('w-full').style("height:100%; width: 100%;"):
with ui.tab_panel(one):
ui.label('First tab')
with ui.tab_panel(two):
aggrid_2 = ui.aggrid({
'columnDefs': [
{'field': 'name', 'editable': True, 'sortable': True},
{'field': 'age', 'editable': True},
{'field': 'id'},
],
'rowData': [
{'id': 0, 'name': 'Alice', 'age': 18},
{'id': 1, 'name': 'Bob', 'age': 21},
{'id': 2, 'name': 'Carol', 'age': 20},
],
'rowSelection': {'mode': 'multiRow'},
'stopEditingWhenCellsLoseFocus': True,
})
def root():
app.add_static_files(max_cache_age=0, url_path='/static', local_directory=os.path.join(os.path.dirname(__file__), 'nicegui_modules/static'))