Skip to content

Commit

Permalink
Merge pull request #385 from louisnw01/2.0
Browse files Browse the repository at this point in the history
2.0
  • Loading branch information
louisnw01 authored Jun 1, 2024
2 parents d34acfb + e4f53a8 commit 5453759
Show file tree
Hide file tree
Showing 89 changed files with 5,824 additions and 2,373 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ ___
## Features
1. Streamlined for live data, with methods for updating directly from tick data.
2. Multi-pane charts using [Subcharts](https://lightweight-charts-python.readthedocs.io/en/latest/reference/abstract_chart.html#AbstractChart.create_subchart).
3. The [Toolbox](https://lightweight-charts-python.readthedocs.io/en/latest/reference/toolbox.html), allowing for trendlines, rays and horizontal lines to be drawn directly onto charts.
3. The [Toolbox](https://lightweight-charts-python.readthedocs.io/en/latest/reference/toolbox.html), allowing for trendlines, rectangles, rays and horizontal lines to be drawn directly onto charts.
4. [Events](https://lightweight-charts-python.readthedocs.io/en/latest/tutorials/events.html) allowing for timeframe selectors (1min, 5min, 30min etc.), searching, hotkeys, and more.
5. [Tables](https://lightweight-charts-python.readthedocs.io/en/latest/reference/tables.html) for watchlists, order entry, and trade management.
6. Direct integration of market data through [Polygon.io's](https://polygon.io/?utm_source=affiliate&utm_campaign=pythonlwcharts) market data API.

__Supports:__ Jupyter Notebooks, PyQt5, PySide6, wxPython, Streamlit, and asyncio.
__Supports:__ Jupyter Notebooks, PyQt6, PyQt5, PySide6, wxPython, Streamlit, and asyncio.

PartTimeLarry: [Interactive Brokers API and TradingView Charts in Python](https://www.youtube.com/watch?v=TlhDI3PforA)
___
Expand Down
34 changes: 34 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m'

ERROR="${RED}[ERROR]${NC} "
INFO="${CYAN}[INFO]${NC} "
WARNING="${WARNING}[WARNING]${NC} "

rm -rf dist/bundle.js dist/typings/

if [[ $? -eq 0 ]]; then
echo -e "${INFO}deleted bundle.js and typings.."
else
echo -e "${WARNING}could not delete old dist files, continuing.."
fi

npx rollup -c rollup.config.js
if [[ $? -ne 0 ]]; then
exit 1
fi

cp dist/bundle.js src/general/styles.css lightweight_charts/js
if [[ $? -eq 0 ]]; then
echo -e "${INFO}copied bundle.js, style.css into python package"
else
echo -e "${ERROR}could not copy dist into python package ?"
exit 1
fi
echo -e "\n${GREEN}[BUILD SUCCESS]${NC}"

2 changes: 1 addition & 1 deletion docs/source/examples/gui_examples.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Alternative GUI's


## PyQt5 / PySide6
## PyQt6 / PyQt5 / PySide6

```python
import pandas as pd
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/toolbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def on_timeframe_selection(chart):
if new_data.empty:
return
# The symbol has not changed, so we want to re-render the drawings.
chart.set(new_data, render_drawings=True)
chart.set(new_data, keep_drawings=True)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion docs/source/polygon.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The `websockets` library is required when using live data.
```{important}
When using live data and the standard `show` method, the `block` parameter __must__ be set to `True` in order for the data to congregate on the chart (`chart.show(block=True)`).
If `show_async` is used with live data, `block` can be either value.
`show_async` can also be used with live data.
```
Expand Down
8 changes: 5 additions & 3 deletions docs/source/reference/abstract_chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ___
```{py:method} set(data: pd.DataFrame, render_drawings: bool = False)
```{py:method} set(data: pd.DataFrame, keep_drawings: bool = False)
Sets the initial data for the chart.
Expand All @@ -17,17 +17,19 @@ Columns should be named:
Time can be given in the index rather than a column, and volume can be omitted if volume is not used. Column names are not case sensitive.
If `render_drawings` is `True`, any drawings made using the `toolbox` will be redrawn with the new data. This is designed to be used when switching to a different timeframe of the same symbol.
If `keep_drawings` is `True`, any drawings made using the `toolbox` will be redrawn with the new data. This is designed to be used when switching to a different timeframe of the same symbol.
`None` can also be given, which will erase all candle and volume data displayed on the chart.
You can also add columns to color the candles (https://tradingview.github.io/lightweight-charts/tutorials/customization/data-points)
```
___
```{py:method} update(series: pd.Series, render_drawings: bool = False)
```{py:method} update(series: pd.Series, keep_drawings: bool = False)
Updates the chart data from a bar.
Series labels should be akin to [`set`](#AbstractChart.set).
Expand Down
4 changes: 2 additions & 2 deletions docs/source/reference/charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ___
```{py:method} show_async(block: bool)
```{py:method} show_async()
:async:
Show the chart asynchronously.
Expand Down Expand Up @@ -85,7 +85,7 @@ ___
The `QtChart` object allows the use of charts within a `QMainWindow` object, and has similar functionality to the `Chart` object for manipulating data, configuring and styling.
Either the `PyQt5` or `PySide6` libraries will work with this chart.
Either the `PyQt5`, `PyQt6` or `PySide6` libraries will work with this chart.
Callbacks can be received through the Qt event loop.
___
Expand Down
5 changes: 5 additions & 0 deletions docs/source/reference/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Fires when the range (visibleLogicalRange) changes.
```
```{py:method} click -> (chart: Chart, time: NUM, price: NUM)
Fires when the mouse is clicked, returning the time and price of the clicked location.
```
````

Tutorial: [Topbar & Events](../tutorials/events.md)
Expand Down
5 changes: 2 additions & 3 deletions docs/source/tutorials/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def update_clock(chart):
async def main():
chart = Chart()
chart.topbar.textbox('clock')
await asyncio.gather(chart.show_async(block=True), update_clock(chart))
await asyncio.gather(chart.show_async(), update_clock(chart))


if __name__ == '__main__':
Expand Down Expand Up @@ -130,7 +130,6 @@ async def data_loop(chart):
return
chart.update_from_tick(ticks.iloc[i])
await asyncio.sleep(0.03)
i += 1


def on_new_bar(chart):
Expand All @@ -150,7 +149,7 @@ async def main():
df = pd.read_csv('ohlc.csv')

chart.set(df)
await asyncio.gather(chart.show_async(block=True), data_loop(chart))
await asyncio.gather(chart.show_async(), data_loop(chart))


if __name__ == '__main__':
Expand Down
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<!-- redirect to example page -->
<meta http-equiv="refresh" content="0; URL=src/example/" />
</head>
</html>
Loading

0 comments on commit 5453759

Please sign in to comment.