Expose plotting logic in a local Python module

This commit is contained in:
moshferatu 2024-01-30 11:16:06 -08:00
parent f2bc5938bf
commit 23d5ffb391
12 changed files with 30 additions and 21 deletions

View File

@ -1,8 +1,6 @@
from database.ohlc import ohlc from database.ohlc import ohlc
from datetime import datetime, timedelta from datetime import datetime, timedelta
from plotting import CandlestickChart, plot
from candlestick_chart import CandlestickChart
from plot import plot
end_date = datetime.today().date() end_date = datetime.today().date()
start_date = (end_date - timedelta(days = 90)) start_date = (end_date - timedelta(days = 90))

View File

@ -1,9 +1,6 @@
from database.ohlc import ohlc from database.ohlc import ohlc
from datetime import datetime, timedelta from datetime import datetime, timedelta
from plotting import Line, LineChart, plot
from line import Line
from line_chart import LineChart
from plot import plot
end_date = datetime.today().date() end_date = datetime.today().date()
start_date = (end_date - timedelta(days = 90)) start_date = (end_date - timedelta(days = 90))

View File

@ -1,9 +1,6 @@
from database.ohlc import ohlc from database.ohlc import ohlc
from datetime import datetime, timedelta from datetime import datetime, timedelta
from plotting import Line, LineChart, plot
from line import Line
from line_chart import LineChart
from plot import plot
end_date = datetime.today().date() end_date = datetime.today().date()
start_date = (end_date - timedelta(days = 90)) start_date = (end_date - timedelta(days = 90))

5
plotting/__init__.py Normal file
View File

@ -0,0 +1,5 @@
from .backtest_chart import BacktestChart
from .candlestick_chart import CandlestickChart
from .line import Line
from .line_chart import LineChart
from .plot import figure_with_subplots, plot

View File

@ -1,9 +1,10 @@
from chart import Chart
from numpy import where from numpy import where
from pandas import Series from pandas import Series
from plotly.graph_objects import Bar from plotly.graph_objects import Bar
from typing import List from typing import List
from .chart import Chart
class BacktestChart(Chart): class BacktestChart(Chart):
def __init__( def __init__(

View File

@ -1,8 +1,9 @@
from chart import Chart
from pandas import Series from pandas import Series
from plotly.graph_objects import Candlestick from plotly.graph_objects import Candlestick
from typing import List from typing import List
from .chart import Chart
class CandlestickChart(Chart): class CandlestickChart(Chart):
def __init__( def __init__(

View File

@ -1,9 +1,10 @@
from chart import Chart
from line import Line
from pandas import Series from pandas import Series
from plotly.graph_objects import Scatter from plotly.graph_objects import Scatter
from typing import List from typing import List
from .chart import Chart
from .line import Line
class LineChart(Chart): class LineChart(Chart):
def __init__(self, x: Series, lines: List[Line], title: str = ''): def __init__(self, x: Series, lines: List[Line], title: str = ''):

View File

@ -1,8 +1,9 @@
from chart import Chart
from plotly.graph_objects import Figure from plotly.graph_objects import Figure
from plotly.subplots import make_subplots from plotly.subplots import make_subplots
from typing import List from typing import List
from .chart import Chart
def subplot_titles(subplots: List[List[Chart]]) -> List[str]: def subplot_titles(subplots: List[List[Chart]]) -> List[str]:
subplot_titles = [] subplot_titles = []
for row in subplots: for row in subplots:

12
setup.py Normal file
View File

@ -0,0 +1,12 @@
from setuptools import setup, find_packages
setup(
name="plotting",
version="1.0",
packages=find_packages(),
install_requires=[
'numpy',
'pandas',
'plotly'
],
)

View File

@ -1,10 +1,6 @@
from database.ohlc import ohlc from database.ohlc import ohlc
from datetime import datetime, timedelta from datetime import datetime, timedelta
from plotting import CandlestickChart, figure_with_subplots, Line, LineChart
from candlestick_chart import CandlestickChart
from line import Line
from line_chart import LineChart
from plot import figure_with_subplots
end_date = datetime.today().date() end_date = datetime.today().date()
start_date = (end_date - timedelta(days = 90)) start_date = (end_date - timedelta(days = 90))