forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdsx.py
More file actions
148 lines (137 loc) · 5.16 KB
/
dsx.py
File metadata and controls
148 lines (137 loc) · 5.16 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# -*- coding: utf-8 -*-
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
from ccxt.liqui import liqui
import hashlib
class dsx (liqui):
def describe(self):
return self.deep_extend(super(dsx, self).describe(), {
'id': 'dsx',
'name': 'DSX',
'countries': ['UK'],
'rateLimit': 1500,
'has': {
'CORS': False,
'fetchOrder': True,
'fetchOrders': True,
'fetchOpenOrders': True,
'fetchClosedOrders': True,
'fetchTickers': True,
'fetchMyTrades': True,
},
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/27990275-1413158a-645a-11e7-931c-94717f7510e3.jpg',
'api': {
'public': 'https://dsx.uk/mapi', # market data
'private': 'https://dsx.uk/tapi', # trading
'dwapi': 'https://dsx.uk/dwapi', # deposit/withdraw
},
'www': 'https://dsx.uk',
'doc': [
'https://api.dsx.uk',
'https://dsx.uk/api_docs/public',
'https://dsx.uk/api_docs/private',
'',
],
},
'api': {
# market data(public)
'public': {
'get': [
'barsFromMoment/{id}/{period}/{start}', # empty reply :\
'depth/{pair}',
'info',
'lastBars/{id}/{period}/{amount}', # period is(m, h or d)
'periodBars/{id}/{period}/{start}/{end}',
'ticker/{pair}',
'trades/{pair}',
],
},
# trading(private)
'private': {
'post': [
'getInfo',
'TransHistory',
'TradeHistory',
'OrderHistory',
'ActiveOrders',
'Trade',
'CancelOrder',
],
},
# deposit / withdraw(private)
'dwapi': {
'post': [
'getCryptoDepositAddress',
'cryptoWithdraw',
'fiatWithdraw',
'getTransactionStatus',
'getTransactions',
],
},
},
})
def get_base_quote_from_market_id(self, id):
uppercase = id.upper()
base = uppercase[0:3]
quote = uppercase[3:6]
base = self.common_currency_code(base)
quote = self.common_currency_code(quote)
return [base, quote]
def fetch_balance(self, params={}):
self.load_markets()
response = self.privatePostGetInfo()
balances = response['return']
result = {'info': balances}
funds = balances['funds']
currencies = list(funds.keys())
for c in range(0, len(currencies)):
currency = currencies[c]
uppercase = currency.upper()
uppercase = self.common_currency_code(uppercase)
account = {
'free': funds[currency],
'used': 0.0,
'total': balances['total'][currency],
}
account['used'] = account['total'] - account['free']
result[uppercase] = account
return self.parse_balance(result)
def parse_ticker(self, ticker, market=None):
timestamp = ticker['updated'] * 1000
symbol = None
if market:
symbol = market['symbol']
average = self.safe_float(ticker, 'avg')
if average is not None:
if average > 0:
average = 1 / average
last = self.safe_float(ticker, 'last')
return {
'symbol': symbol,
'timestamp': timestamp,
'datetime': self.iso8601(timestamp),
'high': self.safe_float(ticker, 'high'),
'low': self.safe_float(ticker, 'low'),
'bid': self.safe_float(ticker, 'buy'),
'bidVolume': None,
'ask': self.safe_float(ticker, 'sell'),
'askVolume': None,
'vwap': None,
'open': None,
'close': last,
'last': last,
'previousClose': None,
'change': None,
'percentage': None,
'average': average,
'baseVolume': self.safe_float(ticker, 'vol'),
'quoteVolume': self.safe_float(ticker, 'vol_cur'),
'info': ticker,
}
def get_order_id_key(self):
return 'orderId'
def sign_body_with_secret(self, body):
return self.decode(self.hmac(self.encode(body), self.encode(self.secret), hashlib.sha512, 'base64'))
def get_version_string(self):
return '' # they don't prepend version number to public URLs as other BTC-e clones do