forked from dtbartle/altcoin-autosell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exchange_api.py
53 lines (44 loc) · 1.43 KB
/
exchange_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# An exception that any methods in exchange may raise.
class ExchangeException(Exception):
def __init__(self, message):
Exception.__init__(self, message)
# An available market.
class Market(object):
source_currency_id = None
target_currency_id = None
market_id = None
trade_minimum = 0.00000001
def __init__(self, source_currency_id, target_currency_id, market_id,
trade_minimum=0.0000001):
self.source_currency_id = source_currency_id
self.target_currency_id = target_currency_id
self.market_id = market_id
self.trade_minimum = trade_minimum
# A base class for Exchanges.
class Exchange(object):
# The name of the exchange.
name = ''
# Returns a dict of currency_name to currency_id, e.g.
# {
# 'BTC' : 1,
# 'LTC' : 2,
# 'DOGE': 12,
# '42': 15,
# }
def GetCurrencies(self):
raise NotImplementedError
# Returns a dict of currency_id to balance, e.g.
# {
# 12: 173.23,
# 13: 19,347,
# }
def GetBalances(self):
raise NotImplementedError
# Returns an array of Markets.
def GetMarkets(self):
raise NotImplementedError
# Creates an order (market order if price is 0).
# If 'bid' is True, this is a bid/buy order, otherwise an ask/sell order.
# Returns an order_id.
def CreateOrder(self, market_id, amount, bid=True, price=0):
raise NotImplementedError