def candle(s_ticker: str, s_start: str):
    df_stock = trend.load_ticker(s_ticker, s_start)
    df_stock = trend.find_trendline(df_stock, "OC_High", "high")
    df_stock = trend.find_trendline(df_stock, "OC_Low", "low")

    mc = mpf.make_marketcolors(
        up="green", down="red", edge="black", wick="black", volume="in", ohlc="i"
    )

    s = mpf.make_mpf_style(marketcolors=mc, gridstyle=":", y_on_right=True)

    ap0 = []

    if "OC_High_trend" in df_stock.columns:
        ap0.append(
            mpf.make_addplot(df_stock["OC_High_trend"], color="g"),
        )

    if "OC_Low_trend" in df_stock.columns:
        ap0.append(
            mpf.make_addplot(df_stock["OC_Low_trend"], color="b"),
        )

    if gtff.USE_ION:
        plt.ion()

    mpf.plot(
        df_stock,
        type="candle",
        mav=(20, 50),
        volume=True,
        title=f"\n{s_ticker} - Last 6 months",
        addplot=ap0,
        xrotation=10,
        style=s,
        figratio=(10, 7),
        figscale=1.10,
        figsize=(plot_autoscale()),
        update_width_config=dict(
            candle_linewidth=1.0, candle_width=0.8, volume_linewidth=1.0
        ),
    )
    print("")
def draw_graph(
    ticker: str,
    report_cache_dir: str,
    time_delta: int = 180,
    line_type: str = "candle",
    draw_mas: tuple = (20, 50),
    draw_volume: bool = True,
    high_trend: bool = True,
    low_trend: bool = True,
):
    """Draw Graph is a helper that wraps mplfinance, caching and trendline

    Parameters
    ----------
    ticker : str
        Stock ticker to draw
    report_cache_dir : str
        Ticker data cache directory to use
    time_delta : int, optional
        Graph period in days, by default 180
    line_type : str, optional
        Graph line type to pass to mplfinance, by default "candle"
    draw_mas : tuple, optional
        SMAs to draw, by default (20, 50)
    draw_volume : bool, optional
        Switch to draw trading volume by default True
    high_trend : bool, optional
        Switch to draw high trend line, by default True
    low_trend : bool, optional
        Switch to draw low trend line, by default True
    """
    df_stock_cache = pathlib.Path(
        report_cache_dir, f"{ticker}_stock_data_{time_delta}.pkl"
    )
    if os.path.isfile(df_stock_cache):
        # print(f"Found a cache file. Loading {df_stock_cache}")
        df_stock = pd.read_pickle(df_stock_cache)
    else:
        # print("Cache file not found. Getting data")
        df_stock = trend.load_ticker(
            ticker, (datetime.now() - timedelta(days=time_delta)).strftime("%Y-%m-%d")
        )
        df_stock = trend.find_trendline(df_stock, "OC_High", "high")
        df_stock = trend.find_trendline(df_stock, "OC_Low", "how")
        # print("Savind cache file")
        df_stock.to_pickle(df_stock_cache)
        # print(os.listdir(report_cache_dir))

    df_stock = trend.load_ticker(
        ticker, (datetime.now() - timedelta(days=time_delta)).strftime("%Y-%m-%d")
    )
    df_stock = trend.find_trendline(df_stock, "OC_High", "high")
    df_stock = trend.find_trendline(df_stock, "OC_Low", "how")

    mc = mpf.make_marketcolors(
        up="green", down="red", edge="black", wick="black", volume="in", ohlc="i"
    )
    s = mpf.make_mpf_style(marketcolors=mc, gridstyle=":", y_on_right=True)

    ap0 = []

    if "OC_High_trend" in df_stock.columns and high_trend:
        ap0.append(
            mpf.make_addplot(df_stock["OC_High_trend"], color="g"),
        )

    if "OC_Low_trend" in df_stock.columns and low_trend:
        ap0.append(
            mpf.make_addplot(df_stock["OC_Low_trend"], color="b"),
        )

    mpf.plot(
        df_stock,
        type=line_type,
        mav=draw_mas,
        volume=draw_volume,
        addplot=ap0,
        xrotation=0,
        style=s,
        figratio=(10, 7),
        figscale=2.00,
        update_width_config=dict(
            candle_linewidth=1.0, candle_width=0.8, volume_linewidth=1.0
        ),
    )