bn-lightweight-charts 1.0.0__py3-none-any.whl → 1.2.0__py3-none-any.whl
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.
- bn_lightweight_charts/abstract.py +2 -1
- bn_lightweight_charts/js/index_bn.html +32 -0
- bn_lightweight_charts/widgets.py +22 -3
- {bn_lightweight_charts-1.0.0.dist-info → bn_lightweight_charts-1.2.0.dist-info}/METADATA +1 -1
- {bn_lightweight_charts-1.0.0.dist-info → bn_lightweight_charts-1.2.0.dist-info}/RECORD +7 -7
- {bn_lightweight_charts-1.0.0.dist-info → bn_lightweight_charts-1.2.0.dist-info}/WHEEL +0 -0
- {bn_lightweight_charts-1.0.0.dist-info → bn_lightweight_charts-1.2.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -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
|
-
|
|
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>
|
bn_lightweight_charts/widgets.py
CHANGED
|
@@ -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
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bn-lightweight-charts
|
|
3
|
-
Version: 1.
|
|
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
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
bn_lightweight_charts/__init__.py,sha256=5RdQFzvOLx8wBAtgxp2NTpqAuDJMMeXfUoMiXNJGiKk,202
|
|
2
|
-
bn_lightweight_charts/abstract.py,sha256=
|
|
2
|
+
bn_lightweight_charts/abstract.py,sha256=FZLpayUtYPpVrhEtecQnay6d1D9EeXOI-K4T3f2lVKk,42123
|
|
3
3
|
bn_lightweight_charts/chart.py,sha256=umQ154Z8NLci2dyQJQxqvsghdjbhAJs8lsoNvScpwEk,7211
|
|
4
4
|
bn_lightweight_charts/drawings.py,sha256=ANg54TShelOp7SvwQkD2P5_7_-zMTYX6tLDdCpsIcOQ,8394
|
|
5
5
|
bn_lightweight_charts/polygon.py,sha256=25HhZflP0_vF_CPVrMHy3X_SBMPk8hH8yXi4Jx7eSwY,18532
|
|
@@ -7,13 +7,13 @@ bn_lightweight_charts/table.py,sha256=72OMLQrUlWfJ7iz7VurexmWrXGzV1vkr_tpjPkm3DU
|
|
|
7
7
|
bn_lightweight_charts/toolbox.py,sha256=PhvpXOW_tDAxDcG94uIGBK_f6gFjNH9h1xHKzQNo5zU,1521
|
|
8
8
|
bn_lightweight_charts/topbar.py,sha256=nSC5_geDvJfjAJ3eBtZs7cRElhXBt7ODDBnJIGnhdJM,4660
|
|
9
9
|
bn_lightweight_charts/util.py,sha256=KAvHsw-1NY0CUKynUnoQWTvuTGaKWa2_-4DI9ajYNpI,8074
|
|
10
|
-
bn_lightweight_charts/widgets.py,sha256=
|
|
10
|
+
bn_lightweight_charts/widgets.py,sha256=yiMDDfvOslPRyqV1OMa6RUidioGsV4lnjUQ_izxJNRA,14826
|
|
11
11
|
bn_lightweight_charts/js/bundle.js,sha256=AQyl4kOKB7g4t0wEyvaynUcMyXulUksGMjf1Bk42FKA,50708
|
|
12
12
|
bn_lightweight_charts/js/index.html,sha256=aErKo-Pbn6esUJ5zwl66NvGhOp00Br3kP6Bejxw9sG4,1475
|
|
13
|
-
bn_lightweight_charts/js/index_bn.html,sha256=
|
|
13
|
+
bn_lightweight_charts/js/index_bn.html,sha256=7RGt-6spy0HDhIhG509HChCnZ5RjruxuKfjkYqYqKDQ,8326
|
|
14
14
|
bn_lightweight_charts/js/lightweight-charts.js,sha256=19vIfLfo_MW1TWxMB1NbNp82m9S84zrJd0A3R1CQl6U,180587
|
|
15
15
|
bn_lightweight_charts/js/styles.css,sha256=hpr57ZOGU_Wibag2rrB6GyvObQkr6d8ySyaSLs9UnZI,4811
|
|
16
|
-
bn_lightweight_charts-1.
|
|
17
|
-
bn_lightweight_charts-1.
|
|
18
|
-
bn_lightweight_charts-1.
|
|
19
|
-
bn_lightweight_charts-1.
|
|
16
|
+
bn_lightweight_charts-1.2.0.dist-info/METADATA,sha256=Gx5cRKPzB-trI-Tsd1LMzhiLyYpUnOOo_iSSCrM3OvE,9994
|
|
17
|
+
bn_lightweight_charts-1.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
18
|
+
bn_lightweight_charts-1.2.0.dist-info/licenses/LICENSE,sha256=c1BNniz3_GfGwKHblopMfeUQ2uiORYkfH33m7el-x7o,1094
|
|
19
|
+
bn_lightweight_charts-1.2.0.dist-info/RECORD,,
|
|
File without changes
|
{bn_lightweight_charts-1.0.0.dist-info → bn_lightweight_charts-1.2.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|