Giter VIP home page Giter VIP logo

cryptotrader's Introduction

CryptoTrader by Haschek Solutions

What does it do?

The heart of this repo is the coinbase-pro.php file which is a simple implementation of the Coinbase Pro API written in PHP.

The aim for this project is to create various tools and bots to make trading easier. It doesn't rely on any external APIs or classes rather than php-curl.

ONLY RUN THIS IF YOU KNOW WHAT YOU ARE DOING. IF YOU LOSE MONEY BECAUSE OF A PROGRAMMING ERROR, IT'S YOUR OWN FAULT. You have been warned.

Install

  • Clone this repo or download the zip file
  • Rename example.config.inc.php to config.inc.php
  • Create an API key on https://pro.coinbase.com/profile/api and fill in the values in your config.inc.php file
  • Install PHP
    • Windows: Download from windows.php.net
    • Linux: apt-get install php5 or better yet apt-get install php7.1 if available
    • MacOS: Install homebrew and then brew update followed by brew upgrade php. Apple is not including PHP in future versions of MacOS. If it is missing brew install php.
  • Run a bot or the example scripts with php

API key generation

Bots

Bot 1: Uptrend Surfer

The first bot is the most simple one.

This bot will buy coins for USD/EUR, track the worth of these coins and if it made a profit, sells the profit and waits for more gain to sell. So this bot will only make any money if the worth of the coin is rising steadily. No market analysis or else, just go with the flow.

# Example usage: Buy 100 USD worth of BTC and sell the profits when it gained 10% in value
php bots/uptrendsurfer.php -p BTC-USD -bw 100 -g 10
Parameter What it does
-p product-string The product string in the format "CRYPTO-PAYMENT". eg: BTC-EUR ETH-USD ETH-EUR, etc..
-bw "buy worth in USD/EUR" This amount will be bought in the crypto you specified. eg "-p BTC-USD -w 100" will buy you 100$ worth of Bitcoin
-g "gain in percent needed for selling" This is the percentage increase needed for the bot to sell its profits
-nib No initial buy. Means that the script won't buy the amount you specified when it's run. You can use this to manage coins you already have
-fip "crypto price in USD/EUR" Only in combination with -nib! Uses a crypto price you specify. Can be used to restore older sessions
-sim Simulate only (no sells or buys are done, but the script thinks they were)

Bot 2: Wave Rider

This is an advanced version of the uptrend surfer

This bot is the same as the Uptrend Surfer with the only difference that after selling the gains, the bot will wait for the crypto price to drop by a percentage you specified before re-buying. This makes the bot a little bit more profitable in normal cases but it will miss steady uptrends. That's why this bot should be used in combination of the uptrend surfer so you have the best of both worlds.

# Example usage: Buy 100 USD worth of BTC, sell when it gained 10% in value and re-buy when the BTC price drops by 5%
php bots/waverider.php -p BTC-USD -bw 100 -g 10 -pv 5
Parameter What it does
-p product-string The product string in the format "CRYPTO-PAYMENT". eg: BTC-EUR ETH-USD ETH-EUR, etc..
-bw "buy worth in USD/EUR" This amount will be bought in the crypto you specified. eg "-p BTC-USD -w 100" will buy you 100$ worth of Bitcoin
-g "gain in percent needed for selling" This is the percentage increase needed for the bot to sell its coins
-pv "plummet value in percent for re-buy" This is the percentage the bot will wait for the crypto price to drop before re-buying
-nib No initial buy. Means that the script won't buy the amount you specified when it's run. You can use this to manage coins you already have
-fip "crypto price in USD/EUR" Only in combination with -nib! Uses a crypto price you specify. Can be used to restore older sessions
-sim Simulate only (no sells or buys are done, but the script thinks they were)

Example scripts for devs

There are multiple example scripts which do specific things.

account_info.php

This script when executed displays the account details.

Example output:

