Polygon:
- Added async methods to polygon. - The `requests` library is no longer required, with `urllib` being used instead. - Added the `get_bar_data` function, which returns a dataframe of aggregate data from polygon. - Opened up the `subscribe` and `unsubscribe` functions Enhancements: - Tables will now scroll when the rows exceed table height. Bugs: - Fixed a bug preventing async functions being used with horizontal line event. - Fixed a bug causing the legend to show duplicate lines if the line was created after the legend. - Fixed a bug causing the line hide icon to persist within the legend after deletion (#75) - Fixed a bug causing the search box to be unfocused when the chart is loaded.
This commit is contained in:
@ -1,6 +1,18 @@
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
from random import choices
|
||||
from typing import Literal
|
||||
from typing import Literal, Union
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class Pane:
|
||||
def __init__(self, window):
|
||||
from lightweight_charts import Window
|
||||
self.win: Window = window
|
||||
self.run_script = window.run_script
|
||||
if hasattr(self, 'id'):
|
||||
return
|
||||
self.id = Window._id_gen.generate()
|
||||
|
||||
|
||||
class IDGen(list):
|
||||
@ -14,6 +26,13 @@ class IDGen(list):
|
||||
self.generate()
|
||||
|
||||
|
||||
def parse_event_message(window, string):
|
||||
name, args = string.split('_~_')
|
||||
args = args.split(';;;')
|
||||
func = window.handlers[name]
|
||||
return func, args
|
||||
|
||||
|
||||
def jbool(b: bool): return 'true' if b is True else 'false' if b is False else None
|
||||
|
||||
|
||||
@ -27,6 +46,12 @@ CROSSHAIR_MODE = Literal['normal', 'magnet']
|
||||
|
||||
PRICE_SCALE_MODE = Literal['normal', 'logarithmic', 'percentage', 'index100']
|
||||
|
||||
TIME = Union[datetime, pd.Timestamp, str]
|
||||
|
||||
NUM = Union[float, int]
|
||||
|
||||
FLOAT = Literal['left', 'right', 'top', 'bottom']
|
||||
|
||||
|
||||
def line_style(line: LINE_STYLE):
|
||||
js = 'LightweightCharts.LineStyle.'
|
||||
@ -65,6 +90,7 @@ class Emitter:
|
||||
def _emit(self, *args):
|
||||
self._callable(*args) if self._callable else None
|
||||
|
||||
|
||||
class JSEmitter:
|
||||
def __init__(self, chart, name, on_iadd, wrapper=None):
|
||||
self._on_iadd = on_iadd
|
||||
@ -78,7 +104,7 @@ class JSEmitter:
|
||||
async def final_async_wrapper(*arg):
|
||||
await other(self._chart, *arg) if not self._wrapper else await self._wrapper(other, self._chart, *arg)
|
||||
|
||||
self._chart._handlers[self._name] = final_async_wrapper if asyncio.iscoroutinefunction(other) else final_wrapper
|
||||
self._chart.win.handlers[self._name] = final_async_wrapper if asyncio.iscoroutinefunction(other) else final_wrapper
|
||||
self._on_iadd(other)
|
||||
return self
|
||||
|
||||
@ -89,7 +115,7 @@ class Events:
|
||||
from lightweight_charts.abstract import JS
|
||||
self.search = JSEmitter(chart, f'search{chart.id}',
|
||||
lambda o: chart.run_script(f'''
|
||||
{JS['callback'] if not chart._callbacks_enabled else ''}
|
||||
{JS['callback']}
|
||||
makeSpinner({chart.id})
|
||||
{chart.id}.search = makeSearchBox({chart.id})
|
||||
''')
|
||||
|
||||
Reference in New Issue
Block a user