catalyst icon indicating copy to clipboard operation
catalyst copied to clipboard

Different Output/Warnings When Changing Slippage

Open usgoose opened this issue 6 years ago • 0 comments

Dear Catalyst Maintainers,

Before I tell you about my issue, let me describe my environment:

Environment

  • Operating System: Windows 10 Pro
  • Python Version: Python 3.6.5
  • How did you install Catalyst: Conda
  • Python packages: https://pastebin.com/U324egCS

Now that you know a little about me, let me tell you about the issue I am having:

Description of Issue

I get different outputs/warnings when I run the backtest with slippage set to 0.0 or 0.001. For example, with

Running the mean reversion example algo on the docs, with context.set_slippage(slippage=0.000)

I receive the following output:

[2019-01-31 23:59:22.471076] INFO: run_algo: Catalyst version 0.5.21
[2019-01-31 23:59:22.472078] WARNING: run_algo: Catalyst is currently in ALPHA. It is going through rapid development and it is subject to errors. Please use carefully. We encourage you to report any issue on GitHub: https://github.com/enigmampc/catalyst/issues
[2019-01-31 23:59:25.473210] INFO: run_algo: running algo in backtest mode
[2019-01-31 23:59:25.476216] INFO: exchange_algorithm: initialized trading algorithm in backtest mode
[2019-01-31 23:59:27.337759] INFO: 2-RSI: 2018-08-05 23:59:00+00:00: 
Buying Price: 7025.8, 
RSI: 6.092071232109683
[2019-01-31 23:59:28.468297] INFO: 2-RSI: 2018-08-26 23:59:00+00:00: 
Selling Price: 6707.0, 
RSI: 71.14864745728694
[2019-01-31 23:59:31.212581] INFO: 2-RSI: 2018-11-17 23:59:00+00:00: 
Buying Price: 5628.3, 
RSI: 2.0004676192960575
[2019-01-31 23:59:31.222577] INFO: exchange_blotter: order has not reached the trigger at current price 5659.5
[2019-01-31 23:59:31.253578] INFO: 2-RSI: exiting because orders are open: defaultdict(<class 'list'>, {Trading Pair btc_usd(98871) Exchange: bitfinex, Introduced On: 2013-03-31 00:00:00+00:00, Base Currency: btc, Quote Currency: usd, Exchange Leverage: 1.0, Minimum Trade Size: 0.004 Last daily ingestion: 2019-01-28 00:00:00+00:00 Last minutely ingestion: 2019-01-28 00:00:00+00:00: [Order({'id': 'bff8af87b41349db9374fb2989824beb', 'dt': Timestamp('2018-11-17 23:59:00+0000', tz='UTC'), 'reason': None, 'created': Timestamp('2018-11-17 23:59:00+0000', tz='UTC'), 'amount': 1.761688329918857, 'filled': 0, 'commission': 0, 'stop': None, 'limit': 5656.4415, 'stop_reached': False, 'limit_reached': False, 'sid': Trading Pair btc_usd(98871) Exchange: bitfinex, Introduced On: 2013-03-31 00:00:00+00:00, Base Currency: btc, Quote Currency: usd, Exchange Leverage: 1.0, Minimum Trade Size: 0.004 Last daily ingestion: 2019-01-28 00:00:00+00:00 Last minutely ingestion: 2019-01-28 00:00:00+00:00, 'status': 0})]})
[2019-01-31 23:59:32.107220] INFO: Performance: Simulated 365 trading days out of 365.
[2019-01-31 23:59:32.108218] INFO: Performance: first open: 2018-01-01 00:00:00+00:00
[2019-01-31 23:59:32.109193] INFO: Performance: last close: 2018-12-31 23:59:00+00:00
[2019-01-31 23:59:32.297196] INFO: 2-RSI: elapsed time: 0:00:06.816974
[2019-01-31 23:59:32.742207] INFO: 2-RSI: Saved performance stats: 

When I set it to 0.001: context.set_slippage(slippage=0.001)

I get the following output:

