implement drawing methods, fix horizontal line bug, continue refactor

This commit is contained in:
louisnw
2024-04-14 16:29:15 +01:00
parent 3ead45f858
commit 3fdd19e3ce
33 changed files with 732 additions and 365 deletions

View File

@ -2,33 +2,42 @@
"SYM": [
{
"type": "Box",
"p1": {
"time": 1675036800,
"logical": 2928,
"price": 130.25483664317744
},
"p2": {
"time": 1676332800,
"logical": 2939,
"price": 145.52389493914157
},
"color": "#FFF",
"style": 0
"points":
[
{
"time": 1675036800,
"logical": 2928,
"price": 130.25483664317744
},
{
"time": 1676332800,
"logical": 2939,
"price": 145.52389493914157
}
],
"options": {
"color": "#FFF",
"style": 0
}
},
{
"type": "TrendLine",
"p1": {
"time": 1669939200,
"logical": 2890,
"price": 196.12991672005123
},
"p2": {
"time": 1673222400,
"logical": 2914,
"price": 223.17796284433055
},
"color": "#FFF",
"style": 0
"points": [
{
"time": 1669939200,
"logical": 2890,
"price": 196.12991672005123
},
{
"time": 1673222400,
"logical": 2914,
"price": 223.17796284433055
}
],
"options": {
"color": "#FFF",
"style": 0
}
}
]
}

View File

@ -2,10 +2,41 @@ import unittest
import pandas as pd
from lightweight_charts import Chart
from util import BARS, Tester
from time import sleep
class TestToolBox(unittest.TestCase):
...
class TestToolBox(Tester):
def test_create_horizontal_line(self):
self.chart.set(BARS)
horz_line = self.chart.horizontal_line(200, width=4)
self.chart.show()
result = self.chart.win.run_script_and_get(f"{horz_line.id}._options");
self.assertTrue(result)
self.chart.exit()
def test_create_trend_line(self):
self.chart.set(BARS)
horz_line = self.chart.trend_line(BARS.iloc[-10]['date'], 180, BARS.iloc[-3]['date'], 190)
self.chart.show()
result = self.chart.win.run_script_and_get(f"{horz_line.id}._options");
self.assertTrue(result)
self.chart.exit()
def test_create_box(self):
self.chart.set(BARS)
horz_line = self.chart.box(BARS.iloc[-10]['date'], 180, BARS.iloc[-3]['date'], 190)
self.chart.show()
result = self.chart.win.run_script_and_get(f"{horz_line.id}._options");
self.assertTrue(result)
self.chart.exit()
def test_create_vertical_line(self):
...
def test_create_vertical_span(self):
...
if __name__ == '__main__':

View File

@ -10,7 +10,7 @@ BARS = pd.read_csv('../examples/1_setting_data/ohlcv.csv')
class Tester(unittest.TestCase):
def setUp(self):
self.chart: Chart = Chart();
self.chart: Chart = Chart(100, 100, 800, 100);
def tearDown(self) -> None:
self.chart.exit()