[i] Account overview
-----------------
 [i] Currency: ETH
   [ETH] Total balance:                 5.0055172700000000 ETH
   [ETH] Currently in open orders:      3.8327153400000000 ETH
   [ETH] Available:                     1.1728019300000000 ETH

 [i] Currency: BTC
   [BTC] Total balance:                 0.1242994896243332 BTC
   [BTC] Currently in open orders:      0.1242994800000000 BTC
   [BTC] Available:                     0.0000000096243332 BTC

 [i] Currency: USD
   [BTC] Total balance:                 15.000000000000000 BTC
   [BTC] Currently in open orders:      0.000000000000000 BTC
   [BTC] Available:                     15.000000000000000 BTC

price_check.php

This script prints out the market price from the last successful purchase

Example output:

[i] Price info for BTC-EUR
-----------
 [i] Ask price:         2090.98 EUR
 [i] Bid price:         2086.86 EUR
 [i] Spread:            4.1199999999999 EUR

cryptotrader's People

Contributors

csolisprimus avatar dandb2 avatar geek-at avatar genr8r avatar theebuddylee 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cryptotrader's Issues

Nib and fip parameters

Hello!
I'm trying to figure out how the fip value works. I have bought 0.21189432 ETH for 228 € when it's price was 1074.30€. Is this the right command to run?

php bots/waverider.php -p ETH-EUR -bw 228 -g 10 -pv 5 -nib fip 1074.30

Thank you!

Error message

Hi Christian,

I am currently running the cryptotrader and I do really admire you for being able to put such nice little app in place.

I am, however, wondering whether you could help with the following: When I run the script, I receive the following error-messages:

PHP Notice: Undefined index: message in /home/pi/cryptotrader/gdax.php on line 230
PHP Notice: Undefined property: gdax::$lowestask in /home/pi/cryptotrader/gdax.php on line 53
PHP Notice: Undefined property: gdax::$highestbid in /home/pi/cryptotrader/gdax.php on line 55
PHP Notice: Undefined index: message in /home/pi/cryptotrader/gdax.php on line 230

Can you help to resolve this?

The script runs on a RPi3 with php5.

Looking forward to hearing from you. Greetings to AUT.

Cheers,
Daniel

About rebuying option

First, I want to thank you for this great project!

My question is about the rebuying function. How does it work? When you say, waits for a drop, and then rebuy what quantity?

In the example command:

# Example usage: Buy 100 USD worth of BTC, sell when it gained 10% in value and re-buy when the BTC price drops by 5%
php bots/uptrendsurfer.php -p BTC-USD -bw 100 -g 10 -pv 5

When the prize drops over a 5%, then the bot rebuys, right? How much? 100USD again?

Thank you in advance.

gdax.php line 53, 55 & 230 errors

When starting bot:

PHP Notice: Undefined index: message in /home/pi/cryptotrader-master/gdax.php on line 230
PHP Notice: Undefined property: gdax::$lowestask in /home/pi/cryptotrader-master/gdax.php on line 53
PHP Notice: Undefined property: gdax::$highestbid in /home/pi/cryptotrader-master/gdax.php on line 55

This errors keep coming up.

Discord Webhook Integration

Hello Haschek,

I was wondering if there's any way or chance to get this to run through a webhook for Discord? I've tried creating my own but I'm having a lot of issues, any integration or instructions would be massively appreciated,

Error while making a call. Message: size is too accurate

php bots/waverider.php -p XLM-USD -bw 40 -g 10 -pv 5
[i] Trading XLM-USD
[i] Will buy 40 USD in XLM
[i] Will sell when XLM will gain 10%, meaning when it's worth 44 USD
[i] After selling I will wait for XLM to drop by 5% before re-buying

====== BOT STARTING ======

[i] 40 USD currently is 141.2354572 XLM
[!] Buying 141.2354572 XLM!
[X] Error while making a call. Message: size is too accurate. Smallest unit is 1.00000000
Current worth: 40.068075501268 Change: +0.07 USD

