Skip to Content
Mastering Python for Finance - Second Edition
book

Mastering Python for Finance - Second Edition

by James Ma Weiming
April 2019
Intermediate to advanced
426 pages
11h 13m
English
Packt Publishing
Content preview from Mastering Python for Finance - Second Edition

Implementing the mean-reversion trader class

The resample interval and the number of periods in our calculation are two important parameters that are required by our trading system. First, create a class named MeanReversionTrader, which we can instantiate and run as our trading system:

import timeimport datetime as dtimport pandas as pdclass MeanReversionTrader(object):    def __init__(        self, broker, symbol=None, units=1,        resample_interval='60s', mean_periods=5    ):        """        A trading platform that trades on one side            based on a mean-reverting algorithm.        :param broker: Broker object        :param symbol: A str object recognized by the broker for trading        :param units: Number of units to trade        :param resample_interval:  Frequency for resampling price time series ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python for Finance - Second Edition

Python for Finance - Second Edition

Yuxing Yan
Python for Finance

Python for Finance

Yves Hilpisch

Publisher Resources

ISBN: 9781789346466Supplemental Content