Giter VIP home page Giter VIP logo

backtrader-pyqt-ui's Introduction

Discord

Skinok backtrader UI (PyQt and finplot)

Backtrader PyQt Ui

Backtrader PyQt Ui 2

Backtrader PyQt Ui 3

How to install ?

You should have python installed on your machine (obvisously)

Please run the following commands :

pip install git+https://github.com/backtrader2/backtrader matplotlib requests \
            websocket websocket-client oandapy qdarkstyle git+https://github.com/blampe/IbPy.git \
            git+https://github.com/oanda/oandapy.git git+https://github.com/Skinok/finplot.git  

How to use it ?

  • Put your CSV Data in the data folder
  • Create your strategy and put it in the strategies folder
    Your strategy file name should be exactly the same as the strategy class name
    You can take a look at the provided exemples

backtrader-pyqt-ui's People

Contributors

ghmole avatar ilyakrotov avatar skinok 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

backtrader-pyqt-ui's Issues

Import custom fields in CSV file

Hi,

first thank you for this promising framework / tool!
I need to add some additional fields to the CSV file in order to use them in a strategy. How can I achieve that and where do I start.
For now I get the following error:
image

Thank you and best regards,
Anton

How to run it on python2

Hi Guy,
I just tried the package, it's nice! Some tips followed below:

  1. It's designed for Python2.
  2. If you wanna run on Python3, you need to modify C:\ProgramData\anaconda3\Lib\site-packages\ib\lib_init_.py as following

#!/usr/bin/env python

-- coding: utf-8 --

Just enough auxiliary bits to make the translated code work.

This package provides the support necessary to use the translated

code. The configuration modules used in translation take care of

many semantic differences between Java and Python, while this

package provides the rest.

import copy
import functools
import socket
import struct
import sys

def toTypeName(value):
return '%s%s' % (value[0].upper(), value[1:])

def maybeName(obj):
""" Returns an object's name attribute or it's string representation.

@param obj any object
@return obj name or string representation
"""
try:
    return obj.__name__
except (AttributeError, ):
    return str(obj)

class classmethod_(classmethod):
""" Classmethod that provides attribute delegation.

"""
def __init__(self, func):
    classmethod.__init__(self, func)
    self.func = func

def __getattr__(self, name):
    return getattr(self.func, name)

def synchronized(lock):
""" Synchronization decorator.

from http://wiki.python.org/moin/PythonDecoratorLibrary

@param lock Lock or RLock instance
@return decorator that provides automatic locking
"""
def wrapper(func):
    @functools.wraps(func)
    def inner(*args, **kwds):
        lock.acquire()
        try:
            return func(*args, **kwds)
        finally:
            lock.release()
    return inner
return wrapper

class Boolean(object):
""" Partial implementation of Java Boolean type.

"""
def __init__(self, value):
    """ Constructor.

    @param value bool instance, True or False
    """
    self.value = value

def booleanValue(self):
    """ The value of this instance (a bool).

    @return True or False
    """
    return self.value

@classmethod
def valueOf(cls, text):
    """ Creates an instance of this class with a bool value.

    @param cls this class
    @param text string
    @return instance of cls
    """
    value = str(text).lower() == 'true'
    return cls(value)

class Cloneable(object):
""" Stub for the Cloneable Java interface.

Some of the translated code implements the Java Cloneable
interface, but its methods are never used.  We provide this class
for sub typing, and will implement methods as needed later.
"""
def clone(self):
    return copy.copy(self)

class DataInputStream(object):
""" Partial implementation of the Java DataInputStream type.

"""
def __init__(self, stream):
    """ Constructor.

    @param stream any object with recv method
    """
    self.stream = stream
    self.recv = stream.recv

def readByte(self, unpack=struct.unpack):
    """ Reads a byte from the contained stream.

    @return string read from stream
    """
    return unpack('!b', self.recv(1))[0]

class DataOutputStream(object):
""" Partial implementation of the Java DataOutputStream type

"""
def __init__(self, stream):
    """ Constructor.

    @param stream any object with send method
    """
    self.send = stream.send

def write(self, data, pack=struct.pack, eol=struct.pack('!b', 0)):
    """ Writes data to the contained stream.

    @param data string to send, or 0
    @return None
    """
    send = self.send
    if data == 0:
        send(eol)
    else:
        for char in data:
            if sys.version_info[0] > 2:
                char = char.encode('utf-8')
            send(pack('!c', char))

class Double(float):
""" Partial implementation of Java Double type.

"""
##
# sentinel value used by the socket writer
MAX_VALUE = sys.maxsize

@staticmethod
def parseDouble(text):
    """ Float double (float) from string.

    @param text value to parse
    @return float instance
    """
    return float(text or 0)

class Integer(int):
""" Partial implementation of Java Integer type.

"""
##
# sentinel value used by the socket writer
MAX_VALUE = sys.maxsize

@staticmethod
def parseInt(text):
    """ Int from string.

    @param text value to parse
    @return int instance
    """
    return int(text or 0)

@staticmethod
def parseLong(text):
    """ Long from string.

    @param text value to parse
    @return long instance
    """
    return long(text or 0)

The generated code uses Longs just like Integers, so we use an alias

instead of a subclass (for now).

Long = Integer

class Socket(socket.socket):
""" Partial implementation of the Java Socket type.

"""
def __init__(self, host, port):
    """ Constructor; attempts connection immediately.

    @param host hostname as string
    @param port port number as integer
    """
    socket.socket.__init__(self, socket.AF_INET, socket.SOCK_STREAM)
    self.connect((host, port))

def getInputStream(self):
    """ Returns this instance, which has a send method.

    """
    return self

