Giter Site home page Giter Site logo

lasticotsoftware / astibot Goto Github PK

View Code? Open in Web Editor NEW
207.0 15.0 48.0 498 KB

Astibot is a simple, visual and automated trading software for Coinbase Pro cryptocurrencies (Bitcoin trading bot)

License: MIT License

Python 100.00%
bitcoin trading trading-bot trading-algorithms trading-platform automated-trading price cryptocurrency cryptocurrency-trading-bot

astibot's Introduction

Astibot

Astibot is a simple, visual and automated trading software for Coinbase Pro cryptocurrencies

Astibot is a trading bot that operates on the Coinbase Pro trading platform through a set of API keys. Its trading strategy is basic, but it provides a powerful and interactive simulation tool to backtest your settings.

Astibot bases its decisions on 2 real-time indicators:

  • a MACD-like indicator: it provides buy and sell signals based on 2 moving averages: one fast, one slow. These averages can be tuned to be short-term focused (very sensitive, ~5 min chart) or more robust to price noise (less sensitive, ~2h chart). They are not computed in a traditional way, but with signal processing algorithms (recursive low pass filters).
  • a risk indicator: the purpose of this risk line is to avoid opening a trade too high that could hardly be sold with a profit. The user can set his own risk level thanks to a dedicated cursor. This line evolves automatically to match the average market level (based on the last few hours), but its value is weighted by the risk level the user has set.

Alt text

Main features

  • Real-time graph update
  • On-graph trades display (buy and sell markers)
  • Live trading mode (real-time trading)
  • Simulation mode (to backtest the settings)
  • Customizable MACD-like decision indicator (to detect buy and sell opportunities)
  • Supported Coinbase pro trading pairs must be defined in the src/GDAXCurrencies.py file within the get_all_pairs method.

Advanced features

  • Risk line: a customizable, real-time updated limit price limit above which Astibot will never buy
  • Stop loss: crypto is automatically sold if price is below a customizable percentage of the buy price
  • Sell trigger: a fixed percentage above the buy price to sell, for scalping. After a buy, Astibot places a limit order at this percentage of the buy price. If this parameter is set to zero this feature is disabled and Astibot will rely on its MACD-like indicator to decide when to sell.
  • Limit and Market orders management: when Astibot detects a buy (or a sell) opportunity, it first tries to buy (or sell) the asset through a limit order to benefit from the fee reduction (limit orders are less expensive and on the right side of the spread). If the order cannot be filled, Astibot decides to perform a market order (immediate effect, more expensive) or to cancel the buy if the buy opportunity strength has decreased too much.

How to use Astibot ?

Astibot can run on any computer capable of runnning Python 3, including Raspberry Pi (very convenient for 24/7 trading).

Install required dependencies

pip3 install pyqt5 pyqtgraph tzlocal cbpro twilio scipy ipdb

Start-up

  1. python Astibot.py
  2. At first start-up, enter your Coinbase Pro API keys (view and trade permissions are required)

Results

Let's talk about the key topic! I have run Astibot serveral weeks on my Raspberry pi. Here are my conclusions:

  • Astibot needs volatility to make profit: a 0.8% - 1% price amplitude on the short term chart is a minimum. These variations are required to detect dips and tops properly with the smoothing indicators, and to cover the buy and sell fees.
  • Astibot runs well during sideways periods. If volume and volatility are good, Astibot can outperform the chart.
  • Astibot is not very interesting during a bull market. Price dips are harder to find, and because of the risk line, Astibot never buys when price is too high.
  • Astibot is not profitable during a bear market: it will detect a lot of dips, buy these dips and it will not be able to close a trade with profit because price will have decreased.

To sum up, the mose difficult part is to know when it is interesting to run Astibot for the next hours or days. But, there's no rule. Use the Simulation mode and tune the cursors to try :)

Development

I think current Astibot version could be a good starting point to implement more sophisticated strategies. To understand the general software breakdown, a diagram is worth thousand words. Top modules call services from the modules below. Alt text

Known limitations

  • Astibot is designed to prioritize the execution of limit orders over market orders. However limit orders placing, monitoring and replacing on top of the order book in real-time when a buy/sell signal is raised is tricky to implement and I don't think it works perfectly. To avoid problems with this limit order mode feature, I configured Astibot to use market orders only by default (see TradingBotConfig file).
  • Astibot only implements the Coinbase Pro API . It would not be that hard to create a "BinanceControler", "BitfinexControler" ... to add multiplatform support. These specific controlers could herit from a more generic and abstract controler seen from higher level modules (polymorphism).

Development and design improvements

  • Some modules are too big and could be split into more micro modules (UIGraph for example)
  • Astibot was originally designed to trade fiat-crypto pairs. Recently, I added the support for BTC based pairs but I didn't have time to rename all the variable labelled "fiatXXX" that were orginally are designed to contain data about the fiat currency. So for example, variables fiatAccountBalance and cryptoAccountBalance should have more generic names like account1Balance, account2Balance.

astibot's People

Contributors

kayoslab avatar lasticotsoftware avatar rogerthomas84 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

astibot's Issues

Proposed changes

@LasticotSoftware - I'm contemplating changing the way this works slightly.

