Package: alpyen
.. raw:: html======
alpyen.. image::https://img.shields.io/pypi/v/alpyen.svg:target:https://pypi.python.org/pypi/alpyen.. image::https://readthedocs.org/projects/alpyen/badge/?version=latest:target:https://alpyen.readthedocs.io/en/latest/?version=latest:alt: Documentation Status
.. image::https://pepy.tech/badge/alpyen:target:https://pepy.tech/project/alpyen.. image::https://img.shields.io/github/repo-size/peeeffchang/alpyen:alt: GitHub repo size.. image::https://img.shields.io/pypi/pyversions/alpyen.. image::https://img.shields.io/github/commit-activity/m/peeeffchang/alpyenA lite-weight backtesting and live-trading algo engine for multiple brokers:Interactive Brokers (IB)GeminiLicense: GNU General Public License v3
Documentation:https://alpyen.readthedocs.io.FeaturesProviding a trading platform for IB that includes the functions ofData gatheringAlgo signal calculationAutomatic tradingBook monitoring and portfolio managementCurrent VersionAble to perform backtesting and live trading.Support This ProjectUse and discuss usReport a bugSubmit a bug fixInstallation::pip install alpyen"Hello World"/Quick StartFor a quick demo, do the following:Install alpyenCreate a py file that perform either backtesting (use thetest_backtesting_macrossing_reshuffletest as an example) or live trading (use thetest_live_tradingtest as an example)For live trading, create a yml control file (use thetest_control.ymlfile as an example)Example.. code-block:: pythonfrom alpyen import datacontainer
from alpyen import backtesting
from alpyen import utils

# Read data (assuming that BBH.csv from Yahoo Finance is in the Data folder)
data_folder = 'Data\\'
ticker_name = 'BBH'
file_path = os.path.join(os.path.dirname(__file__), data_folder)
short_lookback = 5
long_lookback = 200
short_lookback_name = ticker_name + '_MA_' + str(short_lookback)
long_lookback_name = ticker_name + '_MA_' + str(long_lookback)
ticker_names = [ticker_name]
all_input = datacontainer.DataUtils.aggregate_yahoo_data(ticker_names, file_path)

# Subscribe to signals
signal_info_dict = {}
signal_info_dict[short_lookback_name]\
    = utils.SignalInfo('MA', ticker_names, [], [], short_lookback, {})
signal_info_dict[long_lookback_name]\
    = utils.SignalInfo('MA', ticker_names, [], [], long_lookback, {})

# Subscribe to strategies
strategy_info_dict = {}
strategy_name = ticker_name + '_MACrossing_01'
strategy_info_dict[strategy_name] = utils.StrategyInfo(
    'MACrossing',
    [short_lookback_name, long_lookback_name],
    1, {}, ticker_names, combo_definition={'combo1': [1.0]})

# Create backtester and run backtest
number_path = 1000
my_backtester = backtesting.Backtester(all_input, ticker_names, signal_info_dict, strategy_info_dict,
                                       number_path)
my_backtester.run_backtest()
backtest_results = my_backtester.get_results()Themoving average signal / MA-crossing trading strategy; andweighted momentum signal / VAA strategyare built-in in the package, and are intended to serve as examples. Users can use them as references and create their custom signals/strategies by deriving from theSignalBaseclass within thesignalmodule, and theStrategyBaseclass within thestrategymodule. Note that the package needs a unique signature string for each derived signals/strategies for reflective object creation, so for example:.. code-block:: pythonclass MASignal(SignalBase):
    """
    Moving average signal.
    """

    _signal_signature = 'MA'
    
class MACrossingStrategy(StrategyBase):
    """
    MA Crossing Strategy
    """

    _strategy_signature = 'MACrossing'CreditsThis package was created with Cookiecutter_ and theaudreyr/cookiecutter-pypackage_ project template... _Cookiecutter:https://github.com/audreyr/cookiecutter.. _audreyr/cookiecutter-pypackage:https://github.com/audreyr/cookiecutter-pypackage=======
History0.1.0 (2021-09-12)First release on PyPI.0.1.1 (2021-10-12)0.1.2 (2021-10-17)0.1.3 (2021-11-12)0.1.4 (2021-11-19)