ccxt 4.3.6__py2.py3-none-any.whl → 4.3.8__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.
- ccxt/__init__.py +1 -1
- ccxt/abstract/coinbase.py +5 -0
- ccxt/ace.py +5 -0
- ccxt/alpaca.py +6 -0
- ccxt/ascendex.py +2 -2
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ace.py +5 -0
- ccxt/async_support/alpaca.py +6 -0
- ccxt/async_support/ascendex.py +2 -2
- ccxt/async_support/base/exchange.py +27 -1
- ccxt/async_support/bigone.py +1 -1
- ccxt/async_support/binance.py +6 -4
- ccxt/async_support/bingx.py +4 -2
- ccxt/async_support/bitbank.py +4 -1
- ccxt/async_support/bitfinex.py +1 -1
- ccxt/async_support/bitfinex2.py +1 -1
- ccxt/async_support/bitflyer.py +1 -1
- ccxt/async_support/bitget.py +71 -5
- ccxt/async_support/bithumb.py +5 -1
- ccxt/async_support/bitmart.py +1 -1
- ccxt/async_support/bitmex.py +3 -1
- ccxt/async_support/bitopro.py +6 -1
- ccxt/async_support/bitrue.py +1 -1
- ccxt/async_support/bitso.py +4 -1
- ccxt/async_support/bitstamp.py +4 -1
- ccxt/async_support/bitteam.py +4 -0
- ccxt/async_support/bitvavo.py +4 -1
- ccxt/async_support/bl3p.py +3 -0
- ccxt/async_support/blockchaincom.py +1 -1
- ccxt/async_support/btcalpha.py +3 -0
- ccxt/async_support/btcbox.py +3 -0
- ccxt/async_support/btcmarkets.py +4 -1
- ccxt/async_support/btcturk.py +3 -0
- ccxt/async_support/bybit.py +116 -14
- ccxt/async_support/cex.py +6 -0
- ccxt/async_support/coinbase.py +94 -18
- ccxt/async_support/coinbaseinternational.py +3 -1
- ccxt/async_support/coinbasepro.py +7 -1
- ccxt/async_support/coincheck.py +3 -0
- ccxt/async_support/coinex.py +255 -192
- ccxt/async_support/coinlist.py +5 -1
- ccxt/async_support/coinmate.py +4 -1
- ccxt/async_support/coinone.py +3 -0
- ccxt/async_support/coinsph.py +5 -1
- ccxt/async_support/coinspot.py +3 -0
- ccxt/async_support/cryptocom.py +3 -1
- ccxt/async_support/delta.py +2 -2
- ccxt/async_support/deribit.py +1 -1
- ccxt/async_support/digifinex.py +3 -3
- ccxt/async_support/exmo.py +8 -3
- ccxt/async_support/gate.py +112 -24
- ccxt/async_support/gemini.py +1 -1
- ccxt/async_support/hitbtc.py +7 -6
- ccxt/async_support/hollaex.py +1 -1
- ccxt/async_support/htx.py +3 -1
- ccxt/async_support/huobijp.py +1 -1
- ccxt/async_support/hyperliquid.py +2 -2
- ccxt/async_support/idex.py +4 -1
- ccxt/async_support/independentreserve.py +3 -0
- ccxt/async_support/indodax.py +4 -1
- ccxt/async_support/kraken.py +1 -1
- ccxt/async_support/kucoin.py +3 -1
- ccxt/async_support/kucoinfutures.py +3 -1
- ccxt/async_support/kuna.py +1 -1
- ccxt/async_support/latoken.py +6 -0
- ccxt/async_support/lbank.py +1 -1
- ccxt/async_support/luno.py +3 -0
- ccxt/async_support/lykke.py +6 -1
- ccxt/async_support/mercado.py +4 -1
- ccxt/async_support/mexc.py +110 -4
- ccxt/async_support/ndax.py +5 -1
- ccxt/async_support/novadax.py +5 -1
- ccxt/async_support/okcoin.py +1 -1
- ccxt/async_support/okx.py +81 -5
- ccxt/async_support/onetrading.py +4 -1
- ccxt/async_support/p2b.py +3 -0
- ccxt/async_support/phemex.py +1 -1
- ccxt/async_support/poloniex.py +1 -1
- ccxt/async_support/probit.py +4 -1
- ccxt/async_support/timex.py +3 -0
- ccxt/async_support/tokocrypto.py +1 -1
- ccxt/async_support/tradeogre.py +3 -0
- ccxt/async_support/upbit.py +1 -1
- ccxt/async_support/wavesexchange.py +4 -1
- ccxt/async_support/wazirx.py +3 -0
- ccxt/async_support/whitebit.py +1 -1
- ccxt/async_support/woo.py +4 -2
- ccxt/async_support/yobit.py +4 -1
- ccxt/async_support/zaif.py +1 -1
- ccxt/async_support/zonda.py +1 -1
- ccxt/base/exchange.py +38 -4
- ccxt/bigone.py +1 -1
- ccxt/binance.py +6 -4
- ccxt/bingx.py +4 -2
- ccxt/bitbank.py +4 -1
- ccxt/bitfinex.py +1 -1
- ccxt/bitfinex2.py +1 -1
- ccxt/bitflyer.py +1 -1
- ccxt/bitget.py +71 -5
- ccxt/bithumb.py +5 -1
- ccxt/bitmart.py +1 -1
- ccxt/bitmex.py +3 -1
- ccxt/bitopro.py +6 -1
- ccxt/bitrue.py +1 -1
- ccxt/bitso.py +4 -1
- ccxt/bitstamp.py +4 -1
- ccxt/bitteam.py +4 -0
- ccxt/bitvavo.py +4 -1
- ccxt/bl3p.py +3 -0
- ccxt/blockchaincom.py +1 -1
- ccxt/btcalpha.py +3 -0
- ccxt/btcbox.py +3 -0
- ccxt/btcmarkets.py +4 -1
- ccxt/btcturk.py +3 -0
- ccxt/bybit.py +116 -14
- ccxt/cex.py +6 -0
- ccxt/coinbase.py +94 -18
- ccxt/coinbaseinternational.py +3 -1
- ccxt/coinbasepro.py +7 -1
- ccxt/coincheck.py +3 -0
- ccxt/coinex.py +255 -192
- ccxt/coinlist.py +5 -1
- ccxt/coinmate.py +4 -1
- ccxt/coinone.py +3 -0
- ccxt/coinsph.py +5 -1
- ccxt/coinspot.py +3 -0
- ccxt/cryptocom.py +3 -1
- ccxt/delta.py +2 -2
- ccxt/deribit.py +1 -1
- ccxt/digifinex.py +3 -3
- ccxt/exmo.py +8 -3
- ccxt/gate.py +112 -24
- ccxt/gemini.py +1 -1
- ccxt/hitbtc.py +7 -6
- ccxt/hollaex.py +1 -1
- ccxt/htx.py +3 -1
- ccxt/huobijp.py +1 -1
- ccxt/hyperliquid.py +2 -2
- ccxt/idex.py +4 -1
- ccxt/independentreserve.py +3 -0
- ccxt/indodax.py +4 -1
- ccxt/kraken.py +1 -1
- ccxt/kucoin.py +3 -1
- ccxt/kucoinfutures.py +3 -1
- ccxt/kuna.py +1 -1
- ccxt/latoken.py +6 -0
- ccxt/lbank.py +1 -1
- ccxt/luno.py +3 -0
- ccxt/lykke.py +6 -1
- ccxt/mercado.py +4 -1
- ccxt/mexc.py +110 -4
- ccxt/ndax.py +5 -1
- ccxt/novadax.py +5 -1
- ccxt/okcoin.py +1 -1
- ccxt/okx.py +81 -5
- ccxt/onetrading.py +4 -1
- ccxt/p2b.py +3 -0
- ccxt/phemex.py +1 -1
- ccxt/poloniex.py +1 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bybit.py +1 -1
- ccxt/pro/coinbase.py +28 -28
- ccxt/probit.py +4 -1
- ccxt/timex.py +3 -0
- ccxt/tokocrypto.py +1 -1
- ccxt/tradeogre.py +3 -0
- ccxt/upbit.py +1 -1
- ccxt/wavesexchange.py +4 -1
- ccxt/wazirx.py +3 -0
- ccxt/whitebit.py +1 -1
- ccxt/woo.py +4 -2
- ccxt/yobit.py +4 -1
- ccxt/zaif.py +1 -1
- ccxt/zonda.py +1 -1
- {ccxt-4.3.6.dist-info → ccxt-4.3.8.dist-info}/METADATA +4 -4
- {ccxt-4.3.6.dist-info → ccxt-4.3.8.dist-info}/RECORD +178 -178
- {ccxt-4.3.6.dist-info → ccxt-4.3.8.dist-info}/WHEEL +0 -0
- {ccxt-4.3.6.dist-info → ccxt-4.3.8.dist-info}/top_level.txt +0 -0
ccxt/btcturk.py
CHANGED
@@ -66,8 +66,11 @@ class btcturk(Exchange, ImplicitAPI):
|
|
66
66
|
'fetchOrderBook': True,
|
67
67
|
'fetchOrders': True,
|
68
68
|
'fetchPosition': False,
|
69
|
+
'fetchPositionHistory': False,
|
69
70
|
'fetchPositionMode': False,
|
70
71
|
'fetchPositions': False,
|
72
|
+
'fetchPositionsForSymbol': False,
|
73
|
+
'fetchPositionsHistory': False,
|
71
74
|
'fetchPositionsRisk': False,
|
72
75
|
'fetchPremiumIndexOHLCV': False,
|
73
76
|
'fetchTicker': True,
|
ccxt/bybit.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bybit import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Greeks, Int, Leverage, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Greeks, Int, Leverage, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -116,7 +116,9 @@ class bybit(Exchange, ImplicitAPI):
|
|
116
116
|
'fetchOrders': False,
|
117
117
|
'fetchOrderTrades': True,
|
118
118
|
'fetchPosition': True,
|
119
|
+
'fetchPositionHistory': 'emulated',
|
119
120
|
'fetchPositions': True,
|
121
|
+
'fetchPositionsHistory': True,
|
120
122
|
'fetchPremiumIndexOHLCV': True,
|
121
123
|
'fetchSettlementHistory': True,
|
122
124
|
'fetchTicker': True,
|
@@ -5613,7 +5615,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
5613
5615
|
}
|
5614
5616
|
return self.safe_string(types, type, type)
|
5615
5617
|
|
5616
|
-
def withdraw(self, code: str, amount: float, address, tag=None, params={}):
|
5618
|
+
def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
|
5617
5619
|
"""
|
5618
5620
|
make a withdrawal
|
5619
5621
|
:see: https://bybit-exchange.github.io/docs/v5/asset/withdraw
|
@@ -6013,31 +6015,57 @@ class bybit(Exchange, ImplicitAPI):
|
|
6013
6015
|
# "tradeMode": 0
|
6014
6016
|
# }
|
6015
6017
|
#
|
6018
|
+
# fetchPositionsHistory
|
6019
|
+
#
|
6020
|
+
# {
|
6021
|
+
# symbol: 'XRPUSDT',
|
6022
|
+
# orderType: 'Market',
|
6023
|
+
# leverage: '10',
|
6024
|
+
# updatedTime: '1712717265572',
|
6025
|
+
# side: 'Sell',
|
6026
|
+
# orderId: '071749f3-a9fa-427b-b5ca-27b2f52b81de',
|
6027
|
+
# closedPnl: '-0.00049568',
|
6028
|
+
# avgEntryPrice: '0.6045',
|
6029
|
+
# qty: '3',
|
6030
|
+
# cumEntryValue: '1.8135',
|
6031
|
+
# createdTime: '1712717265566',
|
6032
|
+
# orderPrice: '0.5744',
|
6033
|
+
# closedSize: '3',
|
6034
|
+
# avgExitPrice: '0.605',
|
6035
|
+
# execType: 'Trade',
|
6036
|
+
# fillCount: '1',
|
6037
|
+
# cumExitValue: '1.815'
|
6038
|
+
# }
|
6039
|
+
#
|
6040
|
+
closedSize = self.safe_string(position, 'closedSize')
|
6041
|
+
isHistory = (closedSize is not None)
|
6016
6042
|
contract = self.safe_string(position, 'symbol')
|
6017
6043
|
market = self.safe_market(contract, market, None, 'contract')
|
6018
|
-
size = Precise.string_abs(self.
|
6044
|
+
size = Precise.string_abs(self.safe_string_2(position, 'size', 'qty'))
|
6019
6045
|
side = self.safe_string(position, 'side')
|
6020
6046
|
if side is not None:
|
6021
6047
|
if side == 'Buy':
|
6022
|
-
side = 'long'
|
6048
|
+
side = 'short' if isHistory else 'long'
|
6023
6049
|
elif side == 'Sell':
|
6024
|
-
side = 'short'
|
6050
|
+
side = 'long' if isHistory else 'short'
|
6025
6051
|
else:
|
6026
6052
|
side = None
|
6027
|
-
notional = self.
|
6053
|
+
notional = self.safe_string_2(position, 'positionValue', 'cumExitValue')
|
6028
6054
|
unrealisedPnl = self.omit_zero(self.safe_string(position, 'unrealisedPnl'))
|
6029
|
-
initialMarginString = self.
|
6055
|
+
initialMarginString = self.safe_string_n(position, ['positionIM', 'cumEntryValue'])
|
6030
6056
|
maintenanceMarginString = self.safe_string(position, 'positionMM')
|
6031
|
-
timestamp = self.
|
6032
|
-
|
6033
|
-
|
6057
|
+
timestamp = self.safe_integer_n(position, ['createdTime', 'createdAt'])
|
6058
|
+
lastUpdateTimestamp = self.parse8601(self.safe_string(position, 'updated_at'))
|
6059
|
+
if lastUpdateTimestamp is None:
|
6060
|
+
lastUpdateTimestamp = self.safe_integer_n(position, ['updatedTime', 'updatedAt', 'updatedTime'])
|
6034
6061
|
tradeMode = self.safe_integer(position, 'tradeMode', 0)
|
6035
6062
|
marginMode = None
|
6036
6063
|
if (not self.options['enableUnifiedAccount']) or (self.options['enableUnifiedAccount'] and market['inverse']):
|
6037
6064
|
# tradeMode would work for classic and UTA(inverse)
|
6038
|
-
marginMode
|
6065
|
+
if not isHistory: # cannot tell marginMode for fetchPositionsHistory, and closedSize will only be defined for fetchPositionsHistory response
|
6066
|
+
marginMode = 'isolated' if (tradeMode == 1) else 'cross'
|
6039
6067
|
collateralString = self.safe_string(position, 'positionBalance')
|
6040
|
-
entryPrice = self.omit_zero(self.
|
6068
|
+
entryPrice = self.omit_zero(self.safe_string_n(position, ['entryPrice', 'avgPrice', 'avgEntryPrice']))
|
6041
6069
|
liquidationPrice = self.omit_zero(self.safe_string(position, 'liqPrice'))
|
6042
6070
|
leverage = self.safe_string(position, 'leverage')
|
6043
6071
|
if liquidationPrice is not None:
|
@@ -6076,7 +6104,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6076
6104
|
'symbol': market['symbol'],
|
6077
6105
|
'timestamp': timestamp,
|
6078
6106
|
'datetime': self.iso8601(timestamp),
|
6079
|
-
'lastUpdateTimestamp':
|
6107
|
+
'lastUpdateTimestamp': lastUpdateTimestamp,
|
6080
6108
|
'initialMargin': self.parse_number(initialMarginString),
|
6081
6109
|
'initialMarginPercentage': self.parse_number(Precise.string_div(initialMarginString, notional)),
|
6082
6110
|
'maintenanceMargin': self.parse_number(maintenanceMarginString),
|
@@ -6085,12 +6113,13 @@ class bybit(Exchange, ImplicitAPI):
|
|
6085
6113
|
'notional': self.parse_number(notional),
|
6086
6114
|
'leverage': self.parse_number(leverage),
|
6087
6115
|
'unrealizedPnl': self.parse_number(unrealisedPnl),
|
6116
|
+
'realizedPnl': self.safe_number(position, 'closedPnl'),
|
6088
6117
|
'contracts': self.parse_number(size), # in USD for inverse swaps
|
6089
6118
|
'contractSize': self.safe_number(market, 'contractSize'),
|
6090
6119
|
'marginRatio': self.parse_number(marginRatio),
|
6091
6120
|
'liquidationPrice': self.parse_number(liquidationPrice),
|
6092
6121
|
'markPrice': self.safe_number(position, 'markPrice'),
|
6093
|
-
'lastPrice':
|
6122
|
+
'lastPrice': self.safe_number(position, 'avgExitPrice'),
|
6094
6123
|
'collateral': self.parse_number(collateralString),
|
6095
6124
|
'marginMode': marginMode,
|
6096
6125
|
'side': side,
|
@@ -7884,6 +7913,79 @@ class bybit(Exchange, ImplicitAPI):
|
|
7884
7913
|
'quoteVolume': None,
|
7885
7914
|
}
|
7886
7915
|
|
7916
|
+
def fetch_positions_history(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}) -> List[Position]:
|
7917
|
+
"""
|
7918
|
+
fetches historical positions
|
7919
|
+
:see: https://bybit-exchange.github.io/docs/v5/position/close-pnl
|
7920
|
+
:param str [symbol]: unified market symbols, symbols must have the same subType(must all be linear or all be inverse)
|
7921
|
+
:param int [since]: timestamp in ms of the earliest position to fetch, params["until"] - since <= 7 days
|
7922
|
+
:param int [limit]: the maximum amount of records to fetch, default=50, max=100
|
7923
|
+
:param dict params: extra parameters specific to the exchange api endpoint
|
7924
|
+
:param int [params.until]: timestamp in ms of the latest position to fetch, params["until"] - since <= 7 days
|
7925
|
+
:param str [params.subType]: 'linear' or 'inverse'
|
7926
|
+
:returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
|
7927
|
+
"""
|
7928
|
+
self.load_markets()
|
7929
|
+
market = None
|
7930
|
+
subType = None
|
7931
|
+
symbolsLength = 0
|
7932
|
+
if symbols is not None:
|
7933
|
+
symbolsLength = len(symbols)
|
7934
|
+
if symbolsLength > 0:
|
7935
|
+
market = self.market(symbols[0])
|
7936
|
+
until = self.safe_integer(params, 'until')
|
7937
|
+
subType, params = self.handle_sub_type_and_params('fetchPositionsHistory', market, params, 'linear')
|
7938
|
+
params = self.omit(params, 'until')
|
7939
|
+
request = {
|
7940
|
+
'category': subType,
|
7941
|
+
}
|
7942
|
+
if (symbols is not None) and (symbolsLength == 1):
|
7943
|
+
request['symbol'] = market['id']
|
7944
|
+
if since is not None:
|
7945
|
+
request['startTime'] = since
|
7946
|
+
if limit is not None:
|
7947
|
+
request['limit'] = limit
|
7948
|
+
if until is not None:
|
7949
|
+
request['endTime'] = until
|
7950
|
+
response = self.privateGetV5PositionClosedPnl(self.extend(request, params))
|
7951
|
+
#
|
7952
|
+
# {
|
7953
|
+
# retCode: '0',
|
7954
|
+
# retMsg: 'OK',
|
7955
|
+
# result: {
|
7956
|
+
# nextPageCursor: '071749f3-a9fa-427b-b5ca-27b2f52b81de%3A1712717265566520788%2C071749f3-a9fa-427b-b5ca-27b2f52b81de%3A1712717265566520788',
|
7957
|
+
# category: 'linear',
|
7958
|
+
# list: [
|
7959
|
+
# {
|
7960
|
+
# symbol: 'XRPUSDT',
|
7961
|
+
# orderType: 'Market',
|
7962
|
+
# leverage: '10',
|
7963
|
+
# updatedTime: '1712717265572',
|
7964
|
+
# side: 'Sell',
|
7965
|
+
# orderId: '071749f3-a9fa-427b-b5ca-27b2f52b81de',
|
7966
|
+
# closedPnl: '-0.00049568',
|
7967
|
+
# avgEntryPrice: '0.6045',
|
7968
|
+
# qty: '3',
|
7969
|
+
# cumEntryValue: '1.8135',
|
7970
|
+
# createdTime: '1712717265566',
|
7971
|
+
# orderPrice: '0.5744',
|
7972
|
+
# closedSize: '3',
|
7973
|
+
# avgExitPrice: '0.605',
|
7974
|
+
# execType: 'Trade',
|
7975
|
+
# fillCount: '1',
|
7976
|
+
# cumExitValue: '1.815'
|
7977
|
+
# }
|
7978
|
+
# ]
|
7979
|
+
# },
|
7980
|
+
# retExtInfo: {},
|
7981
|
+
# time: '1712717286073'
|
7982
|
+
# }
|
7983
|
+
#
|
7984
|
+
result = self.safe_dict(response, 'result')
|
7985
|
+
rawPositions = self.safe_list(result, 'list')
|
7986
|
+
positions = self.parse_positions(rawPositions, symbols, params)
|
7987
|
+
return self.filter_by_since_limit(positions, since, limit)
|
7988
|
+
|
7887
7989
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
7888
7990
|
url = self.implode_hostname(self.urls['api'][api]) + '/' + path
|
7889
7991
|
if api == 'public':
|
ccxt/cex.py
CHANGED
@@ -75,7 +75,13 @@ class cex(Exchange, ImplicitAPI):
|
|
75
75
|
'fetchOrder': True,
|
76
76
|
'fetchOrderBook': True,
|
77
77
|
'fetchOrders': True,
|
78
|
+
'fetchPosition': False,
|
79
|
+
'fetchPositionHistory': False,
|
78
80
|
'fetchPositionMode': False,
|
81
|
+
'fetchPositions': False,
|
82
|
+
'fetchPositionsForSymbol': False,
|
83
|
+
'fetchPositionsHistory': False,
|
84
|
+
'fetchPositionsRisk': False,
|
79
85
|
'fetchPremiumIndexOHLCV': False,
|
80
86
|
'fetchTicker': True,
|
81
87
|
'fetchTickers': True,
|
ccxt/coinbase.py
CHANGED
@@ -212,6 +212,11 @@ class coinbase(Exchange, ImplicitAPI):
|
|
212
212
|
'public': {
|
213
213
|
'get': {
|
214
214
|
'brokerage/time': 3,
|
215
|
+
'brokerage/market/product_book': 3,
|
216
|
+
'brokerage/market/products': 3,
|
217
|
+
'brokerage/market/products/{product_id}': 3,
|
218
|
+
'brokerage/market/products/{product_id}/candles': 3,
|
219
|
+
'brokerage/market/products/{product_id}/ticker': 3,
|
215
220
|
},
|
216
221
|
},
|
217
222
|
'private': {
|
@@ -1059,7 +1064,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
1059
1064
|
|
1060
1065
|
def fetch_markets(self, params={}) -> List[Market]:
|
1061
1066
|
"""
|
1062
|
-
:see: https://docs.cloud.coinbase.com/advanced-trade-api/reference/
|
1067
|
+
:see: https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicproducts
|
1063
1068
|
:see: https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-currencies#get-fiat-currencies
|
1064
1069
|
:see: https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates#get-exchange-rates
|
1065
1070
|
retrieves data on all markets for coinbase
|
@@ -1142,19 +1147,89 @@ class coinbase(Exchange, ImplicitAPI):
|
|
1142
1147
|
|
1143
1148
|
def fetch_markets_v3(self, params={}):
|
1144
1149
|
spotUnresolvedPromises = [
|
1145
|
-
self.
|
1146
|
-
|
1150
|
+
self.v3PublicGetBrokerageMarketProducts(params),
|
1151
|
+
#
|
1152
|
+
# {
|
1153
|
+
# products: [
|
1154
|
+
# {
|
1155
|
+
# product_id: 'BTC-USD',
|
1156
|
+
# price: '67060',
|
1157
|
+
# price_percentage_change_24h: '3.30054960636883',
|
1158
|
+
# volume_24h: '10967.87426597',
|
1159
|
+
# volume_percentage_change_24h: '141.73048325503036',
|
1160
|
+
# base_increment: '0.00000001',
|
1161
|
+
# quote_increment: '0.01',
|
1162
|
+
# quote_min_size: '1',
|
1163
|
+
# quote_max_size: '150000000',
|
1164
|
+
# base_min_size: '0.00000001',
|
1165
|
+
# base_max_size: '3400',
|
1166
|
+
# base_name: 'Bitcoin',
|
1167
|
+
# quote_name: 'US Dollar',
|
1168
|
+
# watched: False,
|
1169
|
+
# is_disabled: False,
|
1170
|
+
# new: False,
|
1171
|
+
# status: 'online',
|
1172
|
+
# cancel_only: False,
|
1173
|
+
# limit_only: False,
|
1174
|
+
# post_only: False,
|
1175
|
+
# trading_disabled: False,
|
1176
|
+
# auction_mode: False,
|
1177
|
+
# product_type: 'SPOT',
|
1178
|
+
# quote_currency_id: 'USD',
|
1179
|
+
# base_currency_id: 'BTC',
|
1180
|
+
# fcm_trading_session_details: null,
|
1181
|
+
# mid_market_price: '',
|
1182
|
+
# alias: '',
|
1183
|
+
# alias_to: ['BTC-USDC'],
|
1184
|
+
# base_display_symbol: 'BTC',
|
1185
|
+
# quote_display_symbol: 'USD',
|
1186
|
+
# view_only: False,
|
1187
|
+
# price_increment: '0.01',
|
1188
|
+
# display_name: 'BTC-USD',
|
1189
|
+
# product_venue: 'CBE'
|
1190
|
+
# },
|
1191
|
+
# ...
|
1192
|
+
# ],
|
1193
|
+
# num_products: '646'
|
1194
|
+
# }
|
1195
|
+
#
|
1147
1196
|
]
|
1197
|
+
if self.check_required_credentials(False):
|
1198
|
+
spotUnresolvedPromises.append(self.v3PrivateGetBrokerageTransactionSummary(params))
|
1199
|
+
#
|
1200
|
+
# {
|
1201
|
+
# total_volume: '9.995989116664404',
|
1202
|
+
# total_fees: '0.07996791093331522',
|
1203
|
+
# fee_tier: {
|
1204
|
+
# pricing_tier: 'Advanced 1',
|
1205
|
+
# usd_from: '0',
|
1206
|
+
# usd_to: '1000',
|
1207
|
+
# taker_fee_rate: '0.008',
|
1208
|
+
# maker_fee_rate: '0.006',
|
1209
|
+
# aop_from: '',
|
1210
|
+
# aop_to: ''
|
1211
|
+
# },
|
1212
|
+
# margin_rate: null,
|
1213
|
+
# goods_and_services_tax: null,
|
1214
|
+
# advanced_trade_only_volume: '9.995989116664404',
|
1215
|
+
# advanced_trade_only_fees: '0.07996791093331522',
|
1216
|
+
# coinbase_pro_volume: '0',
|
1217
|
+
# coinbase_pro_fees: '0',
|
1218
|
+
# total_balance: '',
|
1219
|
+
# has_promo_fee: False
|
1220
|
+
# }
|
1221
|
+
#
|
1148
1222
|
unresolvedContractPromises = []
|
1149
1223
|
try:
|
1150
1224
|
unresolvedContractPromises = [
|
1151
|
-
self.
|
1152
|
-
self.
|
1153
|
-
self.v3PrivateGetBrokerageTransactionSummary(self.extend(params, {'product_type': 'FUTURE'})),
|
1154
|
-
self.v3PrivateGetBrokerageTransactionSummary(self.extend(params, {'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL'})),
|
1225
|
+
self.v3PublicGetBrokerageMarketProducts(self.extend(params, {'product_type': 'FUTURE'})),
|
1226
|
+
self.v3PublicGetBrokerageMarketProducts(self.extend(params, {'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL'})),
|
1155
1227
|
]
|
1228
|
+
if self.check_required_credentials(False):
|
1229
|
+
unresolvedContractPromises.append(self.extend(params, {'product_type': 'FUTURE'}))
|
1230
|
+
unresolvedContractPromises.append(self.extend(params, {'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL'}))
|
1156
1231
|
except Exception as e:
|
1157
|
-
unresolvedContractPromises = [] # the sync version of ccxt won't have the promise.all line so the request is made here
|
1232
|
+
unresolvedContractPromises = [] # the sync version of ccxt won't have the promise.all line so the request is made here. Some users can't access perpetual products
|
1158
1233
|
promises = spotUnresolvedPromises
|
1159
1234
|
contractPromises = None
|
1160
1235
|
try:
|
@@ -1417,6 +1492,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
1417
1492
|
contractSize = self.safe_number(futureProductDetails, 'contract_size')
|
1418
1493
|
contractExpire = self.safe_string(futureProductDetails, 'contract_expiry')
|
1419
1494
|
expireTimestamp = self.parse8601(contractExpire)
|
1495
|
+
expireDateTime = self.iso8601(expireTimestamp)
|
1420
1496
|
isSwap = (contractExpiryType == 'PERPETUAL')
|
1421
1497
|
baseId = self.safe_string(futureProductDetails, 'contract_root_unit')
|
1422
1498
|
quoteId = self.safe_string(market, 'quote_currency_id')
|
@@ -1458,7 +1534,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
1458
1534
|
'maker': maker,
|
1459
1535
|
'contractSize': contractSize,
|
1460
1536
|
'expiry': expireTimestamp,
|
1461
|
-
'expiryDatetime':
|
1537
|
+
'expiryDatetime': expireDateTime,
|
1462
1538
|
'strike': None,
|
1463
1539
|
'optionType': None,
|
1464
1540
|
'precision': {
|
@@ -1673,7 +1749,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
1673
1749
|
request = {}
|
1674
1750
|
if symbols is not None:
|
1675
1751
|
request['product_ids'] = self.market_ids(symbols)
|
1676
|
-
response = self.
|
1752
|
+
response = self.v3PublicGetBrokerageMarketProducts(self.extend(request, params))
|
1677
1753
|
#
|
1678
1754
|
# {
|
1679
1755
|
# "products": [
|
@@ -1772,7 +1848,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
1772
1848
|
'product_id': market['id'],
|
1773
1849
|
'limit': 1,
|
1774
1850
|
}
|
1775
|
-
response = self.
|
1851
|
+
response = self.v3PublicGetBrokerageMarketProductsProductIdTicker(self.extend(request, params))
|
1776
1852
|
#
|
1777
1853
|
# {
|
1778
1854
|
# "trades": [
|
@@ -3211,7 +3287,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
3211
3287
|
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
3212
3288
|
"""
|
3213
3289
|
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
3214
|
-
:see: https://docs.cloud.coinbase.com/advanced-trade-api/reference/
|
3290
|
+
:see: https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpubliccandles
|
3215
3291
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
3216
3292
|
:param str timeframe: the length of time each candle represents
|
3217
3293
|
:param int [since]: timestamp in ms of the earliest candle to fetch
|
@@ -3249,7 +3325,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
3249
3325
|
else:
|
3250
3326
|
# 300 candles max
|
3251
3327
|
request['end'] = Precise.string_add(sinceString, str(requestedDuration))
|
3252
|
-
response = self.
|
3328
|
+
response = self.v3PublicGetBrokerageMarketProductsProductIdCandles(self.extend(request, params))
|
3253
3329
|
#
|
3254
3330
|
# {
|
3255
3331
|
# "candles": [
|
@@ -3292,7 +3368,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
3292
3368
|
def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
3293
3369
|
"""
|
3294
3370
|
get the list of most recent trades for a particular symbol
|
3295
|
-
:see: https://docs.cloud.coinbase.com/advanced-trade-api/reference/
|
3371
|
+
:see: https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicmarkettrades
|
3296
3372
|
:param str symbol: unified market symbol of the trades
|
3297
3373
|
:param int [since]: not used by coinbase fetchTrades
|
3298
3374
|
:param int [limit]: the maximum number of trade structures to fetch
|
@@ -3314,7 +3390,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
3314
3390
|
request['end'] = self.number_to_string(self.parse_to_int(until / 1000))
|
3315
3391
|
elif since is not None:
|
3316
3392
|
raise ArgumentsRequired(self.id + ' fetchTrades() requires a `until` parameter when you use `since` argument')
|
3317
|
-
response = self.
|
3393
|
+
response = self.v3PublicGetBrokerageMarketProductsProductIdTicker(self.extend(request, params))
|
3318
3394
|
#
|
3319
3395
|
# {
|
3320
3396
|
# "trades": [
|
@@ -3400,7 +3476,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
3400
3476
|
def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
3401
3477
|
"""
|
3402
3478
|
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
3403
|
-
:see: https://docs.cloud.coinbase.com/advanced-trade-api/reference/
|
3479
|
+
:see: https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicproductbook
|
3404
3480
|
:param str symbol: unified symbol of the market to fetch the order book for
|
3405
3481
|
:param int [limit]: the maximum amount of order book entries to return
|
3406
3482
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -3413,7 +3489,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
3413
3489
|
}
|
3414
3490
|
if limit is not None:
|
3415
3491
|
request['limit'] = limit
|
3416
|
-
response = self.
|
3492
|
+
response = self.v3PublicGetBrokerageMarketProductBook(self.extend(request, params))
|
3417
3493
|
#
|
3418
3494
|
# {
|
3419
3495
|
# "pricebook": {
|
@@ -3478,7 +3554,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
3478
3554
|
tickers = self.safe_list(response, 'pricebooks', [])
|
3479
3555
|
return self.parse_tickers(tickers, symbols)
|
3480
3556
|
|
3481
|
-
def withdraw(self, code: str, amount: float, address, tag=None, params={}):
|
3557
|
+
def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
|
3482
3558
|
"""
|
3483
3559
|
make a withdrawal
|
3484
3560
|
:see: https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-transactions#send-money
|
ccxt/coinbaseinternational.py
CHANGED
@@ -99,8 +99,10 @@ class coinbaseinternational(Exchange, ImplicitAPI):
|
|
99
99
|
'fetchOrderBook': False,
|
100
100
|
'fetchOrders': False,
|
101
101
|
'fetchPosition': True,
|
102
|
+
'fetchPositionHistory': False,
|
102
103
|
'fetchPositionMode': False,
|
103
104
|
'fetchPositions': True,
|
105
|
+
'fetchPositionsHistory': False,
|
104
106
|
'fetchPositionsRisk': False,
|
105
107
|
'fetchPremiumIndexOHLCV': False,
|
106
108
|
'fetchTicker': True,
|
@@ -1771,7 +1773,7 @@ class coinbaseinternational(Exchange, ImplicitAPI):
|
|
1771
1773
|
trades = self.safe_list(response, 'results', [])
|
1772
1774
|
return self.parse_trades(trades, market, since, limit)
|
1773
1775
|
|
1774
|
-
def withdraw(self, code: str, amount: float, address, tag=None, params={}):
|
1776
|
+
def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
|
1775
1777
|
"""
|
1776
1778
|
make a withdrawal
|
1777
1779
|
:see: https://docs.cloud.coinbase.com/intx/reference/withdraw
|
ccxt/coinbasepro.py
CHANGED
@@ -64,7 +64,13 @@ class coinbasepro(Exchange, ImplicitAPI):
|
|
64
64
|
'fetchOrderBook': True,
|
65
65
|
'fetchOrders': True,
|
66
66
|
'fetchOrderTrades': True,
|
67
|
+
'fetchPosition': False,
|
68
|
+
'fetchPositionHistory': False,
|
67
69
|
'fetchPositionMode': False,
|
70
|
+
'fetchPositions': False,
|
71
|
+
'fetchPositionsForSymbol': False,
|
72
|
+
'fetchPositionsHistory': False,
|
73
|
+
'fetchPositionsRisk': False,
|
68
74
|
'fetchTicker': True,
|
69
75
|
'fetchTickers': True,
|
70
76
|
'fetchTime': True,
|
@@ -1274,7 +1280,7 @@ class coinbasepro(Exchange, ImplicitAPI):
|
|
1274
1280
|
def fetch_payment_methods(self, params={}):
|
1275
1281
|
return self.privateGetPaymentMethods(params)
|
1276
1282
|
|
1277
|
-
def withdraw(self, code: str, amount: float, address, tag=None, params={}):
|
1283
|
+
def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
|
1278
1284
|
"""
|
1279
1285
|
make a withdrawal
|
1280
1286
|
:see: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawpaymentmethod
|
ccxt/coincheck.py
CHANGED
@@ -56,8 +56,11 @@ class coincheck(Exchange, ImplicitAPI):
|
|
56
56
|
'fetchOpenOrders': True,
|
57
57
|
'fetchOrderBook': True,
|
58
58
|
'fetchPosition': False,
|
59
|
+
'fetchPositionHistory': False,
|
59
60
|
'fetchPositionMode': False,
|
60
61
|
'fetchPositions': False,
|
62
|
+
'fetchPositionsForSymbol': False,
|
63
|
+
'fetchPositionsHistory': False,
|
61
64
|
'fetchPositionsRisk': False,
|
62
65
|
'fetchPremiumIndexOHLCV': False,
|
63
66
|
'fetchTicker': True,
|