Comments (4)
Hi, and Thank you!
I took a look at the intraday.json
you are using and I see a few issues with it:
- It is not chronological
- It contains duplicate times
- It does not occur at regular intervals
Lightweight Charts is quite picky with the data it recieves, so its important to address these before setting the data. For example:
from lightweight_charts import Chart
import pandas as pd
if __name__ == '__main__':
raw_df = pd.read_json("intraday.json", lines = True)
df = pd.DataFrame({
"time" : pd.to_datetime(raw_df.TradingDate + ' ' + raw_df.Time, format = "%d/%m/%Y %H:%M:%S"),
"open" : raw_df.Open,
"high" : raw_df.High,
"low" : raw_df.Low,
"close" : raw_df.Close,
"volume" : raw_df.LastVol
})
df = df.drop_duplicates(subset='time')
df_sorted = df.sort_values('time')
df_filtered = df_sorted[df_sorted['time'].dt.second % 2 == 0]
chart = Chart(volume_enabled=False)
chart.set(df_filtered)
chart.show(block=True)
This removes the duplicate times, sorts them in chronological order, and filters them so that only times with even seconds are used.
from lightweight-charts-python.
Btw, I've printed the first few rows of the data frame which I put into the chart object, for a quick reference:
time open high low close volume
0 2023-05-17 11:30:12 1065.8 1074.7 1065.5 1072.5 1
1 2023-05-17 13:00:03 1065.8 1074.7 1065.5 1072.2 195
2 2023-05-17 13:00:05 1065.8 1074.7 1065.5 1072.2 195
3 2023-05-17 13:00:07 1065.8 1074.7 1065.5 1072.2 195
4 2023-05-17 13:00:06 1065.8 1074.7 1065.5 1072.2 1
from lightweight-charts-python.
@tariusagi the problem is with the datetime object of the dataframe. In my case this, was a series object and worked fine. you can try converting the datetime object into series.
from lightweight-charts-python.
@louisnw01 Thank you very much, I've got it working perfectly now.
from lightweight-charts-python.
Related Issues (20)
- Subchart label HOT 1
- Fill between 2 line HOT 1
- Add `set()` method to menu widget
- option to disable line studies to fit on the chart HOT 2
- NaN values in Lines series are showing up on Screen instead of blank. HOT 4
- remove vertical span HOT 1
- Individual candle color
- How to assign hotkey for up-arrow and down-arrow? HOT 1
- Selecting vertical_span on chart
- Can update volume by update_from_tick()? HOT 1
- Charts with many bars empty HOT 1
- Crosshair sync in different timeframe attaches to the nearest candle instead of exact location
- [BUG] more than one JupyterPlot in one notebook creates infinite output HOT 1
- sharing the chart and trade overview remotely HOT 1
- Error occurred in update_chart_lines: Can only use .str accessor with string values! HOT 1
- chart replay HOT 1
- subchart with streamlit HOT 1
- vertical trendline disappears HOT 1
- delete lines by one click
- [BUG] Error using Widget with WxChart
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lightweight-charts-python.