I have a different bot running with BTC-USD and it was able to execute fine, but when I tried to use XLM, I receive this error message.

Error getting accounts Info

Hi Christian,
first of all thanks for your work.
I am experiencing some issue in getting account info when calling function makeRequest that returns "Error getting accounts".
I guess it could be some problem with CURLOPT_URL but i am not php expert.

Regars

How to re-enter after computer reboot

Hello,

What is the best way to restart the bot after say a power outage or an accidental ctrl+c?

I ask because when the bot starts it buys the requested amount of BTC but if a computer or bot restart is required it no longer has sufficient funds for purchasing. Currently I am manually selling once profitable and then restarting the bot.

And Thank You for sharing your hard work.

-Jeff C.

Waverider bot wont start

I followed the installation commands then ran the command for the waverider bot and it looks like its starting but then fails and gives the error:

PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /home/pi/cryptotrader/coinbase-pro.php:198
Stack trace:
#0 /home/pi/cryptotrader/coinbase-pro.php(41): CoinbaseExchange->makeRequest('/products/BTC-U...')
#1 /home/pi/cryptotrader/bots/waverider.php(53): CoinbaseExchange->updatePrices('BTC-USD')
#2 {main}
thrown in /home/pi/cryptotrader/coinbase-pro.php on line 198

Thank you for creating cryptotrader! looks like fun!

Web stat output ?

Is it possible to have webhook for notification or an web dashboard simple with a short log or a graph with profit or lose

rate-limits

[X] Error getting products
[X] Error while making a call. Message: Rate limit exceeded. For rate limit information see https://docs.gdax.com/#rate-limits

Hello, again, thanks to your great work, i use your bot and it's simple and all i need,
if i can help i will do it with pleasure :-)

i see this error when i run this beautiful bot :-)


the docs say :

Rate Limits
When a rate limit is exceeded, a status of 429 Too Many Requests will be returned.

REST API
PUBLIC ENDPOINTS
We throttle public endpoints by IP: 3 requests per second, up to 6 requests per second in bursts.

PRIVATE ENDPOINTS
We throttle private endpoints by user ID: 5 requests per second, up to 10 requests per second in bursts.

FINANCIAL INFORMATION EXCHANGE API
The FIX API throttles each command type (eg.: NewOrderSingle, OrderCancelRequest) to 50 commands per second.

Perhaps can we set the bot to follow the numbers of request ?

Call to undefined function curl_init()

Hello,
i just tried to run command php /home/pi/cryptotrader/examples/account_info.php
but i get the following error :
PHP Fatal error: Call to undefined function curl_init() in /home/pi/cryptotrader/gdax.php on line 197

Could you please help me?
Regards

2020 update to coinbase pro

Thanks to all who have contributed to the update 2020 / Coinbase Pro. Very well done.

One question though:

The scripts run very well under macOS (php 7.3.11). They do however not run under Raspbian (php 7.3.19). The output is as follows:

WAVERIDER:
pi@raspberrypi:~/cryptotrader-master $ php bots/waverider.php -p ETH-EUR -bw 100 -g 10 -pv 5 -nib -sim

SIMULATION MODE

[i] Trading ETH-EUR
[i] Will buy 100 EUR in ETH
[i] Will sell when ETH will gain 10%, meaning when it's worth 110 EUR
[i] After selling I will wait for ETH to drop by 5% before re-buying

====== BOT STARTING ======

PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /home/pi/cryptotrader-master/coinbase-pro.php:198
Stack trace:
#0 /home/pi/cryptotrader-master/coinbase-pro.php(41): CoinbaseExchange->makeRequest('/products/ETH-E...')
#1 /home/pi/cryptotrader-master/bots/waverider.php(53): CoinbaseExchange->updatePrices('ETH-EUR')
#2 {main}
thrown in /home/pi/cryptotrader-master/coinbase-pro.php on line 198

