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 datetime import datetime, timedelta
from candlestick_chart import CandlestickChart
from plot import plot
from plotting import CandlestickChart, plot
end_date = datetime.today().date()
start_date = (end_date - timedelta(days = 90))

View File

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

View File

@ -1,9 +1,6 @@
from database.ohlc import ohlc
from datetime import datetime, timedelta
from line import Line
from line_chart import LineChart
from plot import plot
from plotting import Line, LineChart, plot
end_date = datetime.today().date()
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 pandas import Series
from plotly.graph_objects import Bar
from typing import List
from .chart import Chart
class BacktestChart(Chart):
def __init__(

View File

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

View File

@ -1,9 +1,10 @@
from chart import Chart
from line import Line
from pandas import Series
from plotly.graph_objects import Scatter
from typing import List
from .chart import Chart
from .line import Line
class LineChart(Chart):
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.subplots import make_subplots
from typing import List
from .chart import Chart
def subplot_titles(subplots: List[List[Chart]]) -> List[str]:
subplot_titles = []
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 datetime import datetime, timedelta
from candlestick_chart import CandlestickChart
from line import Line
from line_chart import LineChart
from plot import figure_with_subplots
from plotting import CandlestickChart, figure_with_subplots, Line, LineChart
end_date = datetime.today().date()
start_date = (end_date - timedelta(days = 90))