Skip to content

Skip empty dataframes when creating addplots #103

@fxhuhn

Description

@fxhuhn

I add signals to my diagram using make_addplot. But if there are no signals in the selected time period, I get an error.

I have solved it for me as follows:

            if stock[stock['Signal'].notnull()].shape[0] == 0:
                print ("- no Signal")
            else:
                signal_short = mpf.make_addplot(stock['Signal'] * 0.93,
                                                scatter=True,
                                                markersize=150,
                                                marker='v',
                                                color='red'
                                                )
                add_plots.append(signal_short)

Would it not be an option to integrate this directly into the function and, if necessary, only issue a warning?

    if data.notnull()].shape[0] == 0:
        raise Warning("Empty Dataframe!")

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions