All Projects → mtusman → gemini-python

mtusman / gemini-python

Licence: MIT License
A python client for the Gemini API and Websocket

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to gemini-python

Cryptofeed
Cryptocurrency Exchange Websocket Data Feed Handler
Stars: ✭ 643 (+805.63%)
Mutual labels:  trading, websockets, exchange, gemini
Python Poloniex
Poloniex API wrapper for Python 2.7 & 3
Stars: ✭ 557 (+684.51%)
Mutual labels:  trading, exchange, api-wrapper
Socktrader
🚀 Websocket based trading bot for 💰cryptocurrencies 📈
Stars: ✭ 152 (+114.08%)
Mutual labels:  trading, websockets, exchange
bot-trader
Simple bot trader for Bitmex
Stars: ✭ 14 (-80.28%)
Mutual labels:  trading, exchange
binance-pump-bot
Automation for Binance p&d(pump and dump) activity, ensures fastest purchase and provides auto selling functionality to lockdown profit during these events.
Stars: ✭ 112 (+57.75%)
Mutual labels:  trading, exchange
coinbase-pro-rs
Coinbase pro client for Rust
Stars: ✭ 127 (+78.87%)
Mutual labels:  trading, exchange
adamant-tradebot
Free market-making software for cryptocurrency projects and exchanges. Makes trade volume, maintains spread and liquidity/depth, set price range, and builds live-like dynamic order book.
Stars: ✭ 113 (+59.15%)
Mutual labels:  trading, exchange
bitmex-client-websocket
🛠️ C# client for Bitmex websocket API
Stars: ✭ 60 (-15.49%)
Mutual labels:  websockets, exchange
algo-coin
Python library for algorithmic trading cryptocurrencies across multiple exchanges
Stars: ✭ 386 (+443.66%)
Mutual labels:  exchange, gemini
b2s-trader
Application to automate trading process
Stars: ✭ 22 (-69.01%)
Mutual labels:  trading, exchange
tellerbot
Telegram Bot for over-the-counter trading
Stars: ✭ 17 (-76.06%)
Mutual labels:  trading, exchange
hurtrade
An Open Source Forex Trading Platform
Stars: ✭ 22 (-69.01%)
Mutual labels:  trading, exchange
Mida
The open-source and cross-platform trading framework
Stars: ✭ 263 (+270.42%)
Mutual labels:  trading, exchange
roq-samples
How to use the Roq C++20 API for Live Cryptocurrency Algorithmic and High-Frequency Trading as well as for Back-Testing and Historical Simulation
Stars: ✭ 119 (+67.61%)
Mutual labels:  trading, exchange
coincube
A Python/Vue.js crypto portfolio management and trade automation program with support for 10 exchanges.
Stars: ✭ 85 (+19.72%)
Mutual labels:  trading, exchange
ocaml-gemini
OCaml REST and WebSockets client for the Gemini Trading Exchange.
Stars: ✭ 16 (-77.46%)
Mutual labels:  gemini, gemini-api
intrinio-realtime-python-sdk
Intrinio Python SDK for Real-Time Stock Prices
Stars: ✭ 79 (+11.27%)
Mutual labels:  websockets, exchange
cryptogalaxy
Get any cryptocurrencies ticker and trade data in real time from multiple exchanges and then save it in multiple storage systems.
Stars: ✭ 96 (+35.21%)
Mutual labels:  exchange, gemini-api
crypto-websocket-extensions
🧰 Unified and optimized data structures across cryptocurrency exchanges
Stars: ✭ 31 (-56.34%)
Mutual labels:  websockets, exchange
Cryptotrader
A cryptocurrency trader for all famous exchanges
Stars: ✭ 228 (+221.13%)
Mutual labels:  trading, exchange

gemini-python

A python client for the Gemini API and Websocket

Getting Started

Installation

pip install gemini_python

PublicClient

This endpoint doesn't require an api-key and can be used without having a Gemini account. This README will document some of the methods and features of the class.

import gemini
r = gemini.PublicClient()
# Alternatively, for a sandbox environment, set sandbox=True
r = gemini.PublicClient(sandbox=True)

PublicClient Methods

r.symbols()
r.symbol_details("BTCUSD")
r.get_ticker("BTCUSD")
r.get_current_order_book("BTCUSD")
# Will get the latest 500 trades
r.get_trade_history("BTCUSD")
# Alternatively, it can be specified for a specific date
r.get_trade_history("BTCUSD", since="17/06/2017")
# Will get the latest 500 auctions
r.get_auction_history("BTCUSD")
# Alternatively, it can be specified for a specific date
r.get_auction_history("BTCUSD", since="17/06/2017")

PrivateClient

This endpoint requires both a public and private key to access the API. Hence, one must have an account with Gemini and register an application. So far, if the 'heartbeat' option is enabled for the API, the user must manually revive the heartbeat. Further options will be added in the future in order to avoid doing this manually.

