.. _introduction: Introduction ============ Automated trading strategies are advantagous because they remove human bias, stringently adhereing to pre-defined rules on how to enter and exit the market. Additionally, they are inherently reactive to real time data, which is impractical for many investors who are unable to constantly monitor markets. Developing an automated trading strategy requires 'backtesting' against historical data for both design and validation. In practice, both design and validation processes require many backtests to optimize for increased profitability and minimized risk. This python pacakge streamlines the development and deploylment of Backtested & Optimized Automated Trading Strategies (BOATS). Features: ~~~~~~~~~ 1. :ref:`Historical ` and :ref:`real time ` market data acquisition 2. Local :ref:`database ` for maintaining historical data 3. :ref:`Indicators` library (Moving averages, RSI, Bollinger Bands, etc) 4. Compatibility with 3rd party software and data 5. Simulated :ref:`broker model ` 6. Fast and parrallizable backtesting routine (see :ref:`Performance`) 7. :ref:`Performance metrics ` library (sharpe and calmer ratios, max drawdown, etc) 8. Python SDKs for :ref:`external ` broker APIs (Alpaca, Coinbase, more coming soon) 9. :ref:`Live ` testing and execution 10. Graphical :ref:`visualization` of backtests and live execution via matplotlib 11. Strategy :ref:`optimization ` routines: parameter scan, (gradient descent, random forest, and other optimization algorithms coming soon) 12. Periodic optimization strategy (see :ref:`Active Optimization `) Package Structure and Concepts: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. automodule:: src.boatwright A trading :ref:`Strategy ` is the logic on how to enter and exit market positions including the generation of any technical indicators used for the decision making process. Strategies are interchangable between :ref:`Backtest ` and :ref:`LiveExecution ` instances enabling the seamless transition from testing to deployment. .. image:: Backtest_LiveExec.png :align: center Data is passed to backtest and maintained in live execution instances as `Pandas.DataFrames `_ with columns [datetime, open, high, low, close, volume]. The use of pandas leverages its efficiency for computing along large datasets, in this context additional technical indicators which are then appeneded to the dataframe. Additionality, it is easy to encorporate 3rd party data or software into pandas dataframes. For each 'step' in the backtest or execution process the strategy evaluates the signals, and accordingly generates orders which it then places with a broker. The :ref:`Broker ` class enforces common functionality to the :ref:`BacktestBroker ` model, and live broker interfances (e.g. :ref:`CoinbaseBroker ` and :ref:`AlpacaBroker `). Presently, this includes handling :ref:`Order ` types: :class:`MarketOrder`, :class:`LimitOrder`, :class:`StopOrder`, :class:`TrailingOrder`, and informational inquiries regarding order status, and asset values. In this way, order generation and managment by strategies is kept independent of differences between different brokers and APIs. .. image:: OrderFlow.png :align: center Optimizing your strategy: ~~~~~~~~~~~~~~~~~~~~~~~~~ Our thesis is that the ability to quickly iterate through new ideas and different market conditions will empower users to more efficiently develop a strategy which maximizes profitability and minimizes risk. To further accelerate that process :ref:`optimization ` routines are provided which can generate many backtests, exploring strategy parameters, market condtions, or even different technical indicators. Backtests and optimization processes can even be built into strategies themselves; as with the :ref:`active optimization ` strategy which periodically runs an optimization on the most recent data and chooses the best performing parameters to use subsequently. Additional Resources: ~~~~~~~~~~~~~~~~~~~~~ - See the :ref:`examples` section for use cases of this package. - See the :ref:`modules` section for detail on the each submodule.