Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to add new layouts (markers and lines) in RenderBokeh() method #17

Closed
Tim55667757 opened this issue Dec 30, 2022 · 7 comments
Assignees
Labels
Task A small task or improvements
Milestone

Comments

@Tim55667757
Copy link
Owner

No description provided.

@Tim55667757 Tim55667757 added the Task A small task or improvements label Dec 30, 2022
@Tim55667757 Tim55667757 self-assigned this Dec 30, 2022
@Tim55667757 Tim55667757 changed the title Add possibility to add new layouts in RenderBokeh() method Add possibility to add new layouts (markers and lines) in RenderBokeh() method Jan 1, 2023
Tim55667757 added a commit that referenced this issue Jan 1, 2023
…t will be used dark theme, `False` mean light theme.
Tim55667757 added a commit that referenced this issue Jan 1, 2023
Tim55667757 added a commit that referenced this issue Jan 1, 2023
…nt, then will be used dark theme. Default: light theme.
Tim55667757 added a commit that referenced this issue Jan 1, 2023
…Jupyter Notebook cell. `False` by default.
Tim55667757 added a commit that referenced this issue Jan 1, 2023
Tim55667757 added a commit that referenced this issue Jan 1, 2023
Tim55667757 added a commit that referenced this issue Jan 1, 2023
Tim55667757 added a commit that referenced this issue Jan 1, 2023
Tim55667757 added a commit that referenced this issue Jan 1, 2023
@Tim55667757
Copy link
Owner Author

Tim55667757 commented Jan 1, 2023

You can manipulate with chart and adding lines or markers to the main chart now. Use markers and lines parameters for it.

markers is a list with custom series, where additional markers will place on main series. None by default. One marker is a custom symbol, e.g. ×, ↓ or ↑ or anyone else. Marker data must contain at least two columns. There are datetime with date and time and some markers columns (markersUpper, markersCenter or markersLower). Length of marker dataframes must be equal to the length of main candle series.

lines is a list with custom series, where additional chart-lines will place on main series. None by default. Line data must contain at least two columns. There are datetime with date and time and custom_line_name with y-coordinates. Length of the chart-line dataframes must be equal to the length of main candle series.

Example:

from pricegenerator.PriceGenerator import PriceGenerator, uLogger
from datetime import datetime, timedelta
import pandas as pd

uLogger.setLevel(0)  # Disable logging messages.

# Initialize PriceGenerator:
priceModel = PriceGenerator()
priceModel.ticker = "TEST_PRICES"
priceModel.precision = 0
priceModel.timeframe = timedelta(days=1)
priceModel.timeStart = datetime.today()
priceModel.horizon = 75
priceModel.maxClose = 140
priceModel.minClose = 40
priceModel.initClose = 50
priceModel.maxOutlier = 35
priceModel.maxCandleBody = 15
priceModel.maxVolume = 400000
priceModel.upCandlesProb = 0.51
priceModel.outliersProb = 0.1
priceModel.trendDeviation = 0.005
priceModel.trendSplit = "/\/"
priceModel.splitCount = [40, 10, 25]

priceModel.Generate()  # Generate main candles series.

# Let's draw new average line on the main chart and set markers on the top, center and bottom of candles:
priceModel.prices["avg"] = priceModel.prices.low + (priceModel.prices.high - priceModel.prices.low) / 2
priceModel.prices["markersUpper"] = pd.Series(["↓"] * len(priceModel.prices.high))
priceModel.prices["markersCenter"] = pd.Series(["×"] * len(priceModel.prices.avg))
priceModel.prices["markersLower"] = pd.Series(["↑"] * len(priceModel.prices.low))
priceModel.RenderBokeh(
    fileName="index1.html",
    viewInBrowser=True,
    darkTheme=True,  # Set `False` for light theme.
    markers=priceModel.prices[["datetime", "markersUpper", "markersCenter", "markersLower"]],
    lines=[priceModel.prices[["datetime", "avg"]]],
    showStatOnChart=True,
    showControlsOnChart=True,
    inline=False,  # Set `True` if script runs in Jupyter Notebook.
)

