import os,sys sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import dash import pandas as pd import dash_bootstrap_components as dbc from dash.dependencies import Input, Output from dash import dcc, html, dash_table from uuid import UUID, uuid4 from alpaca.trading.enums import OrderSide, OrderStatus, TradeEvent, OrderType from common.model import TradeUpdate, Order from rich import print import threading import asyncio from config import BT_DELAYS from utils.utils import AttributeDict, ltp, zoneNY, trunc, count_decimals from utils.tlog import tlog from datetime import datetime import pandas as pd import matplotlib.pyplot as plt import seaborn; seaborn.set() import mplfinance as mpf import plotly.graph_objects as go from plotly.subplots import make_subplots import numpy as np from bisect import bisect_left from backtesting.backtester import Backtester from uuid import UUID import datetime from html.parser import HTMLParser import requests ###html saver def patch_file(file_path: str, content: bytes, extra: dict = None) -> bytes: if file_path == 'index.html': index_html_content = content.decode('utf8') extra_jsons = f''' var patched_jsons_content={{ {','.join(["'/" + k + "':" + v.decode("utf8") + "" for k, v in extra.items()])} }}; ''' patched_content = index_html_content.replace( '