I think if you (or I'll be happy to do it) add a simple txt or JSON file with the defined currencies we could change the instructions on the README to say something like...

Copy the currencies.example.json file to currencies.json and add or remove trading pairs that you'd like to work with.

Just thinking then the currencies.json file can be added to the .gitignore file so that other users can make easier changes to the code to propose bug fixes.

Would be keen to know your thoughts. Like I said, I'm more than happy to do that change.

TransactionManager crashes on CancelOngoingLimitOrder

Hi,

I think there is a reference error at:

self.GDAX_CancelOngoingLimitOrder()

All other calls to GDAX_CancelOngoingLimitOrder() in TransactionManager.py are made to self.theGDAXControler.

The corresponding error message of it in live trading:
`TRNM - threadOrderPlacing: Buy order replace is needed. Current Bid is 1159.73, Best order book bid is: 1159.98
TRNM - threadOrderPlacing: Placing / Replacing a Buy limit order on the top of the order book
TRNM - computeBuyCapabilityInCrypto: capability is 0.04741069003720261 (current balance is 54.99 + 49.74 (hold))
TRNM - threadOrderPlacing: live best bid price too high: cancel order
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 1254, in run
self.function(*self.args, **self.kwargs)
File "/home/oswald/Projects/astibot/Astibot/src/TransactionManager.py", line 564, in threadOrderPlacing
self.GDAX_CancelOngoingLimitOrder()
AttributeError: 'TransactionManager' object has no attribute 'GDAX_CancelOngoingLimitOrder'

`

What I can recollect about the state and actions of the Bot:
It sent two Limit Orders to Buy at 1159.73โ‚ฌ on Coinbase, which went through.
Afterwards the UI was still showing: "Waiting to BUY ..." and the Live Price froze, although it still showed the green 'updating' text in the bottom right regularly.
I think it even showed the new Coinbase Balance, althought I might have only noticed this after pressing the Stop Button.

I changed the line #564 in my local files and will restart the Bot, hope it works better this time ;)
It is a very nice looking UI and the simulation are easily played with ;) thank you very much for creating it!

My only direct question so far:
Does the Bot really crash unrecoverably if the TransactionManager throws an Exception like this? (I have the lurking feeling, that I prematurely stopped trading and closed the bot too soon...)

Thanks for your time,
have a nice day,
oswald

Orders keep failing

I get this in the logs:
computeBuyCapabilityInCrypto: capability is 0.009044019958343245 (current balance is 50.0 + 0.0 (hold))

not sure why I get that 0.0 but it seems to be the reason why a bit after I get:

GDAX - Limit order placing sent. Request return is: {'message': 'Invalid price 0.0'}
GDAX - Buy limit order has been interpreted as rejected
TRNM - threadOrderPlacing: Placing the order failed. Waiting for next BUY opportunity
TRAD - Buy limit order canceled: go back to WAITING TO BUY state ============================================

any idea?

Cheers.

non va

ho installato tutto quello che cera scritto ma quando faccio partire il programma mi dice questo ๐Ÿ‘

Traceback (most recent call last):
File "C:\Users\rosario\Desktop\Astibot-master\src\Astibot.py", line 15, in
from GDAXControler import GDAXControler
File "C:\Users\rosario\Desktop\Astibot-master\src\GDAXControler.py", line 1, in
import cbpro
File "C:\Users\rosario\AppData\Local\Programs\Python\Python310\lib\site-packages\cbpro_init_.py", line 1, in
from cbpro.authenticated_client import AuthenticatedClient
File "C:\Users\rosario\AppData\Local\Programs\Python\Python310\lib\site-packages\cbpro\authenticated_client.py", line 10, in
import requests
File "C:\Users\rosario\AppData\Local\Programs\Python\Python310\lib\site-packages\requests_init_.py", line 63, in
from . import utils
File "C:\Users\rosario\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 29, in
from .cookies import RequestsCookieJar, cookiejar_from_dict
File "C:\Users\rosario\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\cookies.py", line 174, in
class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping

Resume ?

Hi what happen if the bot crash or lost internet connection but had buy some crypto just before ?
Will it resume his trading process ?

[Bug] the wrong currency symbol is used in one specific location

When trading on pair X-Y, when a buy order has been placed, the app says the following:

HH:mm - 0.000 Y Bought @ 0.000 X - Waiting for a sell opportunity above 0.000 Y

When it should say:

HH:mm - 0.000 Y Bought @ 0.000 X - Waiting for a sell opportunity above 0.000 X

Also "connection" is spelled incorrectly as "connexion" at least twice

errno 104 connection reset by peer

Hello , i have and error when the scripts run some time its puts trace:

MRKT - Applied coefficients : 6
MRKT - Coefficients updated. New self.maxMACDForNormalization is 6.95706, WnFas$
[Errno 104] Connection reset by peer - data: None
GDAX - WebSocket connexion closed (callback)
GDAX - Unexpected close of websocket. Trying to restart.
GDAX - Restarting Websocket in 10 seconds...
GDAX - WebSocket connexion opened (callback) on ETH-EUR
GDAX - End of on_close()
Error: messages missing (5826794202 - 5827292647). Re-initializing book at seq$
UIFO - Show
UIFO - Show

Thanks for all.
It is running on rpi3b with python3.7

Unable to refresh account and doesnt trade

I keep getting this errorGDAX - Error in refreshAccounts it also refuses to trade even though it would of made trades in the simulation. Im having the same issue on mac windows and linux.

Dependencies

There were a few extra dependencies not listed in the guide

ipdb
scipy
twilio
tzlocal
gdax

also your run command is python even though you specified python 3 as dependency, but I am running this using "python3 Astibot.py"

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.