UPTRENDSURFER:
pi@raspberrypi:~/cryptotrader-master $ php bots/uptrendsurfer.php -p ETH-EUR -bw 150 -g 5 -nib -sim

SIMULATION MODE

[i] Trading ETH-EUR
[i] Will buy 150 EUR in ETH
[i] Will sell when ETH will gain 5%, meaning when it's worth 157.5 EUR

====== BOT STARTING ======

PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /home/pi/cryptotrader-master/coinbase-pro.php:198
Stack trace:
#0 /home/pi/cryptotrader-master/coinbase-pro.php(41): CoinbaseExchange->makeRequest('/products/ETH-E...')
#1 /home/pi/cryptotrader-master/bots/uptrendsurfer.php(50): CoinbaseExchange->updatePrices('ETH-EUR')
#2 {main}
thrown in /home/pi/cryptotrader-master/coinbase-pro.php on line 198

Can you please help?

Error while making a call. Message: Invalid API Key

I keep getting this message when starting the bot:
`
====== BOT STARTING ======

[i] 100 USD currently is 0.0085224 BTC
[!] Buying 0.0085224 BTC!
[X] Error while making a call. Message: Invalid API Key
`
Api details have been put into config.inc.php correctly. Have tried creating new API key on GDAX but no success. Any clues?

UPDATE: nevermind I solved it! I was replacing the labels with the actual key data inside config.inc.php oops.

PHP Fatal error: Call to undefined function curl_init()

====== BOT STARTING ======

PHP Fatal error: Call to undefined function curl_init() in /home/ubuntu/cryptotrader/gdax.php on line 197
ubuntu@linuxpc:~/cryptotrader$ php bots/uptrendsurfer.php -p BTC-EUR -bw 50 -g 30 -pv 10 -sim
PHP Notice: Undefined offset: 10 in /home/dorian/cryptotrader/gdax.php on line 255
PHP Notice: Undefined offset: 10 in /home/dorian/cryptotrader/gdax.php on line 255

SIMULATION MODE

[i] Trading BTC-EUR
[i] Will buy 50 EUR in BTC
[i] Will sell when BTC will gain 30%, meaning when it's worth 65 EUR

====== BOT STARTING ======

PHP Fatal error: Call to undefined function curl_init() in /home/ubuntu/cryptotrader/gdax.php on line 197

launch

how to launch it, not launching with a server

Fills

how can i get fills (trade history)?

[X] Error while making a call. Message: size must be a number

I'm trying to figure out what exactly this error is referring to. I'm playing around with a small amount of money (around $10 USD worth) to test the waters, and when the uptrend hits the threshold, it attempts to sell for profit, however it also returns the above error.

**php7.4 bots/uptrendsurfer.php -p BTC-USD -bw 10 -g 0.1 -nib
[i] Trading BTC-USD
[i] Will buy 10 USD in BTC
[i] Will sell when BTC will gain 0.1%, meaning when it's worth 10.01 USD

====== BOT STARTING ======

[i] 10 USD currently is 0.000237 BTC
Current worth: 10.01200101 Change: +0.01 USD
[!!] Coins gained 0.1%, will sell the profits of 0.01 USD now!
[X] Error while making a call. Message: size must be a number
[BTC] Now still holding 0.0002368 BTC (sold 2.0E-7)
[i] Will sell profits again when it's worth 10.01 USD
Current worth: 10.018875392 Change: +0.02 USD
[!!] Coins gained 0.1%, will sell the profits of 0.02 USD now!
[X] Error while making a call. Message: size must be a number
[BTC] Now still holding 0.0002363 BTC (sold 5.0E-7)
[i] Will sell profits again when it's worth 10.01 USD**

Any insight of how I can correct this?

How to set up buy and sell points

Hello,

I saw your previous bots projects and thats how I found this one. I cloned everthing onto my Raspberry but I am now just wondering how to I set up buy and sell points? In the previous bot your wrote you mentioned that, in this one I am not able to locate that.

Thanks for your help!

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.