[2019-02-01 00:06:02.757598] INFO: run_algo: Catalyst version 0.5.21
[2019-02-01 00:06:02.760637] WARNING: run_algo: Catalyst is currently in ALPHA. It is going through rapid development and it is subject to errors. Please use carefully. We encourage you to report any issue on GitHub: https://github.com/enigmampc/catalyst/issues
[2019-02-01 00:06:05.761719] INFO: run_algo: running algo in backtest mode
[2019-02-01 00:06:09.031925] INFO: exchange_algorithm: initialized trading algorithm in backtest mode
[2019-02-01 00:06:12.627698] INFO: 2-RSI: 2018-08-05 23:59:00+00:00: 
Buying Price: 7025.8, 
RSI: 6.092071232109683
[2019-02-01 00:06:12.992659] INFO: 2-RSI: 2018-08-26 23:59:00+00:00: 
Selling Price: 6707.0, 
RSI: 71.14864745728694
[2019-02-01 00:06:14.174657] INFO: 2-RSI: 2018-11-17 23:59:00+00:00: 
Buying Price: 5628.3, 
RSI: 2.0004676192960575
[2019-02-01 00:06:14.181662] INFO: exchange_blotter: order has not reached the trigger at current price 5659.5
[2019-02-01 00:06:14.194660] INFO: 2-RSI: exiting because orders are open: defaultdict(<class 'list'>, {Trading Pair btc_usd(98871) Exchange: bitfinex, Introduced On: 2013-03-31 00:00:00+00:00, Base Currency: btc, Quote Currency: usd, Exchange Leverage: 1.0, Minimum Trade Size: 0.004 Last daily ingestion: 2019-01-30 00:00:00+00:00 Last minutely ingestion: 2019-01-30 00:00:00+00:00: [Order({'id': 'd2d119bd9bc146168a21b56ac989a572', 'dt': Timestamp('2018-11-17 23:59:00+0000', tz='UTC'), 'reason': None, 'created': Timestamp('2018-11-17 23:59:00+0000', tz='UTC'), 'amount': 1.7581856733251215, 'filled': 0, 'commission': 0, 'stop': None, 'limit': 5656.4415, 'stop_reached': False, 'limit_reached': False, 'sid': Trading Pair btc_usd(98871) Exchange: bitfinex, Introduced On: 2013-03-31 00:00:00+00:00, Base Currency: btc, Quote Currency: usd, Exchange Leverage: 1.0, Minimum Trade Size: 0.004 Last daily ingestion: 2019-01-30 00:00:00+00:00 Last minutely ingestion: 2019-01-30 00:00:00+00:00, 'status': 0})]})
[2019-02-01 00:06:14.860698] INFO: Performance: Simulated 365 trading days out of 365.
[2019-02-01 00:06:14.862669] INFO: Performance: first open: 2018-01-01 00:00:00+00:00
[2019-02-01 00:06:14.863665] INFO: Performance: last close: 2018-12-31 23:59:00+00:00
[2019-02-01 00:06:15.024663] INFO: 2-RSI: elapsed time: 0:00:04.000981
C:\Users\Usman\Anaconda3\lib\site-packages\ipywidgets\widgets\widget.py:281: DeprecationWarning:

Widget registration using a string name has been deprecated. Widget registration now uses a plain `@register` decorator.

[2019-02-01 00:06:29.100766] INFO: 2-RSI: Saved performance stats: 

When I run it again with slippage at 0.001:

[2019-02-01 00:07:33.278524] INFO: run_algo: Catalyst version 0.5.21
[2019-02-01 00:07:33.279495] WARNING: run_algo: Catalyst is currently in ALPHA. It is going through rapid development and it is subject to errors. Please use carefully. We encourage you to report any issue on GitHub: https://github.com/enigmampc/catalyst/issues
[2019-02-01 00:07:36.281190] INFO: run_algo: running algo in backtest mode
[2019-02-01 00:07:36.283980] INFO: exchange_algorithm: initialized trading algorithm in backtest mode
[2019-02-01 00:07:37.940015] INFO: 2-RSI: 2018-08-05 23:59:00+00:00: 
Buying Price: 7025.8, 
RSI: 6.092071232109683
[2019-02-01 00:07:38.314977] INFO: 2-RSI: 2018-08-26 23:59:00+00:00: 
Selling Price: 6707.0, 
RSI: 71.14864745728694
[2019-02-01 00:07:39.609007] INFO: 2-RSI: 2018-11-17 23:59:00+00:00: 
Buying Price: 5628.3, 
RSI: 2.0004676192960575
[2019-02-01 00:07:39.614010] INFO: exchange_blotter: order has not reached the trigger at current price 5659.5
[2019-02-01 00:07:39.630008] INFO: 2-RSI: exiting because orders are open: defaultdict(<class 'list'>, {Trading Pair btc_usd(98871) Exchange: bitfinex, Introduced On: 2013-03-31 00:00:00+00:00, Base Currency: btc, Quote Currency: usd, Exchange Leverage: 1.0, Minimum Trade Size: 0.004 Last daily ingestion: 2019-01-30 00:00:00+00:00 Last minutely ingestion: 2019-01-30 00:00:00+00:00: [Order({'id': '4099dd411f354b09b0d8dc0f6563f47a', 'dt': Timestamp('2018-11-17 23:59:00+0000', tz='UTC'), 'reason': None, 'created': Timestamp('2018-11-17 23:59:00+0000', tz='UTC'), 'amount': 1.7581856733251215, 'filled': 0, 'commission': 0, 'stop': None, 'limit': 5656.4415, 'stop_reached': False, 'limit_reached': False, 'sid': Trading Pair btc_usd(98871) Exchange: bitfinex, Introduced On: 2013-03-31 00:00:00+00:00, Base Currency: btc, Quote Currency: usd, Exchange Leverage: 1.0, Minimum Trade Size: 0.004 Last daily ingestion: 2019-01-30 00:00:00+00:00 Last minutely ingestion: 2019-01-30 00:00:00+00:00, 'status': 0})]})
[2019-02-01 00:07:40.345007] INFO: Performance: Simulated 365 trading days out of 365.
[2019-02-01 00:07:40.346008] INFO: Performance: first open: 2018-01-01 00:00:00+00:00
[2019-02-01 00:07:40.346008] INFO: Performance: last close: 2018-12-31 23:59:00+00:00
[2019-02-01 00:07:40.543054] INFO: 2-RSI: elapsed time: 0:00:04.253039
C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\cbook\deprecation.py:107: MatplotlibDeprecationWarning:

Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.

