Git Product home page Git Product logo

binancetesttrading's Introduction

BinanceTestTrading

Simple trading strategy that will place orders in an event-driven way on BTCUSDT perpetual futures.

This strategy is event-based driven from on websocket feed messages to track order book, positions and open orders. The strategy always sets up 2 bid and 2 ask orders of size 0.1 BTC:

  • the bids are placed at the best available bid and at the best available bid minus 10 dollars
  • the asks are placed at the best available bid and at the best available ask plus 10 dollars

Bids orders are only placed if the current BTC position is <= 1 BTC while asks orders are only placed if the current BTC position is >= -1 BTC. Orders and cancels are inserted via RESTful POST API endpoints.

Note: Some functions from crytofeed for the POST API do not work for the Sandbox environment, a few workarounds were added to bypass this.

The strategy listens to the feed and updates its quotes based on new information. It maintains an internal expectation of the state of its orders to prevent duplication but is able to reconciles with the feed gracefully if there is a discrepancy.

Potential drawbacks include:

  • The open order internal state is only a best guess estimate by tracking post orders and is reconciled only on as it only updated on feed updates
  • Order updates are only sent on book updates, if this feed is delayed the orders may be incorrect
  • This pulls all orders on a trade, hence orders lose priority if re-inserted on the same level

Running the strategy

  • Requires Python 3.8
  • Use pipenv shell to enter the virtual environment
  • Run pipenv sync to install dependencies
  • Set exchange key_id and key_secret in config.yaml
  • Run python main.py to run the strategy

For development and testing

  • Use pipenv shell to enter the virtual environment.
  • Run pipenv sync --dev to install dependencies
  • To run the tests, use pipenv run test
  • Coding linting is available via Black and isort
    • To run linter, use pipenv run fmt

binancetesttrading's People

Contributors

raell avatar

Watchers

 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.