def getOutputStream(self):
    """ Returns this instance, which has a recv method.

    """
    return self

def disconnect(self):
    self.shutdown(socket.SHUT_RDWR)
    self.close()

def isConnected(self):
    try:
        throwaway = self.getpeername()
        return True
    except (socket.error, ) as ex:
        return False

class StringBuffer(list):
""" Partial implementation of the Java StringBuffer type

Translated code uses instances of this type to build up strings.
The list base type provides the append method.
"""
def __str__(self, join=str.join, chr=chr):
    """ the string value of this instance

    @return string from characters contained in this instance
    """
    return join('', [chr(v) for v in self])

if 'qt' in sys.modules:
from qt import QThread

class ThreadType(QThread):
    """ Partial implementation of Java Thread type, based on Qt3 QThread.

    """
    def __init__(self, name):
        """ Constructor.

        @param name ignored
        """
        QThread.__init__(self)

    def interrupt(self):
        """ Stop this thread (by call to terminate).

        """
        return self.terminate()

    def isInterrupted(self):
        """ Check state of thread.

        @return True if thread is finished
        """
        return self.finished()

    def setDaemon(self, value):
        """ No-op.

        @param value ignored
        @return None
        """

    def setName(self, value):
        """ No-op.

        @param value ignored
        @return None
        """

elif 'PyQt4' in sys.modules:
from PyQt4.QtCore import QThread

class ThreadType(QThread):
    """ Partial implementation of Java Thread type, based on Qt4 QThread.

    """
    def __init__(self, name):
        """ Constructor.

        @param name ignored
        """
        QThread.__init__(self)

    def interrupt(self):
        """ stop this thread (by call to exit)

        """
        return self.exit()

    def isInterrupted(self):
        """ check state of thread

        @return True if thread is finished
        """
        return self.isFinished()

    def setDaemon(self, value):
        """ No-op.

        @param value ignored
        @return None
        """

    def setName(self, value):
        """ sets the name of this QObject

        @param value name of object as string
        @return None
        """
        self.setObjectName(value)

else:
import threading

class ThreadType(threading.Thread):
    """ Partial implementation of Java Thread type, based on Python Thread.

    """
    def __init__(self, name):
        """ Constructor.

        @param name name of this thread
        """
        threading.Thread.__init__(self, name=name)
        self.setDaemon(True)

    def interrupt(self):
        """ No-op; Python threads are not directly interruptible.

        """
        return False

    def isInterrupted(self):
        """ Check state of thread (always False).

        @return False
        """
        return False

class Thread(ThreadType):
""" Thread parent type, based on available framework

"""
def __init__(self, name, parent, dis):
    """ Constructor.

    @param name name of this thread
    @param parent ignored
    @param dis ignored
    """
    ThreadType.__init__(self, name=name)


def term(self):
    def isInterrupted():
        print('down town')
        return True
    self.isInterrupted = isInterrupted
    self.m_dis.stream.shutdown(socket.SHUT_RDWR)
    self.m_dis.stream.close()

ModuleNotFoundError: No module named 'dateutil'

Python3

I run

pip install git+https://github.com/backtrader2/backtrader matplotlib requests \
            websocket websocket-client oandapy qdarkstyle git+https://github.com/blampe/IbPy.git \
            git+https://github.com/oanda/oandapy.git git+https://github.com/Skinok/finplot.git \ 
-i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

error
image

A fabulous tool

Just a brief thank you both for a great project and for all your work.

Best

Fig

function missing in finplot

#in finplotwindow.py:
##def zoomTo(self, dateStr1, dateStr2):

    for win in fplt.windows:
        for ax in win.axs:
            x1 = fplt._dateStr2x(ax,dateStr1)
            x2 = fplt._dateStr2x(ax,dateStr2)

##but could not find "_dateStr2x" in finplot

AttributeError: 'UserInterface' object has no attribute 'current_timeframe'

when I run main.py, error occurs:
(venv_quant389) E:\myquant\backtrader-pyqt-ui-main>e:/myquant/venv_quant389/Scripts/python.exe e:/myquant/backtrader-pyqt-ui-main/main.py
Traceback (most recent call last):
File "e:\myquant\backtrader-pyqt-ui-main\strategyTesterUI.py", line 46, in strategyNameActivated
self.controller.addStrategy(stratBaseName)
File "e:\myquant\backtrader-pyqt-ui-main\SkinokBacktraderUI.py", line 212, in addStrategy
mod = import(strategyName, fromlist=[strategyName]) # first strategyName is the file name, and second (fromlist) is the class name
File "E:\myquant\backtrader-pyqt-ui-main/strategies\AiStableBaselinesModel.py", line 23, in
from stable_baselines3 import PPO
ModuleNotFoundError: No module named 'stable_baselines3'
Traceback (most recent call last):
File "e:\myquant\backtrader-pyqt-ui-main\userInterface.py", line 645, in resetChart
self.fpltWindow[self.current_timeframe].resetChart()
AttributeError: 'UserInterface' object has no attribute 'current_timeframe'
Traceback (most recent call last):
File "e:\myquant\backtrader-pyqt-ui-main\userInterface.py", line 665, in addSma
self.fpltWindow[self.current_timeframe].drawSma( period, qColor, width)
AttributeError: 'UserInterface' object has no attribute 'current_timeframe'

multiple exception types must be parenthesized

发生异常: SyntaxError
multiple exception types must be parenthesized (init.py, line 239)
File "E:\学习资料\backtrader-pyqt-ui-main\SkinokBacktraderUI.py", line 22, in
import backtrader as bt
SyntaxError: multiple exception types must be parenthesized (init.py, line 239)

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.