Code Monkey home page Code Monkey logo

quantdom's Introduction

Quantdom

image

image

image

image

image

Quantdom is a simple but powerful backtesting framework written in python, that strives to let you focus on modeling financial strategies, portfolio management, and analyzing backtests. It has been created as a useful and flexible tool to save the systematic trading community from re-inventing the wheel and let them evaluate their trading ideas easier with minimal effort. It's designed for people who are already comfortable with Python and who want to create, test and explore their own trading strategies.

image

Quantdom is in an early alpha state at the moment. So please be patient with possible errors and report them.

Features

  • Free, open-source and cross-platform backtesting framework
  • Multiple data feeds: csv files and online sources such as Google Finance, Yahoo Finance, Quandl and more
  • Investment Analysis (performance and risk analysis of financial portfolio)
  • Charting and reporting that help visualize backtest results

Requirements

Installation

Using the binaries

You can download binary packages for your system (see the Github Releases page for available downloads):

Running from source code

You can install last stable release from pypi:

$ pip install quantdom

And latest development version can be installed directly from GitHub:

$ pip install -U git+https://github.com/constverum/Quantdom.git

After that, to run the application just execute one command:

$ quantdom

Usage

  1. Run Quantdom.
  2. Choose a market instrument (symbol) for backtesting on the Data tab.
  3. Specify a file with your strategies on the Quotes tab, and select one of them.
  4. Run a backtest. Once this is done, you can analyze the results and optimize parameters of the strategy.

Strategy Examples

Three-bar strategy

A simple trading strategy based on the assumption that after three consecutive bullish bars (bar closing occurred higher than its opening) bulls predominate in the market and therefore the price will continue to grow; after 3 consecutive bearish bars (the bar closes lower than its opening), the price will continue to down, since bears predominate in the market.

from quantdom import AbstractStrategy, Order, Portfolio

class ThreeBarStrategy(AbstractStrategy):

    def init(self, high_bars=3, low_bars=3):
        Portfolio.initial_balance = 100000  # default value
        self.seq_low_bars = 0
        self.seq_high_bars = 0
        self.signal = None
        self.last_position = None
        self.volume = 100  # shares
        self.high_bars = high_bars
        self.low_bars = low_bars

    def handle(self, quote):
        if self.signal:
            props = {
                'symbol': self.symbol,  # current selected symbol
                'otype': self.signal,
                'price': quote.open,
                'volume': self.volume,
                'time': quote.time,
            }
            if not self.last_position:
                self.last_position = Order.open(**props)
            elif self.last_position.type != self.signal:
                Order.close(self.last_position, price=quote.open, time=quote.time)
                self.last_position = Order.open(**props)
            self.signal = False
            self.seq_high_bars = self.seq_low_bars = 0

        if quote.close > quote.open:
            self.seq_high_bars += 1
            self.seq_low_bars = 0
        else:
            self.seq_high_bars = 0
            self.seq_low_bars += 1

        if self.seq_high_bars == self.high_bars:
            self.signal = Order.BUY
        elif self.seq_low_bars == self.low_bars:
            self.signal = Order.SELL

Documentation

In progress ;)

TODO

  • Add integration with TA-Lib
  • Add the ability to use TensorFlow/CatBoost/Scikit-Learn and other ML tools to create incredible algorithms and strategies. Just as one of the first tasks is Elliott Wave Theory(Principle) - to recognize of current wave and on the basis of this predict price movement at confidence intervals
  • Add the ability to make a sentiment analysis from different sources (news, tweets, etc)
  • Add ability to create custom screens, ranking functions, reports

Contributing

  • Fork it: https://github.com/constverum/Quantdom/fork
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request!

Disclaimer

This software should not be used as a financial advisor, it is for educational use only. Absolutely no warranty is implied with this product. By using this software you release the author(s) from any liability regarding the use of this software. You can lose money because this program probably has some errors in it, so use it at your own risk. And please don't take risks with money you can't afford to lose.

Feedback

I'm very interested in your experience with Quantdom. Please feel free to send me any feedback, ideas, enhancement requests or anything else.

License

Licensed under the Apache License, Version 2.0

quantdom's People

Contributors

constverum 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  avatar

Watchers

 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

quantdom's Issues

Google Finance Issue

Hi my installation is succesful:

Successfully installed PyQt5-5.12 PyQt5-sip-4.19.14 certifi-2018.11.29 chardet-3.0.4 idna-2.8 lxml-4.3.1 numpy-1.16.1 pandas-0.24.1 pandas-datareader-0.7.0 pyqtgraph-0.10.0 python-dateutil-2.8.0 pytz-2018.9 quantdom-0.1 requests-2.21.0 six-1.12.0 urllib3-1.24.1 wrapt-1.11.1

But when I type quantdom in the cmd prompt. It launches for a minute. When I click on 'Load' to load the data, gives following error:

