Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ValueError: Invalid frequency: ME #1257

Open
Labels
wontfixThis will not be worked on
@xXgordonXx

Description

Expected behavior

what i do:

  1. pip install backtesting
  2. run
    from backtesting import Backtest, Strategy
    from backtesting.lib import crossover

from backtesting.test import SMA, GOOG

class SmaCross(Strategy):
def init(self):
price = self.data.Close
self.ma1 = self.I(SMA, price, 10)
self.ma2 = self.I(SMA, price, 20)

def next(self):
 if crossover(self.ma1, self.ma2):
 self.buy()
 elif crossover(self.ma2, self.ma1):
 self.sell()

bt = Backtest(GOOG, SmaCross, commission=.002,
exclusive_orders=True)
stats = bt.run()
bt.plot()

  1. expected result: is ploting a sample graph

Code sample

from backtesting import Backtest, Strategy
from backtesting.lib import crossover
from backtesting.test import SMA, GOOG
class SmaCross(Strategy):
 def init(self):
 price = self.data.Close
 self.ma1 = self.I(SMA, price, 10)
 self.ma2 = self.I(SMA, price, 20)
 def next(self):
 if crossover(self.ma1, self.ma2):
 self.buy()
 elif crossover(self.ma2, self.ma1):
 self.sell()
bt = Backtest(GOOG, SmaCross, commission=.002,
 exclusive_orders=True)
stats = bt.run()
bt.plot()

Actual behavior

  1. error/ related report
    [ValueError: Invalid frequency: ME]

Image

reference: pandas-dev/pandas#57197

Additional info, steps to reproduce, full crash traceback, screenshots

  1. seems there is typo in _plot_superimposed_ohlc() function

    def _plot_superimposed_ohlc():
    """Superimposed, downsampled vbars"""
    time_resolution = pd.DatetimeIndex(df['datetime']).resolution
    resample_rule = (superimpose if isinstance(superimpose, str) else
    dict(day='ME',
    hour='D',
    minute='h',
    second='min',
    millisecond='s').get(time_resolution))

Software versions

  • Backtesting version: 0.?.?
  • bokeh.__version__:
  • OS:

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /