GithubHelp home page GithubHelp logo

tryphe / trader Goto Github PK

View Code? Open in Web Editor NEW
26.0 5.0 15.0 1.94 MB

a ping pong and maker/taker order bot for trading cryptocurrency on Waves Exchange, Poloniex, Bittrex, and Binance

License: MIT License

C++ 75.64% QMake 0.72% C 23.44% Shell 0.01% Python 0.19%
bot trading-bot bitcoin altcoin cryptocurrency exchange ping-pong tit-for-tat poloniex bittrex

trader's Introduction

Warning: this repo is in a transition phase. Use the code as you wish, but take caution.

What is Trader?

Trader is a bot that makes manual orders for the user, and/or makes automatic ping-pong orders. Trader can execute one-time, fill-or-kill, and maker/taker orders, and simulates these modes on exchanges without direct support. Trader also respects exchange limits like maximum number of orders, minimum price, maximum price, minimum lot size, price ticksize, etc.

License

Trader is released under the terms of the MIT license.

Features

  • Low resource usage. 5MB static binary, 15-20MB ram usage.
  • Runs headless.
  • Supports a large number of build targets. See Qt platform requirements for more details.
  • Order engine is adaptable to any exchange.
  • Runtime sanity testing and fairly extensive order execution simulation for consistency.
  • Uses GMP multi-precision integers. No floating-point instructions are used. How can floats fail?
  • Real-time slippage calculation which prevents local order collision and greatly reduces the frequency of exchange post-only mode collisions.
  • Anti-mistake. Prevents taking a price 10% lower or higher from the current spread(also overridable), and more!
  • Ping-pong using fixed, user-generated positions. Also able to combine positions.
  • Automatic ping-ping (wip)
  • Because trades aren't made using a browser interface, coin theft by withdrawal through browser hijacking is impossible.

Exchanges

  • Bittrex REST support. (deprecated)
  • Binance REST support. (deprecated, partially broken)
  • Poloniex REST and WSS feed support (deprecated)
  • Waves support

TODO

  • Create readme and documentation for new strategy
  • Stats tracker for persistence. (wip)
  • Add more exchanges.
  • GUI (abandoned)
  • WSS notifications (abandoned)

Dependencies: Compiling Qt and installing libgmp (unix/linux)

Trader requires Qt 5.10 or later, built with the core, network, and websockets modules. To build:

  1. Install dependencies: - sudo apt build-dep qt5-default - sudo apt install libgmp-dev
  2. Open your source directory, ie. cd ~/src. If it doesn't exist, run mkdir ~/src first.
  3. Pull any currently maintained Qt source: wget https://download.qt.io/archive/qt/5.13/5.13.1/single/qt-everywhere-src-5.13.1.tar.xz
  4. Extract: tar xf qt-everywhere-src-5.13.1.tar.xz
  5. Go there: cd qt-everywhere-src-5.13.1
  6. Configure Qt. Important: replace username with your username. (Choose only one) - Click here to configure a dynamic build, to run Trader on your machine - Click here to configure a static build, to copy Trader to another machine with the same OS
  7. If there are no errors, run make: make -j (if low on RAM or single CPU, you can skip the -j)
  8. If there are no errors, run make install
  9. Now, run qmake -v prefixed with your install path (type the whole thing): ~/localqt/Qt-5.13.1-minimal/bin/qmake -v ~~~ QMake version 3.1 Using Qt version 5.13.1 in /home/username/localqt/Qt-5.13.1-minimal/lib ~~~ If you are having problems with step 9 and interfering Qt versions, invoke qmake using qtchooser instead.

Compiling

  1. Open your source directory, ie. cd ~/src
  2. Clone this repo: git clone https://github.com/tryphe/trader
  3. Go there: cd trader
  4. Hardcode your API keys into daemon/keydefs.h (choose only one): - Run python generate_keys.py - or: Copy the example keydefs file: cp daemon/keydefs.h.example daemon/keydefs.h then paste your keys in with your favorite editor. - or: (non-hardcoded keys): Create keydefs.h using the example file above, but leave the keys blank or as-is during compile. Then, each time you run the binary, modify the bulk input file <config-directory>/in.txt, adding this line: setkeyandsecret <key> <secret>.
  5. Run qmake: ~/localqt/Qt-5.13.1-minimal/bin/qmake
  6. Compile: make -j, or make -jn where n is the number of simultaneous makes.

Updating

Run git pull to pull the latest code, then repeat step 6 from the Compiling section. You should do this frequently - minor bugfixes are common.

Running the daemon

Sessionize traderd so it stays running: setsid ./traderd

Config directory

~/.config/trader

Tailing the logs (note: CLI output goes to the logs)

Running the daemons and relying terminal output is suboptimal if the terminal closes. It's enabled by default, but can be disabled in daemon/build-config.h. All output is also routed to the logfiles. There's a color log, and a noncolor log. To tail, run: tail -f --lines=200 ~/.config/trader/log.<timestamp>_color.txt.

Commands

Check out the list of commands. (warning: most of these commands are now deprecated)

FAQS

What the bot is NOT

The bot doesn't use common chart indicators, like momentum indicators or standard deviation formulas. Instead, it relies on user-generated ping-pong, and automatic ping-pong based on a cross-market tit-for-tat strategy (coming soon).

What about supporting xyz exchange?

It's fairly easily to integrate the bot with any API, as long as it can read its current orders and get ticker prices. Currently, it would take roughly 1000 lines to add another exchange. If you know of a good exchange, let me know.

trader's People

Contributors

tryphe 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

Watchers

 avatar  avatar  avatar  avatar  avatar

trader's Issues

engine/rest: partial fills are not tracked

Previously, I had only used the bot to either make ping-pong orders, or onetime orders (without timeouts). In these modes, it's completely fine to ignore partial fills, as we only care about the order being completely filled, and we assume that the bot will run that long, ignoring the partials between bot restarts or position resets, etc.

However, with onetime orders with timeouts, and spruce strat orders, we rely on cancelling these orders, and must count the partial fills that occurred before timeout/cancellation. This matters because they should occur at a much greater frequency than the circumstances above.

It would be nice to fix this, but I'll have to think about the right approach.

engine/rest: market names between exchanges are very inconsistent

Trying to differentiate between market names on different exchanges sucks. Need to combine them. Formatting is:

Poloniex: BASE_QUOTE
Bittrex: BASE-QUOTE
Binance: QUOTEBASE

Maybe I'll just convert everything to do BASE_QUOTE. The other option would be to split it into 2 strings, which changes more stuff, so prefer not to do it this way. Update: We want to support the concept of base currency and quote currency separately now, because of the way spruce strat takes currency names and applies them to the base.

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.