(quantdom) D:\WinPython-3670>quantdom
qt.qpa.fonts: Unable to open default EUDC font: "EUDC.TTE"
Traceback (most recent call last):
File "d:\winpython-3670\quantdom\lib\site-packages\quantdom\ui.py", line 185, in update_data
date_to=self.date_to,
File "d:\winpython-3670\quantdom\lib\site-packages\quantdom\lib\loaders.py", line 123, in get_quotes
quotes = loader.get_quotes(*args, **kwargs)
File "d:\winpython-3670\quantdom\lib\site-packages\quantdom\lib\utils.py", line 52, in wrapper
res = fn(*args, **kwargs)
File "d:\winpython-3670\quantdom\lib\site-packages\quantdom\lib\loaders.py", line 66, in get_quotes
quotes = cls._get(symbol, date_from, date_to)
File "d:\winpython-3670\quantdom\lib\site-packages\quantdom\lib\loaders.py", line 90, in _get
return get_data_google(symbol, date_from, date_to)
File "d:\winpython-3670\quantdom\lib\site-packages\pandas_datareader\data.py", line 66, in get_data_google
return GoogleDailyReader(*args, **kwargs).read()
File "d:\winpython-3670\quantdom\lib\site-packages\pandas_datareader\google\daily.py", line 36, in init
raise ImmediateDeprecationError(DEP_ERROR_MSG.format('Google finance'))
pandas_datareader.exceptions.ImmediateDeprecationError:
Google finance has been immediately deprecated due to large breaks in the API without the
introduction of a stable replacement. Pull Requests to re-enable these data
connectors are welcome.

Explanation

can I have an Explanation on this project
its understanding but
equity tab is not understanding properly

i need some explanation on this project with some detailed information
regards
([email protected])

No module named 'quantdom.lib'

Traceback (most recent call last):
  File "/usr/local/bin/quantdom", line 7, in <module>
    from quantdom.cli import cli
  File "/usr/local/lib/python3.6/site-packages/quantdom/__init__.py", line 29, in <module>
    from .ui import *  # noqa
  File "/usr/local/lib/python3.6/site-packages/quantdom/ui.py", line 10, in <module>
    from .lib import (  # noqa
ModuleNotFoundError: No module named 'quantdom.lib'

Wan't run on Win10

c:\Program Files (x86)\Python\Lib\site-packages>quantdom
Traceback (most recent call last):
File "c:\program files (x86)\python\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "c:\program files (x86)\python\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Program Files (x86)\Python\Scripts\quantdom.exe_main
.py", line 5, in
File "c:\program files (x86)\python\lib\site-packages\quantdom_init
.py", line 29, in
from .ui import * # noqa
File "c:\program files (x86)\python\lib\site-packages\quantdom\ui.py", line 10, in
from .lib import ( # noqa
ModuleNotFoundError: No module named 'quantdom.lib'

Is this project still maintained?

@constverum very cool project and idea.

Are you still maintaining it?
I see the last commit is from March 19'.

I am interested in re-using a bunch of the Qt charting components that you use with pyqtgraph and am wondering how you'd feel about moving them into a standalone library or package?
I'd be willing to help maintain this library if you're interested.

Error on drawing charts

Hi
When i run quantdom and hit load button i got thie error:

qt5ct: using qt5ct plugin
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/quantdom/ui.py", line 424, in _update_quotes_chart
    self.quotes_tab.update_chart(self.symbol)
  File "/usr/local/lib/python3.7/dist-packages/quantdom/ui.py", line 292, in update_chart
    self.chart.plot(symbol)
  File "/usr/local/lib/python3.7/dist-packages/quantdom/lib/charts.py", line 554, in plot
    self._update_quotes_chart()
  File "/usr/local/lib/python3.7/dist-packages/quantdom/lib/charts.py", line 474, in _update_quotes_chart
    self.chart.addItem(_get_chart_points(self.style))
  File "/usr/local/lib/python3.7/dist-packages/quantdom/lib/charts.py", line 791, in _get_chart_points
    return CandlestickItem()
  File "/usr/local/lib/python3.7/dist-packages/quantdom/lib/charts.py", line 355, in __init__
    self.generatePicture()
  File "/usr/local/lib/python3.7/dist-packages/quantdom/lib/utils.py", line 52, in wrapper
    res = fn(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/quantdom/lib/charts.py", line 384, in generatePicture
    self._generate(p)
  File "/usr/local/lib/python3.7/dist-packages/quantdom/lib/charts.py", line 416, in _generate
    p.drawRects(*rects[Quotes.close < Quotes.open])
TypeError: arguments did not match any overloaded call:
  drawRects(self, QRectF, *): not enough arguments
  drawRects(self, Iterable[QRectF]): not enough arguments
  drawRects(self, QRect, *): not enough arguments
  drawRects(self, Iterable[QRect]): not enough arguments

Any idea?
I have installed:

PyQt5       5.12.3       
PyQt5-sip   4.19.19      
pyqtgraph   0.10.0  

How can I use Elliot wave calculator?

Is there any library in your project that I can use for Elliot wave calculator in other project? I mean I like to read a .CSV file as input and make an array like [1,2,3,4,5,a,b,c,1,2,3,4,5,a,b,c, ...] as the output!
Is it possible using your project?

Custom data menu grayed out

I've installed Quantdom from source and from binaries (for Mac).

I can run backtests using Shares/Futures/ETFs data, but I cannot import any custom data as the menu is grayed out.

I've checked that the requirements are correctly installed (especially PyQt5).

screen shot 2018-08-04 at 09 58 31

can't load data

C:\Users\Omar>quantdom
Traceback (most recent call last):
File "c:\users\omar\appdata\local\programs\python\python37\lib\site-packages\quantdom\ui.py", line 39, in run
symbols = get_symbols()
File "c:\users\omar\appdata\local\programs\python\python37\lib\site-packages\quantdom\lib\loaders.py", line 168, in get_symbols
symbols.reset_index(inplace=True)
AttributeError: 'NoneType' object has no attribute 'reset_index'

I have pandas 0.24.1

No requirements.txt

Quantdom looks interesting.

I want to check out Quantdom and possibly integrate my Python 3 Pandas TA Library https://github.com/twopirllc/pandas-ta.git (which is largely correlated with TA-Lib <http://ta-lib.org/>) however the link to the requirements.txt in the README and code base is missing.

Thanks

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.