Output:

Marked chart

@Tim55667757
Copy link
Owner Author

Implemented since v1.2.dev77

Debug build: https://app.travis-ci.com/github/Tim55667757/PriceGenerator/builds/259302083
Artifact in PyPI for testing: https://pypi.org/project/pricegenerator/1.2.dev77/

@Tim55667757 Tim55667757 reopened this Jan 3, 2023
Tim55667757 added a commit that referenced this issue Jan 3, 2023
…lies was added to markers legend label.
Tim55667757 added a commit that referenced this issue Jan 3, 2023
@Tim55667757
Copy link
Owner Author

Parameter markers has Pandas DataFrame type now. Count of anomalies was added to markers legend label.

Tim55667757 added a commit that referenced this issue Jan 3, 2023
Tim55667757 added a commit that referenced this issue Jan 3, 2023
@Tim55667757
Copy link
Owner Author

Render will be faster now if you setshowStatOnChart=False

Tim55667757 added a commit that referenced this issue Jan 3, 2023
@Tim55667757 Tim55667757 added this to the release-1.3 milestone Jan 3, 2023
@Tim55667757
Copy link
Owner Author

New test code for checking this issue:

from pricegenerator.PriceGenerator import PriceGenerator, uLogger
from datetime import datetime, timedelta
import pandas as pd

uLogger.setLevel(10)
uLogger.level = 10
uLogger.handlers[0].level = 10

# Initialize PriceGenerator:
priceModel = PriceGenerator()
priceModel.ticker = "TEST_PRICES"
priceModel.precision = 0
priceModel.timeframe = timedelta(days=1)
priceModel.timeStart = datetime.today()
priceModel.horizon = 75
priceModel.maxClose = 240
priceModel.minClose = 140
priceModel.initClose = 150
priceModel.maxOutlier = 35
priceModel.maxCandleBody = 15
priceModel.maxVolume = 400000
priceModel.upCandlesProb = 0.51
priceModel.outliersProb = 0.1
priceModel.trendDeviation = 0.005
# priceModel.trendSplit = "/\/"
# priceModel.splitCount = [40, 10, 25]

priceModel.Generate()  # Generate main candles series.
# priceModel.LoadFromFile("pricegenerator/test.csv")  # Generate main candles series.

# Let's draw new average line on the main chart and set markers on the top, center and bottom of candles:
priceModel.prices["avg"] = priceModel.prices.low + (priceModel.prices.high - priceModel.prices.low) / 2
priceModel.prices["markersUpper"] = pd.Series(["↓"] * len(priceModel.prices.high))
priceModel.prices["markersCenter"] = pd.Series(["×"] * len(priceModel.prices.avg))
priceModel.prices["markersLower"] = pd.Series([""] * len(priceModel.prices.low))
priceModel.RenderBokeh(
    fileName="index1.html",
    viewInBrowser=True,
    darkTheme=True,  # Set `False` for light theme.
    markers=priceModel.prices[["datetime", "markersUpper", "markersCenter", "markersLower"]],
    lines=[priceModel.prices[["datetime", "avg"]]],
    title="Test",
    showControlsOnChart=True,
    showStatOnChart=True,
    inline=False,
)

Dark style example:

image

Light style example:

image

Tim55667757 added a commit that referenced this issue Jan 4, 2023
@Tim55667757
Copy link
Owner Author

Also, #19 bug fixed. Example:

image

@Tim55667757
Copy link
Owner Author

Implement since build v1.3.dev78

Debug build: https://app.travis-ci.com/github/Tim55667757/PriceGenerator/builds/259412521
PyPI artifact for testing: https://pypi.org/project/pricegenerator/1.3.dev78/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Task A small task or improvements
Projects
None yet
Development

No branches or pull requests

1 participant