ccxt 4.2.77__py2.py3-none-any.whl → 4.4.48__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.
- ccxt/__init__.py +36 -14
- ccxt/abstract/alpaca.py +4 -0
- ccxt/abstract/bigone.py +1 -1
- ccxt/abstract/binance.py +112 -48
- ccxt/abstract/binancecoinm.py +112 -48
- ccxt/abstract/binanceus.py +147 -83
- ccxt/abstract/binanceusdm.py +112 -48
- ccxt/abstract/bingx.py +133 -78
- ccxt/abstract/bitbank.py +5 -0
- ccxt/abstract/bitfinex.py +136 -65
- ccxt/abstract/bitfinex1.py +69 -0
- ccxt/abstract/bitflyer.py +1 -0
- ccxt/abstract/bitget.py +8 -1
- ccxt/abstract/bitmart.py +13 -1
- ccxt/abstract/bitopro.py +1 -0
- ccxt/abstract/bitpanda.py +0 -12
- ccxt/abstract/bitrue.py +3 -3
- ccxt/abstract/bitstamp.py +26 -3
- ccxt/abstract/blofin.py +24 -0
- ccxt/abstract/btcbox.py +1 -0
- ccxt/abstract/bybit.py +29 -14
- ccxt/abstract/cex.py +28 -29
- ccxt/abstract/coinbase.py +6 -0
- ccxt/abstract/coinbaseadvanced.py +94 -0
- ccxt/abstract/{coinbasepro.py → coinbaseexchange.py} +1 -0
- ccxt/abstract/coinbaseinternational.py +1 -1
- ccxt/abstract/coincatch.py +94 -0
- ccxt/abstract/coinex.py +233 -123
- ccxt/abstract/coinmetro.py +1 -0
- ccxt/abstract/cryptocom.py +14 -0
- ccxt/abstract/defx.py +69 -0
- ccxt/abstract/deribit.py +1 -0
- ccxt/abstract/digifinex.py +1 -0
- ccxt/abstract/ellipx.py +25 -0
- ccxt/abstract/gate.py +20 -0
- ccxt/abstract/gateio.py +20 -0
- ccxt/abstract/gemini.py +1 -0
- ccxt/abstract/hashkey.py +67 -0
- ccxt/abstract/hyperliquid.py +1 -1
- ccxt/abstract/independentreserve.py +6 -0
- ccxt/abstract/kraken.py +4 -3
- ccxt/abstract/krakenfutures.py +4 -0
- ccxt/abstract/kucoin.py +24 -0
- ccxt/abstract/kucoinfutures.py +34 -0
- ccxt/abstract/luno.py +2 -0
- ccxt/abstract/mexc.py +4 -0
- ccxt/abstract/myokx.py +340 -0
- ccxt/abstract/oceanex.py +5 -0
- ccxt/abstract/okx.py +30 -0
- ccxt/abstract/onetrading.py +0 -12
- ccxt/abstract/oxfun.py +34 -0
- ccxt/abstract/paradex.py +40 -0
- ccxt/abstract/phemex.py +1 -0
- ccxt/abstract/upbit.py +4 -0
- ccxt/abstract/vertex.py +19 -0
- ccxt/abstract/whitebit.py +31 -1
- ccxt/abstract/woo.py +6 -2
- ccxt/abstract/woofipro.py +119 -0
- ccxt/abstract/xt.py +153 -0
- ccxt/abstract/zonda.py +6 -0
- ccxt/ace.py +164 -60
- ccxt/alpaca.py +727 -63
- ccxt/ascendex.py +395 -249
- ccxt/async_support/__init__.py +36 -14
- ccxt/async_support/ace.py +164 -60
- ccxt/async_support/alpaca.py +727 -63
- ccxt/async_support/ascendex.py +396 -249
- ccxt/async_support/base/exchange.py +531 -155
- ccxt/async_support/base/ws/aiohttp_client.py +28 -5
- ccxt/async_support/base/ws/cache.py +3 -2
- ccxt/async_support/base/ws/client.py +26 -5
- ccxt/async_support/base/ws/fast_client.py +4 -3
- ccxt/async_support/base/ws/functions.py +1 -1
- ccxt/async_support/base/ws/future.py +40 -31
- ccxt/async_support/base/ws/order_book_side.py +3 -0
- ccxt/async_support/bequant.py +1 -1
- ccxt/async_support/bigone.py +329 -202
- ccxt/async_support/binance.py +3030 -1087
- ccxt/async_support/binancecoinm.py +2 -1
- ccxt/async_support/binanceus.py +12 -1
- ccxt/async_support/binanceusdm.py +3 -1
- ccxt/async_support/bingx.py +3104 -880
- ccxt/async_support/bit2c.py +119 -38
- ccxt/async_support/bitbank.py +215 -76
- ccxt/async_support/bitbns.py +124 -53
- ccxt/async_support/bitfinex.py +3236 -1078
- ccxt/async_support/bitfinex1.py +1711 -0
- ccxt/async_support/bitflyer.py +238 -49
- ccxt/async_support/bitget.py +1513 -563
- ccxt/async_support/bithumb.py +199 -65
- ccxt/async_support/bitmart.py +1320 -435
- ccxt/async_support/bitmex.py +308 -111
- ccxt/async_support/bitopro.py +256 -96
- ccxt/async_support/bitrue.py +365 -233
- ccxt/async_support/bitso.py +201 -89
- ccxt/async_support/bitstamp.py +438 -269
- ccxt/async_support/bitteam.py +179 -73
- ccxt/async_support/bitvavo.py +180 -70
- ccxt/async_support/bl3p.py +92 -25
- ccxt/async_support/blockchaincom.py +193 -79
- ccxt/async_support/blofin.py +392 -148
- ccxt/async_support/btcalpha.py +161 -55
- ccxt/async_support/btcbox.py +250 -34
- ccxt/async_support/btcmarkets.py +232 -85
- ccxt/async_support/btcturk.py +159 -60
- ccxt/async_support/bybit.py +2231 -1193
- ccxt/async_support/cex.py +1409 -1329
- ccxt/async_support/coinbase.py +1454 -287
- ccxt/async_support/coinbaseadvanced.py +17 -0
- ccxt/async_support/{coinbasepro.py → coinbaseexchange.py} +233 -99
- ccxt/async_support/coinbaseinternational.py +428 -88
- ccxt/async_support/coincatch.py +5152 -0
- ccxt/async_support/coincheck.py +121 -38
- ccxt/async_support/coinex.py +4020 -3339
- ccxt/async_support/coinlist.py +273 -116
- ccxt/async_support/coinmate.py +204 -97
- ccxt/async_support/coinmetro.py +203 -110
- ccxt/async_support/coinone.py +142 -68
- ccxt/async_support/coinsph.py +206 -89
- ccxt/async_support/coinspot.py +137 -62
- ccxt/async_support/cryptocom.py +515 -185
- ccxt/async_support/currencycom.py +203 -85
- ccxt/async_support/defx.py +2066 -0
- ccxt/async_support/delta.py +404 -109
- ccxt/async_support/deribit.py +557 -323
- ccxt/async_support/digifinex.py +340 -223
- ccxt/async_support/ellipx.py +1826 -0
- ccxt/async_support/exmo.py +259 -128
- ccxt/async_support/gate.py +1472 -463
- ccxt/async_support/gemini.py +206 -84
- ccxt/async_support/hashkey.py +4164 -0
- ccxt/async_support/hitbtc.py +334 -178
- ccxt/async_support/hollaex.py +134 -83
- ccxt/async_support/htx.py +1095 -563
- ccxt/async_support/huobijp.py +105 -56
- ccxt/async_support/hyperliquid.py +1633 -268
- ccxt/async_support/idex.py +148 -95
- ccxt/async_support/independentreserve.py +236 -31
- ccxt/async_support/indodax.py +165 -62
- ccxt/async_support/kraken.py +871 -354
- ccxt/async_support/krakenfutures.py +324 -100
- ccxt/async_support/kucoin.py +917 -357
- ccxt/async_support/kucoinfutures.py +1004 -149
- ccxt/async_support/kuna.py +138 -106
- ccxt/async_support/latoken.py +135 -79
- ccxt/async_support/lbank.py +290 -113
- ccxt/async_support/luno.py +112 -62
- ccxt/async_support/lykke.py +104 -55
- ccxt/async_support/mercado.py +36 -29
- ccxt/async_support/mexc.py +995 -429
- ccxt/async_support/myokx.py +43 -0
- ccxt/async_support/ndax.py +163 -82
- ccxt/async_support/novadax.py +121 -75
- ccxt/async_support/oceanex.py +175 -59
- ccxt/async_support/okcoin.py +222 -163
- ccxt/async_support/okx.py +1776 -454
- ccxt/async_support/onetrading.py +132 -414
- ccxt/async_support/oxfun.py +2832 -0
- ccxt/async_support/p2b.py +79 -51
- ccxt/async_support/paradex.py +2017 -0
- ccxt/async_support/paymium.py +56 -32
- ccxt/async_support/phemex.py +572 -196
- ccxt/async_support/poloniex.py +218 -95
- ccxt/async_support/poloniexfutures.py +260 -92
- ccxt/async_support/probit.py +143 -110
- ccxt/async_support/timex.py +123 -70
- ccxt/async_support/tokocrypto.py +129 -93
- ccxt/async_support/tradeogre.py +39 -25
- ccxt/async_support/upbit.py +322 -113
- ccxt/async_support/vertex.py +2983 -0
- ccxt/async_support/wavesexchange.py +227 -173
- ccxt/async_support/wazirx.py +145 -65
- ccxt/async_support/whitebit.py +533 -138
- ccxt/async_support/woo.py +1137 -296
- ccxt/async_support/woofipro.py +2716 -0
- ccxt/async_support/xt.py +4628 -0
- ccxt/async_support/yobit.py +160 -92
- ccxt/async_support/zaif.py +80 -33
- ccxt/async_support/zonda.py +140 -69
- ccxt/base/errors.py +51 -20
- ccxt/base/exchange.py +1722 -480
- ccxt/base/precise.py +10 -0
- ccxt/base/types.py +223 -4
- ccxt/bequant.py +1 -1
- ccxt/bigone.py +329 -202
- ccxt/binance.py +3030 -1087
- ccxt/binancecoinm.py +2 -1
- ccxt/binanceus.py +12 -1
- ccxt/binanceusdm.py +3 -1
- ccxt/bingx.py +3104 -880
- ccxt/bit2c.py +119 -38
- ccxt/bitbank.py +215 -76
- ccxt/bitbns.py +124 -53
- ccxt/bitfinex.py +3235 -1078
- ccxt/bitfinex1.py +1710 -0
- ccxt/bitflyer.py +238 -49
- ccxt/bitget.py +1513 -563
- ccxt/bithumb.py +198 -65
- ccxt/bitmart.py +1320 -435
- ccxt/bitmex.py +308 -111
- ccxt/bitopro.py +256 -96
- ccxt/bitrue.py +365 -233
- ccxt/bitso.py +201 -89
- ccxt/bitstamp.py +438 -269
- ccxt/bitteam.py +179 -73
- ccxt/bitvavo.py +180 -70
- ccxt/bl3p.py +92 -25
- ccxt/blockchaincom.py +193 -79
- ccxt/blofin.py +392 -148
- ccxt/btcalpha.py +161 -55
- ccxt/btcbox.py +250 -34
- ccxt/btcmarkets.py +232 -85
- ccxt/btcturk.py +159 -60
- ccxt/bybit.py +2231 -1193
- ccxt/cex.py +1408 -1329
- ccxt/coinbase.py +1454 -287
- ccxt/coinbaseadvanced.py +17 -0
- ccxt/{coinbasepro.py → coinbaseexchange.py} +233 -99
- ccxt/coinbaseinternational.py +428 -88
- ccxt/coincatch.py +5152 -0
- ccxt/coincheck.py +121 -38
- ccxt/coinex.py +4020 -3339
- ccxt/coinlist.py +273 -116
- ccxt/coinmate.py +204 -97
- ccxt/coinmetro.py +203 -110
- ccxt/coinone.py +142 -68
- ccxt/coinsph.py +206 -89
- ccxt/coinspot.py +137 -62
- ccxt/cryptocom.py +515 -185
- ccxt/currencycom.py +203 -85
- ccxt/defx.py +2065 -0
- ccxt/delta.py +404 -109
- ccxt/deribit.py +557 -323
- ccxt/digifinex.py +340 -223
- ccxt/ellipx.py +1826 -0
- ccxt/exmo.py +259 -128
- ccxt/gate.py +1472 -463
- ccxt/gemini.py +206 -84
- ccxt/hashkey.py +4164 -0
- ccxt/hitbtc.py +334 -178
- ccxt/hollaex.py +134 -83
- ccxt/htx.py +1095 -563
- ccxt/huobijp.py +105 -56
- ccxt/hyperliquid.py +1632 -268
- ccxt/idex.py +148 -95
- ccxt/independentreserve.py +235 -31
- ccxt/indodax.py +165 -62
- ccxt/kraken.py +871 -354
- ccxt/krakenfutures.py +324 -100
- ccxt/kucoin.py +917 -357
- ccxt/kucoinfutures.py +1004 -149
- ccxt/kuna.py +138 -106
- ccxt/latoken.py +135 -79
- ccxt/lbank.py +290 -113
- ccxt/luno.py +112 -62
- ccxt/lykke.py +104 -55
- ccxt/mercado.py +36 -29
- ccxt/mexc.py +994 -429
- ccxt/myokx.py +43 -0
- ccxt/ndax.py +163 -82
- ccxt/novadax.py +121 -75
- ccxt/oceanex.py +175 -59
- ccxt/okcoin.py +222 -163
- ccxt/okx.py +1776 -454
- ccxt/onetrading.py +132 -414
- ccxt/oxfun.py +2831 -0
- ccxt/p2b.py +79 -51
- ccxt/paradex.py +2017 -0
- ccxt/paymium.py +56 -32
- ccxt/phemex.py +572 -196
- ccxt/poloniex.py +218 -95
- ccxt/poloniexfutures.py +260 -92
- ccxt/pro/__init__.py +29 -5
- ccxt/pro/alpaca.py +32 -17
- ccxt/pro/ascendex.py +62 -14
- ccxt/pro/bequant.py +4 -0
- ccxt/pro/binance.py +1596 -329
- ccxt/pro/binancecoinm.py +1 -0
- ccxt/pro/binanceus.py +2 -9
- ccxt/pro/binanceusdm.py +2 -0
- ccxt/pro/bingx.py +527 -134
- ccxt/pro/bitcoincom.py +4 -1
- ccxt/pro/bitfinex.py +731 -266
- ccxt/pro/bitfinex1.py +635 -0
- ccxt/pro/bitget.py +726 -357
- ccxt/pro/bithumb.py +380 -0
- ccxt/pro/bitmart.py +138 -39
- ccxt/pro/bitmex.py +199 -40
- ccxt/pro/bitopro.py +25 -13
- ccxt/pro/bitrue.py +31 -32
- ccxt/pro/bitstamp.py +7 -6
- ccxt/pro/bitvavo.py +203 -81
- ccxt/pro/blockchaincom.py +30 -17
- ccxt/pro/blofin.py +692 -0
- ccxt/pro/bybit.py +791 -82
- ccxt/pro/cex.py +99 -51
- ccxt/pro/coinbase.py +220 -30
- ccxt/{async_support/hitbtc3.py → pro/coinbaseadvanced.py} +5 -5
- ccxt/pro/{coinbasepro.py → coinbaseexchange.py} +19 -19
- ccxt/pro/coinbaseinternational.py +193 -30
- ccxt/pro/coincatch.py +1464 -0
- ccxt/pro/coincheck.py +11 -6
- ccxt/pro/coinex.py +965 -665
- ccxt/pro/coinone.py +17 -10
- ccxt/pro/cryptocom.py +446 -66
- ccxt/pro/currencycom.py +11 -10
- ccxt/pro/defx.py +832 -0
- ccxt/pro/deribit.py +167 -31
- ccxt/pro/exmo.py +252 -20
- ccxt/pro/gate.py +729 -64
- ccxt/pro/gemini.py +44 -26
- ccxt/pro/hashkey.py +802 -0
- ccxt/pro/hitbtc.py +208 -103
- ccxt/pro/hollaex.py +25 -9
- ccxt/pro/htx.py +83 -39
- ccxt/pro/huobijp.py +17 -16
- ccxt/pro/hyperliquid.py +502 -31
- ccxt/pro/idex.py +28 -13
- ccxt/pro/independentreserve.py +21 -16
- ccxt/pro/kraken.py +298 -51
- ccxt/pro/krakenfutures.py +166 -75
- ccxt/pro/kucoin.py +395 -77
- ccxt/pro/kucoinfutures.py +400 -99
- ccxt/pro/lbank.py +52 -31
- ccxt/pro/luno.py +12 -10
- ccxt/pro/mexc.py +400 -50
- ccxt/pro/myokx.py +28 -0
- ccxt/pro/ndax.py +25 -12
- ccxt/pro/okcoin.py +28 -9
- ccxt/pro/okx.py +935 -124
- ccxt/pro/onetrading.py +41 -24
- ccxt/pro/oxfun.py +1054 -0
- ccxt/pro/p2b.py +100 -24
- ccxt/pro/paradex.py +352 -0
- ccxt/pro/phemex.py +92 -33
- ccxt/pro/poloniex.py +128 -49
- ccxt/pro/poloniexfutures.py +53 -32
- ccxt/pro/probit.py +92 -85
- ccxt/pro/upbit.py +401 -8
- ccxt/pro/vertex.py +943 -0
- ccxt/pro/wazirx.py +46 -28
- ccxt/pro/whitebit.py +65 -12
- ccxt/pro/woo.py +437 -65
- ccxt/pro/woofipro.py +1271 -0
- ccxt/pro/xt.py +1067 -0
- ccxt/probit.py +143 -110
- ccxt/static_dependencies/__init__.py +1 -1
- ccxt/static_dependencies/lark/__init__.py +38 -0
- ccxt/static_dependencies/lark/__pyinstaller/__init__.py +6 -0
- ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +14 -0
- ccxt/static_dependencies/lark/ast_utils.py +59 -0
- ccxt/static_dependencies/lark/common.py +86 -0
- ccxt/static_dependencies/lark/exceptions.py +292 -0
- ccxt/static_dependencies/lark/grammar.py +130 -0
- ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
- ccxt/static_dependencies/lark/indenter.py +143 -0
- ccxt/static_dependencies/lark/lark.py +658 -0
- ccxt/static_dependencies/lark/lexer.py +678 -0
- ccxt/static_dependencies/lark/load_grammar.py +1428 -0
- ccxt/static_dependencies/lark/parse_tree_builder.py +391 -0
- ccxt/static_dependencies/lark/parser_frontends.py +257 -0
- ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
- ccxt/static_dependencies/lark/parsers/cyk.py +340 -0
- ccxt/static_dependencies/lark/parsers/earley.py +314 -0
- ccxt/static_dependencies/lark/parsers/earley_common.py +42 -0
- ccxt/static_dependencies/lark/parsers/earley_forest.py +801 -0
- ccxt/static_dependencies/lark/parsers/grammar_analysis.py +203 -0
- ccxt/static_dependencies/lark/parsers/lalr_analysis.py +332 -0
- ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +158 -0
- ccxt/static_dependencies/lark/parsers/lalr_parser.py +122 -0
- ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +110 -0
- ccxt/static_dependencies/lark/parsers/xearley.py +165 -0
- ccxt/static_dependencies/lark/py.typed +0 -0
- ccxt/static_dependencies/lark/reconstruct.py +107 -0
- ccxt/static_dependencies/lark/tools/__init__.py +70 -0
- ccxt/static_dependencies/lark/tools/nearley.py +202 -0
- ccxt/static_dependencies/lark/tools/serialize.py +32 -0
- ccxt/static_dependencies/lark/tools/standalone.py +196 -0
- ccxt/static_dependencies/lark/tree.py +267 -0
- ccxt/static_dependencies/lark/tree_matcher.py +186 -0
- ccxt/static_dependencies/lark/tree_templates.py +180 -0
- ccxt/static_dependencies/lark/utils.py +343 -0
- ccxt/static_dependencies/lark/visitors.py +596 -0
- ccxt/static_dependencies/marshmallow/__init__.py +81 -0
- ccxt/static_dependencies/marshmallow/base.py +65 -0
- ccxt/static_dependencies/marshmallow/class_registry.py +94 -0
- ccxt/static_dependencies/marshmallow/decorators.py +231 -0
- ccxt/static_dependencies/marshmallow/error_store.py +60 -0
- ccxt/static_dependencies/marshmallow/exceptions.py +71 -0
- ccxt/static_dependencies/marshmallow/fields.py +2114 -0
- ccxt/static_dependencies/marshmallow/orderedset.py +89 -0
- ccxt/static_dependencies/marshmallow/py.typed +0 -0
- ccxt/static_dependencies/marshmallow/schema.py +1228 -0
- ccxt/static_dependencies/marshmallow/types.py +12 -0
- ccxt/static_dependencies/marshmallow/utils.py +378 -0
- ccxt/static_dependencies/marshmallow/validate.py +678 -0
- ccxt/static_dependencies/marshmallow/warnings.py +2 -0
- ccxt/static_dependencies/marshmallow_dataclass/__init__.py +1047 -0
- ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +51 -0
- ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +45 -0
- ccxt/static_dependencies/marshmallow_dataclass/mypy.py +71 -0
- ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
- ccxt/static_dependencies/marshmallow_dataclass/typing.py +14 -0
- ccxt/static_dependencies/marshmallow_dataclass/union_field.py +82 -0
- ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +1 -0
- ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +193 -0
- ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
- ccxt/static_dependencies/starknet/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/data_types.py +123 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +77 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +46 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +138 -0
- ccxt/static_dependencies/starknet/cairo/felt.py +64 -0
- ccxt/static_dependencies/starknet/cairo/type_parser.py +121 -0
- ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +59 -0
- ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +77 -0
- ccxt/static_dependencies/starknet/ccxt_utils.py +7 -0
- ccxt/static_dependencies/starknet/common.py +15 -0
- ccxt/static_dependencies/starknet/constants.py +39 -0
- ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
- ccxt/static_dependencies/starknet/hash/address.py +79 -0
- ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +111 -0
- ccxt/static_dependencies/starknet/hash/selector.py +16 -0
- ccxt/static_dependencies/starknet/hash/storage.py +12 -0
- ccxt/static_dependencies/starknet/hash/utils.py +78 -0
- ccxt/static_dependencies/starknet/models/__init__.py +0 -0
- ccxt/static_dependencies/starknet/models/typed_data.py +45 -0
- ccxt/static_dependencies/starknet/serialization/__init__.py +24 -0
- ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +40 -0
- ccxt/static_dependencies/starknet/serialization/_context.py +142 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +10 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +82 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +43 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +37 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +66 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +71 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +71 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +50 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +58 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +43 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +40 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +72 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +36 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +36 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +76 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +100 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +32 -0
- ccxt/static_dependencies/starknet/serialization/errors.py +10 -0
- ccxt/static_dependencies/starknet/serialization/factory.py +229 -0
- ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +110 -0
- ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +59 -0
- ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
- ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +86 -0
- ccxt/static_dependencies/starknet/utils/iterable.py +13 -0
- ccxt/static_dependencies/starknet/utils/schema.py +13 -0
- ccxt/static_dependencies/starknet/utils/typed_data.py +182 -0
- ccxt/static_dependencies/starkware/__init__.py +0 -0
- ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
- ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +50 -0
- ccxt/static_dependencies/starkware/crypto/math_utils.py +78 -0
- ccxt/static_dependencies/starkware/crypto/signature.py +2344 -0
- ccxt/static_dependencies/starkware/crypto/utils.py +63 -0
- ccxt/static_dependencies/sympy/__init__.py +0 -0
- ccxt/static_dependencies/sympy/core/__init__.py +0 -0
- ccxt/static_dependencies/sympy/core/intfunc.py +35 -0
- ccxt/static_dependencies/sympy/external/__init__.py +0 -0
- ccxt/static_dependencies/sympy/external/gmpy.py +345 -0
- ccxt/static_dependencies/sympy/external/importtools.py +187 -0
- ccxt/static_dependencies/sympy/external/ntheory.py +637 -0
- ccxt/static_dependencies/sympy/external/pythonmpq.py +341 -0
- ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
- ccxt/static_dependencies/typing_inspect/typing_inspect.py +851 -0
- ccxt/test/{test_async.py → tests_async.py} +456 -391
- ccxt/test/tests_helpers.py +285 -0
- ccxt/test/tests_init.py +39 -0
- ccxt/test/{test_sync.py → tests_sync.py} +456 -393
- ccxt/timex.py +123 -70
- ccxt/tokocrypto.py +129 -93
- ccxt/tradeogre.py +39 -25
- ccxt/upbit.py +322 -113
- ccxt/vertex.py +2983 -0
- ccxt/wavesexchange.py +227 -173
- ccxt/wazirx.py +145 -65
- ccxt/whitebit.py +533 -138
- ccxt/woo.py +1137 -296
- ccxt/woofipro.py +2716 -0
- ccxt/xt.py +4627 -0
- ccxt/yobit.py +159 -92
- ccxt/zaif.py +80 -33
- ccxt/zonda.py +140 -69
- ccxt-4.4.48.dist-info/LICENSE.txt +21 -0
- ccxt-4.4.48.dist-info/METADATA +646 -0
- ccxt-4.4.48.dist-info/RECORD +669 -0
- {ccxt-4.2.77.dist-info → ccxt-4.4.48.dist-info}/WHEEL +1 -1
- ccxt/abstract/bitbay.py +0 -47
- ccxt/abstract/bitfinex2.py +0 -139
- ccxt/abstract/hitbtc3.py +0 -115
- ccxt/async_support/bitbay.py +0 -17
- ccxt/async_support/bitfinex2.py +0 -3496
- ccxt/async_support/flowbtc.py +0 -34
- ccxt/bitbay.py +0 -17
- ccxt/bitfinex2.py +0 -3496
- ccxt/flowbtc.py +0 -34
- ccxt/hitbtc3.py +0 -16
- ccxt/pro/bitfinex2.py +0 -1081
- ccxt/test/base/__init__.py +0 -28
- ccxt/test/base/test_account.py +0 -26
- ccxt/test/base/test_balance.py +0 -56
- ccxt/test/base/test_borrow_interest.py +0 -35
- ccxt/test/base/test_borrow_rate.py +0 -32
- ccxt/test/base/test_calculate_fee.py +0 -51
- ccxt/test/base/test_crypto.py +0 -127
- ccxt/test/base/test_currency.py +0 -76
- ccxt/test/base/test_datetime.py +0 -103
- ccxt/test/base/test_decimal_to_precision.py +0 -392
- ccxt/test/base/test_deep_extend.py +0 -68
- ccxt/test/base/test_deposit_withdrawal.py +0 -50
- ccxt/test/base/test_exchange_datetime_functions.py +0 -76
- ccxt/test/base/test_funding_rate_history.py +0 -29
- ccxt/test/base/test_last_price.py +0 -32
- ccxt/test/base/test_ledger_entry.py +0 -45
- ccxt/test/base/test_ledger_item.py +0 -48
- ccxt/test/base/test_leverage_tier.py +0 -33
- ccxt/test/base/test_margin_mode.py +0 -24
- ccxt/test/base/test_margin_modification.py +0 -35
- ccxt/test/base/test_market.py +0 -190
- ccxt/test/base/test_number.py +0 -411
- ccxt/test/base/test_ohlcv.py +0 -32
- ccxt/test/base/test_open_interest.py +0 -32
- ccxt/test/base/test_order.py +0 -64
- ccxt/test/base/test_order_book.py +0 -63
- ccxt/test/base/test_position.py +0 -60
- ccxt/test/base/test_shared_methods.py +0 -345
- ccxt/test/base/test_status.py +0 -24
- ccxt/test/base/test_throttle.py +0 -126
- ccxt/test/base/test_ticker.py +0 -86
- ccxt/test/base/test_trade.py +0 -47
- ccxt/test/base/test_trading_fee.py +0 -26
- ccxt/test/base/test_transaction.py +0 -39
- ccxt-4.2.77.dist-info/METADATA +0 -626
- ccxt-4.2.77.dist-info/RECORD +0 -534
- {ccxt-4.2.77.dist-info → ccxt-4.4.48.dist-info}/top_level.txt +0 -0
ccxt/async_support/deribit.py
CHANGED
@@ -6,9 +6,10 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.deribit import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Account, Balances, Currency, Greeks, Int, Market, MarketInterface, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Account, Balances, Currencies, Currency, DepositAddress, Greeks, Int, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFees, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
|
+
from ccxt.base.errors import AuthenticationError
|
12
13
|
from ccxt.base.errors import PermissionDenied
|
13
14
|
from ccxt.base.errors import ArgumentsRequired
|
14
15
|
from ccxt.base.errors import BadRequest
|
@@ -20,7 +21,6 @@ from ccxt.base.errors import NotSupported
|
|
20
21
|
from ccxt.base.errors import DDoSProtection
|
21
22
|
from ccxt.base.errors import ExchangeNotAvailable
|
22
23
|
from ccxt.base.errors import OnMaintenance
|
23
|
-
from ccxt.base.errors import AuthenticationError
|
24
24
|
from ccxt.base.decimal_to_precision import TICK_SIZE
|
25
25
|
from ccxt.base.precise import Precise
|
26
26
|
|
@@ -65,6 +65,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
65
65
|
'fetchCurrencies': True,
|
66
66
|
'fetchDeposit': False,
|
67
67
|
'fetchDepositAddress': True,
|
68
|
+
'fetchDepositAddresses': False,
|
69
|
+
'fetchDepositAddressesByNetwork': False,
|
68
70
|
'fetchDeposits': True,
|
69
71
|
'fetchDepositWithdrawFees': True,
|
70
72
|
'fetchFundingRate': True,
|
@@ -83,6 +85,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
83
85
|
'fetchMyTrades': True,
|
84
86
|
'fetchOHLCV': True,
|
85
87
|
'fetchOpenOrders': True,
|
88
|
+
'fetchOption': True,
|
89
|
+
'fetchOptionChain': True,
|
86
90
|
'fetchOrder': True,
|
87
91
|
'fetchOrderBook': True,
|
88
92
|
'fetchOrders': False,
|
@@ -105,6 +109,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
105
109
|
'fetchVolatilityHistory': True,
|
106
110
|
'fetchWithdrawal': False,
|
107
111
|
'fetchWithdrawals': True,
|
112
|
+
'sandbox': True,
|
108
113
|
'transfer': True,
|
109
114
|
'withdraw': True,
|
110
115
|
},
|
@@ -215,6 +220,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
215
220
|
'enable_api_key': 1,
|
216
221
|
'get_access_log': 1,
|
217
222
|
'get_account_summary': 1,
|
223
|
+
'get_account_summaries': 1,
|
218
224
|
'get_affiliate_program_info': 1,
|
219
225
|
'get_email_language': 1,
|
220
226
|
'get_new_announcements': 1,
|
@@ -415,70 +421,6 @@ class deribit(Exchange, ImplicitAPI):
|
|
415
421
|
},
|
416
422
|
})
|
417
423
|
|
418
|
-
def convert_expire_date(self, date):
|
419
|
-
# parse YYMMDD to timestamp
|
420
|
-
year = date[0:2]
|
421
|
-
month = date[2:4]
|
422
|
-
day = date[4:6]
|
423
|
-
reconstructedDate = '20' + year + '-' + month + '-' + day + 'T00:00:00Z'
|
424
|
-
return reconstructedDate
|
425
|
-
|
426
|
-
def convert_market_id_expire_date(self, date):
|
427
|
-
# parse 19JAN24 to 240119
|
428
|
-
monthMappping = {
|
429
|
-
'JAN': '01',
|
430
|
-
'FEB': '02',
|
431
|
-
'MAR': '03',
|
432
|
-
'APR': '04',
|
433
|
-
'MAY': '05',
|
434
|
-
'JUN': '06',
|
435
|
-
'JUL': '07',
|
436
|
-
'AUG': '08',
|
437
|
-
'SEP': '09',
|
438
|
-
'OCT': '10',
|
439
|
-
'NOV': '11',
|
440
|
-
'DEC': '12',
|
441
|
-
}
|
442
|
-
year = date[0:2]
|
443
|
-
monthName = date[2:5]
|
444
|
-
month = self.safe_string(monthMappping, monthName)
|
445
|
-
day = date[5:7]
|
446
|
-
reconstructedDate = day + month + year
|
447
|
-
return reconstructedDate
|
448
|
-
|
449
|
-
def convert_expire_date_to_market_id_date(self, date):
|
450
|
-
# parse 240119 to 19JAN24
|
451
|
-
year = date[0:2]
|
452
|
-
monthRaw = date[2:4]
|
453
|
-
month = None
|
454
|
-
day = date[4:6]
|
455
|
-
if monthRaw == '01':
|
456
|
-
month = 'JAN'
|
457
|
-
elif monthRaw == '02':
|
458
|
-
month = 'FEB'
|
459
|
-
elif monthRaw == '03':
|
460
|
-
month = 'MAR'
|
461
|
-
elif monthRaw == '04':
|
462
|
-
month = 'APR'
|
463
|
-
elif monthRaw == '05':
|
464
|
-
month = 'MAY'
|
465
|
-
elif monthRaw == '06':
|
466
|
-
month = 'JUN'
|
467
|
-
elif monthRaw == '07':
|
468
|
-
month = 'JUL'
|
469
|
-
elif monthRaw == '08':
|
470
|
-
month = 'AUG'
|
471
|
-
elif monthRaw == '09':
|
472
|
-
month = 'SEP'
|
473
|
-
elif monthRaw == '10':
|
474
|
-
month = 'OCT'
|
475
|
-
elif monthRaw == '11':
|
476
|
-
month = 'NOV'
|
477
|
-
elif monthRaw == '12':
|
478
|
-
month = 'DEC'
|
479
|
-
reconstructedDate = day + month + year
|
480
|
-
return reconstructedDate
|
481
|
-
|
482
424
|
def create_expired_option_market(self, symbol: str):
|
483
425
|
# support expired option contracts
|
484
426
|
quote = 'USD'
|
@@ -563,7 +505,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
563
505
|
async def fetch_time(self, params={}):
|
564
506
|
"""
|
565
507
|
fetches the current integer timestamp in milliseconds from the exchange server
|
566
|
-
|
508
|
+
|
509
|
+
https://docs.deribit.com/#public-get_time
|
510
|
+
|
567
511
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
568
512
|
:returns int: the current integer timestamp in milliseconds from the exchange server
|
569
513
|
"""
|
@@ -580,10 +524,12 @@ class deribit(Exchange, ImplicitAPI):
|
|
580
524
|
#
|
581
525
|
return self.safe_integer(response, 'result')
|
582
526
|
|
583
|
-
async def fetch_currencies(self, params={}):
|
527
|
+
async def fetch_currencies(self, params={}) -> Currencies:
|
584
528
|
"""
|
585
529
|
fetches all available currencies on an exchange
|
586
|
-
|
530
|
+
|
531
|
+
https://docs.deribit.com/#public-get_currencies
|
532
|
+
|
587
533
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
588
534
|
:returns dict: an associative dictionary of currencies
|
589
535
|
"""
|
@@ -611,7 +557,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
611
557
|
# }
|
612
558
|
#
|
613
559
|
data = self.safe_value(response, 'result', {})
|
614
|
-
result = {}
|
560
|
+
result: dict = {}
|
615
561
|
for i in range(0, len(data)):
|
616
562
|
currency = data[i]
|
617
563
|
currencyId = self.safe_string(currency, 'currency')
|
@@ -654,7 +600,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
654
600
|
async def fetch_status(self, params={}):
|
655
601
|
"""
|
656
602
|
the latest known information on the availability of the exchange API
|
657
|
-
|
603
|
+
|
604
|
+
https://docs.deribit.com/#public-status
|
605
|
+
|
658
606
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
659
607
|
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
|
660
608
|
"""
|
@@ -685,7 +633,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
685
633
|
async def fetch_accounts(self, params={}) -> List[Account]:
|
686
634
|
"""
|
687
635
|
fetch all the accounts associated with a profile
|
688
|
-
|
636
|
+
|
637
|
+
https://docs.deribit.com/#private-get_subaccounts
|
638
|
+
|
689
639
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
690
640
|
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
|
691
641
|
"""
|
@@ -750,121 +700,133 @@ class deribit(Exchange, ImplicitAPI):
|
|
750
700
|
'code': self.safe_currency_code(None, currency),
|
751
701
|
}
|
752
702
|
|
753
|
-
async def fetch_markets(self, params={}):
|
703
|
+
async def fetch_markets(self, params={}) -> List[Market]:
|
754
704
|
"""
|
755
705
|
retrieves data on all markets for deribit
|
756
|
-
|
706
|
+
|
707
|
+
https://docs.deribit.com/#public-get_currencies
|
708
|
+
https://docs.deribit.com/#public-get_instruments
|
709
|
+
|
757
710
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
758
711
|
:returns dict[]: an array of objects representing market data
|
759
712
|
"""
|
760
|
-
|
761
|
-
#
|
762
|
-
# {
|
763
|
-
# "jsonrpc": "2.0",
|
764
|
-
# "result": [
|
765
|
-
# {
|
766
|
-
# "withdrawal_priorities": [
|
767
|
-
# {value: 0.15, name: "very_low"},
|
768
|
-
# {value: 1.5, name: "very_high"},
|
769
|
-
# ],
|
770
|
-
# "withdrawal_fee": 0.0005,
|
771
|
-
# "min_withdrawal_fee": 0.0005,
|
772
|
-
# "min_confirmations": 1,
|
773
|
-
# "fee_precision": 4,
|
774
|
-
# "currency_long": "Bitcoin",
|
775
|
-
# "currency": "BTC",
|
776
|
-
# "coin_type": "BITCOIN"
|
777
|
-
# }
|
778
|
-
# ],
|
779
|
-
# "usIn": 1583761588590479,
|
780
|
-
# "usOut": 1583761588590544,
|
781
|
-
# "usDiff": 65,
|
782
|
-
# "testnet": False
|
783
|
-
# }
|
784
|
-
#
|
785
|
-
parsedMarkets = {}
|
786
|
-
currenciesResult = self.safe_value(currenciesResponse, 'result', [])
|
713
|
+
instrumentsResponses = []
|
787
714
|
result = []
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
715
|
+
parsedMarkets: dict = {}
|
716
|
+
fetchAllMarkets = None
|
717
|
+
fetchAllMarkets, params = self.handle_option_and_params(params, 'fetchMarkets', 'fetchAllMarkets', True)
|
718
|
+
if fetchAllMarkets:
|
719
|
+
instrumentsResponse = await self.publicGetGetInstruments(params)
|
720
|
+
instrumentsResponses.append(instrumentsResponse)
|
721
|
+
else:
|
722
|
+
currenciesResponse = await self.publicGetGetCurrencies(params)
|
794
723
|
#
|
795
724
|
# {
|
796
|
-
# "jsonrpc":"2.0",
|
797
|
-
# "result":[
|
798
|
-
# {
|
799
|
-
# "tick_size":0.0005,
|
800
|
-
# "taker_commission":0.0003,
|
801
|
-
# "strike":52000.0,
|
802
|
-
# "settlement_period":"month",
|
803
|
-
# "settlement_currency":"BTC",
|
804
|
-
# "quote_currency":"BTC",
|
805
|
-
# "option_type":"put", # put, call
|
806
|
-
# "min_trade_amount":0.1,
|
807
|
-
# "maker_commission":0.0003,
|
808
|
-
# "kind":"option",
|
809
|
-
# "is_active":true,
|
810
|
-
# "instrument_name":"BTC-24JUN22-52000-P",
|
811
|
-
# "expiration_timestamp":1656057600000,
|
812
|
-
# "creation_timestamp":1648199543000,
|
813
|
-
# "counter_currency":"USD",
|
814
|
-
# "contract_size":1.0,
|
815
|
-
# "block_trade_commission":0.0003,
|
816
|
-
# "base_currency":"BTC"
|
817
|
-
# },
|
725
|
+
# "jsonrpc": "2.0",
|
726
|
+
# "result": [
|
818
727
|
# {
|
819
|
-
# "
|
820
|
-
#
|
821
|
-
#
|
822
|
-
#
|
823
|
-
# "
|
824
|
-
# "
|
825
|
-
# "
|
826
|
-
# "
|
827
|
-
# "
|
828
|
-
# "
|
829
|
-
# "
|
830
|
-
#
|
831
|
-
# "future_type":"reversed",
|
832
|
-
# "expiration_timestamp":1653638400000,
|
833
|
-
# "creation_timestamp":1648195209000,
|
834
|
-
# "counter_currency":"USD",
|
835
|
-
# "contract_size":10.0,
|
836
|
-
# "block_trade_commission":0.0001,
|
837
|
-
# "base_currency":"BTC"
|
838
|
-
# },
|
839
|
-
# {
|
840
|
-
# "tick_size":0.5,
|
841
|
-
# "taker_commission":0.0005,
|
842
|
-
# "settlement_period":"perpetual",
|
843
|
-
# "settlement_currency":"BTC",
|
844
|
-
# "quote_currency":"USD",
|
845
|
-
# "min_trade_amount":10.0,
|
846
|
-
# "max_liquidation_commission":0.0075,
|
847
|
-
# "max_leverage":50,
|
848
|
-
# "maker_commission":0.0,
|
849
|
-
# "kind":"future",
|
850
|
-
# "is_active":true,
|
851
|
-
# "instrument_name":"BTC-PERPETUAL",
|
852
|
-
# "future_type":"reversed",
|
853
|
-
# "expiration_timestamp":32503708800000,
|
854
|
-
# "creation_timestamp":1534242287000,
|
855
|
-
# "counter_currency":"USD",
|
856
|
-
# "contract_size":10.0,
|
857
|
-
# "block_trade_commission":0.0001,
|
858
|
-
# "base_currency":"BTC"
|
859
|
-
# },
|
728
|
+
# "withdrawal_priorities": [
|
729
|
+
# {value: 0.15, name: "very_low"},
|
730
|
+
# {value: 1.5, name: "very_high"},
|
731
|
+
# ],
|
732
|
+
# "withdrawal_fee": 0.0005,
|
733
|
+
# "min_withdrawal_fee": 0.0005,
|
734
|
+
# "min_confirmations": 1,
|
735
|
+
# "fee_precision": 4,
|
736
|
+
# "currency_long": "Bitcoin",
|
737
|
+
# "currency": "BTC",
|
738
|
+
# "coin_type": "BITCOIN"
|
739
|
+
# }
|
860
740
|
# ],
|
861
|
-
# "usIn":
|
862
|
-
# "usOut":
|
863
|
-
# "usDiff":
|
864
|
-
# "testnet":
|
741
|
+
# "usIn": 1583761588590479,
|
742
|
+
# "usOut": 1583761588590544,
|
743
|
+
# "usDiff": 65,
|
744
|
+
# "testnet": False
|
865
745
|
# }
|
866
746
|
#
|
867
|
-
|
747
|
+
currenciesResult = self.safe_value(currenciesResponse, 'result', [])
|
748
|
+
for i in range(0, len(currenciesResult)):
|
749
|
+
currencyId = self.safe_string(currenciesResult[i], 'currency')
|
750
|
+
request: dict = {
|
751
|
+
'currency': currencyId,
|
752
|
+
}
|
753
|
+
instrumentsResponse = await self.publicGetGetInstruments(self.extend(request, params))
|
754
|
+
#
|
755
|
+
# {
|
756
|
+
# "jsonrpc":"2.0",
|
757
|
+
# "result":[
|
758
|
+
# {
|
759
|
+
# "tick_size":0.0005,
|
760
|
+
# "taker_commission":0.0003,
|
761
|
+
# "strike":52000.0,
|
762
|
+
# "settlement_period":"month",
|
763
|
+
# "settlement_currency":"BTC",
|
764
|
+
# "quote_currency":"BTC",
|
765
|
+
# "option_type":"put", # put, call
|
766
|
+
# "min_trade_amount":0.1,
|
767
|
+
# "maker_commission":0.0003,
|
768
|
+
# "kind":"option",
|
769
|
+
# "is_active":true,
|
770
|
+
# "instrument_name":"BTC-24JUN22-52000-P",
|
771
|
+
# "expiration_timestamp":1656057600000,
|
772
|
+
# "creation_timestamp":1648199543000,
|
773
|
+
# "counter_currency":"USD",
|
774
|
+
# "contract_size":1.0,
|
775
|
+
# "block_trade_commission":0.0003,
|
776
|
+
# "base_currency":"BTC"
|
777
|
+
# },
|
778
|
+
# {
|
779
|
+
# "tick_size":0.5,
|
780
|
+
# "taker_commission":0.0005,
|
781
|
+
# "settlement_period":"month", # month, week
|
782
|
+
# "settlement_currency":"BTC",
|
783
|
+
# "quote_currency":"USD",
|
784
|
+
# "min_trade_amount":10.0,
|
785
|
+
# "max_liquidation_commission":0.0075,
|
786
|
+
# "max_leverage":50,
|
787
|
+
# "maker_commission":0.0,
|
788
|
+
# "kind":"future",
|
789
|
+
# "is_active":true,
|
790
|
+
# "instrument_name":"BTC-27MAY22",
|
791
|
+
# "future_type":"reversed",
|
792
|
+
# "expiration_timestamp":1653638400000,
|
793
|
+
# "creation_timestamp":1648195209000,
|
794
|
+
# "counter_currency":"USD",
|
795
|
+
# "contract_size":10.0,
|
796
|
+
# "block_trade_commission":0.0001,
|
797
|
+
# "base_currency":"BTC"
|
798
|
+
# },
|
799
|
+
# {
|
800
|
+
# "tick_size":0.5,
|
801
|
+
# "taker_commission":0.0005,
|
802
|
+
# "settlement_period":"perpetual",
|
803
|
+
# "settlement_currency":"BTC",
|
804
|
+
# "quote_currency":"USD",
|
805
|
+
# "min_trade_amount":10.0,
|
806
|
+
# "max_liquidation_commission":0.0075,
|
807
|
+
# "max_leverage":50,
|
808
|
+
# "maker_commission":0.0,
|
809
|
+
# "kind":"future",
|
810
|
+
# "is_active":true,
|
811
|
+
# "instrument_name":"BTC-PERPETUAL",
|
812
|
+
# "future_type":"reversed",
|
813
|
+
# "expiration_timestamp":32503708800000,
|
814
|
+
# "creation_timestamp":1534242287000,
|
815
|
+
# "counter_currency":"USD",
|
816
|
+
# "contract_size":10.0,
|
817
|
+
# "block_trade_commission":0.0001,
|
818
|
+
# "base_currency":"BTC"
|
819
|
+
# },
|
820
|
+
# ],
|
821
|
+
# "usIn":1648691472831791,
|
822
|
+
# "usOut":1648691472831896,
|
823
|
+
# "usDiff":105,
|
824
|
+
# "testnet":false
|
825
|
+
# }
|
826
|
+
#
|
827
|
+
instrumentsResponses.append(instrumentsResponse)
|
828
|
+
for i in range(0, len(instrumentsResponses)):
|
829
|
+
instrumentsResult = self.safe_value(instrumentsResponses[i], 'result', [])
|
868
830
|
for k in range(0, len(instrumentsResult)):
|
869
831
|
market = instrumentsResult[k]
|
870
832
|
kind = self.safe_string(market, 'kind')
|
@@ -892,6 +854,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
892
854
|
type = 'option'
|
893
855
|
elif isSpot:
|
894
856
|
type = 'spot'
|
857
|
+
inverse = None
|
858
|
+
linear = None
|
895
859
|
if isSpot:
|
896
860
|
symbol = base + '/' + quote
|
897
861
|
elif not isComboMarket:
|
@@ -903,6 +867,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
903
867
|
optionType = self.safe_string(market, 'option_type')
|
904
868
|
letter = 'C' if (optionType == 'call') else 'P'
|
905
869
|
symbol = symbol + '-' + self.number_to_string(strike) + '-' + letter
|
870
|
+
inverse = (quote != settle)
|
871
|
+
linear = (settle == quote)
|
906
872
|
parsedMarketValue = self.safe_value(parsedMarkets, symbol)
|
907
873
|
if parsedMarketValue:
|
908
874
|
continue
|
@@ -926,8 +892,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
926
892
|
'option': option,
|
927
893
|
'active': self.safe_value(market, 'is_active'),
|
928
894
|
'contract': not isSpot,
|
929
|
-
'linear':
|
930
|
-
'inverse':
|
895
|
+
'linear': linear,
|
896
|
+
'inverse': inverse,
|
931
897
|
'taker': self.safe_number(market, 'taker_commission'),
|
932
898
|
'maker': self.safe_number(market, 'maker_commission'),
|
933
899
|
'contractSize': self.safe_number(market, 'contract_size'),
|
@@ -963,32 +929,48 @@ class deribit(Exchange, ImplicitAPI):
|
|
963
929
|
return result
|
964
930
|
|
965
931
|
def parse_balance(self, balance) -> Balances:
|
966
|
-
result = {
|
932
|
+
result: dict = {
|
967
933
|
'info': balance,
|
968
934
|
}
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
935
|
+
summaries = []
|
936
|
+
if 'summaries' in balance:
|
937
|
+
summaries = self.safe_list(balance, 'summaries')
|
938
|
+
else:
|
939
|
+
summaries = [balance]
|
940
|
+
for i in range(0, len(summaries)):
|
941
|
+
data = summaries[i]
|
942
|
+
currencyId = self.safe_string(data, 'currency')
|
943
|
+
currencyCode = self.safe_currency_code(currencyId)
|
944
|
+
account = self.account()
|
945
|
+
account['free'] = self.safe_string(data, 'available_funds')
|
946
|
+
account['used'] = self.safe_string(data, 'maintenance_margin')
|
947
|
+
account['total'] = self.safe_string(data, 'equity')
|
948
|
+
result[currencyCode] = account
|
976
949
|
return self.safe_balance(result)
|
977
950
|
|
978
951
|
async def fetch_balance(self, params={}) -> Balances:
|
979
952
|
"""
|
980
953
|
query for balance and get the amount of funds available for trading or funds locked in orders
|
981
|
-
|
954
|
+
|
955
|
+
https://docs.deribit.com/#private-get_account_summary
|
956
|
+
https://docs.deribit.com/#private-get_account_summaries
|
957
|
+
|
982
958
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
959
|
+
:param str [params.code]: unified currency code of the currency for the balance, if defined 'privateGetGetAccountSummary' will be used, otherwise 'privateGetGetAccountSummaries' will be used
|
983
960
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
984
961
|
"""
|
985
962
|
await self.load_markets()
|
986
|
-
code = self.
|
987
|
-
|
988
|
-
request = {
|
989
|
-
'currency': currency['id'],
|
963
|
+
code = self.safe_string(params, 'code')
|
964
|
+
params = self.omit(params, 'code')
|
965
|
+
request: dict = {
|
990
966
|
}
|
991
|
-
|
967
|
+
if code is not None:
|
968
|
+
request['currency'] = self.currency_id(code)
|
969
|
+
response = None
|
970
|
+
if code is None:
|
971
|
+
response = await self.privateGetGetAccountSummaries(params)
|
972
|
+
else:
|
973
|
+
response = await self.privateGetGetAccountSummary(self.extend(request, params))
|
992
974
|
#
|
993
975
|
# {
|
994
976
|
# "jsonrpc": "2.0",
|
@@ -1031,20 +1013,22 @@ class deribit(Exchange, ImplicitAPI):
|
|
1031
1013
|
# "testnet": False
|
1032
1014
|
# }
|
1033
1015
|
#
|
1034
|
-
result = self.
|
1016
|
+
result = self.safe_dict(response, 'result', {})
|
1035
1017
|
return self.parse_balance(result)
|
1036
1018
|
|
1037
1019
|
async def create_deposit_address(self, code: str, params={}):
|
1038
1020
|
"""
|
1039
1021
|
create a currency deposit address
|
1040
|
-
|
1022
|
+
|
1023
|
+
https://docs.deribit.com/#private-create_deposit_address
|
1024
|
+
|
1041
1025
|
:param str code: unified currency code of the currency for the deposit address
|
1042
1026
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1043
1027
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
1044
1028
|
"""
|
1045
1029
|
await self.load_markets()
|
1046
1030
|
currency = self.currency(code)
|
1047
|
-
request = {
|
1031
|
+
request: dict = {
|
1048
1032
|
'currency': currency['id'],
|
1049
1033
|
}
|
1050
1034
|
response = await self.privateGetCreateDepositAddress(self.extend(request, params))
|
@@ -1070,17 +1054,19 @@ class deribit(Exchange, ImplicitAPI):
|
|
1070
1054
|
'info': response,
|
1071
1055
|
}
|
1072
1056
|
|
1073
|
-
async def fetch_deposit_address(self, code: str, params={}):
|
1057
|
+
async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
|
1074
1058
|
"""
|
1075
1059
|
fetch the deposit address for a currency associated with self account
|
1076
|
-
|
1060
|
+
|
1061
|
+
https://docs.deribit.com/#private-get_current_deposit_address
|
1062
|
+
|
1077
1063
|
:param str code: unified currency code
|
1078
1064
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1079
1065
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
1080
1066
|
"""
|
1081
1067
|
await self.load_markets()
|
1082
1068
|
currency = self.currency(code)
|
1083
|
-
request = {
|
1069
|
+
request: dict = {
|
1084
1070
|
'currency': currency['id'],
|
1085
1071
|
}
|
1086
1072
|
response = await self.privateGetGetCurrentDepositAddress(self.extend(request, params))
|
@@ -1105,14 +1091,14 @@ class deribit(Exchange, ImplicitAPI):
|
|
1105
1091
|
address = self.safe_string(result, 'address')
|
1106
1092
|
self.check_address(address)
|
1107
1093
|
return {
|
1094
|
+
'info': response,
|
1108
1095
|
'currency': code,
|
1096
|
+
'network': None,
|
1109
1097
|
'address': address,
|
1110
1098
|
'tag': None,
|
1111
|
-
'network': None,
|
1112
|
-
'info': response,
|
1113
1099
|
}
|
1114
1100
|
|
1115
|
-
def parse_ticker(self, ticker, market: Market = None) -> Ticker:
|
1101
|
+
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
1116
1102
|
#
|
1117
1103
|
# fetchTicker /public/ticker
|
1118
1104
|
#
|
@@ -1184,20 +1170,24 @@ class deribit(Exchange, ImplicitAPI):
|
|
1184
1170
|
'average': None,
|
1185
1171
|
'baseVolume': None,
|
1186
1172
|
'quoteVolume': self.safe_string(stats, 'volume'),
|
1173
|
+
'markPrice': self.safe_string(ticker, 'mark_price'),
|
1174
|
+
'indexPrice': self.safe_string(ticker, 'index_price'),
|
1187
1175
|
'info': ticker,
|
1188
1176
|
}, market)
|
1189
1177
|
|
1190
1178
|
async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
1191
1179
|
"""
|
1192
1180
|
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
1193
|
-
|
1181
|
+
|
1182
|
+
https://docs.deribit.com/#public-ticker
|
1183
|
+
|
1194
1184
|
:param str symbol: unified symbol of the market to fetch the ticker for
|
1195
1185
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1196
1186
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1197
1187
|
"""
|
1198
1188
|
await self.load_markets()
|
1199
1189
|
market = self.market(symbol)
|
1200
|
-
request = {
|
1190
|
+
request: dict = {
|
1201
1191
|
'instrument_name': market['id'],
|
1202
1192
|
}
|
1203
1193
|
response = await self.publicGetTicker(self.extend(request, params))
|
@@ -1229,22 +1219,28 @@ class deribit(Exchange, ImplicitAPI):
|
|
1229
1219
|
# "testnet": False
|
1230
1220
|
# }
|
1231
1221
|
#
|
1232
|
-
result = self.
|
1222
|
+
result = self.safe_dict(response, 'result')
|
1233
1223
|
return self.parse_ticker(result, market)
|
1234
1224
|
|
1235
1225
|
async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
1236
1226
|
"""
|
1237
1227
|
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
1238
|
-
|
1239
|
-
|
1228
|
+
|
1229
|
+
https://docs.deribit.com/#public-get_book_summary_by_currency
|
1230
|
+
|
1231
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
1240
1232
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1233
|
+
:param str [params.code]: *required* the currency code to fetch the tickers for, eg. 'BTC', 'ETH'
|
1241
1234
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1242
1235
|
"""
|
1243
1236
|
await self.load_markets()
|
1244
1237
|
symbols = self.market_symbols(symbols)
|
1245
|
-
code = self.
|
1238
|
+
code = self.safe_string_2(params, 'code', 'currency')
|
1239
|
+
params = self.omit(params, ['code'])
|
1240
|
+
if code is None:
|
1241
|
+
raise ArgumentsRequired(self.id + ' fetchTickers requires a currency/code(eg: BTC/ETH/USDT) parameter to fetch tickers for')
|
1246
1242
|
currency = self.currency(code)
|
1247
|
-
request = {
|
1243
|
+
request: dict = {
|
1248
1244
|
'currency': currency['id'],
|
1249
1245
|
}
|
1250
1246
|
response = await self.publicGetGetBookSummaryByCurrency(self.extend(request, params))
|
@@ -1278,8 +1274,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
1278
1274
|
# "testnet": False
|
1279
1275
|
# }
|
1280
1276
|
#
|
1281
|
-
result = self.
|
1282
|
-
tickers = {}
|
1277
|
+
result = self.safe_list(response, 'result', [])
|
1278
|
+
tickers: dict = {}
|
1283
1279
|
for i in range(0, len(result)):
|
1284
1280
|
ticker = self.parse_ticker(result[i])
|
1285
1281
|
symbol = ticker['symbol']
|
@@ -1289,17 +1285,25 @@ class deribit(Exchange, ImplicitAPI):
|
|
1289
1285
|
async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
1290
1286
|
"""
|
1291
1287
|
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
1292
|
-
|
1288
|
+
|
1289
|
+
https://docs.deribit.com/#public-get_tradingview_chart_data
|
1290
|
+
|
1293
1291
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
1294
1292
|
:param str timeframe: the length of time each candle represents
|
1295
1293
|
:param int [since]: timestamp in ms of the earliest candle to fetch
|
1296
1294
|
:param int [limit]: the maximum amount of candles to fetch
|
1297
1295
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1296
|
+
:param boolean [params.paginate]: whether to paginate the results, set to False by default
|
1297
|
+
:param int [params.until]: the latest time in ms to fetch ohlcv for
|
1298
1298
|
:returns int[][]: A list of candles ordered, open, high, low, close, volume
|
1299
1299
|
"""
|
1300
1300
|
await self.load_markets()
|
1301
|
+
paginate = False
|
1302
|
+
paginate, params = self.handle_option_and_params(params, 'fetchOHLCV', 'paginate')
|
1303
|
+
if paginate:
|
1304
|
+
return await self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 5000)
|
1301
1305
|
market = self.market(symbol)
|
1302
|
-
request = {
|
1306
|
+
request: dict = {
|
1303
1307
|
'instrument_name': market['id'],
|
1304
1308
|
'resolution': self.safe_string(self.timeframes, timeframe, timeframe),
|
1305
1309
|
}
|
@@ -1317,6 +1321,10 @@ class deribit(Exchange, ImplicitAPI):
|
|
1317
1321
|
request['end_timestamp'] = now
|
1318
1322
|
else:
|
1319
1323
|
request['end_timestamp'] = self.sum(since, limit * duration * 1000)
|
1324
|
+
until = self.safe_integer(params, 'until')
|
1325
|
+
if until is not None:
|
1326
|
+
params = self.omit(params, 'until')
|
1327
|
+
request['end_timestamp'] = until
|
1320
1328
|
response = await self.publicGetGetTradingviewChartData(self.extend(request, params))
|
1321
1329
|
#
|
1322
1330
|
# {
|
@@ -1341,7 +1349,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1341
1349
|
ohlcvs = self.convert_trading_view_to_ohlcv(result, 'ticks', 'open', 'high', 'low', 'close', 'volume', True)
|
1342
1350
|
return self.parse_ohlcvs(ohlcvs, market, timeframe, since, limit)
|
1343
1351
|
|
1344
|
-
def parse_trade(self, trade, market: Market = None) -> Trade:
|
1352
|
+
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
1345
1353
|
#
|
1346
1354
|
# fetchTrades(public)
|
1347
1355
|
#
|
@@ -1429,18 +1437,21 @@ class deribit(Exchange, ImplicitAPI):
|
|
1429
1437
|
|
1430
1438
|
async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
1431
1439
|
"""
|
1432
|
-
|
1433
|
-
|
1440
|
+
|
1441
|
+
https://docs.deribit.com/#public-get_last_trades_by_instrument
|
1442
|
+
https://docs.deribit.com/#public-get_last_trades_by_instrument_and_time
|
1443
|
+
|
1434
1444
|
get the list of most recent trades for a particular symbol.
|
1435
1445
|
:param str symbol: unified symbol of the market to fetch trades for
|
1436
1446
|
:param int [since]: timestamp in ms of the earliest trade to fetch
|
1437
1447
|
:param int [limit]: the maximum amount of trades to fetch
|
1438
1448
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1449
|
+
:param int [params.until]: the latest time in ms to fetch trades for
|
1439
1450
|
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
|
1440
1451
|
"""
|
1441
1452
|
await self.load_markets()
|
1442
1453
|
market = self.market(symbol)
|
1443
|
-
request = {
|
1454
|
+
request: dict = {
|
1444
1455
|
'instrument_name': market['id'],
|
1445
1456
|
'include_old': True,
|
1446
1457
|
}
|
@@ -1448,8 +1459,12 @@ class deribit(Exchange, ImplicitAPI):
|
|
1448
1459
|
request['start_timestamp'] = since
|
1449
1460
|
if limit is not None:
|
1450
1461
|
request['count'] = min(limit, 1000) # default 10
|
1462
|
+
until = self.safe_integer_2(params, 'until', 'end_timestamp')
|
1463
|
+
if until is not None:
|
1464
|
+
params = self.omit(params, ['until'])
|
1465
|
+
request['end_timestamp'] = until
|
1451
1466
|
response = None
|
1452
|
-
if since is None:
|
1467
|
+
if (since is None) and not ('end_timestamp' in request):
|
1453
1468
|
response = await self.publicGetGetLastTradesByInstrument(self.extend(request, params))
|
1454
1469
|
else:
|
1455
1470
|
response = await self.publicGetGetLastTradesByInstrumentAndTime(self.extend(request, params))
|
@@ -1479,20 +1494,22 @@ class deribit(Exchange, ImplicitAPI):
|
|
1479
1494
|
# }
|
1480
1495
|
#
|
1481
1496
|
result = self.safe_value(response, 'result', {})
|
1482
|
-
trades = self.
|
1497
|
+
trades = self.safe_list(result, 'trades', [])
|
1483
1498
|
return self.parse_trades(trades, market, since, limit)
|
1484
1499
|
|
1485
|
-
async def fetch_trading_fees(self, params={}):
|
1500
|
+
async def fetch_trading_fees(self, params={}) -> TradingFees:
|
1486
1501
|
"""
|
1487
1502
|
fetch the trading fees for multiple markets
|
1488
|
-
|
1503
|
+
|
1504
|
+
https://docs.deribit.com/#private-get_account_summary
|
1505
|
+
|
1489
1506
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1490
1507
|
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
|
1491
1508
|
"""
|
1492
1509
|
await self.load_markets()
|
1493
1510
|
code = self.code_from_options('fetchTradingFees', params)
|
1494
1511
|
currency = self.currency(code)
|
1495
|
-
request = {
|
1512
|
+
request: dict = {
|
1496
1513
|
'currency': currency['id'],
|
1497
1514
|
'extended': True,
|
1498
1515
|
}
|
@@ -1548,9 +1565,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
1548
1565
|
#
|
1549
1566
|
result = self.safe_value(response, 'result', {})
|
1550
1567
|
fees = self.safe_value(result, 'fees', [])
|
1551
|
-
perpetualFee = {}
|
1552
|
-
futureFee = {}
|
1553
|
-
optionFee = {}
|
1568
|
+
perpetualFee: dict = {}
|
1569
|
+
futureFee: dict = {}
|
1570
|
+
optionFee: dict = {}
|
1554
1571
|
for i in range(0, len(fees)):
|
1555
1572
|
fee = fees[i]
|
1556
1573
|
instrumentType = self.safe_string(fee, 'instrument_type')
|
@@ -1572,11 +1589,11 @@ class deribit(Exchange, ImplicitAPI):
|
|
1572
1589
|
'maker': self.safe_number(fee, 'maker_fee'),
|
1573
1590
|
'taker': self.safe_number(fee, 'taker_fee'),
|
1574
1591
|
}
|
1575
|
-
parsedFees = {}
|
1592
|
+
parsedFees: dict = {}
|
1576
1593
|
for i in range(0, len(self.symbols)):
|
1577
1594
|
symbol = self.symbols[i]
|
1578
1595
|
market = self.market(symbol)
|
1579
|
-
fee = {
|
1596
|
+
fee: dict = {
|
1580
1597
|
'info': market,
|
1581
1598
|
'symbol': symbol,
|
1582
1599
|
'percentage': True,
|
@@ -1596,7 +1613,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
1596
1613
|
async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
1597
1614
|
"""
|
1598
1615
|
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
1599
|
-
|
1616
|
+
|
1617
|
+
https://docs.deribit.com/#public-get_order_book
|
1618
|
+
|
1600
1619
|
:param str symbol: unified symbol of the market to fetch the order book for
|
1601
1620
|
:param int [limit]: the maximum amount of order book entries to return
|
1602
1621
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -1604,7 +1623,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1604
1623
|
"""
|
1605
1624
|
await self.load_markets()
|
1606
1625
|
market = self.market(symbol)
|
1607
|
-
request = {
|
1626
|
+
request: dict = {
|
1608
1627
|
'instrument_name': market['id'],
|
1609
1628
|
}
|
1610
1629
|
if limit is not None:
|
@@ -1656,8 +1675,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
1656
1675
|
orderbook['nonce'] = nonce
|
1657
1676
|
return orderbook
|
1658
1677
|
|
1659
|
-
def parse_order_status(self, status):
|
1660
|
-
statuses = {
|
1678
|
+
def parse_order_status(self, status: Str):
|
1679
|
+
statuses: dict = {
|
1661
1680
|
'open': 'open',
|
1662
1681
|
'cancelled': 'canceled',
|
1663
1682
|
'filled': 'closed',
|
@@ -1666,8 +1685,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
1666
1685
|
}
|
1667
1686
|
return self.safe_string(statuses, status, status)
|
1668
1687
|
|
1669
|
-
def parse_time_in_force(self, timeInForce):
|
1670
|
-
timeInForces = {
|
1688
|
+
def parse_time_in_force(self, timeInForce: Str):
|
1689
|
+
timeInForces: dict = {
|
1671
1690
|
'good_til_cancelled': 'GTC',
|
1672
1691
|
'fill_or_kill': 'FOK',
|
1673
1692
|
'immediate_or_cancel': 'IOC',
|
@@ -1675,7 +1694,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1675
1694
|
return self.safe_string(timeInForces, timeInForce, timeInForce)
|
1676
1695
|
|
1677
1696
|
def parse_order_type(self, orderType):
|
1678
|
-
orderTypes = {
|
1697
|
+
orderTypes: dict = {
|
1679
1698
|
'stop_limit': 'limit',
|
1680
1699
|
'take_limit': 'limit',
|
1681
1700
|
'stop_market': 'market',
|
@@ -1683,7 +1702,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1683
1702
|
}
|
1684
1703
|
return self.safe_string(orderTypes, orderType, orderType)
|
1685
1704
|
|
1686
|
-
def parse_order(self, order, market: Market = None) -> Order:
|
1705
|
+
def parse_order(self, order: dict, market: Market = None) -> Order:
|
1687
1706
|
#
|
1688
1707
|
# createOrder
|
1689
1708
|
#
|
@@ -1725,7 +1744,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1725
1744
|
filledString = self.safe_string(order, 'filled_amount')
|
1726
1745
|
amount = self.safe_string(order, 'amount')
|
1727
1746
|
cost = Precise.string_mul(filledString, averageString)
|
1728
|
-
if market
|
1747
|
+
if self.safe_bool(market, 'inverse'):
|
1729
1748
|
if averageString != '0':
|
1730
1749
|
cost = Precise.string_div(amount, averageString)
|
1731
1750
|
lastTradeTimestamp = None
|
@@ -1748,7 +1767,6 @@ class deribit(Exchange, ImplicitAPI):
|
|
1748
1767
|
# injected in createOrder
|
1749
1768
|
trades = self.safe_value(order, 'trades')
|
1750
1769
|
timeInForce = self.parse_time_in_force(self.safe_string(order, 'time_in_force'))
|
1751
|
-
stopPrice = self.safe_value(order, 'stop_price')
|
1752
1770
|
postOnly = self.safe_value(order, 'post_only')
|
1753
1771
|
return self.safe_order({
|
1754
1772
|
'info': order,
|
@@ -1763,8 +1781,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1763
1781
|
'postOnly': postOnly,
|
1764
1782
|
'side': side,
|
1765
1783
|
'price': priceString,
|
1766
|
-
'
|
1767
|
-
'triggerPrice': stopPrice,
|
1784
|
+
'triggerPrice': self.safe_value(order, 'stop_price'),
|
1768
1785
|
'amount': amount,
|
1769
1786
|
'cost': cost,
|
1770
1787
|
'average': averageString,
|
@@ -1778,13 +1795,16 @@ class deribit(Exchange, ImplicitAPI):
|
|
1778
1795
|
async def fetch_order(self, id: str, symbol: Str = None, params={}):
|
1779
1796
|
"""
|
1780
1797
|
fetches information on an order made by the user
|
1781
|
-
|
1798
|
+
|
1799
|
+
https://docs.deribit.com/#private-get_order_state
|
1800
|
+
|
1801
|
+
:param str id: order id
|
1782
1802
|
:param str symbol: unified symbol of the market the order was made in
|
1783
1803
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1784
1804
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1785
1805
|
"""
|
1786
1806
|
await self.load_markets()
|
1787
|
-
request = {
|
1807
|
+
request: dict = {
|
1788
1808
|
'order_id': id,
|
1789
1809
|
}
|
1790
1810
|
market = None
|
@@ -1819,19 +1839,21 @@ class deribit(Exchange, ImplicitAPI):
|
|
1819
1839
|
# }
|
1820
1840
|
# }
|
1821
1841
|
#
|
1822
|
-
result = self.
|
1842
|
+
result = self.safe_dict(response, 'result')
|
1823
1843
|
return self.parse_order(result, market)
|
1824
1844
|
|
1825
1845
|
async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
1826
1846
|
"""
|
1827
1847
|
create a trade order
|
1828
|
-
|
1829
|
-
|
1848
|
+
|
1849
|
+
https://docs.deribit.com/#private-buy
|
1850
|
+
https://docs.deribit.com/#private-sell
|
1851
|
+
|
1830
1852
|
:param str symbol: unified symbol of the market to create an order in
|
1831
1853
|
:param str type: 'market' or 'limit'
|
1832
1854
|
:param str side: 'buy' or 'sell'
|
1833
|
-
:param float amount: how much you want to trade in units of the base currency. For
|
1834
|
-
:param float [price]: the price at which the order is to be
|
1855
|
+
:param float amount: how much you want to trade in units of the base currency. For perpetual and inverse futures the amount is in USD units. For options it is in the underlying assets base currency.
|
1856
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1835
1857
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1836
1858
|
:param str [params.trigger]: the trigger type 'index_price', 'mark_price', or 'last_price', default is 'last_price'
|
1837
1859
|
:param float [params.trailingAmount]: the quote amount to trail away from the current market price
|
@@ -1839,7 +1861,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1839
1861
|
"""
|
1840
1862
|
await self.load_markets()
|
1841
1863
|
market = self.market(symbol)
|
1842
|
-
request = {
|
1864
|
+
request: dict = {
|
1843
1865
|
'instrument_name': market['id'],
|
1844
1866
|
'amount': self.amount_to_precision(symbol, amount),
|
1845
1867
|
'type': type, # limit, stop_limit, market, stop_market, default is limit
|
@@ -1982,13 +2004,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
1982
2004
|
async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
|
1983
2005
|
"""
|
1984
2006
|
edit a trade order
|
1985
|
-
|
2007
|
+
|
2008
|
+
https://docs.deribit.com/#private-edit
|
2009
|
+
|
1986
2010
|
:param str id: edit order id
|
1987
2011
|
:param str [symbol]: unified symbol of the market to edit an order in
|
1988
2012
|
:param str [type]: 'market' or 'limit'
|
1989
2013
|
:param str [side]: 'buy' or 'sell'
|
1990
|
-
:param float amount: how much you want to trade in units of the base currency
|
1991
|
-
:param float [price]: the price at which the order is to be
|
2014
|
+
:param float amount: how much you want to trade in units of the base currency. For perpetual and inverse futures the amount is in USD units. For options it is in the underlying assets base currency.
|
2015
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1992
2016
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1993
2017
|
:param float [params.trailingAmount]: the quote amount to trail away from the current market price
|
1994
2018
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
@@ -1996,7 +2020,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1996
2020
|
if amount is None:
|
1997
2021
|
raise ArgumentsRequired(self.id + ' editOrder() requires an amount argument')
|
1998
2022
|
await self.load_markets()
|
1999
|
-
request = {
|
2023
|
+
request: dict = {
|
2000
2024
|
'order_id': id,
|
2001
2025
|
'amount': self.amount_to_precision(symbol, amount),
|
2002
2026
|
# 'post_only': False, # if the new price would cause the order to be filled immediately(as taker), the price will be changed to be just below the spread.
|
@@ -2022,31 +2046,35 @@ class deribit(Exchange, ImplicitAPI):
|
|
2022
2046
|
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
2023
2047
|
"""
|
2024
2048
|
cancels an open order
|
2025
|
-
|
2049
|
+
|
2050
|
+
https://docs.deribit.com/#private-cancel
|
2051
|
+
|
2026
2052
|
:param str id: order id
|
2027
2053
|
:param str symbol: not used by deribit cancelOrder()
|
2028
2054
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2029
2055
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2030
2056
|
"""
|
2031
2057
|
await self.load_markets()
|
2032
|
-
request = {
|
2058
|
+
request: dict = {
|
2033
2059
|
'order_id': id,
|
2034
2060
|
}
|
2035
2061
|
response = await self.privateGetCancel(self.extend(request, params))
|
2036
|
-
result = self.
|
2062
|
+
result = self.safe_dict(response, 'result', {})
|
2037
2063
|
return self.parse_order(result)
|
2038
2064
|
|
2039
2065
|
async def cancel_all_orders(self, symbol: Str = None, params={}):
|
2040
2066
|
"""
|
2041
2067
|
cancel all open orders
|
2042
|
-
|
2043
|
-
|
2068
|
+
|
2069
|
+
https://docs.deribit.com/#private-cancel_all
|
2070
|
+
https://docs.deribit.com/#private-cancel_all_by_instrument
|
2071
|
+
|
2044
2072
|
:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
|
2045
2073
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2046
2074
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2047
2075
|
"""
|
2048
2076
|
await self.load_markets()
|
2049
|
-
request = {}
|
2077
|
+
request: dict = {}
|
2050
2078
|
response = None
|
2051
2079
|
if symbol is None:
|
2052
2080
|
response = await self.privateGetCancelAll(self.extend(request, params))
|
@@ -2054,13 +2082,29 @@ class deribit(Exchange, ImplicitAPI):
|
|
2054
2082
|
market = self.market(symbol)
|
2055
2083
|
request['instrument_name'] = market['id']
|
2056
2084
|
response = await self.privateGetCancelAllByInstrument(self.extend(request, params))
|
2057
|
-
|
2085
|
+
#
|
2086
|
+
# {
|
2087
|
+
# jsonrpc: '2.0',
|
2088
|
+
# result: '1',
|
2089
|
+
# usIn: '1720508354127369',
|
2090
|
+
# usOut: '1720508354133603',
|
2091
|
+
# usDiff: '6234',
|
2092
|
+
# testnet: True
|
2093
|
+
# }
|
2094
|
+
#
|
2095
|
+
return [
|
2096
|
+
self.safe_order({
|
2097
|
+
'info': response,
|
2098
|
+
}),
|
2099
|
+
]
|
2058
2100
|
|
2059
2101
|
async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
2060
2102
|
"""
|
2061
2103
|
fetch all unfilled currently open orders
|
2062
|
-
|
2063
|
-
|
2104
|
+
|
2105
|
+
https://docs.deribit.com/#private-get_open_orders_by_currency
|
2106
|
+
https://docs.deribit.com/#private-get_open_orders_by_instrument
|
2107
|
+
|
2064
2108
|
:param str symbol: unified market symbol
|
2065
2109
|
:param int [since]: the earliest time in ms to fetch open orders for
|
2066
2110
|
:param int [limit]: the maximum number of open orders structures to retrieve
|
@@ -2068,7 +2112,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2068
2112
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2069
2113
|
"""
|
2070
2114
|
await self.load_markets()
|
2071
|
-
request = {}
|
2115
|
+
request: dict = {}
|
2072
2116
|
market = None
|
2073
2117
|
response = None
|
2074
2118
|
if symbol is None:
|
@@ -2080,14 +2124,16 @@ class deribit(Exchange, ImplicitAPI):
|
|
2080
2124
|
market = self.market(symbol)
|
2081
2125
|
request['instrument_name'] = market['id']
|
2082
2126
|
response = await self.privateGetGetOpenOrdersByInstrument(self.extend(request, params))
|
2083
|
-
result = self.
|
2127
|
+
result = self.safe_list(response, 'result', [])
|
2084
2128
|
return self.parse_orders(result, market, since, limit)
|
2085
2129
|
|
2086
2130
|
async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
2087
2131
|
"""
|
2088
2132
|
fetches information on multiple closed orders made by the user
|
2089
|
-
|
2090
|
-
|
2133
|
+
|
2134
|
+
https://docs.deribit.com/#private-get_order_history_by_currency
|
2135
|
+
https://docs.deribit.com/#private-get_order_history_by_instrument
|
2136
|
+
|
2091
2137
|
:param str symbol: unified market symbol of the market orders were made in
|
2092
2138
|
:param int [since]: the earliest time in ms to fetch orders for
|
2093
2139
|
:param int [limit]: the maximum number of order structures to retrieve
|
@@ -2095,7 +2141,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2095
2141
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2096
2142
|
"""
|
2097
2143
|
await self.load_markets()
|
2098
|
-
request = {}
|
2144
|
+
request: dict = {}
|
2099
2145
|
market = None
|
2100
2146
|
response = None
|
2101
2147
|
if symbol is None:
|
@@ -2107,13 +2153,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2107
2153
|
market = self.market(symbol)
|
2108
2154
|
request['instrument_name'] = market['id']
|
2109
2155
|
response = await self.privateGetGetOrderHistoryByInstrument(self.extend(request, params))
|
2110
|
-
result = self.
|
2156
|
+
result = self.safe_list(response, 'result', [])
|
2111
2157
|
return self.parse_orders(result, market, since, limit)
|
2112
2158
|
|
2113
2159
|
async def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2114
2160
|
"""
|
2115
2161
|
fetch all the trades made from a single order
|
2116
|
-
|
2162
|
+
|
2163
|
+
https://docs.deribit.com/#private-get_user_trades_by_order
|
2164
|
+
|
2117
2165
|
:param str id: order id
|
2118
2166
|
:param str symbol: unified market symbol
|
2119
2167
|
:param int [since]: the earliest time in ms to fetch trades for
|
@@ -2122,7 +2170,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2122
2170
|
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
2123
2171
|
"""
|
2124
2172
|
await self.load_markets()
|
2125
|
-
request = {
|
2173
|
+
request: dict = {
|
2126
2174
|
'order_id': id,
|
2127
2175
|
}
|
2128
2176
|
response = await self.privateGetGetUserTradesByOrder(self.extend(request, params))
|
@@ -2159,16 +2207,18 @@ class deribit(Exchange, ImplicitAPI):
|
|
2159
2207
|
# }
|
2160
2208
|
# }
|
2161
2209
|
#
|
2162
|
-
result = self.
|
2210
|
+
result = self.safe_list(response, 'result', [])
|
2163
2211
|
return self.parse_trades(result, None, since, limit)
|
2164
2212
|
|
2165
2213
|
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2166
2214
|
"""
|
2167
2215
|
fetch all trades made by the user
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2216
|
+
|
2217
|
+
https://docs.deribit.com/#private-get_user_trades_by_currency
|
2218
|
+
https://docs.deribit.com/#private-get_user_trades_by_currency_and_time
|
2219
|
+
https://docs.deribit.com/#private-get_user_trades_by_instrument
|
2220
|
+
https://docs.deribit.com/#private-get_user_trades_by_instrument_and_time
|
2221
|
+
|
2172
2222
|
:param str symbol: unified market symbol
|
2173
2223
|
:param int [since]: the earliest time in ms to fetch trades for
|
2174
2224
|
:param int [limit]: the maximum number of trades structures to retrieve
|
@@ -2176,7 +2226,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2176
2226
|
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
2177
2227
|
"""
|
2178
2228
|
await self.load_markets()
|
2179
|
-
request = {
|
2229
|
+
request: dict = {
|
2180
2230
|
'include_old': True,
|
2181
2231
|
}
|
2182
2232
|
market = None
|
@@ -2234,13 +2284,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2234
2284
|
# }
|
2235
2285
|
#
|
2236
2286
|
result = self.safe_value(response, 'result', {})
|
2237
|
-
trades = self.
|
2287
|
+
trades = self.safe_list(result, 'trades', [])
|
2238
2288
|
return self.parse_trades(trades, market, since, limit)
|
2239
2289
|
|
2240
2290
|
async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
2241
2291
|
"""
|
2242
2292
|
fetch all deposits made to an account
|
2243
|
-
|
2293
|
+
|
2294
|
+
https://docs.deribit.com/#private-get_deposits
|
2295
|
+
|
2244
2296
|
:param str code: unified currency code
|
2245
2297
|
:param int [since]: the earliest time in ms to fetch deposits for
|
2246
2298
|
:param int [limit]: the maximum number of deposits structures to retrieve
|
@@ -2251,7 +2303,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2251
2303
|
raise ArgumentsRequired(self.id + ' fetchDeposits() requires a currency code argument')
|
2252
2304
|
await self.load_markets()
|
2253
2305
|
currency = self.currency(code)
|
2254
|
-
request = {
|
2306
|
+
request: dict = {
|
2255
2307
|
'currency': currency['id'],
|
2256
2308
|
}
|
2257
2309
|
if limit is not None:
|
@@ -2278,13 +2330,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2278
2330
|
# }
|
2279
2331
|
#
|
2280
2332
|
result = self.safe_value(response, 'result', {})
|
2281
|
-
data = self.
|
2333
|
+
data = self.safe_list(result, 'data', [])
|
2282
2334
|
return self.parse_transactions(data, currency, since, limit, params)
|
2283
2335
|
|
2284
2336
|
async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
2285
2337
|
"""
|
2286
2338
|
fetch all withdrawals made from an account
|
2287
|
-
|
2339
|
+
|
2340
|
+
https://docs.deribit.com/#private-get_withdrawals
|
2341
|
+
|
2288
2342
|
:param str code: unified currency code
|
2289
2343
|
:param int [since]: the earliest time in ms to fetch withdrawals for
|
2290
2344
|
:param int [limit]: the maximum number of withdrawals structures to retrieve
|
@@ -2295,7 +2349,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2295
2349
|
raise ArgumentsRequired(self.id + ' fetchWithdrawals() requires a currency code argument')
|
2296
2350
|
await self.load_markets()
|
2297
2351
|
currency = self.currency(code)
|
2298
|
-
request = {
|
2352
|
+
request: dict = {
|
2299
2353
|
'currency': currency['id'],
|
2300
2354
|
}
|
2301
2355
|
if limit is not None:
|
@@ -2326,17 +2380,17 @@ class deribit(Exchange, ImplicitAPI):
|
|
2326
2380
|
# }
|
2327
2381
|
#
|
2328
2382
|
result = self.safe_value(response, 'result', {})
|
2329
|
-
data = self.
|
2383
|
+
data = self.safe_list(result, 'data', [])
|
2330
2384
|
return self.parse_transactions(data, currency, since, limit, params)
|
2331
2385
|
|
2332
|
-
def parse_transaction_status(self, status):
|
2333
|
-
statuses = {
|
2386
|
+
def parse_transaction_status(self, status: Str):
|
2387
|
+
statuses: dict = {
|
2334
2388
|
'completed': 'ok',
|
2335
2389
|
'unconfirmed': 'pending',
|
2336
2390
|
}
|
2337
2391
|
return self.safe_string(statuses, status, status)
|
2338
2392
|
|
2339
|
-
def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
|
2393
|
+
def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
|
2340
2394
|
#
|
2341
2395
|
# fetchWithdrawals
|
2342
2396
|
#
|
@@ -2404,7 +2458,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2404
2458
|
'fee': fee,
|
2405
2459
|
}
|
2406
2460
|
|
2407
|
-
def parse_position(self, position, market: Market = None):
|
2461
|
+
def parse_position(self, position: dict, market: Market = None):
|
2408
2462
|
#
|
2409
2463
|
# {
|
2410
2464
|
# "jsonrpc": "2.0",
|
@@ -2473,14 +2527,16 @@ class deribit(Exchange, ImplicitAPI):
|
|
2473
2527
|
async def fetch_position(self, symbol: str, params={}):
|
2474
2528
|
"""
|
2475
2529
|
fetch data on a single open contract trade position
|
2476
|
-
|
2530
|
+
|
2531
|
+
https://docs.deribit.com/#private-get_position
|
2532
|
+
|
2477
2533
|
:param str symbol: unified market symbol of the market the position is held in, default is None
|
2478
2534
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2479
2535
|
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
2480
2536
|
"""
|
2481
2537
|
await self.load_markets()
|
2482
2538
|
market = self.market(symbol)
|
2483
|
-
request = {
|
2539
|
+
request: dict = {
|
2484
2540
|
'instrument_name': market['id'],
|
2485
2541
|
}
|
2486
2542
|
response = await self.privateGetGetPosition(self.extend(request, params))
|
@@ -2510,13 +2566,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2510
2566
|
# }
|
2511
2567
|
# }
|
2512
2568
|
#
|
2513
|
-
result = self.
|
2569
|
+
result = self.safe_dict(response, 'result')
|
2514
2570
|
return self.parse_position(result)
|
2515
2571
|
|
2516
2572
|
async def fetch_positions(self, symbols: Strings = None, params={}):
|
2517
2573
|
"""
|
2518
2574
|
fetch all open positions
|
2519
|
-
|
2575
|
+
|
2576
|
+
https://docs.deribit.com/#private-get_positions
|
2577
|
+
|
2520
2578
|
:param str[]|None symbols: list of unified market symbols
|
2521
2579
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2522
2580
|
:param str [params.kind]: market type filter for positions 'future', 'option', 'spot', 'future_combo' or 'option_combo'
|
@@ -2540,7 +2598,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2540
2598
|
code = settle if (settle is not None) else market['base']
|
2541
2599
|
kind = market['info']['kind']
|
2542
2600
|
currency = self.currency(code)
|
2543
|
-
request = {
|
2601
|
+
request: dict = {
|
2544
2602
|
'currency': currency['id'],
|
2545
2603
|
}
|
2546
2604
|
if kind is not None:
|
@@ -2575,20 +2633,22 @@ class deribit(Exchange, ImplicitAPI):
|
|
2575
2633
|
# ]
|
2576
2634
|
# }
|
2577
2635
|
#
|
2578
|
-
result = self.
|
2636
|
+
result = self.safe_list(response, 'result')
|
2579
2637
|
return self.parse_positions(result, symbols)
|
2580
2638
|
|
2581
2639
|
async def fetch_volatility_history(self, code: str, params={}):
|
2582
2640
|
"""
|
2583
2641
|
fetch the historical volatility of an option market based on an underlying asset
|
2584
|
-
|
2642
|
+
|
2643
|
+
https://docs.deribit.com/#public-get_historical_volatility
|
2644
|
+
|
2585
2645
|
:param str code: unified currency code
|
2586
2646
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2587
2647
|
:returns dict[]: a list of `volatility history objects <https://docs.ccxt.com/#/?id=volatility-structure>`
|
2588
2648
|
"""
|
2589
2649
|
await self.load_markets()
|
2590
2650
|
currency = self.currency(code)
|
2591
|
-
request = {
|
2651
|
+
request: dict = {
|
2592
2652
|
'currency': currency['id'],
|
2593
2653
|
}
|
2594
2654
|
response = await self.publicGetGetHistoricalVolatility(self.extend(request, params))
|
@@ -2636,10 +2696,12 @@ class deribit(Exchange, ImplicitAPI):
|
|
2636
2696
|
})
|
2637
2697
|
return result
|
2638
2698
|
|
2639
|
-
async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
2699
|
+
async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
|
2640
2700
|
"""
|
2641
2701
|
fetch a history of internal transfers made on an account
|
2642
|
-
|
2702
|
+
|
2703
|
+
https://docs.deribit.com/#private-get_transfers
|
2704
|
+
|
2643
2705
|
:param str code: unified currency code of the currency transferred
|
2644
2706
|
:param int [since]: the earliest time in ms to fetch transfers for
|
2645
2707
|
:param int [limit]: the maximum number of transfers structures to retrieve
|
@@ -2650,7 +2712,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2650
2712
|
raise ArgumentsRequired(self.id + ' fetchTransfers() requires a currency code argument')
|
2651
2713
|
await self.load_markets()
|
2652
2714
|
currency = self.currency(code)
|
2653
|
-
request = {
|
2715
|
+
request: dict = {
|
2654
2716
|
'currency': currency['id'],
|
2655
2717
|
}
|
2656
2718
|
if limit is not None:
|
@@ -2690,14 +2752,16 @@ class deribit(Exchange, ImplicitAPI):
|
|
2690
2752
|
# }
|
2691
2753
|
#
|
2692
2754
|
result = self.safe_value(response, 'result', {})
|
2693
|
-
transfers = self.
|
2755
|
+
transfers = self.safe_list(result, 'data', [])
|
2694
2756
|
return self.parse_transfers(transfers, currency, since, limit, params)
|
2695
2757
|
|
2696
2758
|
async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
|
2697
2759
|
"""
|
2698
2760
|
transfer currency internally between wallets on the same account
|
2699
|
-
|
2700
|
-
|
2761
|
+
|
2762
|
+
https://docs.deribit.com/#private-submit_transfer_to_user
|
2763
|
+
https://docs.deribit.com/#private-submit_transfer_to_subaccount
|
2764
|
+
|
2701
2765
|
:param str code: unified currency code
|
2702
2766
|
:param float amount: amount to transfer
|
2703
2767
|
:param str fromAccount: account to transfer from
|
@@ -2707,7 +2771,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2707
2771
|
"""
|
2708
2772
|
await self.load_markets()
|
2709
2773
|
currency = self.currency(code)
|
2710
|
-
request = {
|
2774
|
+
request: dict = {
|
2711
2775
|
'amount': amount,
|
2712
2776
|
'currency': currency['id'],
|
2713
2777
|
'destination': toAccount,
|
@@ -2739,10 +2803,10 @@ class deribit(Exchange, ImplicitAPI):
|
|
2739
2803
|
# }
|
2740
2804
|
# }
|
2741
2805
|
#
|
2742
|
-
result = self.
|
2806
|
+
result = self.safe_dict(response, 'result', {})
|
2743
2807
|
return self.parse_transfer(result, currency)
|
2744
2808
|
|
2745
|
-
def parse_transfer(self, transfer, currency: Currency = None):
|
2809
|
+
def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
|
2746
2810
|
#
|
2747
2811
|
# {
|
2748
2812
|
# "updated_timestamp": 1550232862350,
|
@@ -2766,15 +2830,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2766
2830
|
'id': self.safe_string(transfer, 'id'),
|
2767
2831
|
'status': self.parse_transfer_status(status),
|
2768
2832
|
'amount': self.safe_number(transfer, 'amount'),
|
2769
|
-
'
|
2833
|
+
'currency': self.safe_currency_code(currencyId, currency),
|
2770
2834
|
'fromAccount': direction != account if 'payment' else None,
|
2771
2835
|
'toAccount': direction == account if 'payment' else None,
|
2772
2836
|
'timestamp': timestamp,
|
2773
2837
|
'datetime': self.iso8601(timestamp),
|
2774
2838
|
}
|
2775
2839
|
|
2776
|
-
def parse_transfer_status(self, status):
|
2777
|
-
statuses = {
|
2840
|
+
def parse_transfer_status(self, status: Str) -> Str:
|
2841
|
+
statuses: dict = {
|
2778
2842
|
'prepared': 'pending',
|
2779
2843
|
'confirmed': 'ok',
|
2780
2844
|
'cancelled': 'cancelled',
|
@@ -2782,10 +2846,12 @@ class deribit(Exchange, ImplicitAPI):
|
|
2782
2846
|
}
|
2783
2847
|
return self.safe_string(statuses, status, status)
|
2784
2848
|
|
2785
|
-
async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
|
2849
|
+
async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
|
2786
2850
|
"""
|
2787
2851
|
make a withdrawal
|
2788
|
-
|
2852
|
+
|
2853
|
+
https://docs.deribit.com/#private-withdraw
|
2854
|
+
|
2789
2855
|
:param str code: unified currency code
|
2790
2856
|
:param float amount: the amount to withdraw
|
2791
2857
|
:param str address: the address to withdraw to
|
@@ -2797,7 +2863,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2797
2863
|
self.check_address(address)
|
2798
2864
|
await self.load_markets()
|
2799
2865
|
currency = self.currency(code)
|
2800
|
-
request = {
|
2866
|
+
request: dict = {
|
2801
2867
|
'currency': currency['id'],
|
2802
2868
|
'address': address, # must be in the address book
|
2803
2869
|
'amount': amount,
|
@@ -2838,7 +2904,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
2838
2904
|
async def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
|
2839
2905
|
"""
|
2840
2906
|
fetch deposit and withdraw fees
|
2841
|
-
|
2907
|
+
|
2908
|
+
https://docs.deribit.com/#public-get_currencies
|
2909
|
+
|
2842
2910
|
:param str[]|None codes: list of unified currency codes
|
2843
2911
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2844
2912
|
:returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
|
@@ -2867,13 +2935,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2867
2935
|
# "testnet": True
|
2868
2936
|
# }
|
2869
2937
|
#
|
2870
|
-
data = self.
|
2938
|
+
data = self.safe_list(response, 'result', [])
|
2871
2939
|
return self.parse_deposit_withdraw_fees(data, codes, 'currency')
|
2872
2940
|
|
2873
|
-
async def fetch_funding_rate(self, symbol: str, params={}):
|
2941
|
+
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
2874
2942
|
"""
|
2875
2943
|
fetch the current funding rate
|
2876
|
-
|
2944
|
+
|
2945
|
+
https://docs.deribit.com/#public-get_funding_rate_value
|
2946
|
+
|
2877
2947
|
:param str symbol: unified market symbol
|
2878
2948
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2879
2949
|
:param int [params.start_timestamp]: fetch funding rate starting from self timestamp
|
@@ -2883,7 +2953,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2883
2953
|
await self.load_markets()
|
2884
2954
|
market = self.market(symbol)
|
2885
2955
|
time = self.milliseconds()
|
2886
|
-
request = {
|
2956
|
+
request: dict = {
|
2887
2957
|
'instrument_name': market['id'],
|
2888
2958
|
'start_timestamp': time - (8 * 60 * 60 * 1000), # 8h ago,
|
2889
2959
|
'end_timestamp': time,
|
@@ -2904,8 +2974,12 @@ class deribit(Exchange, ImplicitAPI):
|
|
2904
2974
|
async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2905
2975
|
"""
|
2906
2976
|
fetch the current funding rate
|
2907
|
-
|
2977
|
+
|
2978
|
+
https://docs.deribit.com/#public-get_funding_rate_history
|
2979
|
+
|
2908
2980
|
:param str symbol: unified market symbol
|
2981
|
+
:param int [since]: the earliest time in ms to fetch funding rate history for
|
2982
|
+
:param int [limit]: the maximum number of entries to retrieve
|
2909
2983
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2910
2984
|
:param int [params.end_timestamp]: fetch funding rate ending at self timestamp
|
2911
2985
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
@@ -2921,7 +2995,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2921
2995
|
month = 30 * 24 * 60 * 60 * 1000
|
2922
2996
|
if since is None:
|
2923
2997
|
since = time - month
|
2924
|
-
request = {
|
2998
|
+
request: dict = {
|
2925
2999
|
'instrument_name': market['id'],
|
2926
3000
|
'start_timestamp': since - 1,
|
2927
3001
|
'end_timestamp': time,
|
@@ -2950,7 +3024,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2950
3024
|
rates.append(rate)
|
2951
3025
|
return self.filter_by_symbol_since_limit(rates, symbol, since, limit)
|
2952
3026
|
|
2953
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
3027
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
2954
3028
|
#
|
2955
3029
|
# {
|
2956
3030
|
# "jsonrpc":"2.0",
|
@@ -2990,12 +3064,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2990
3064
|
'previousFundingRate': None,
|
2991
3065
|
'previousFundingTimestamp': None,
|
2992
3066
|
'previousFundingDatetime': None,
|
3067
|
+
'interval': '8h',
|
2993
3068
|
}
|
2994
3069
|
|
2995
3070
|
async def fetch_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
|
2996
3071
|
"""
|
2997
3072
|
retrieves the public liquidations of a trading pair
|
2998
|
-
|
3073
|
+
|
3074
|
+
https://docs.deribit.com/#public-get_last_settlements_by_currency
|
3075
|
+
|
2999
3076
|
:param str symbol: unified CCXT market symbol
|
3000
3077
|
:param int [since]: the earliest time in ms to fetch liquidations for
|
3001
3078
|
:param int [limit]: the maximum number of liquidation structures to retrieve
|
@@ -3011,7 +3088,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3011
3088
|
market = self.market(symbol)
|
3012
3089
|
if market['spot']:
|
3013
3090
|
raise NotSupported(self.id + ' fetchLiquidations() does not support ' + market['type'] + ' markets')
|
3014
|
-
request = {
|
3091
|
+
request: dict = {
|
3015
3092
|
'instrument_name': market['id'],
|
3016
3093
|
'type': 'bankruptcy',
|
3017
3094
|
}
|
@@ -3065,7 +3142,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
3065
3142
|
async def fetch_my_liquidations(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3066
3143
|
"""
|
3067
3144
|
retrieves the users liquidated positions
|
3068
|
-
|
3145
|
+
|
3146
|
+
https://docs.deribit.com/#private-get_settlement_history_by_instrument
|
3147
|
+
|
3069
3148
|
:param str symbol: unified CCXT market symbol
|
3070
3149
|
:param int [since]: the earliest time in ms to fetch liquidations for
|
3071
3150
|
:param int [limit]: the maximum number of liquidation structures to retrieve
|
@@ -3078,7 +3157,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3078
3157
|
market = self.market(symbol)
|
3079
3158
|
if market['spot']:
|
3080
3159
|
raise NotSupported(self.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' markets')
|
3081
|
-
request = {
|
3160
|
+
request: dict = {
|
3082
3161
|
'instrument_name': market['id'],
|
3083
3162
|
'type': 'bankruptcy',
|
3084
3163
|
}
|
@@ -3112,7 +3191,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3112
3191
|
# }
|
3113
3192
|
#
|
3114
3193
|
result = self.safe_value(response, 'result', {})
|
3115
|
-
settlements = self.
|
3194
|
+
settlements = self.safe_list(result, 'settlements', [])
|
3116
3195
|
return self.parse_liquidations(settlements, market, since, limit)
|
3117
3196
|
|
3118
3197
|
def parse_liquidation(self, liquidation, market: Market = None):
|
@@ -3144,14 +3223,16 @@ class deribit(Exchange, ImplicitAPI):
|
|
3144
3223
|
async def fetch_greeks(self, symbol: str, params={}) -> Greeks:
|
3145
3224
|
"""
|
3146
3225
|
fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
3147
|
-
|
3226
|
+
|
3227
|
+
https://docs.deribit.com/#public-ticker
|
3228
|
+
|
3148
3229
|
:param str symbol: unified symbol of the market to fetch greeks for
|
3149
3230
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3150
3231
|
:returns dict: a `greeks structure <https://docs.ccxt.com/#/?id=greeks-structure>`
|
3151
3232
|
"""
|
3152
3233
|
await self.load_markets()
|
3153
3234
|
market = self.market(symbol)
|
3154
|
-
request = {
|
3235
|
+
request: dict = {
|
3155
3236
|
'instrument_name': market['id'],
|
3156
3237
|
}
|
3157
3238
|
response = await self.publicGetTicker(self.extend(request, params))
|
@@ -3204,7 +3285,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3204
3285
|
result = self.safe_value(response, 'result', {})
|
3205
3286
|
return self.parse_greeks(result, market)
|
3206
3287
|
|
3207
|
-
def parse_greeks(self, greeks, market: Market = None):
|
3288
|
+
def parse_greeks(self, greeks: dict, market: Market = None) -> Greeks:
|
3208
3289
|
#
|
3209
3290
|
# {
|
3210
3291
|
# "estimated_delivery_price": 36552.72,
|
@@ -3270,6 +3351,159 @@ class deribit(Exchange, ImplicitAPI):
|
|
3270
3351
|
'info': greeks,
|
3271
3352
|
}
|
3272
3353
|
|
3354
|
+
async def fetch_option(self, symbol: str, params={}) -> Option:
|
3355
|
+
"""
|
3356
|
+
fetches option data that is commonly found in an option chain
|
3357
|
+
|
3358
|
+
https://docs.deribit.com/#public-get_book_summary_by_instrument
|
3359
|
+
|
3360
|
+
:param str symbol: unified market symbol
|
3361
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3362
|
+
:returns dict: an `option chain structure <https://docs.ccxt.com/#/?id=option-chain-structure>`
|
3363
|
+
"""
|
3364
|
+
await self.load_markets()
|
3365
|
+
market = self.market(symbol)
|
3366
|
+
request: dict = {
|
3367
|
+
'instrument_name': market['id'],
|
3368
|
+
}
|
3369
|
+
response = await self.publicGetGetBookSummaryByInstrument(self.extend(request, params))
|
3370
|
+
#
|
3371
|
+
# {
|
3372
|
+
# "jsonrpc": "2.0",
|
3373
|
+
# "result": [
|
3374
|
+
# {
|
3375
|
+
# "mid_price": 0.04025,
|
3376
|
+
# "volume_usd": 11045.12,
|
3377
|
+
# "quote_currency": "BTC",
|
3378
|
+
# "estimated_delivery_price": 65444.72,
|
3379
|
+
# "creation_timestamp": 1711100949273,
|
3380
|
+
# "base_currency": "BTC",
|
3381
|
+
# "underlying_index": "BTC-27DEC24",
|
3382
|
+
# "underlying_price": 73742.14,
|
3383
|
+
# "volume": 4.0,
|
3384
|
+
# "interest_rate": 0.0,
|
3385
|
+
# "price_change": -6.9767,
|
3386
|
+
# "open_interest": 274.2,
|
3387
|
+
# "ask_price": 0.042,
|
3388
|
+
# "bid_price": 0.0385,
|
3389
|
+
# "instrument_name": "BTC-27DEC24-240000-C",
|
3390
|
+
# "mark_price": 0.04007735,
|
3391
|
+
# "last": 0.04,
|
3392
|
+
# "low": 0.04,
|
3393
|
+
# "high": 0.043
|
3394
|
+
# }
|
3395
|
+
# ],
|
3396
|
+
# "usIn": 1711100949273223,
|
3397
|
+
# "usOut": 1711100949273580,
|
3398
|
+
# "usDiff": 357,
|
3399
|
+
# "testnet": False
|
3400
|
+
# }
|
3401
|
+
#
|
3402
|
+
result = self.safe_list(response, 'result', [])
|
3403
|
+
chain = self.safe_dict(result, 0, {})
|
3404
|
+
return self.parse_option(chain, None, market)
|
3405
|
+
|
3406
|
+
async def fetch_option_chain(self, code: str, params={}) -> OptionChain:
|
3407
|
+
"""
|
3408
|
+
fetches data for an underlying asset that is commonly found in an option chain
|
3409
|
+
|
3410
|
+
https://docs.deribit.com/#public-get_book_summary_by_currency
|
3411
|
+
|
3412
|
+
:param str code: base currency to fetch an option chain for
|
3413
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3414
|
+
:returns dict: a list of `option chain structures <https://docs.ccxt.com/#/?id=option-chain-structure>`
|
3415
|
+
"""
|
3416
|
+
await self.load_markets()
|
3417
|
+
currency = self.currency(code)
|
3418
|
+
request: dict = {
|
3419
|
+
'currency': currency['id'],
|
3420
|
+
'kind': 'option',
|
3421
|
+
}
|
3422
|
+
response = await self.publicGetGetBookSummaryByCurrency(self.extend(request, params))
|
3423
|
+
#
|
3424
|
+
# {
|
3425
|
+
# "jsonrpc": "2.0",
|
3426
|
+
# "result": [
|
3427
|
+
# {
|
3428
|
+
# "mid_price": 0.4075,
|
3429
|
+
# "volume_usd": 2836.83,
|
3430
|
+
# "quote_currency": "BTC",
|
3431
|
+
# "estimated_delivery_price": 65479.26,
|
3432
|
+
# "creation_timestamp": 1711101594477,
|
3433
|
+
# "base_currency": "BTC",
|
3434
|
+
# "underlying_index": "BTC-28JUN24",
|
3435
|
+
# "underlying_price": 68827.27,
|
3436
|
+
# "volume": 0.1,
|
3437
|
+
# "interest_rate": 0.0,
|
3438
|
+
# "price_change": 0.0,
|
3439
|
+
# "open_interest": 364.1,
|
3440
|
+
# "ask_price": 0.411,
|
3441
|
+
# "bid_price": 0.404,
|
3442
|
+
# "instrument_name": "BTC-28JUN24-42000-C",
|
3443
|
+
# "mark_price": 0.40752052,
|
3444
|
+
# "last": 0.423,
|
3445
|
+
# "low": 0.423,
|
3446
|
+
# "high": 0.423
|
3447
|
+
# }
|
3448
|
+
# ],
|
3449
|
+
# "usIn": 1711101594456388,
|
3450
|
+
# "usOut": 1711101594484065,
|
3451
|
+
# "usDiff": 27677,
|
3452
|
+
# "testnet": False
|
3453
|
+
# }
|
3454
|
+
#
|
3455
|
+
result = self.safe_list(response, 'result', [])
|
3456
|
+
return self.parse_option_chain(result, 'base_currency', 'instrument_name')
|
3457
|
+
|
3458
|
+
def parse_option(self, chain: dict, currency: Currency = None, market: Market = None) -> Option:
|
3459
|
+
#
|
3460
|
+
# {
|
3461
|
+
# "mid_price": 0.04025,
|
3462
|
+
# "volume_usd": 11045.12,
|
3463
|
+
# "quote_currency": "BTC",
|
3464
|
+
# "estimated_delivery_price": 65444.72,
|
3465
|
+
# "creation_timestamp": 1711100949273,
|
3466
|
+
# "base_currency": "BTC",
|
3467
|
+
# "underlying_index": "BTC-27DEC24",
|
3468
|
+
# "underlying_price": 73742.14,
|
3469
|
+
# "volume": 4.0,
|
3470
|
+
# "interest_rate": 0.0,
|
3471
|
+
# "price_change": -6.9767,
|
3472
|
+
# "open_interest": 274.2,
|
3473
|
+
# "ask_price": 0.042,
|
3474
|
+
# "bid_price": 0.0385,
|
3475
|
+
# "instrument_name": "BTC-27DEC24-240000-C",
|
3476
|
+
# "mark_price": 0.04007735,
|
3477
|
+
# "last": 0.04,
|
3478
|
+
# "low": 0.04,
|
3479
|
+
# "high": 0.043
|
3480
|
+
# }
|
3481
|
+
#
|
3482
|
+
marketId = self.safe_string(chain, 'instrument_name')
|
3483
|
+
market = self.safe_market(marketId, market)
|
3484
|
+
currencyId = self.safe_string(chain, 'base_currency')
|
3485
|
+
code = self.safe_currency_code(currencyId, currency)
|
3486
|
+
timestamp = self.safe_integer(chain, 'timestamp')
|
3487
|
+
return {
|
3488
|
+
'info': chain,
|
3489
|
+
'currency': code,
|
3490
|
+
'symbol': market['symbol'],
|
3491
|
+
'timestamp': timestamp,
|
3492
|
+
'datetime': self.iso8601(timestamp),
|
3493
|
+
'impliedVolatility': None,
|
3494
|
+
'openInterest': self.safe_number(chain, 'open_interest'),
|
3495
|
+
'bidPrice': self.safe_number(chain, 'bid_price'),
|
3496
|
+
'askPrice': self.safe_number(chain, 'ask_price'),
|
3497
|
+
'midPrice': self.safe_number(chain, 'mid_price'),
|
3498
|
+
'markPrice': self.safe_number(chain, 'mark_price'),
|
3499
|
+
'lastPrice': self.safe_number(chain, 'last'),
|
3500
|
+
'underlyingPrice': self.safe_number(chain, 'underlying_price'),
|
3501
|
+
'change': None,
|
3502
|
+
'percentage': self.safe_number(chain, 'price_change'),
|
3503
|
+
'baseVolume': self.safe_number(chain, 'volume'),
|
3504
|
+
'quoteVolume': self.safe_number(chain, 'volume_usd'),
|
3505
|
+
}
|
3506
|
+
|
3273
3507
|
def nonce(self):
|
3274
3508
|
return self.milliseconds()
|
3275
3509
|
|
@@ -3294,7 +3528,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3294
3528
|
url = self.urls['api']['rest'] + request
|
3295
3529
|
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
3296
3530
|
|
3297
|
-
def handle_errors(self, httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody):
|
3531
|
+
def handle_errors(self, httpCode: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
|
3298
3532
|
if not response:
|
3299
3533
|
return None # fallback to default error handler
|
3300
3534
|
#
|