Giter Site home page Giter Site logo

edouardpoitras / nowtrade Goto Github PK

View Code? Open in Web Editor NEW
102.0 14.0 38.0 168 KB

Python library for backtesting technical/mechanical strategies in the stock and currency markets

License: MIT License

Shell 0.17% Python 99.83%
trading technical-indicators neural-network random-forest stock currency algorithmic-trading-library python machine-learning

nowtrade's Introduction

NowTrade

Build Status Coverage Status

NowTrade is an algorithmic trading library with a focus on creating powerful strategies using easily-readable and simple Python code. With the help of NowTrade, full blown stock/currency trading strategies, harnessing the power of machine learning, can be implemented with few lines of code.

NowTrade strategies are not event driven like most other algorithmic trading libraries available. The strategies are implemented in a sequential manner (one line at a time) without worrying about events, callbacks, or object overloading.

The Basics

All strategies follow this basic pattern:

  • Load the required data for your strategy
  • Train your machine learning algorithm (optional)
  • Add your technical indicators (example: moving average, relative strength index, neural network, random forest, etc)
  • Add criteria based on your technical indicators (example: neural network prediction is higher than current price)
  • Associate actions to those criteria (example: go long when a certain criteria is true)
  • Create a trading profile (includes information such as your capital, trading amount rules, trading fee rules, slippage rules, etc)
  • Send all of this information to a strategy simulator and wait for results

Check out some example strategies in the examples directory.

Features

Here is a list of reasons you may want to use NowTrade over alternatives:

  • Implement strategies easily
  • Flexible data connections (store data locally from any remote data connection)
  • Easily implement machine learning into strategies (neural networks, random forest, etc)
  • Simple, small, and clean code base (build failure on pylint warning)

Cons

List of reasons you may not want to choose NowTrade over alternatives:

  • Not mature yet
  • Performance sacrificed for simple abstraction and code base
  • Still lacking many features (contributions welcome!)

Installation

NowTrade has only been tested on Ubuntu 14.04 and 16.04. It will most likely run just fine on any UNIX-based operating system provided all dependencies have been met.

Dependencies
apt-get install python-pip python-numpy python-pandas python-scipy cython
pip install pandas-datareader
TaLib for Technical Indicators
wget -O ta-lib-0.4.0-src.tar.gz http://sourceforge.net/projects/ta-lib/files/ta-lib/0.4.0/ta-lib-0.4.0-src.tar.gz/download
tar xvzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
make install
pip install Ta-Lib
Matplotlib for pretty charts
apt-get install python-matplotlib
For MySQL Support
apt-get install python-mysqldb
For MongoDB Local Storage Support
apt-get install mongodb python-pymongo

Note: You may need to un-comment the line '#port 27017' in /etc/mongodb.conf for NowTrade to communicate with mongo

For ensemble (random forest) support
apt-get install python-sklearn
For neural network support
pip install pybrain
Finally, install nowtrade
python setup.py install
Tests

To run the tests you'll need nose:

apt-get install python-nose

Then you can run the tests by running the following command in the root of the repository:

sh tests/test_all.sh

Give it a Spin

You can try out some strategies in the examples directory.

I recommend taking a look at the following examples:

See Also

You may also be interested in these other python-based backtesting systems:

Author

Edouard Poitras [email protected]

nowtrade's People

Contributors

edouardpoitras avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nowtrade's Issues

Replace Position criteria with Above/Below criteria

Position criteria is a bit more convoluted than necessary. Replace with a Above and Below criteria.
Instead of Position(technical_indicator1, 'below', technical_indicator2), we should have Below(technial_indicator1, technical_indicator2).
Same thing for the Above criteria.

Rename or replace TimeSinceAction criteria

TimeSinceAction is not named properly. It insinuates that we will be able to specify a time (like 10 minutes, or 5 hours) since an action occurred.
It should either be renamed to something more accurate (like BarsSinceAction?) or replaced with more specific criteria such as:
LongOccured/LongHappened/BarsSinceLong
ShortOccured/ShortHappened/BarsSinceShort
LongExitOccured/LongExitHappened/BarsSinceLongExit
ShortExitOccured/ShortExitHappend/BarsSinceShortExit

Better way of managing configuration options

We need a better way of handling configuration options than the configuration.py file in the nowtrade library folder. The user should have the options of having a nowtrade.conf file in their PYTHONPATH that would be parsed every time NowTrade is imported.

There should be sensitive defaults for when the configuration file is not present.

Easy way of identifying next action in market

NowTrade is primarily a backtesting system. However, it would be nice to be able to access a 'next_action' from a strategy previously simulated. This would be used for active trading in real markets.

For example, if a user had picked out a strategy on a day time frame, the user could simply re-run the strategy with the latest market data every day and extract the 'next_action' from the strategy results.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.