Giter Site home page Giter Site logo

yehjames / leveraged-grid-trading-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mosutw/leveraged-grid-trading-bot

2.0 1.0 6.0 40 KB

Leveraged grid-trading bot using CCXT/CCXT Pro library in FTX exchange.

License: MIT License

Python 100.00%

leveraged-grid-trading-bot's Introduction

Leveraged-grid-trading-bot

The code is designed to perform infinity grid trading strategy in FTX exchange.

The basic trader named Gridtrader.py control the number of grids dynamically using the setting in JSON file.

asyncGridtrader.py will do the same job asynchronously.

Trader with database support, Gridtrader_with_db.py and asyncGridtrader_with_db.py, will store the transaction info in database via mysql.

If the trader termineated accidentally, the next execution of trader will follow the history stored in the database.

It is recommended to execeute the code in Linux system with Python version 3.7+.

The bot will show the following information in log file:

  1. Cash flow
  2. Realized profit, averaged profit per day (Not including fee)
  3. Total volume, averaged volume per day
  4. Maker ratio in filled orders
  5. Number of filled orders
  6. Transaction fee

How leveraged?

Most of the funds is locked in normal grid trading bot, while this bot will only create limit orders near the market price (controlled by parameters in setting file). Under this circumstance, the profit can be much greater for short-term price volatility by increasing the transaction frequency. The funds may not be enough to afford the infinity grid trading under the same parameter settings, so it can be regarded as leveraged trading policy.

Reguired packages

For async-supported version:

For database-supported version:

Cheatsheet

pip install pytz ccxt simplejson asyncio mysql-connector-python

Setting.json

This grid trader will create at least grid_level and at most 2x grid_level numerber of grids for buy/sell, respectively. That is, the trader will make sure the number of orders for buy and sell are both not less than grid_level and also not greater than 2x grid_level.

The price difference of grids is set as interval_prof . For each transaction, the amount is set as amount.

Getting started

  1. Rename setting.json.sample to setting.json (Not required).
  2. Edit the parameters in setting.json
  3. Run the command (See examples).

Cautions

It is recommended to create a subaccount to use this trading bot to avoid your orders being cancelled by the bot at the beginning.

Examples

Without async support and without database

python3 GridTrader.py your.setting.json

This command execute GridTrader.py with json file named your.setting.json.

python3 GridTrader.py

This command execute GridTrader.py with json file named setting.json.

For other version of trader, change the Gridtrader.py to others in above commands.

Log snapshots (ETH/USD)

Aug 05 2021 17:37:11, ##########.Trading Info.##########
Trade balance: -218.06 USD, +0.1000 ETH
Return: 54.3300 USD, 20.6422 USD/Day
Volume: 93891.71 USD, 35673.27 USD/Day
Maker ratio: 96.50%, Total: 3681
Fee: 2.12847845 USD, 0.00000000 ETH
##########.##########.##########.##########.##########
Aug 05 2021 17:37:34, buy at 2588.4, place new sell at 2591.4.
Aug 05 2021 17:37:35, Enlarge grid for buy at 2468.4
Aug 05 2021 17:37:35, ##########.Trading Info.##########
Trade balance: -243.94 USD, +0.1100 ETH
Return: 54.3300 USD, 20.6401 USD/Day
Volume: 93917.59 USD, 35679.49 USD/Day
Maker ratio: 96.50%, Total: 3682
Fee: 2.12847845 USD, 0.00000000 ETH
##########.##########.##########.##########.##########
Aug 05 2021 17:37:39, buy at 2585.4, place new sell at 2588.4.
Aug 05 2021 17:37:39, Enlarge grid for buy at 2465.4
Aug 05 2021 17:37:44, buy at 2582.4, place new sell at 2585.4.
Aug 05 2021 17:37:44, Enlarge grid for buy at 2462.4
Aug 05 2021 17:37:53, sell at 2585.4, place new buy at 2582.4.

Buy me a coffee

BTC address: bc1qdqw277tqsqv0jqsc3hk4h2rwfa6zvfel2j09xe

ETH address: 0xCD5ea947424EaC5c277AbA8EcEDB1Ee760aBd265

FTX Pay

leveraged-grid-trading-bot's People

Stargazers

 avatar  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.