An execution framework for systematic strategies

Related tags

Miscellaneous wagmi
Overview

WAGMI is an execution framework for systematic strategies.

It is very much a work in progress, please don't expect it to work!

Architecture

The Django framework ties this project together and so a basic knowledge of Django is very useful if you want to work on this.

This has no dependencies on GCP or AWS, a DockerFile is provided as a deployment option. There is also a Makefile with some handy commands to get up and running.

Scheduling of tasks uses apscheduler, wrapped in django_apscheduler.

There are two key apps, "sizing" and "execution". Other apps can be added as strategies. The only strategy app included is "yolo", which is a RobotWealth strategy and requires a Robot Wealth API key. See https://robotwealth.com/.

The Sizing app collects Strategy Position Requests from each strategy, and then sizes the resultant trades based on the capital allocated to each strategy. The Sizing app then resolves the combined aggregate Target Positions for each Security.

The Execution app compares the actual account positions on the Exchange to the Target Positions, calculates the delta, and places an order for each Security to bring the actual account positions in line with the Target Positions.

All of this is logged, including fees, arrtival prices and fill prices.

Status

Some of the above works, some is incomplete. I ripped this code out of another project with the view of creatign a combined execution framework that can be used with a number of strategies on a number of different exchanges. For the purpose of simplicity, I have ripped out all of the IB execution code and other strategies (that aren't really for the public domain).

Getting Started

clone the repo create a virtualenv (I recommend pyenv-virtualenv) install the requirements 'pip install -r requirements.txt' make a .env file (based on .env-example) setup a database (connection string and password in the env file) - if you like, you can get a postgres running locally in docker using 'make runpg' then 'make createdb'

check everything is working: ./manage.py migrate (if not - fix any errors) load the fixtures: ./manage.py loaddata exchanges.yaml make a user: ./manage.py createsuperuser run it: ./manage.py runserver go to: https://localhost:8000/wagmi/ and login.

Contributing

Please use create a fork and submit pull requests!

The plan is:

  1. Get this working for RW "yolo" on ftx.
  2. Make sure the blotting is accurate (fills and fees)
  3. Consider optimising execution (it currently just tries to place an aggressive order inthe order book)
  4. Serve as a framework for other strategies.

BSD License

Copyright (c) 2021, Rich Atkinson

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE

Comments
  • Draft behavior of order execution logic

    Draft behavior of order execution logic

    Should we draft a spec with the overall behavior we want to implement? Then translate that into actual code handled by the right module.

    This could take the form of a github gist (with python pseudo code, e.g), or a google doc, or other

    No strong idea on the format. I find this kind of doc interesting: https://docs.hummingbot.io/strategies/twap note the activity diagram that helps build a finite state machine (pseudo code can be enough) that could be tick-ed from a task queue, eg.

    This could be the opportunity to clarify behavior (eg: are we supposed to have open orders overnight? what do we do with open orders intraday: what is the trigger for us to decide to replace their price? Should a TargetPositionRequest be considered constant during a day? etc)

    opened by arnaudj 2
  • Supervisord is not started when running with docker compose

    Supervisord is not started when running with docker compose

    Currently, when starting wagmi with docker compose, it seems that supervisord is not started.

    Possible cause

    In trading-server.yaml, service "django", defines command: ./wagmi/start.sh This overrides DockerFile's CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]" [supervisord], as per https://github.com/compose-spec/compose-spec/blob/master/spec.md#command

    Current behavior

    supervisord is not started (main effect: apscheduler is not started)

    Expect behavior - to confirm

    to confirm: Do we want

    • start.sh to run only python /app/manage.py runapscheduler?
    • start.sh to run [supervisord] as well?

    More generally, we have different behaviors between: supervisord.conf, start.sh, and manual steps in README.md (the readme mentions fixtures loading: exchanges.yaml, strategies.yaml)

    suggestion: we should define what file is involved in which use case (eg: supervisord for prod? start.sh for local testing?)

    question 
    opened by arnaudj 2
  • Wagmi can start in docker

    Wagmi can start in docker

    While testing locally with "docker-compose up" on OSX, I had a few errors. This fixes these errors and allows to run wagmi in docker. Cheers

    opened by arnaudj 1
  • Development hints

    Development hints

    Hi All,

    thank you for your work till now. I have few questions:

    1. What functionalities are already implemented and what is your road map for development?
    2. It is possible to have exchanges.yaml and strategies.yaml ?
    3. I have now docker containers up and running and I can connect to 8080 but I do not know how to use it...can you give me some hints?

    Thanks. Best regards. Marco.

    opened by mg64ve 0
  • Implement blotting for analytics

    Implement blotting for analytics

    Implement blotting, create a reports app that has all of the fills, orders, strategy position requests, original API call data (weights), target positions, funding… (ideally everything)

    TODO; have a discussion to put some concrete specifications on this

    enhancement 
    opened by CharlesFr 2
  • Running each strategy on a different sub-account

    Running each strategy on a different sub-account

    Add the ability to pass sub-account names from the strategy in order to trade them on separate sub-accounts.

    This is primarily to make PnL calculations more manageable. Also provides isolation between strategies for better risk mitigation.

    enhancement 
    opened by CharlesFr 2
  • FtxExchange should cater for futures and spot

    FtxExchange should cater for futures and spot

    The ftx API treats futures and spot differently; we should not conflate them.

    execution.exchanges.Exchange defines a base class for Exchanges (currently the only implementation is execution.exchanges.ftx.FtxExchange which is incomplete).

    We need to support strategies that work with spot, and futures.

    opened by atkinson 2
  • Implement trade buffer with a sensible default

    Implement trade buffer with a sensible default

    A trade buffer prevents you from sending an order to the market if it only makes a minor change to the position.

    e.g. if we have a position of 0.1 ETH and the algorithm says, make it 0.1001 ETH, we probably want to leave the position as is, avoiding trading fees.

    pseudocode:

    current_position = self.get_position(market)
    delta = current_position - units
    if abs(delta) > (trade_buffer * abs(current_position)):
        if delta < 0:
            self._place_order(market, side.SHORT, delta)
        else:
            self._place_order(market, side.LONG, delta)
    

    trade buffer needs to originate in the strategy (e.g. yolo), and shouldn't really thread all of the way through to execution for implementation.

    opened by atkinson 0
Owner
Rich Atkinson
CTO at Airteam. Problem solvers in software engineering and UX design. We are a trusted, safe pair of hands for many leading Australian organisations.
Rich Atkinson
Goddard A collection of small, simple strategies for Freqtrade

Goddard A collection of small, simple strategies for Freqtrade. Simply add the strategy you choose in your strategies folder and run. ⚠️ General Crypt

Shane Jones 118 Dec 14, 2022
Demo repository for Saltconf21 talk - Testing strategies for Salt states

Saltconf21 testing strategies Demonstration repository for my Saltconf21 talk "Strategies for testing Salt states" Talk recording Slides and demos Get

Barney Sowood 3 Mar 31, 2022
Hypothesis strategies for generating Python programs, something like CSmith

hypothesmith Hypothesis strategies for generating Python programs, something like CSmith. This is definitely pre-alpha, but if you want to play with i

Zac Hatfield-Dodds 73 Dec 14, 2022
Oblique Strategies for Python

Oblique Strategies for Python

Łukasz Langa 3 Feb 17, 2022
Web UI for your scripts with execution management

Script-server is a Web UI for scripts. As an administrator, you add your existing scripts into Script server and other users would be ab

Iaroslav Shepilov 1.1k Jan 9, 2023
laTEX is awesome but we are lazy -> groff with markdown syntax and inline code execution

pyGroff A wrapper for groff using python to have a nicer syntax for groff documents DOCUMENTATION Very similar to markdown. So if you know what that i

Subhaditya Mukherjee 27 Jul 23, 2022
Remote execution of a simple function on the server

FunFetch Remote execution of a simple function on the server All types of Python support objects.

Decave 4 Jun 30, 2022
This module is for finding the execution time of a whole python program

exetime 3.8 This module is for finding the execution time of a whole program How to install $ pip install exetime Contents: General Information Instru

Saikat Das 4 Oct 18, 2021
Unified Distributed Execution

Unified Distributed Execution The framework supports multiple execution backends: Ray, Dask, MPI and MultiProcessing. To run tests you need to install

null 17 Dec 25, 2022
LinkML based SPARQL template library and execution engine

sparqlfun LinkML based SPARQL template library and execution engine modularized core library of SPARQL templates generic templates using common vocabs

Linked data Modeling Language 6 Oct 10, 2022
BlackMamba is a multi client C2/post exploitation framework

BlackMamba is a multi client C2/post exploitation framework with some spyware features. Powered by Python 3.8.6 and QT Framework.

Gustavo 873 Dec 29, 2022
Viewflow is an Airflow-based framework that allows data scientists to create data models without writing Airflow code.

Viewflow Viewflow is a framework built on the top of Airflow that enables data scientists to create materialized views. It allows data scientists to f

DataCamp 114 Oct 12, 2022
Package pyVHR is a comprehensive framework for studying methods of pulse rate estimation relying on remote photoplethysmography (rPPG)

Package pyVHR (short for Python framework for Virtual Heart Rate) is a comprehensive framework for studying methods of pulse rate estimation relying on remote photoplethysmography (rPPG)

PHUSE Lab 261 Jan 3, 2023
Simple dependency injection framework for Python

A simple, strictly typed dependency injection library.

BentoML 14 Jun 29, 2022
Backtest framework based on DAGs

MultitaskQueue It's a simple framework based on three composed concepts: Task: A task is the smaller unit of execution or simple a node in the DAG, ev

null 4 Dec 9, 2021
Framework for creating efficient data processing pipelines

Aqueduct Framework for creating efficient data processing pipelines. Contact Feel free to ask questions in telegram t.me/avito-ml Key Features Increas

avito.tech 137 Dec 29, 2022
A topology optimization framework written in Taichi programming language, which is embedded in Python.

Taichi TopOpt (Under Active Development) Intro A topology optimization framework written in Taichi programming language, which is embedded in Python.

Li Zhehao 41 Nov 17, 2022
Sabe is a python framework written for easy web server setup.

Sabe is a python framework written for easy web server setup. Sabe, kolay web sunucusu kurulumu için yazılmış bir python çerçevesidir. Öğrenmesi kola

null 2 Jan 1, 2022
Reproducible nvim completion framework benchmarks.

Nvim.Bench Reproducible nvim completion framework benchmarks. Runs inside Docker. Fair and balanced Methodology Note: for all "randomness", they are g

i love my dog 14 Nov 20, 2022