Traceback (most recent call last):

  File "<ipython-input-2-d94c8be3f70f>", line 1, in <module>
    runfile('C:/Users/Usman/Code/catalyst-rsi-dualmoving.py', wdir='C:/Users/Usman/Code')

  File "C:\Users\Usman\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\Users\Usman\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/Usman/Code/catalyst-rsi-dualmoving.py", line 362, in <module>
    output=out

  File "C:\Users\Usman\Anaconda3\lib\site-packages\catalyst\utils\run_algo.py", line 643, in run_algorithm
    stats_output=stats_output

  File "C:\Users\Usman\Anaconda3\lib\site-packages\catalyst\utils\run_algo.py", line 361, in _run
    overwrite_sim_params=False,

  File "C:\Users\Usman\Anaconda3\lib\site-packages\catalyst\exchange\exchange_algorithm.py", line 403, in run
    data, overwrite_sim_params

  File "C:\Users\Usman\Anaconda3\lib\site-packages\catalyst\exchange\exchange_algorithm.py", line 360, in run
    data, overwrite_sim_params

  File "C:\Users\Usman\Anaconda3\lib\site-packages\catalyst\algorithm.py", line 731, in run
    self.analyze(daily_stats)

  File "C:\Users\Usman\Anaconda3\lib\site-packages\catalyst\exchange\exchange_algorithm.py", line 399, in analyze
    super(ExchangeTradingAlgorithmBacktest, self).analyze(stats)

  File "C:\Users\Usman\Anaconda3\lib\site-packages\catalyst\algorithm.py", line 486, in analyze
    self._analyze(self, perf)

  File "C:/Users/Usman/Code/catalyst-rsi-dualmoving.py", line 273, in analyze
    perf.loc[:, 'rsi'].plot(ax=ax6, label='RSI')

  File "C:\Users\Usman\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 3600, in __call__
    **kwds)

  File "C:\Users\Usman\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 2674, in plot_series
    **kwds)

  File "C:\Users\Usman\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 2470, in _plot
    plot_obj.generate()

  File "C:\Users\Usman\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 1046, in generate
    self._adorn_subplots()

  File "C:\Users\Usman\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 1201, in _adorn_subplots
    sharey=self.sharey)

  File "C:\Users\Usman\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 3494, in _handle_shared_axes
    _remove_labels_from_axis(ax.xaxis)

  File "C:\Users\Usman\Anaconda3\lib\site-packages\pandas\tools\plotting.py", line 3457, in _remove_labels_from_axis
    for t in axis.get_majorticklabels():

  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\axis.py", line 1245, in get_majorticklabels
    ticks = self.get_major_ticks()

  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\axis.py", line 1396, in get_major_ticks
    numticks = len(self.get_major_locator()())

  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\dates.py", line 1249, in __call__
    self.refresh()

  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\dates.py", line 1269, in refresh
    dmin, dmax = self.viewlim_to_dt()

  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\dates.py", line 1026, in viewlim_to_dt
    .format(vmin))

ValueError: view limit minimum 0.0 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units

Traceback (most recent call last):
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5.py", line 519, in _draw_idle
    self.draw()
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 433, in draw
    self.figure.draw(self.renderer)
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\figure.py", line 1475, in draw
    renderer, self, artists, self.suppressComposite)
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\image.py", line 141, in _draw_list_compositing_images
    a.draw(renderer)
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 2607, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\image.py", line 141, in _draw_list_compositing_images
    a.draw(renderer)
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\axis.py", line 1190, in draw
    ticks_to_draw = self._update_ticks(renderer)
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\axis.py", line 1028, in _update_ticks
    tick_tups = list(self.iter_ticks())  # iter_ticks calls the locator
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\axis.py", line 971, in iter_ticks
    majorLocs = self.major.locator()
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\dates.py", line 1249, in __call__
    self.refresh()
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\dates.py", line 1269, in refresh
    dmin, dmax = self.viewlim_to_dt()
  File "C:\Users\Usman\Anaconda3\lib\site-packages\matplotlib\dates.py", line 1026, in viewlim_to_dt
    .format(vmin))
ValueError: view limit minimum 0.0 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units

I'm getting a lot of exchange blotter issues and I'm not sure where they are coming from.

Thanks

usgoose avatar Feb 01 '19 00:02 usgoose