Git Product home page Git Product logo

pyjuque's Introduction

Python Juju Quant Engine

PYJUQUE     (pai-jook) (Py-thon Ju-ju Qu-ant E-ngine)

This project implements the basic functionality required to engage in algorithmic trading. It can be regarded as a starting point for more complex trading bots.

Getting Started

Make sure you have pip installed. Run:

# To install all the requirements
pip install -r requirements.txt

Add a .env file in the root filepath, then populate it with the following lines. Checkout this example .env file

BINANCE_API_KEY=...
BINANCE_API_SECRET=...

You should be good to go! Check out the example section.

Structure

Code is contained in pyjuque. Tests are in tests.

Features

This library implements the following features:

Strategies

At pyjuque/Strategies.

A base module which allows us to define buying & selling strategies for crypto assets. Each strategy will contain the following phases: setup (where the indicators are computed), getIndicators (to be used for plotting), checkLongSignal, checkShortSignal, getBuySignalsList and getSellSignalsList (the last two to be used for backtesting).

Currently contains a few basic strategies. More strategies will be added together with a build your own strategy template. Should seamlessly connect to the Backtesting & Bot Controller modules.

Bot Controller

At pyjuque/Engine/BotController.py.

A module which handles the buying and selling of assets, given simple or more advanced rules, allowing us to run a strategy indefinitely. Checkout this example.

Current Features:
  • Placing Entry (Buy) Orders on Signal
  • Market, Limit & Stop Loss orders
  • Placing Exit Order when Entry Order was fulfilled
  • Trading below/above signal by some %
Future Features:
  • OCO orders
  • Selling on signals
  • Trailing stop loss
  • Multiple trade entries (in case trade goes against you)

State persistence Using SQLAlchemy.

Backtesting

At pyjuque/Engine/Backtester.

Backtester infrastructure currently supports:

  • stop loss, trailing stop loss
  • subsequent entries logic (as if Dollar Cost Averaging is enabled)

Checkout this example.

Plotting

There is some basic functionality for plotting in pyjuque/Plotter

Exchange Connectors

Implementing multiple exchanges with ccxt. Check out implementation at CcxtExchange. Currently implemented:

binance okex

Older:

At pyjuque/Exchanges.

Indicators

At pyjuque/Indicators.

Started implementing the Indicators module which currently contains some indicators from pyti. Undergoing integration with pandas_ta.

The thinking is that this module should allow us to easily and quickly compute any of the hundreds of indicators out there and to use them in strategies & backtesting. Should seamlessly connect to the Strategies module.

Strategy Optimiser

At pyjuque/Strategies/StrategyOptimiser.py.

Currently allows for optimising strategy parameters using a genetic algorithm. Checkout this example.

Local Order Book (for Binance)

At pyjuque/Exchanges/BinanceOrderBook.py.

Creates and stores a local order book for the specified symbols. Order Book is updated every second through a websocket connection to the Exchange (currently Binance). Checkout this example.

from pyjuque.Exchanges.BinanceOrderBook import OrderBook

# Initialize & start OrderBook with desired symbols
ob = OrderBook(symbols=['BTCUSDT', 'LTCUSDT'])
ob.startOrderBook()
...
# Get Updated Order Book data at any point in your code 
ordb = ob.getOrderBook()
print(ordb)

{
  'BTCUSDT': {
      'asks': [
          ['13662.31000000', '3.24473100'],
          ['13662.82000000', '0.06815300'],
          ['13663.08000000', '0.00900000'],
          ...
          ['20000.00000000', '95.22325900']
        ],
      'bids': [
          ['13662.30000000', '1.26362900'],
          ['13661.78000000', '0.04395000'],
          ['13661.62000000', '0.01439200'],
          ...
          ['10188.00000000', '1.11546400']
        ],
      'lastUpdateId': 6382686192  # ignore this
  },
  'LTCUSDT': {
      'asks': [ ... ],
      'bids': [ ... ],
      'lastUpdateId': 1521585540  # ignore this
  },
 'counter': 11                    # ignore this
}

Tests

Run them with the command nose2

Coming Soon

More Exchanges

Binance Futures, Bitmex, Bitfinex, FTX, Bybit. Margin Trading, Market Making, Hyper Parameter Tuning.

Contributing

To contribute simply fork the repo, write your desired feature in your own fork and make a pull request upon finishing. Please write tests!

Adding new Exchanges

Each exchange should extend the BaseExchange class and implement all functions there.

pyjuque's People

Contributors

tudorelu avatar pimpmypixel avatar userneeds-ahe avatar

Stargazers

Trevor Lee Setford avatar

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.