A program for creating simple orders & complex order arrays on cryptocurrency exchanges
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
The purpose of OperateExchange
is in its name - most actions a user would take on a cryptocurrency exchange, such as creating or cancelling orders, can be done using this program instead. The advantage of using OperateExchange
is that users can create groups of dozens of orders, or cancel groups of orders. This allows for more efficient trading than using an exchange's normal interface, which usually only allows users to open or close one order per click.
-
Python 3.6
-
Pandas
(optional; only necessary for charting) -
Matplotlib
(optional; only necessary for charting) -
CCXT
- The fantasticCCXT
library is critical toConnectToExchange
. Huge thanks to @kroitor and the many otherCCXT
contributors that made this program possible. -
ConnectToExchange
- This is another program I wrote for creating the initial connection to a cryptocurrency exchange. You can read more about it here: github.com/EvanGottschalk/ConnectToExchange -
GetCurrentTime
- This program is imported to help collect time data in a legible fashion. It also allows for the translation of time stamps. You can read more about it here: github.com/EvanGottschalk/GetCurrentTime -
AudioPlayer
- This is a simple program for playing custom audio alerts. It can be used withConnectToExchange
to warn you if an error occurs. You can read more about it here: github.com/EvanGottschalk/AudioPlayer -
QuadraticFormula
- This is a simple program for calculating the solutions to a quadratic equation using the quadratic formula.
OperateExchange
is easy to get up and running. Let me know if you have any trouble! I'm always trying to make installation as smooth as possible.
Before using OperateExchange
, you must first obtain an API key and secret from the cryptocurrency exchange of their choosing. You also need to install the CCXT
library.
-
Install
CCXT
, and optionallyPandas
andMatplotlib
if you want to see data visualizations. The easiest way to do this to downloadrequirements.txt
and usepip
:pip install -r requirements.txt
-
Download the
.py
files from this repository (OperateExchange.py
,ConnectToExchange.py
,GetCurrentTime.py
,QuadraticFormula.py
, and optionallyAudioPlayer.py
) -
In the same folder as
ConnectToExchange.py
, create a.txt
file to store your API information. Its name should start with the exchange you are using, followed by an underscore, followed by the name of the account you're using, and ending with_API.txt
.
For example, if you are using your Main account on Coinbase, you would name the .txt
file Coinbase_Main_API.txt
If your API key is view-only
, you can save your cryptocurrency exchange API key on the 1st line, and your API secret on the 2nd. However, if your API key has trade
priveleges, you should save an encrypted version of both your key and secret on those lines instead.
To encrypt your API information, I recommend using CustomEncryptor.py
, which can be downloaded here: github.com/EvanGottschalk/CustomEncryptor
-
Run
OperateExchange.py
-
Congratulations! You can now use
OperateExchange
to create and cancel orders on your chosen cryptocurrency exchange!
Example 1 - Creating an Order
The following code will create a limit order for $100 worth of bitcoin priced at $30,000.
OE = OperateExchange()
OE.createOrder({'Exchange': 'Coinbase', \
'Symbol': 'BTC/USD', \
'Side': 'buy', \
'Amount': '100', \
'Order Type': 'Limit', \
'Price': 30000})
Example 2 - Getting a dataframe and CSV of the open, high, low, close & volume values over the 1 minute timeframe
OE = OperateExchange()
OE.getOHLCVs('', 'BTC/USDT', '1m')
Example 3 - Cancel a group of orders to buy or sell bitcoin at prices between $32500 and $37500
OE = OperateExchange()
OE.CTE.connect('Coinbase')
OE.cancelOrderGroup({'Symbol': 'BTC/USD', \
'Lowest Cancel Price': 32500, \
'Highest Cancel Price': 37500})
Example 4 - Create an array of orders from $30,000 to $29,000 separated by $50 each on Coinbase totalling $100 in value. Since the style is 'Linear'
, the $100 of buying power will be distributed linearly from $30,000 to $29,000, with the largest order at $29,000 and the smallest at $30,000.
OE = OperateExchange()
OE.createArrayOrder({'Exchange': 'coinbase', \
'Symbol': 'BTC/USD', \
'Side': 'buy', \
'Amount': 100, \
'Order Type': 'limit', \
'Price': 30000}, \
{'Granularity': 50, \
'Spread': 1000, \
'Steepness': 0, \
'Minimum Order Size': 1, \
'Style': 'Linear'})
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the GNU GPL-3 License. See LICENSE
for more information.
Evan Gottschalk - @Fort1Evan - [email protected]
Project Link: https://github.com/EvanGottschalk/OperateExchange
Thinking about contributing to this project? Please do! Your Github username will then appear here.