bn-lightweight-charts 1.0.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/PKG-INFO +1 -1
  2. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/abstract.py +2 -1
  3. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/js/index_bn.html +32 -0
  4. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/widgets.py +22 -3
  5. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/pyproject.toml +1 -1
  6. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/.gitignore +0 -0
  7. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/LICENSE +0 -0
  8. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/README.md +0 -0
  9. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/__init__.py +0 -0
  10. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/chart.py +0 -0
  11. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/drawings.py +0 -0
  12. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/js/bundle.js +0 -0
  13. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/js/index.html +0 -0
  14. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/js/lightweight-charts.js +0 -0
  15. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/js/styles.css +0 -0
  16. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/polygon.py +0 -0
  17. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/table.py +0 -0
  18. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/toolbox.py +0 -0
  19. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/topbar.py +0 -0
  20. {bn_lightweight_charts-1.0.0 → bn_lightweight_charts-1.2.0}/bn_lightweight_charts/util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bn-lightweight-charts
3
- Version: 1.0.0
3
+ Version: 1.2.0
4
4
  Summary: Python framework for TradingView's Lightweight Charts JavaScript library.
5
5
  Project-URL: Homepage, https://github.com/smalinin/bn_lightweight-charts-python
6
6
  Project-URL: Source, https://github.com/smalinin/bn_lightweight-charts-python
@@ -199,7 +199,8 @@ class SeriesCommon(Pane):
199
199
  self._set_interval(df)
200
200
  if not pd.api.types.is_datetime64_any_dtype(df['time']):
201
201
  df['time'] = pd.to_datetime(df['time'])
202
- df['time'] = df['time'].astype('int64') // 10**9
202
+ # Solution for pandas 1.x и 2.x:
203
+ df['time'] = (df['time'] - pd.Timestamp("1970-01-01")) // pd.Timedelta('1s')
203
204
  return df
204
205
 
205
206
  def _series_datetime_format(self, series: pd.Series, exclude_lowercase=None):
@@ -19,6 +19,14 @@
19
19
  Cantarell, "Helvetica Neue", sans-serif;
20
20
  }
21
21
 
22
+ td.dt0, td.dt1, td.dt {
23
+ cursor: pointer;
24
+ text-decoration: underline;
25
+ }
26
+ td.dt0, td.dt1{
27
+ color: blue;
28
+ }
29
+
22
30
  .tableview {
23
31
  background: darkgrey;
24
32
  color: black;
@@ -165,6 +173,30 @@
165
173
  return []
166
174
  }
167
175
  }
176
+
177
+ function scrollToTime(chart, stm0, stm1)
178
+ {
179
+ const tm0 = (new Date((stm0+":00").replace(' ','T')+'Z')).getTime()/1000
180
+ const tm1 = stm1 ? (new Date((stm1+":00").replace(' ','T')+'Z')).getTime()/1000 : null
181
+
182
+ const scale = chart.timeScale()
183
+ const tc0 = scale.timeToCoordinate(tm0)
184
+ if (tc0) {
185
+ const idx0 = scale.coordinateToLogical(tc0)
186
+ if (tm1) {
187
+ const tc1 = scale.timeToCoordinate(tm1)
188
+ if (tc1) {
189
+ const idx1 = scale.coordinateToLogical(tc1)
190
+ scale.setVisibleLogicalRange({ from: idx0 - 5, to: idx1 + 5 });
191
+ document.querySelector("#nav-home-tab").click();
192
+ }
193
+ }
194
+ else {
195
+ scale.setVisibleLogicalRange({ from: idx0 - 5, to: idx0 + 200 + 5 });
196
+ document.querySelector("#nav-home-tab").click();
197
+ }
198
+ }
199
+ }
168
200
  </script>
169
201
  </body>
170
202
  </html>
@@ -259,8 +259,8 @@ class HTMLChart_BN(StaticLWC):
259
259
  }}
260
260
  const pos = v.size > 0 ? 'Long' : 'Short';
261
261
  _html += `<tr><td>${{v.ref}}</td> <td>${{pos}}</td><td>${{v.tradeid}}</td>`
262
- +`<td>${{v.dateopen}}</td><td>${{v.priceopen}}</td>`
263
- +`<td>${{v.dateclose}}</td><td>${{v.priceclose}}</td>`
262
+ +`<td class="dt0">${{v.dateopen}}</td><td>${{v.priceopen}}</td>`
263
+ +`<td class="dt1">${{v.dateclose}}</td><td>${{v.priceclose}}</td>`
264
264
  +`<td>${{v.pnlcomm}}</td><td>${{v.return_pct}}</td><td>${{v.commission}}</td>`
265
265
  +`<td>${{v.barlen}}</td></tr>`;
266
266
  }}
@@ -274,7 +274,7 @@ class HTMLChart_BN(StaticLWC):
274
274
  state = 1;
275
275
  }}
276
276
  const pos = v.o_ordtype===0 ? 'Buy' : 'Sell';
277
- _html += `<tr><td>${{v.o_ref}}</td><td>${{v.o_datetime}}</td><td>${{pos}}</td>`
277
+ _html += `<tr><td>${{v.o_ref}}</td><td class="dt">${{v.o_datetime}}</td><td>${{pos}}</td>`
278
278
  +`<td>${{v.o_price}}</td><td>${{v.o_size}}</td></tr>`;
279
279
  }}
280
280
  }}
@@ -314,6 +314,25 @@ class HTMLChart_BN(StaticLWC):
314
314
  }}
315
315
  }}
316
316
  document.querySelectorAll('#slist a')[0]?.click()
317
+
318
+ document.querySelector('#trades tbody').ondblclick = (e) => {{
319
+ const n = e.target;
320
+ const chart = {self.id}.chart;
321
+ if (n.nodeName==='TD' && n.classList.contains('dt0')) {{
322
+ const dt0 = n.innerText
323
+ const dt1 = n.parentNode.querySelector('td.dt1')?.innerText
324
+ scrollToTime(chart, dt0, dt1)
325
+ }}
326
+ else if (n.nodeName==='TD' && n.classList.contains('dt1')) {{
327
+ const dt1 = n.innerText
328
+ const dt0 = n.parentNode.querySelector('td.dt0')?.innerText
329
+ scrollToTime(chart, dt0, dt1)
330
+ }}
331
+ else if (n.nodeName==='TD' && n.classList.contains('dt')) {{
332
+ const dt0 = n.innerText
333
+ scrollToTime(chart, dt0)
334
+ }}
335
+ }}
317
336
  \n</script></body></html>
318
337
  '''
319
338
  return html_code
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bn-lightweight-charts"
3
- version = "1.0.0"
3
+ version = "1.2.0"
4
4
  description = "Python framework for TradingView's Lightweight Charts JavaScript library."
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }