ccxt 4.1.54__py2.py3-none-any.whl → 4.1.56__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

Files changed (251) hide show
  1. ccxt/__init__.py +2 -2
  2. ccxt/abstract/binance.py +1 -0
  3. ccxt/abstract/binancecoinm.py +1 -0
  4. ccxt/abstract/binanceus.py +1 -0
  5. ccxt/abstract/binanceusdm.py +1 -0
  6. ccxt/abstract/bitbank.py +1 -0
  7. ccxt/abstract/coinbase.py +2 -0
  8. ccxt/abstract/htx.py +3 -0
  9. ccxt/abstract/huobi.py +3 -0
  10. ccxt/abstract/huobipro.py +3 -0
  11. ccxt/abstract/okex.py +3 -1
  12. ccxt/abstract/okex5.py +3 -1
  13. ccxt/abstract/okx.py +3 -1
  14. ccxt/ace.py +23 -23
  15. ccxt/alpaca.py +8 -8
  16. ccxt/ascendex.py +26 -26
  17. ccxt/async_support/__init__.py +2 -2
  18. ccxt/async_support/ace.py +23 -23
  19. ccxt/async_support/alpaca.py +8 -8
  20. ccxt/async_support/ascendex.py +26 -26
  21. ccxt/async_support/base/exchange.py +4 -2216
  22. ccxt/async_support/bigone.py +21 -24
  23. ccxt/async_support/binance.py +61 -54
  24. ccxt/async_support/bingx.py +28 -28
  25. ccxt/async_support/bit2c.py +9 -9
  26. ccxt/async_support/bitbank.py +11 -10
  27. ccxt/async_support/bitbns.py +11 -11
  28. ccxt/async_support/bitfinex.py +15 -15
  29. ccxt/async_support/bitfinex2.py +22 -22
  30. ccxt/async_support/bitflyer.py +13 -13
  31. ccxt/async_support/bitforex.py +10 -10
  32. ccxt/async_support/bitget.py +44 -44
  33. ccxt/async_support/bithumb.py +9 -9
  34. ccxt/async_support/bitmart.py +85 -104
  35. ccxt/async_support/bitmex.py +27 -27
  36. ccxt/async_support/bitopro.py +18 -18
  37. ccxt/async_support/bitpanda.py +18 -18
  38. ccxt/async_support/bitrue.py +14 -14
  39. ccxt/async_support/bitso.py +17 -17
  40. ccxt/async_support/bitstamp.py +17 -17
  41. ccxt/async_support/bittrex.py +22 -24
  42. ccxt/async_support/bitvavo.py +15 -15
  43. ccxt/async_support/bl3p.py +4 -4
  44. ccxt/async_support/blockchaincom.py +17 -17
  45. ccxt/async_support/btcalpha.py +14 -14
  46. ccxt/async_support/btcbox.py +9 -9
  47. ccxt/async_support/btcmarkets.py +17 -17
  48. ccxt/async_support/btcturk.py +9 -9
  49. ccxt/async_support/bybit.py +46 -46
  50. ccxt/async_support/cex.py +10 -10
  51. ccxt/async_support/coinbase.py +69 -25
  52. ccxt/async_support/coinbasepro.py +19 -19
  53. ccxt/async_support/coincheck.py +10 -10
  54. ccxt/async_support/coinex.py +57 -66
  55. ccxt/async_support/coinlist.py +22 -22
  56. ccxt/async_support/coinmate.py +10 -10
  57. ccxt/async_support/coinone.py +10 -10
  58. ccxt/async_support/coinsph.py +17 -17
  59. ccxt/async_support/coinspot.py +5 -5
  60. ccxt/async_support/cryptocom.py +27 -27
  61. ccxt/async_support/currencycom.py +18 -18
  62. ccxt/async_support/delta.py +21 -21
  63. ccxt/async_support/deribit.py +24 -24
  64. ccxt/async_support/digifinex.py +35 -35
  65. ccxt/async_support/exmo.py +19 -19
  66. ccxt/async_support/gate.py +38 -38
  67. ccxt/async_support/gemini.py +11 -11
  68. ccxt/async_support/hitbtc.py +27 -27
  69. ccxt/async_support/hollaex.py +19 -19
  70. ccxt/async_support/htx.py +47 -44
  71. ccxt/async_support/huobijp.py +22 -22
  72. ccxt/async_support/idex.py +20 -20
  73. ccxt/async_support/independentreserve.py +9 -9
  74. ccxt/async_support/indodax.py +10 -10
  75. ccxt/async_support/kraken.py +25 -25
  76. ccxt/async_support/krakenfutures.py +17 -17
  77. ccxt/async_support/kucoin.py +27 -27
  78. ccxt/async_support/kucoinfutures.py +20 -20
  79. ccxt/async_support/kuna.py +19 -19
  80. ccxt/async_support/latoken.py +14 -14
  81. ccxt/async_support/lbank.py +18 -18
  82. ccxt/async_support/luno.py +14 -14
  83. ccxt/async_support/lykke.py +12 -12
  84. ccxt/async_support/mercado.py +11 -11
  85. ccxt/async_support/mexc.py +36 -36
  86. ccxt/async_support/ndax.py +18 -18
  87. ccxt/async_support/novadax.py +17 -17
  88. ccxt/async_support/oceanex.py +12 -12
  89. ccxt/async_support/okcoin.py +19 -19
  90. ccxt/async_support/okx.py +48 -45
  91. ccxt/async_support/p2b.py +6 -6
  92. ccxt/async_support/paymium.py +6 -6
  93. ccxt/async_support/phemex.py +57 -57
  94. ccxt/async_support/poloniex.py +31 -30
  95. ccxt/async_support/poloniexfutures.py +16 -16
  96. ccxt/async_support/probit.py +22 -22
  97. ccxt/async_support/tidex.py +15 -15
  98. ccxt/async_support/timex.py +20 -20
  99. ccxt/async_support/tokocrypto.py +16 -16
  100. ccxt/async_support/upbit.py +15 -15
  101. ccxt/async_support/wavesexchange.py +12 -12
  102. ccxt/async_support/wazirx.py +13 -13
  103. ccxt/async_support/whitebit.py +26 -26
  104. ccxt/async_support/woo.py +47 -47
  105. ccxt/async_support/yobit.py +8 -8
  106. ccxt/async_support/zaif.py +10 -10
  107. ccxt/async_support/zonda.py +16 -16
  108. ccxt/base/errors.py +17 -16
  109. ccxt/base/exchange.py +57 -97
  110. ccxt/base/types.py +138 -139
  111. ccxt/bigone.py +21 -24
  112. ccxt/binance.py +61 -54
  113. ccxt/bingx.py +28 -28
  114. ccxt/bit2c.py +9 -9
  115. ccxt/bitbank.py +11 -10
  116. ccxt/bitbns.py +11 -11
  117. ccxt/bitfinex.py +15 -15
  118. ccxt/bitfinex2.py +22 -22
  119. ccxt/bitflyer.py +13 -13
  120. ccxt/bitforex.py +10 -10
  121. ccxt/bitget.py +44 -44
  122. ccxt/bithumb.py +9 -9
  123. ccxt/bitmart.py +85 -104
  124. ccxt/bitmex.py +27 -27
  125. ccxt/bitopro.py +18 -18
  126. ccxt/bitpanda.py +18 -18
  127. ccxt/bitrue.py +14 -14
  128. ccxt/bitso.py +17 -17
  129. ccxt/bitstamp.py +17 -17
  130. ccxt/bittrex.py +22 -24
  131. ccxt/bitvavo.py +15 -15
  132. ccxt/bl3p.py +4 -4
  133. ccxt/blockchaincom.py +17 -17
  134. ccxt/btcalpha.py +14 -14
  135. ccxt/btcbox.py +9 -9
  136. ccxt/btcmarkets.py +17 -17
  137. ccxt/btcturk.py +9 -9
  138. ccxt/bybit.py +46 -46
  139. ccxt/cex.py +10 -10
  140. ccxt/coinbase.py +69 -25
  141. ccxt/coinbasepro.py +19 -19
  142. ccxt/coincheck.py +10 -10
  143. ccxt/coinex.py +57 -66
  144. ccxt/coinlist.py +22 -22
  145. ccxt/coinmate.py +10 -10
  146. ccxt/coinone.py +10 -10
  147. ccxt/coinsph.py +17 -17
  148. ccxt/coinspot.py +5 -5
  149. ccxt/cryptocom.py +27 -27
  150. ccxt/currencycom.py +18 -18
  151. ccxt/delta.py +21 -21
  152. ccxt/deribit.py +24 -24
  153. ccxt/digifinex.py +35 -35
  154. ccxt/exmo.py +19 -19
  155. ccxt/gate.py +38 -38
  156. ccxt/gemini.py +11 -11
  157. ccxt/hitbtc.py +27 -27
  158. ccxt/hollaex.py +19 -19
  159. ccxt/htx.py +47 -44
  160. ccxt/huobijp.py +22 -22
  161. ccxt/idex.py +20 -20
  162. ccxt/independentreserve.py +9 -9
  163. ccxt/indodax.py +10 -10
  164. ccxt/kraken.py +25 -25
  165. ccxt/krakenfutures.py +17 -17
  166. ccxt/kucoin.py +27 -27
  167. ccxt/kucoinfutures.py +20 -20
  168. ccxt/kuna.py +19 -19
  169. ccxt/latoken.py +14 -14
  170. ccxt/lbank.py +18 -18
  171. ccxt/luno.py +14 -14
  172. ccxt/lykke.py +12 -12
  173. ccxt/mercado.py +11 -11
  174. ccxt/mexc.py +36 -36
  175. ccxt/ndax.py +18 -18
  176. ccxt/novadax.py +17 -17
  177. ccxt/oceanex.py +12 -12
  178. ccxt/okcoin.py +19 -19
  179. ccxt/okx.py +48 -45
  180. ccxt/p2b.py +6 -6
  181. ccxt/paymium.py +6 -6
  182. ccxt/phemex.py +57 -57
  183. ccxt/poloniex.py +31 -30
  184. ccxt/poloniexfutures.py +16 -16
  185. ccxt/pro/__init__.py +1 -1
  186. ccxt/pro/alpaca.py +3 -3
  187. ccxt/pro/ascendex.py +2 -2
  188. ccxt/pro/binance.py +9 -9
  189. ccxt/pro/bingx.py +3 -3
  190. ccxt/pro/bitfinex.py +3 -3
  191. ccxt/pro/bitfinex2.py +3 -3
  192. ccxt/pro/bitget.py +3 -3
  193. ccxt/pro/bitmart.py +2 -2
  194. ccxt/pro/bitmex.py +3 -3
  195. ccxt/pro/bitpanda.py +3 -3
  196. ccxt/pro/bitrue.py +2 -2
  197. ccxt/pro/bitstamp.py +2 -2
  198. ccxt/pro/bittrex.py +3 -3
  199. ccxt/pro/bitvavo.py +3 -3
  200. ccxt/pro/blockchaincom.py +2 -2
  201. ccxt/pro/bybit.py +4 -4
  202. ccxt/pro/cex.py +3 -3
  203. ccxt/pro/coinbasepro.py +3 -3
  204. ccxt/pro/coinex.py +2 -2
  205. ccxt/pro/cryptocom.py +5 -5
  206. ccxt/pro/deribit.py +3 -3
  207. ccxt/pro/exmo.py +2 -2
  208. ccxt/pro/gate.py +3 -3
  209. ccxt/pro/gemini.py +2 -2
  210. ccxt/pro/hitbtc.py +4 -4
  211. ccxt/pro/hollaex.py +3 -3
  212. ccxt/pro/htx.py +3 -3
  213. ccxt/pro/idex.py +3 -3
  214. ccxt/pro/kraken.py +7 -7
  215. ccxt/pro/krakenfutures.py +4 -4
  216. ccxt/pro/kucoin.py +3 -3
  217. ccxt/pro/kucoinfutures.py +3 -3
  218. ccxt/pro/mexc.py +3 -3
  219. ccxt/pro/okcoin.py +2 -2
  220. ccxt/pro/okx.py +6 -6
  221. ccxt/pro/phemex.py +3 -3
  222. ccxt/pro/poloniex.py +3 -3
  223. ccxt/pro/poloniexfutures.py +3 -3
  224. ccxt/pro/probit.py +3 -3
  225. ccxt/pro/wazirx.py +3 -3
  226. ccxt/pro/whitebit.py +3 -3
  227. ccxt/pro/woo.py +2 -2
  228. ccxt/probit.py +22 -22
  229. ccxt/test/base/test_shared_methods.py +3 -3
  230. ccxt/test/test_async.py +543 -535
  231. ccxt/test/test_sync.py +542 -534
  232. ccxt/tidex.py +15 -15
  233. ccxt/timex.py +20 -20
  234. ccxt/tokocrypto.py +16 -16
  235. ccxt/upbit.py +15 -15
  236. ccxt/wavesexchange.py +12 -12
  237. ccxt/wazirx.py +13 -13
  238. ccxt/whitebit.py +26 -26
  239. ccxt/woo.py +47 -47
  240. ccxt/yobit.py +8 -8
  241. ccxt/zaif.py +10 -10
  242. ccxt/zonda.py +16 -16
  243. {ccxt-4.1.54.dist-info → ccxt-4.1.56.dist-info}/METADATA +10 -8
  244. ccxt-4.1.56.dist-info/RECORD +449 -0
  245. ccxt/async_support/bitstamp1.py +0 -402
  246. ccxt/async_support/lbank2.py +0 -2620
  247. ccxt/bitstamp1.py +0 -402
  248. ccxt/lbank2.py +0 -2619
  249. ccxt-4.1.54.dist-info/RECORD +0 -453
  250. {ccxt-4.1.54.dist-info → ccxt-4.1.56.dist-info}/WHEEL +0 -0
  251. {ccxt-4.1.54.dist-info → ccxt-4.1.56.dist-info}/top_level.txt +0 -0
ccxt/bitstamp1.py DELETED
@@ -1,402 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
- # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
-
6
- from ccxt.base.exchange import Exchange
7
- from ccxt.abstract.bitstamp1 import ImplicitAPI
8
- import hashlib
9
- from ccxt.base.types import Balances, Int, OrderBook, OrderSide, OrderType, String, Ticker, Trade
10
- from typing import List
11
- from ccxt.base.errors import ExchangeError
12
- from ccxt.base.errors import BadSymbol
13
- from ccxt.base.decimal_to_precision import TICK_SIZE
14
- from ccxt.base.precise import Precise
15
-
16
-
17
- class bitstamp1(Exchange, ImplicitAPI):
18
-
19
- def describe(self):
20
- return self.deep_extend(super(bitstamp1, self).describe(), {
21
- 'id': 'bitstamp1',
22
- 'name': 'Bitstamp',
23
- 'countries': ['GB'],
24
- 'rateLimit': 1000,
25
- 'version': 'v1',
26
- 'has': {
27
- 'CORS': True,
28
- 'spot': True,
29
- 'margin': False,
30
- 'swap': False,
31
- 'future': False,
32
- 'option': False,
33
- 'addMargin': False,
34
- 'cancelOrder': True,
35
- 'createOrder': True,
36
- 'createReduceOnlyOrder': False,
37
- 'createStopLimitOrder': False,
38
- 'createStopMarketOrder': False,
39
- 'createStopOrder': False,
40
- 'fetchBalance': True,
41
- 'fetchBorrowRate': False,
42
- 'fetchBorrowRateHistories': False,
43
- 'fetchBorrowRateHistory': False,
44
- 'fetchBorrowRates': False,
45
- 'fetchBorrowRatesPerSymbol': False,
46
- 'fetchFundingHistory': False,
47
- 'fetchFundingRate': False,
48
- 'fetchFundingRateHistory': False,
49
- 'fetchFundingRates': False,
50
- 'fetchIndexOHLCV': False,
51
- 'fetchLeverage': False,
52
- 'fetchMarginMode': False,
53
- 'fetchMarkOHLCV': False,
54
- 'fetchMyTrades': True,
55
- 'fetchOpenInterestHistory': False,
56
- 'fetchOrder': False,
57
- 'fetchOrderBook': True,
58
- 'fetchPosition': False,
59
- 'fetchPositionMode': False,
60
- 'fetchPositions': False,
61
- 'fetchPositionsRisk': False,
62
- 'fetchPremiumIndexOHLCV': False,
63
- 'fetchTicker': True,
64
- 'fetchTrades': True,
65
- 'reduceMargin': False,
66
- 'setLeverage': False,
67
- 'setMarginMode': False,
68
- 'setPositionMode': False,
69
- },
70
- 'urls': {
71
- 'logo': 'https://user-images.githubusercontent.com/1294454/27786377-8c8ab57e-5fe9-11e7-8ea4-2b05b6bcceec.jpg',
72
- 'api': {
73
- 'rest': 'https://www.bitstamp.net/api',
74
- },
75
- 'www': 'https://www.bitstamp.net',
76
- 'doc': 'https://www.bitstamp.net/api',
77
- },
78
- 'requiredCredentials': {
79
- 'apiKey': True,
80
- 'secret': True,
81
- 'uid': True,
82
- },
83
- 'api': {
84
- 'public': {
85
- 'get': [
86
- 'ticker',
87
- 'ticker_hour',
88
- 'order_book',
89
- 'transactions',
90
- 'eur_usd',
91
- ],
92
- },
93
- 'private': {
94
- 'post': [
95
- 'balance',
96
- 'user_transactions',
97
- 'open_orders',
98
- 'order_status',
99
- 'cancel_order',
100
- 'cancel_all_orders',
101
- 'buy',
102
- 'sell',
103
- 'bitcoin_deposit_address',
104
- 'unconfirmed_btc',
105
- 'ripple_withdrawal',
106
- 'ripple_address',
107
- 'withdrawal_requests',
108
- 'bitcoin_withdrawal',
109
- ],
110
- },
111
- },
112
- 'precisionMode': TICK_SIZE,
113
- 'markets': {
114
- 'BTC/USD': self.safe_market_structure({'id': 'btcusd', 'symbol': 'BTC/USD', 'base': 'BTC', 'quote': 'USD', 'baseId': 'btc', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
115
- 'BTC/EUR': self.safe_market_structure({'id': 'btceur', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'baseId': 'btc', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
116
- 'EUR/USD': self.safe_market_structure({'id': 'eurusd', 'symbol': 'EUR/USD', 'base': 'EUR', 'quote': 'USD', 'baseId': 'eur', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
117
- 'XRP/USD': self.safe_market_structure({'id': 'xrpusd', 'symbol': 'XRP/USD', 'base': 'XRP', 'quote': 'USD', 'baseId': 'xrp', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
118
- 'XRP/EUR': self.safe_market_structure({'id': 'xrpeur', 'symbol': 'XRP/EUR', 'base': 'XRP', 'quote': 'EUR', 'baseId': 'xrp', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
119
- 'XRP/BTC': self.safe_market_structure({'id': 'xrpbtc', 'symbol': 'XRP/BTC', 'base': 'XRP', 'quote': 'BTC', 'baseId': 'xrp', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
120
- 'LTC/USD': self.safe_market_structure({'id': 'ltcusd', 'symbol': 'LTC/USD', 'base': 'LTC', 'quote': 'USD', 'baseId': 'ltc', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
121
- 'LTC/EUR': self.safe_market_structure({'id': 'ltceur', 'symbol': 'LTC/EUR', 'base': 'LTC', 'quote': 'EUR', 'baseId': 'ltc', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
122
- 'LTC/BTC': self.safe_market_structure({'id': 'ltcbtc', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'baseId': 'ltc', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
123
- 'ETH/USD': self.safe_market_structure({'id': 'ethusd', 'symbol': 'ETH/USD', 'base': 'ETH', 'quote': 'USD', 'baseId': 'eth', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
124
- 'ETH/EUR': self.safe_market_structure({'id': 'etheur', 'symbol': 'ETH/EUR', 'base': 'ETH', 'quote': 'EUR', 'baseId': 'eth', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
125
- 'ETH/BTC': self.safe_market_structure({'id': 'ethbtc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': True}),
126
- },
127
- })
128
-
129
- def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
130
- """
131
- fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
132
- :param str symbol: unified symbol of the market to fetch the order book for
133
- :param int [limit]: the maximum amount of order book entries to return
134
- :param dict [params]: extra parameters specific to the bitstamp1 api endpoint
135
- :returns dict: A dictionary of `order book structures <https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure>` indexed by market symbols
136
- """
137
- if symbol != 'BTC/USD':
138
- raise ExchangeError(self.id + ' ' + self.version + " fetchOrderBook doesn't support " + symbol + ', use it for BTC/USD only')
139
- self.load_markets()
140
- orderbook = self.publicGetOrderBook(params)
141
- timestamp = self.safe_timestamp(orderbook, 'timestamp')
142
- return self.parse_order_book(orderbook, symbol, timestamp)
143
-
144
- def parse_ticker(self, ticker, market=None) -> Ticker:
145
- #
146
- # {
147
- # "volume": "2836.47827985",
148
- # "last": "36544.93",
149
- # "timestamp": "1643372072",
150
- # "bid": "36535.79",
151
- # "vwap":"36594.20",
152
- # "high": "37534.15",
153
- # "low": "35511.32",
154
- # "ask": "36548.47",
155
- # "open": 37179.62
156
- # }
157
- #
158
- symbol = self.safe_symbol(None, market)
159
- timestamp = self.safe_timestamp(ticker, 'timestamp')
160
- vwap = self.safe_string(ticker, 'vwap')
161
- baseVolume = self.safe_string(ticker, 'volume')
162
- quoteVolume = Precise.string_mul(baseVolume, vwap)
163
- last = self.safe_string(ticker, 'last')
164
- return self.safe_ticker({
165
- 'symbol': symbol,
166
- 'timestamp': timestamp,
167
- 'datetime': self.iso8601(timestamp),
168
- 'high': self.safe_string(ticker, 'high'),
169
- 'low': self.safe_string(ticker, 'low'),
170
- 'bid': self.safe_string(ticker, 'bid'),
171
- 'bidVolume': None,
172
- 'ask': self.safe_string(ticker, 'ask'),
173
- 'askVolume': None,
174
- 'vwap': vwap,
175
- 'open': self.safe_string(ticker, 'open'),
176
- 'close': last,
177
- 'last': last,
178
- 'previousClose': None,
179
- 'change': None,
180
- 'percentage': None,
181
- 'average': None,
182
- 'baseVolume': baseVolume,
183
- 'quoteVolume': quoteVolume,
184
- 'info': ticker,
185
- }, market)
186
-
187
- def fetch_ticker(self, symbol: str, params={}) -> Ticker:
188
- """
189
- fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
190
- :param str symbol: unified symbol of the market to fetch the ticker for
191
- :param dict [params]: extra parameters specific to the bitstamp1 api endpoint
192
- :returns dict: a `ticker structure <https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure>`
193
- """
194
- if symbol != 'BTC/USD':
195
- raise ExchangeError(self.id + ' ' + self.version + " fetchTicker doesn't support " + symbol + ', use it for BTC/USD only')
196
- self.load_markets()
197
- market = self.market(symbol)
198
- ticker = self.publicGetTicker(params)
199
- #
200
- # {
201
- # "volume": "2836.47827985",
202
- # "last": "36544.93",
203
- # "timestamp": "1643372072",
204
- # "bid": "36535.79",
205
- # "vwap":"36594.20",
206
- # "high": "37534.15",
207
- # "low": "35511.32",
208
- # "ask": "36548.47",
209
- # "open": 37179.62
210
- # }
211
- #
212
- return self.parse_ticker(ticker, market)
213
-
214
- def parse_trade(self, trade, market=None) -> Trade:
215
- #
216
- # public trade
217
- #
218
- # {
219
- # "amount": "0.00114000",
220
- # "date": "1694287856",
221
- # "price": "25865",
222
- # "tid": 298730788,
223
- # "type": 0
224
- # }
225
- #
226
- timestamp = self.safe_timestamp_2(trade, 'date', 'datetime')
227
- side = 'buy' if (trade['type'] == 0) else 'sell'
228
- orderId = self.safe_string(trade, 'order_id')
229
- id = self.safe_string(trade, 'tid')
230
- price = self.safe_string(trade, 'price')
231
- amount = self.safe_string(trade, 'amount')
232
- marketId = self.safe_string(trade, 'currency_pair')
233
- market = self.safe_market(marketId, market)
234
- return self.safe_trade({
235
- 'id': id,
236
- 'info': trade,
237
- 'timestamp': timestamp,
238
- 'datetime': self.iso8601(timestamp),
239
- 'symbol': market['symbol'],
240
- 'order': orderId,
241
- 'type': None,
242
- 'side': side,
243
- 'takerOrMaker': None,
244
- 'price': price,
245
- 'amount': amount,
246
- 'cost': None,
247
- 'fee': None,
248
- }, market)
249
-
250
- def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
251
- """
252
- get the list of most recent trades for a particular symbol
253
- :param str symbol: unified symbol of the market to fetch trades for
254
- :param int [since]: timestamp in ms of the earliest trade to fetch
255
- :param int [limit]: the maximum amount of trades to fetch
256
- :param dict [params]: extra parameters specific to the bitstamp1 api endpoint
257
- :returns Trade[]: a list of `trade structures <https://github.com/ccxt/ccxt/wiki/Manual#public-trades>`
258
- """
259
- if symbol != 'BTC/USD':
260
- raise BadSymbol(self.id + ' ' + self.version + " fetchTrades doesn't support " + symbol + ', use it for BTC/USD only')
261
- self.load_markets()
262
- market = self.market(symbol)
263
- request = {
264
- 'time': 'minute',
265
- }
266
- response = self.publicGetTransactions(self.extend(request, params))
267
- #
268
- # [
269
- # {
270
- # "amount": "0.00114000",
271
- # "date": "1694287856",
272
- # "price": "25865",
273
- # "tid": 298730788,
274
- # "type": 0
275
- # },
276
- # ]
277
- #
278
- return self.parse_trades(response, market, since, limit)
279
-
280
- def parse_balance(self, response) -> Balances:
281
- result = {'info': response}
282
- codes = list(self.currencies.keys())
283
- for i in range(0, len(codes)):
284
- code = codes[i]
285
- currency = self.currency(code)
286
- currencyId = currency['id']
287
- account = self.account()
288
- account['free'] = self.safe_string(response, currencyId + '_available')
289
- account['used'] = self.safe_string(response, currencyId + '_reserved')
290
- account['total'] = self.safe_string(response, currencyId + '_balance')
291
- result[code] = account
292
- return self.safe_balance(result)
293
-
294
- def fetch_balance(self, params={}) -> Balances:
295
- """
296
- query for balance and get the amount of funds available for trading or funds locked in orders
297
- :param dict [params]: extra parameters specific to the bitstamp1 api endpoint
298
- :returns dict: a `balance structure <https://github.com/ccxt/ccxt/wiki/Manual#balance-structure>`
299
- """
300
- response = self.privatePostBalance(params)
301
- return self.parse_balance(response)
302
-
303
- def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
304
- """
305
- create a trade order
306
- :param str symbol: unified symbol of the market to create an order in
307
- :param str type: 'market' or 'limit'
308
- :param str side: 'buy' or 'sell'
309
- :param float amount: how much of currency you want to trade in units of base currency
310
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
311
- :param dict [params]: extra parameters specific to the bitstamp1 api endpoint
312
- :returns dict: an `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
313
- """
314
- if type != 'limit':
315
- raise ExchangeError(self.id + ' ' + self.version + ' accepts limit orders only')
316
- if symbol != 'BTC/USD':
317
- raise ExchangeError(self.id + ' v1 supports BTC/USD orders only')
318
- self.load_markets()
319
- method = 'privatePost' + self.capitalize(side)
320
- request = {
321
- 'amount': amount,
322
- 'price': price,
323
- }
324
- response = getattr(self, method)(self.extend(request, params))
325
- id = self.safe_string(response, 'id')
326
- return self.safe_order({
327
- 'info': response,
328
- 'id': id,
329
- })
330
-
331
- def cancel_order(self, id: str, symbol: String = None, params={}):
332
- """
333
- cancels an open order
334
- :param str id: order id
335
- :param str symbol: unified symbol of the market the order was made in
336
- :param dict [params]: extra parameters specific to the bitstamp1 api endpoint
337
- :returns dict: An `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
338
- """
339
- return self.privatePostCancelOrder({'id': id})
340
-
341
- def parse_order_status(self, status):
342
- statuses = {
343
- 'In Queue': 'open',
344
- 'Open': 'open',
345
- 'Finished': 'closed',
346
- 'Canceled': 'canceled',
347
- }
348
- return self.safe_string(statuses, status, status)
349
-
350
- def fetch_order_status(self, id: str, symbol: String = None, params={}):
351
- self.load_markets()
352
- request = {
353
- 'id': id,
354
- }
355
- response = self.privatePostOrderStatus(self.extend(request, params))
356
- return self.parse_order_status(response)
357
-
358
- def fetch_my_trades(self, symbol: String = None, since: Int = None, limit: Int = None, params={}):
359
- """
360
- fetch all trades made by the user
361
- :param str symbol: unified market symbol
362
- :param int [since]: the earliest time in ms to fetch trades for
363
- :param int [limit]: the maximum number of trades structures to retrieve
364
- :param dict [params]: extra parameters specific to the bitstamp1 api endpoint
365
- :returns Trade[]: a list of `trade structures <https://github.com/ccxt/ccxt/wiki/Manual#trade-structure>`
366
- """
367
- self.load_markets()
368
- market = None
369
- if symbol is not None:
370
- market = self.market(symbol)
371
- response = self.privatePostUserTransactions(params)
372
- return self.parse_trades(response, market, since, limit)
373
-
374
- def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
375
- url = self.urls['api']['rest'] + '/' + self.implode_params(path, params)
376
- query = self.omit(params, self.extract_params(path))
377
- if api == 'public':
378
- if query:
379
- url += '?' + self.urlencode(query)
380
- else:
381
- self.check_required_credentials()
382
- nonce = str(self.nonce())
383
- auth = nonce + self.uid + self.apiKey
384
- signature = self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256)
385
- query = self.extend({
386
- 'key': self.apiKey,
387
- 'signature': signature.upper(),
388
- 'nonce': nonce,
389
- }, query)
390
- body = self.urlencode(query)
391
- headers = {
392
- 'Content-Type': 'application/x-www-form-urlencoded',
393
- }
394
- return {'url': url, 'method': method, 'body': body, 'headers': headers}
395
-
396
- def handle_errors(self, httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody):
397
- if response is None:
398
- return None
399
- status = self.safe_string(response, 'status')
400
- if status == 'error':
401
- raise ExchangeError(self.id + ' ' + self.json(response))
402
- return None