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:
38
docs/source/examples/table.md
Normal file
38
docs/source/examples/table.md
Normal file
@ -0,0 +1,38 @@
|
||||
# Table
|
||||
|
||||
```python
|
||||
import pandas as pd
|
||||
from lightweight_charts import Chart
|
||||
|
||||
def on_row_click(row):
|
||||
row['PL'] = round(row['PL']+1, 2)
|
||||
row.background_color('PL', 'green' if row['PL'] > 0 else 'red')
|
||||
|
||||
table.footer[1] = row['Ticker']
|
||||
|
||||
if __name__ == '__main__':
|
||||
chart = Chart(width=1000, inner_width=0.7, inner_height=1)
|
||||
subchart = chart.create_subchart(width=0.3, height=0.5)
|
||||
df = pd.read_csv('ohlcv.csv')
|
||||
chart.set(df)
|
||||
subchart.set(df)
|
||||
|
||||
table = chart.create_table(width=0.3, height=0.2,
|
||||
headings=('Ticker', 'Quantity', 'Status', '%', 'PL'),
|
||||
widths=(0.2, 0.1, 0.2, 0.2, 0.3),
|
||||
alignments=('center', 'center', 'right', 'right', 'right'),
|
||||
position='left', func=on_row_click)
|
||||
|
||||
table.format('PL', f'£ {table.VALUE}')
|
||||
table.format('%', f'{table.VALUE} %')
|
||||
|
||||
table.new_row('SPY', 3, 'Submitted', 0, 0)
|
||||
table.new_row('AMD', 1, 'Filled', 25.5, 105.24)
|
||||
table.new_row('NVDA', 2, 'Filled', -0.5, -8.24)
|
||||
|
||||
table.footer(2)
|
||||
table.footer[0] = 'Selected:'
|
||||
|
||||
chart.show(block=True)
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user