The payload of the requests will be a JSON object. Rather than being sent as the body of the POST request, Gemini requires it to be base-64 encoded and stored as a header in the request. Adding a 'nonce' is optional for the API but is highly recommended. That's why the class will always send each request with a unique 'nonce'. An important point to note is that every argument for the methods of PrivateClient must be strings with the exception of 'options'.

import gemini
r = gemini.PrivateClient("EXAMPLE_PUBLIC_KEY", "EXAMPLE_PRIVATE_KEY")
# Alternatively, for a sandbox environment, set sandbox=True
r = gemini.PrivateClient("EXAMPLE_PUBLIC_KEY", "EXAMPLE_PRIVATE_KEY", sandbox=True)

PrivateClient Methods

r.new_order("BTCUSD", "200", "6000", "buy")
r.cancel_order("866403510")
r.wrap_order("GUSDUSD", "10", "buy")
r.cancel_session_orders()
r.cancel_all_orders()
r.status_of_order("866403510")
r.active_orders()
# Will get the last 500 past trades
r.get_past_trades("BTCUSD")
# Alternatively, you can set the limit_trades number to your liking
r.get_past_trades("BTCUSD", limit_trades="200")
r.get_trade_volume()
r.get_balance()
# This will create a new currency address
r.create_deposit_address("BTCUSD")
# Alternatively, you can specify the label
r.create_deposit_address("BTCUSD", label="Main Bitcoin Address")
r.withdraw_to_address("ETH", "0x0287b1B0032Dc42c16640F71BA06F1A87C3a7101", "20")
r.revive_hearbeat()

Websocket Client

If you'd prefer to recieve live updates you can either choose to subsribe to the public market data websocket or the private order events websocket. For more information about the difference between the two websockets visit the official Gemini documentation.

MarketData Websocket

Market data is a public API that streams all the market data on a given symbol.

import gemini
r = gemini.MarketDataWS('btcusd')
# Alternatively, for a sandbox environment, set sandbox=True
r = gemini.MarketDataWS('btcusd', sandbox=True)

MarketData Websocket Methods

  • get list of recorded trades
r.trades
  • get recorded bids
r.bids
  • get recorded asks
r.asks
  • get market book
r.get_market_book()
  • remove a recorded price from bids or asks
# To remove a price from bids
r.remove_from_bids('10000')
# To remove a price from asks
r.remove_from_asks('10000')
  • search for a particular price recorded
r.search_price('10000')
  • export recorded trades to csv
r.export_to_csv(r'/c/Users/user/Documents')
  • export recorded trades to xml
r.export_to_xml(r'/c/Users/user/Documents')

OrderEvents Websocket

Order events is a private API that gives you information about your orders in real time.When you connect, you get a book of your active orders. Then in real time you'll get information about order events like:

  • when your orders are accepted by the exchange
  • when your orders first appear on the book
  • fills
  • cancels
  • and more.

Support for subscription filters is currently under development

import gemini
r = gemini.OrderEventsWS("EXAMPLE_PUBLIC_KEY", "EXAMPLE_PRIVATE_KEY")
# Alternatively, for a sandbox environment, set sandbox=True
r = gemini.OrderEventsWS("EXAMPLE_PUBLIC_KEY", "EXAMPLE_PRIVATE_KEY", sandbox=True)

OrderEvents Websocket Methods

  • get order types
"""All trades are categorised in terms of either subscription_ack', 'heartbeat', 
'initial', 'accepted','rejected', 'booked', 'fill', 'cancelled', 
'cancel_rejected' or 'closed'. The following will print these types"""
r.get_order_types
  • get order book
# Will return all recorded orders
r.get_order_book
  • remove a recorded price from the order book
# Arguments are: type and order_id
r.remove_order('accepted', '12321123')
  • export recorded trades to csv
# Arguments are: directory and type
# The following will export all 'accepted' orders to a csv format
r.export_to_csv(r'/c/Users/user/Documents', 'accepted')
  • export recorded trades to xml
# Arguments are: directory and type. 
# The following will export all 'accepted' orders to a xml format
r.export_to_xml(r'/c/Users/user/Documents', 'accepted')

Under Development

  • Add filter options to order events websocket
  • Improve options to add and remove orders from market data websocket
  • Add options to choose whether a particular class is cached or not
  • Export recorded data from market data or order events websocket into a matplotlib graph
  • Export recorded data from market data or order events websocket into a sqlite, postgresl or sql database
  • Add test for the cached metaclass

Change Log

0.2.0

  • Created BaseWebsocket class
  • Created OrderEventsWS class to interact with the order events websocket
  • Created MarketDataWS class to interact with the market data websocket
  • Added greater support for heartbeat API's
  • Improved the Cached metaclass
  • Added support for sandbox urls

0.0.1

  • Original release
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].