Skip to content

Kevin-Roberts/coinbase_trader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

coinbase_trader

A python application to set complex Coinbase trading orders. Market orders, Limits, stop losses, trailing stop losses by percent or value, and one starts another orders. Uses Coinbase API and your api_key or oauth2 credentials (https://coinbase.com/docs/api/authentication) to execute real trades through Coinbase. Nearly every Coinbase API function has been implemented so you can also send, receive, and request bitcoins or check your account information, transaction history, ect.

Requirements

Example

from trader import Trader, CoinOrder
# oauth2 example setup can be seen in example.py of coinbase_python library
myTrader = Trader(api_key = 'my API key', logname = "mylog.txt")
# Setup order to Sell 0.5 bitcoin 10% lower than highest price seen by Trader.trade() 
# Use the optional price attribute to specify the max seen price so far, default is 0.
myTrader.setTrailingStopLossPercent(qty = 0.5, changeval = 10) 
# Setup order to Buy 0.5 bitcoin at 800 dollars per coin
myTrader.setLimitBuy(qty = 0.5, price = 800)
# Attempt to execute all trades once per sleep time until all trades have been executed
myTrader.trade(sleeptime = 60)

Notes

  • Trader.trade() function can run for a specified length of time.
  • Support has been added to easily run Trader.trade() in a seperate thread safely. Allowing you to add or remove orders from the orderbook easily (see testTrader.py for examples).
  • Can call functions from coinbase_python api via Trader.account object (could be dangerous in multithreaded mode without Trader._executeLock mutex)
  • TODO: preserve orderbook in a file and optionally reload the orderbook via an input to the python call this would be more useful once the threading feature above were added to save the user input and the other reason for this is to save the max seen value for trailing stop loss orders. The only time that max value is lost when the CoinOrder object is destroyed for any reason.
  • TODO: Setup as module with setup.py vs just importing
  • TODO: I am contemplating adding btc-e support (through a module already created for btc-e or with the requests library used by coinbase_python) and an algorithm that will trade on its own accord. For example, the program could pull in historical data and run a predictive learning classifier model to either buy or sell your coins based on historical data (possibly an SVM classifier), this would be a more significant update.

Contributing / Credits

So far just me Kevin-Roberts but contributions are greatly appreciated.

Disclaimer

This program executes REAL bitcoin trades with money from your coinbase account using the Coinbase API. Use and trade with this program at your own risk as I am not liable for any losses incurred using this software.

License

(The MIT License)

Copyright (c) 2014 Kevin Roberts kr0b1486@hotmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A python application to set complex Coinbase trading orders. Limits, stop losses, trailing stop losses, ect.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages