Giter VIP home page Giter VIP logo

gridtrader's Introduction

ADSactly Grid Trader

Grid trading algorithm: setup a grid of LIMIT BUY and LIMIT SELL orders around the current market price of a coin.

For precise details on the algorithm, consult SPEC.md

The original purpose of this code was to trade within a range and have futures positions setup above and below this range.

Installation

  1. git clone [email protected]:metaperl/surgetrader.git
  2. pip3 install -r requirements.txt

API Key

Login to Bittrex, Binance or wherever and create an API key with trading privileges enabled for that account. Record the key and secret. You will need to store them.

API Key

Configuration

Setup a config file for each account

shell> cd src/config ; cp sample.ini.sample myAccount.ini

Edit src/config/myAccount.ini per the docs in the .ini file.

Make a logfile directory

shell> mkdir -p src/log/myAccount

Add an entry to system.ini for each account to trade

[accounts]
active = bluechip.ini

Usage

shell>
shell> python gridtrader/gridtrader.py --help
shell> python gridtrader/gridtrader.py --balances $accountName # List balances of account
shell> python gridtrader/gridtrader.py --init $accountName    # Run once to set things up.
shell> python gridtrader.py --monitor $accountName # Run every X minutes over and over.

Automation

Convenience Scripts for Everything

in the batch directory is a run.py which should allow you do everything you want. Just set it up per the README.md there.

Once you configure your list of accounts in acccounts.py then you can run all the commands in gridtrader/gridtrader.py without specifying the account(s):

shell> ./batch/run.py --init         # will also cancel orders
shell> ./batch/run.py --balances     # show coin holdings
shell> ./batch/run.py --monitor      # monitor buy/sell grids and adjust
shell> ./batch/run.py --loop-monitor # run monitor indefinitely every `delay` minutes

Cron

You may wish to go the cron route, but this code should run fine on Windows. It was where it was initially developed (dons flame-retardant vest).

# m h  dom mon dow   command

MAILTO=""
PY=~/install/miniconda/bin/python
SRC=~/prg/adsactly-gridtrader/src
GT=./gridtrader.py

*/10 * * * * cd $SRC ; $PY $GT --monitor bluechip

# Cleanup

@daily find $GT/src/log/ -name '*.log' -mtime +1 -delete

Suggestions and Discussion

This code should only be run on coins that you are long-term bullish on. I.e, should the coin drop in price versus the quote currency, you have no problem with accumulating more.

In my case, I see the Binance token (BNB) as a sureshot long-term gainer coin, because of the obvious use case and incentive to buy.

It is very possible for this bot to drain ALL of your quote currency in a very short period of time. At that point, you have a "bag" of the base currency and you need to decide what to do with it. In my case, the options are:

  1. Move it to my portfolio account, where it is held with other long-term coins.
  2. Move it to another trading account, setting a limit order for profit.

Initial Coin Proportions

I recommend that you only make use of 25% of your base and quote currencies for the initial grids. That way, when new buy/sell grids are created when the old ones are exhausted

WARNING

If you change the program code you MUST run --init again. You cannot run --monitor right after a change to the source code. You must --init after that in ALL cases, because of how the serialization of program objects to disk between runs works.

Batch execution on Windows

src/batch/run.py

gridtrader's People

Contributors

metaperl avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

gridtrader's Issues

Error

python3 gridtrader.py --init myAccount.ini
File "gridtrader.py", line 319
logger.info(f"market={market}, core_position={core_position}")
^
SyntaxError: invalid syntax

Error

python3 gridtrader/gridtrader.py --init myAccount.ini
ic| self.configo: ConfigObj({})
Traceback (most recent call last):
File "gridtrader/gridtrader.py", line 626, in
dispatch_command(main)
File "/home/d9635776/TEST2/lib/python3.7/site-packages/argh/dispatching.py", line 306, in dispatch_command
dispatch(parser, *args, **kwargs)
File "/home/d9635776/TEST2/lib/python3.7/site-packages/argh/dispatching.py", line 174, in dispatch
for line in lines:
File "/home/d9635776/TEST2/lib/python3.7/site-packages/argh/dispatching.py", line 277, in _execute_command
for line in result:
File "/home/d9635776/TEST2/lib/python3.7/site-packages/argh/dispatching.py", line 260, in _call
result = function(*positional, **keywords)
File "gridtrader/gridtrader.py", line 577, in main
exchange = user_configo.make_exchangeo()
File "/home/d9635776/gridtrader/gridtrader/configo.py", line 103, in make_exchangeo
_ = exchange.abstract.Abstract.factory(self)
File "/home/d9635776/gridtrader/gridtrader/exchange/abstract.py", line 26, in factory
exchange_label = configo.exchange_label
File "/home/d9635776/gridtrader/gridtrader/configo.py", line 116, in exchange_label
_ = self.exchange('label')
File "/home/d9635776/gridtrader/gridtrader/configo.py", line 111, in exchange
_ = self.configo['exchange'][param]
File "/home/d9635776/TEST2/lib/python3.7/site-packages/configobj.py", line 554, in getitem
val = dict.getitem(self, key)
KeyError: 'exchange'

Exchange - deribit

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.