ccxt 4.2.77__py2.py3-none-any.whl → 4.4.49__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 +3205 -937
- 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 +1525 -573
- 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 +223 -97
- 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 +639 -323
- ccxt/async_support/digifinex.py +465 -233
- ccxt/async_support/ellipx.py +1887 -0
- ccxt/async_support/exmo.py +317 -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 +433 -178
- ccxt/async_support/hollaex.py +207 -83
- ccxt/async_support/htx.py +1095 -563
- ccxt/async_support/huobijp.py +178 -56
- ccxt/async_support/hyperliquid.py +1678 -292
- ccxt/async_support/idex.py +219 -95
- ccxt/async_support/independentreserve.py +300 -31
- ccxt/async_support/indodax.py +226 -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 +198 -107
- ccxt/async_support/latoken.py +199 -79
- ccxt/async_support/lbank.py +360 -113
- ccxt/async_support/luno.py +185 -62
- ccxt/async_support/lykke.py +168 -55
- ccxt/async_support/mercado.py +101 -29
- ccxt/async_support/mexc.py +995 -429
- ccxt/async_support/myokx.py +53 -0
- ccxt/async_support/ndax.py +234 -82
- ccxt/async_support/novadax.py +195 -75
- ccxt/async_support/oceanex.py +244 -59
- ccxt/async_support/okcoin.py +301 -165
- ccxt/async_support/okx.py +1776 -454
- ccxt/async_support/onetrading.py +198 -414
- ccxt/async_support/oxfun.py +2898 -0
- ccxt/async_support/p2b.py +142 -52
- ccxt/async_support/paradex.py +2085 -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 +3205 -937
- 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 +1525 -573
- 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 +223 -97
- 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 +639 -323
- ccxt/digifinex.py +465 -233
- ccxt/ellipx.py +1887 -0
- ccxt/exmo.py +317 -128
- ccxt/gate.py +1472 -463
- ccxt/gemini.py +206 -84
- ccxt/hashkey.py +4164 -0
- ccxt/hitbtc.py +433 -178
- ccxt/hollaex.py +207 -83
- ccxt/htx.py +1095 -563
- ccxt/huobijp.py +178 -56
- ccxt/hyperliquid.py +1677 -292
- ccxt/idex.py +219 -95
- ccxt/independentreserve.py +299 -31
- ccxt/indodax.py +226 -62
- ccxt/kraken.py +871 -354
- ccxt/krakenfutures.py +324 -100
- ccxt/kucoin.py +917 -357
- ccxt/kucoinfutures.py +1004 -149
- ccxt/kuna.py +198 -107
- ccxt/latoken.py +199 -79
- ccxt/lbank.py +360 -113
- ccxt/luno.py +185 -62
- ccxt/lykke.py +168 -55
- ccxt/mercado.py +101 -29
- ccxt/mexc.py +994 -429
- ccxt/myokx.py +53 -0
- ccxt/ndax.py +234 -82
- ccxt/novadax.py +195 -75
- ccxt/oceanex.py +244 -59
- ccxt/okcoin.py +301 -165
- ccxt/okx.py +1776 -454
- ccxt/onetrading.py +198 -414
- ccxt/oxfun.py +2897 -0
- ccxt/p2b.py +142 -52
- ccxt/paradex.py +2085 -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 +143 -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.49.dist-info/LICENSE.txt +21 -0
- ccxt-4.4.49.dist-info/METADATA +646 -0
- ccxt-4.4.49.dist-info/RECORD +669 -0
- {ccxt-4.2.77.dist-info → ccxt-4.4.49.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.49.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,
|
@@ -285,6 +291,88 @@ class deribit(Exchange, ImplicitAPI):
|
|
285
291
|
},
|
286
292
|
},
|
287
293
|
},
|
294
|
+
'features': {
|
295
|
+
'default': {
|
296
|
+
'sandbox': True,
|
297
|
+
'createOrder': {
|
298
|
+
'marginMode': False,
|
299
|
+
'triggerPrice': True, # todo
|
300
|
+
# todo implement
|
301
|
+
'triggerPriceType': {
|
302
|
+
'last': True,
|
303
|
+
'mark': True,
|
304
|
+
'index': True,
|
305
|
+
},
|
306
|
+
'triggerDirection': False,
|
307
|
+
'stopLossPrice': False, # todo
|
308
|
+
'takeProfitPrice': False, # todo
|
309
|
+
'attachedStopLossTakeProfit': None,
|
310
|
+
'timeInForce': {
|
311
|
+
'IOC': True,
|
312
|
+
'FOK': True,
|
313
|
+
'PO': True,
|
314
|
+
'GTD': True,
|
315
|
+
},
|
316
|
+
'hedged': False,
|
317
|
+
'selfTradePrevention': False,
|
318
|
+
'trailing': True, # todo
|
319
|
+
'leverage': False,
|
320
|
+
'marketBuyByCost': True, # todo
|
321
|
+
'marketBuyRequiresPrice': False,
|
322
|
+
'iceberg': True, # todo
|
323
|
+
},
|
324
|
+
'createOrders': None,
|
325
|
+
'fetchMyTrades': {
|
326
|
+
'marginMode': False,
|
327
|
+
'limit': 100, # todo: revise
|
328
|
+
'daysBack': 100000,
|
329
|
+
'untilDays': 100000,
|
330
|
+
},
|
331
|
+
'fetchOrder': {
|
332
|
+
'marginMode': False,
|
333
|
+
'trigger': False,
|
334
|
+
'trailing': False,
|
335
|
+
},
|
336
|
+
'fetchOpenOrders': {
|
337
|
+
'marginMode': False,
|
338
|
+
'limit': None,
|
339
|
+
'trigger': False,
|
340
|
+
'trailing': False,
|
341
|
+
},
|
342
|
+
'fetchOrders': None,
|
343
|
+
'fetchClosedOrders': {
|
344
|
+
'marginMode': False,
|
345
|
+
'limit': 100,
|
346
|
+
'daysBack': 100000,
|
347
|
+
'daysBackCanceled': 1,
|
348
|
+
'untilDays': 100000,
|
349
|
+
'trigger': False,
|
350
|
+
'trailing': False,
|
351
|
+
},
|
352
|
+
'fetchOHLCV': {
|
353
|
+
'limit': 1000, # todo: recheck
|
354
|
+
},
|
355
|
+
},
|
356
|
+
'spot': {
|
357
|
+
'extends': 'default',
|
358
|
+
},
|
359
|
+
'swap': {
|
360
|
+
'linear': {
|
361
|
+
'extends': 'default',
|
362
|
+
},
|
363
|
+
'inverse': {
|
364
|
+
'extends': 'default',
|
365
|
+
},
|
366
|
+
},
|
367
|
+
'future': {
|
368
|
+
'linear': {
|
369
|
+
'extends': 'default',
|
370
|
+
},
|
371
|
+
'inverse': {
|
372
|
+
'extends': 'default',
|
373
|
+
},
|
374
|
+
},
|
375
|
+
},
|
288
376
|
'exceptions': {
|
289
377
|
# 0 or absent Success, No error.
|
290
378
|
'9999': PermissionDenied, # 'api_not_enabled' User didn't enable API for the Account.
|
@@ -415,70 +503,6 @@ class deribit(Exchange, ImplicitAPI):
|
|
415
503
|
},
|
416
504
|
})
|
417
505
|
|
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
506
|
def create_expired_option_market(self, symbol: str):
|
483
507
|
# support expired option contracts
|
484
508
|
quote = 'USD'
|
@@ -563,7 +587,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
563
587
|
async def fetch_time(self, params={}):
|
564
588
|
"""
|
565
589
|
fetches the current integer timestamp in milliseconds from the exchange server
|
566
|
-
|
590
|
+
|
591
|
+
https://docs.deribit.com/#public-get_time
|
592
|
+
|
567
593
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
568
594
|
:returns int: the current integer timestamp in milliseconds from the exchange server
|
569
595
|
"""
|
@@ -580,10 +606,12 @@ class deribit(Exchange, ImplicitAPI):
|
|
580
606
|
#
|
581
607
|
return self.safe_integer(response, 'result')
|
582
608
|
|
583
|
-
async def fetch_currencies(self, params={}):
|
609
|
+
async def fetch_currencies(self, params={}) -> Currencies:
|
584
610
|
"""
|
585
611
|
fetches all available currencies on an exchange
|
586
|
-
|
612
|
+
|
613
|
+
https://docs.deribit.com/#public-get_currencies
|
614
|
+
|
587
615
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
588
616
|
:returns dict: an associative dictionary of currencies
|
589
617
|
"""
|
@@ -611,7 +639,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
611
639
|
# }
|
612
640
|
#
|
613
641
|
data = self.safe_value(response, 'result', {})
|
614
|
-
result = {}
|
642
|
+
result: dict = {}
|
615
643
|
for i in range(0, len(data)):
|
616
644
|
currency = data[i]
|
617
645
|
currencyId = self.safe_string(currency, 'currency')
|
@@ -654,7 +682,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
654
682
|
async def fetch_status(self, params={}):
|
655
683
|
"""
|
656
684
|
the latest known information on the availability of the exchange API
|
657
|
-
|
685
|
+
|
686
|
+
https://docs.deribit.com/#public-status
|
687
|
+
|
658
688
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
659
689
|
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
|
660
690
|
"""
|
@@ -685,7 +715,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
685
715
|
async def fetch_accounts(self, params={}) -> List[Account]:
|
686
716
|
"""
|
687
717
|
fetch all the accounts associated with a profile
|
688
|
-
|
718
|
+
|
719
|
+
https://docs.deribit.com/#private-get_subaccounts
|
720
|
+
|
689
721
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
690
722
|
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
|
691
723
|
"""
|
@@ -750,121 +782,133 @@ class deribit(Exchange, ImplicitAPI):
|
|
750
782
|
'code': self.safe_currency_code(None, currency),
|
751
783
|
}
|
752
784
|
|
753
|
-
async def fetch_markets(self, params={}):
|
785
|
+
async def fetch_markets(self, params={}) -> List[Market]:
|
754
786
|
"""
|
755
787
|
retrieves data on all markets for deribit
|
756
|
-
|
788
|
+
|
789
|
+
https://docs.deribit.com/#public-get_currencies
|
790
|
+
https://docs.deribit.com/#public-get_instruments
|
791
|
+
|
757
792
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
758
793
|
:returns dict[]: an array of objects representing market data
|
759
794
|
"""
|
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', [])
|
795
|
+
instrumentsResponses = []
|
787
796
|
result = []
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
797
|
+
parsedMarkets: dict = {}
|
798
|
+
fetchAllMarkets = None
|
799
|
+
fetchAllMarkets, params = self.handle_option_and_params(params, 'fetchMarkets', 'fetchAllMarkets', True)
|
800
|
+
if fetchAllMarkets:
|
801
|
+
instrumentsResponse = await self.publicGetGetInstruments(params)
|
802
|
+
instrumentsResponses.append(instrumentsResponse)
|
803
|
+
else:
|
804
|
+
currenciesResponse = await self.publicGetGetCurrencies(params)
|
794
805
|
#
|
795
806
|
# {
|
796
|
-
# "jsonrpc":"2.0",
|
797
|
-
# "result":[
|
807
|
+
# "jsonrpc": "2.0",
|
808
|
+
# "result": [
|
798
809
|
# {
|
799
|
-
# "
|
800
|
-
#
|
801
|
-
#
|
802
|
-
#
|
803
|
-
# "
|
804
|
-
# "
|
805
|
-
# "
|
806
|
-
# "
|
807
|
-
# "
|
808
|
-
# "
|
809
|
-
# "
|
810
|
-
#
|
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
|
-
# },
|
818
|
-
# {
|
819
|
-
# "tick_size":0.5,
|
820
|
-
# "taker_commission":0.0005,
|
821
|
-
# "settlement_period":"month", # month, week
|
822
|
-
# "settlement_currency":"BTC",
|
823
|
-
# "quote_currency":"USD",
|
824
|
-
# "min_trade_amount":10.0,
|
825
|
-
# "max_liquidation_commission":0.0075,
|
826
|
-
# "max_leverage":50,
|
827
|
-
# "maker_commission":0.0,
|
828
|
-
# "kind":"future",
|
829
|
-
# "is_active":true,
|
830
|
-
# "instrument_name":"BTC-27MAY22",
|
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
|
-
# },
|
810
|
+
# "withdrawal_priorities": [
|
811
|
+
# {value: 0.15, name: "very_low"},
|
812
|
+
# {value: 1.5, name: "very_high"},
|
813
|
+
# ],
|
814
|
+
# "withdrawal_fee": 0.0005,
|
815
|
+
# "min_withdrawal_fee": 0.0005,
|
816
|
+
# "min_confirmations": 1,
|
817
|
+
# "fee_precision": 4,
|
818
|
+
# "currency_long": "Bitcoin",
|
819
|
+
# "currency": "BTC",
|
820
|
+
# "coin_type": "BITCOIN"
|
821
|
+
# }
|
860
822
|
# ],
|
861
|
-
# "usIn":
|
862
|
-
# "usOut":
|
863
|
-
# "usDiff":
|
864
|
-
# "testnet":
|
823
|
+
# "usIn": 1583761588590479,
|
824
|
+
# "usOut": 1583761588590544,
|
825
|
+
# "usDiff": 65,
|
826
|
+
# "testnet": False
|
865
827
|
# }
|
866
828
|
#
|
867
|
-
|
829
|
+
currenciesResult = self.safe_value(currenciesResponse, 'result', [])
|
830
|
+
for i in range(0, len(currenciesResult)):
|
831
|
+
currencyId = self.safe_string(currenciesResult[i], 'currency')
|
832
|
+
request: dict = {
|
833
|
+
'currency': currencyId,
|
834
|
+
}
|
835
|
+
instrumentsResponse = await self.publicGetGetInstruments(self.extend(request, params))
|
836
|
+
#
|
837
|
+
# {
|
838
|
+
# "jsonrpc":"2.0",
|
839
|
+
# "result":[
|
840
|
+
# {
|
841
|
+
# "tick_size":0.0005,
|
842
|
+
# "taker_commission":0.0003,
|
843
|
+
# "strike":52000.0,
|
844
|
+
# "settlement_period":"month",
|
845
|
+
# "settlement_currency":"BTC",
|
846
|
+
# "quote_currency":"BTC",
|
847
|
+
# "option_type":"put", # put, call
|
848
|
+
# "min_trade_amount":0.1,
|
849
|
+
# "maker_commission":0.0003,
|
850
|
+
# "kind":"option",
|
851
|
+
# "is_active":true,
|
852
|
+
# "instrument_name":"BTC-24JUN22-52000-P",
|
853
|
+
# "expiration_timestamp":1656057600000,
|
854
|
+
# "creation_timestamp":1648199543000,
|
855
|
+
# "counter_currency":"USD",
|
856
|
+
# "contract_size":1.0,
|
857
|
+
# "block_trade_commission":0.0003,
|
858
|
+
# "base_currency":"BTC"
|
859
|
+
# },
|
860
|
+
# {
|
861
|
+
# "tick_size":0.5,
|
862
|
+
# "taker_commission":0.0005,
|
863
|
+
# "settlement_period":"month", # month, week
|
864
|
+
# "settlement_currency":"BTC",
|
865
|
+
# "quote_currency":"USD",
|
866
|
+
# "min_trade_amount":10.0,
|
867
|
+
# "max_liquidation_commission":0.0075,
|
868
|
+
# "max_leverage":50,
|
869
|
+
# "maker_commission":0.0,
|
870
|
+
# "kind":"future",
|
871
|
+
# "is_active":true,
|
872
|
+
# "instrument_name":"BTC-27MAY22",
|
873
|
+
# "future_type":"reversed",
|
874
|
+
# "expiration_timestamp":1653638400000,
|
875
|
+
# "creation_timestamp":1648195209000,
|
876
|
+
# "counter_currency":"USD",
|
877
|
+
# "contract_size":10.0,
|
878
|
+
# "block_trade_commission":0.0001,
|
879
|
+
# "base_currency":"BTC"
|
880
|
+
# },
|
881
|
+
# {
|
882
|
+
# "tick_size":0.5,
|
883
|
+
# "taker_commission":0.0005,
|
884
|
+
# "settlement_period":"perpetual",
|
885
|
+
# "settlement_currency":"BTC",
|
886
|
+
# "quote_currency":"USD",
|
887
|
+
# "min_trade_amount":10.0,
|
888
|
+
# "max_liquidation_commission":0.0075,
|
889
|
+
# "max_leverage":50,
|
890
|
+
# "maker_commission":0.0,
|
891
|
+
# "kind":"future",
|
892
|
+
# "is_active":true,
|
893
|
+
# "instrument_name":"BTC-PERPETUAL",
|
894
|
+
# "future_type":"reversed",
|
895
|
+
# "expiration_timestamp":32503708800000,
|
896
|
+
# "creation_timestamp":1534242287000,
|
897
|
+
# "counter_currency":"USD",
|
898
|
+
# "contract_size":10.0,
|
899
|
+
# "block_trade_commission":0.0001,
|
900
|
+
# "base_currency":"BTC"
|
901
|
+
# },
|
902
|
+
# ],
|
903
|
+
# "usIn":1648691472831791,
|
904
|
+
# "usOut":1648691472831896,
|
905
|
+
# "usDiff":105,
|
906
|
+
# "testnet":false
|
907
|
+
# }
|
908
|
+
#
|
909
|
+
instrumentsResponses.append(instrumentsResponse)
|
910
|
+
for i in range(0, len(instrumentsResponses)):
|
911
|
+
instrumentsResult = self.safe_value(instrumentsResponses[i], 'result', [])
|
868
912
|
for k in range(0, len(instrumentsResult)):
|
869
913
|
market = instrumentsResult[k]
|
870
914
|
kind = self.safe_string(market, 'kind')
|
@@ -892,6 +936,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
892
936
|
type = 'option'
|
893
937
|
elif isSpot:
|
894
938
|
type = 'spot'
|
939
|
+
inverse = None
|
940
|
+
linear = None
|
895
941
|
if isSpot:
|
896
942
|
symbol = base + '/' + quote
|
897
943
|
elif not isComboMarket:
|
@@ -903,6 +949,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
903
949
|
optionType = self.safe_string(market, 'option_type')
|
904
950
|
letter = 'C' if (optionType == 'call') else 'P'
|
905
951
|
symbol = symbol + '-' + self.number_to_string(strike) + '-' + letter
|
952
|
+
inverse = (quote != settle)
|
953
|
+
linear = (settle == quote)
|
906
954
|
parsedMarketValue = self.safe_value(parsedMarkets, symbol)
|
907
955
|
if parsedMarketValue:
|
908
956
|
continue
|
@@ -926,8 +974,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
926
974
|
'option': option,
|
927
975
|
'active': self.safe_value(market, 'is_active'),
|
928
976
|
'contract': not isSpot,
|
929
|
-
'linear':
|
930
|
-
'inverse':
|
977
|
+
'linear': linear,
|
978
|
+
'inverse': inverse,
|
931
979
|
'taker': self.safe_number(market, 'taker_commission'),
|
932
980
|
'maker': self.safe_number(market, 'maker_commission'),
|
933
981
|
'contractSize': self.safe_number(market, 'contract_size'),
|
@@ -963,32 +1011,48 @@ class deribit(Exchange, ImplicitAPI):
|
|
963
1011
|
return result
|
964
1012
|
|
965
1013
|
def parse_balance(self, balance) -> Balances:
|
966
|
-
result = {
|
1014
|
+
result: dict = {
|
967
1015
|
'info': balance,
|
968
1016
|
}
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
1017
|
+
summaries = []
|
1018
|
+
if 'summaries' in balance:
|
1019
|
+
summaries = self.safe_list(balance, 'summaries')
|
1020
|
+
else:
|
1021
|
+
summaries = [balance]
|
1022
|
+
for i in range(0, len(summaries)):
|
1023
|
+
data = summaries[i]
|
1024
|
+
currencyId = self.safe_string(data, 'currency')
|
1025
|
+
currencyCode = self.safe_currency_code(currencyId)
|
1026
|
+
account = self.account()
|
1027
|
+
account['free'] = self.safe_string(data, 'available_funds')
|
1028
|
+
account['used'] = self.safe_string(data, 'maintenance_margin')
|
1029
|
+
account['total'] = self.safe_string(data, 'equity')
|
1030
|
+
result[currencyCode] = account
|
976
1031
|
return self.safe_balance(result)
|
977
1032
|
|
978
1033
|
async def fetch_balance(self, params={}) -> Balances:
|
979
1034
|
"""
|
980
1035
|
query for balance and get the amount of funds available for trading or funds locked in orders
|
981
|
-
|
1036
|
+
|
1037
|
+
https://docs.deribit.com/#private-get_account_summary
|
1038
|
+
https://docs.deribit.com/#private-get_account_summaries
|
1039
|
+
|
982
1040
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1041
|
+
: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
1042
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
984
1043
|
"""
|
985
1044
|
await self.load_markets()
|
986
|
-
code = self.
|
987
|
-
|
988
|
-
request = {
|
989
|
-
'currency': currency['id'],
|
1045
|
+
code = self.safe_string(params, 'code')
|
1046
|
+
params = self.omit(params, 'code')
|
1047
|
+
request: dict = {
|
990
1048
|
}
|
991
|
-
|
1049
|
+
if code is not None:
|
1050
|
+
request['currency'] = self.currency_id(code)
|
1051
|
+
response = None
|
1052
|
+
if code is None:
|
1053
|
+
response = await self.privateGetGetAccountSummaries(params)
|
1054
|
+
else:
|
1055
|
+
response = await self.privateGetGetAccountSummary(self.extend(request, params))
|
992
1056
|
#
|
993
1057
|
# {
|
994
1058
|
# "jsonrpc": "2.0",
|
@@ -1031,20 +1095,22 @@ class deribit(Exchange, ImplicitAPI):
|
|
1031
1095
|
# "testnet": False
|
1032
1096
|
# }
|
1033
1097
|
#
|
1034
|
-
result = self.
|
1098
|
+
result = self.safe_dict(response, 'result', {})
|
1035
1099
|
return self.parse_balance(result)
|
1036
1100
|
|
1037
1101
|
async def create_deposit_address(self, code: str, params={}):
|
1038
1102
|
"""
|
1039
1103
|
create a currency deposit address
|
1040
|
-
|
1104
|
+
|
1105
|
+
https://docs.deribit.com/#private-create_deposit_address
|
1106
|
+
|
1041
1107
|
:param str code: unified currency code of the currency for the deposit address
|
1042
1108
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1043
1109
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
1044
1110
|
"""
|
1045
1111
|
await self.load_markets()
|
1046
1112
|
currency = self.currency(code)
|
1047
|
-
request = {
|
1113
|
+
request: dict = {
|
1048
1114
|
'currency': currency['id'],
|
1049
1115
|
}
|
1050
1116
|
response = await self.privateGetCreateDepositAddress(self.extend(request, params))
|
@@ -1070,17 +1136,19 @@ class deribit(Exchange, ImplicitAPI):
|
|
1070
1136
|
'info': response,
|
1071
1137
|
}
|
1072
1138
|
|
1073
|
-
async def fetch_deposit_address(self, code: str, params={}):
|
1139
|
+
async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
|
1074
1140
|
"""
|
1075
1141
|
fetch the deposit address for a currency associated with self account
|
1076
|
-
|
1142
|
+
|
1143
|
+
https://docs.deribit.com/#private-get_current_deposit_address
|
1144
|
+
|
1077
1145
|
:param str code: unified currency code
|
1078
1146
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1079
1147
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
1080
1148
|
"""
|
1081
1149
|
await self.load_markets()
|
1082
1150
|
currency = self.currency(code)
|
1083
|
-
request = {
|
1151
|
+
request: dict = {
|
1084
1152
|
'currency': currency['id'],
|
1085
1153
|
}
|
1086
1154
|
response = await self.privateGetGetCurrentDepositAddress(self.extend(request, params))
|
@@ -1105,14 +1173,14 @@ class deribit(Exchange, ImplicitAPI):
|
|
1105
1173
|
address = self.safe_string(result, 'address')
|
1106
1174
|
self.check_address(address)
|
1107
1175
|
return {
|
1176
|
+
'info': response,
|
1108
1177
|
'currency': code,
|
1178
|
+
'network': None,
|
1109
1179
|
'address': address,
|
1110
1180
|
'tag': None,
|
1111
|
-
'network': None,
|
1112
|
-
'info': response,
|
1113
1181
|
}
|
1114
1182
|
|
1115
|
-
def parse_ticker(self, ticker, market: Market = None) -> Ticker:
|
1183
|
+
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
1116
1184
|
#
|
1117
1185
|
# fetchTicker /public/ticker
|
1118
1186
|
#
|
@@ -1184,20 +1252,24 @@ class deribit(Exchange, ImplicitAPI):
|
|
1184
1252
|
'average': None,
|
1185
1253
|
'baseVolume': None,
|
1186
1254
|
'quoteVolume': self.safe_string(stats, 'volume'),
|
1255
|
+
'markPrice': self.safe_string(ticker, 'mark_price'),
|
1256
|
+
'indexPrice': self.safe_string(ticker, 'index_price'),
|
1187
1257
|
'info': ticker,
|
1188
1258
|
}, market)
|
1189
1259
|
|
1190
1260
|
async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
1191
1261
|
"""
|
1192
1262
|
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
1193
|
-
|
1263
|
+
|
1264
|
+
https://docs.deribit.com/#public-ticker
|
1265
|
+
|
1194
1266
|
:param str symbol: unified symbol of the market to fetch the ticker for
|
1195
1267
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1196
1268
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1197
1269
|
"""
|
1198
1270
|
await self.load_markets()
|
1199
1271
|
market = self.market(symbol)
|
1200
|
-
request = {
|
1272
|
+
request: dict = {
|
1201
1273
|
'instrument_name': market['id'],
|
1202
1274
|
}
|
1203
1275
|
response = await self.publicGetTicker(self.extend(request, params))
|
@@ -1229,22 +1301,28 @@ class deribit(Exchange, ImplicitAPI):
|
|
1229
1301
|
# "testnet": False
|
1230
1302
|
# }
|
1231
1303
|
#
|
1232
|
-
result = self.
|
1304
|
+
result = self.safe_dict(response, 'result')
|
1233
1305
|
return self.parse_ticker(result, market)
|
1234
1306
|
|
1235
1307
|
async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
1236
1308
|
"""
|
1237
1309
|
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
1238
|
-
|
1239
|
-
|
1310
|
+
|
1311
|
+
https://docs.deribit.com/#public-get_book_summary_by_currency
|
1312
|
+
|
1313
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
1240
1314
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1315
|
+
:param str [params.code]: *required* the currency code to fetch the tickers for, eg. 'BTC', 'ETH'
|
1241
1316
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1242
1317
|
"""
|
1243
1318
|
await self.load_markets()
|
1244
1319
|
symbols = self.market_symbols(symbols)
|
1245
|
-
code = self.
|
1320
|
+
code = self.safe_string_2(params, 'code', 'currency')
|
1321
|
+
params = self.omit(params, ['code'])
|
1322
|
+
if code is None:
|
1323
|
+
raise ArgumentsRequired(self.id + ' fetchTickers requires a currency/code(eg: BTC/ETH/USDT) parameter to fetch tickers for')
|
1246
1324
|
currency = self.currency(code)
|
1247
|
-
request = {
|
1325
|
+
request: dict = {
|
1248
1326
|
'currency': currency['id'],
|
1249
1327
|
}
|
1250
1328
|
response = await self.publicGetGetBookSummaryByCurrency(self.extend(request, params))
|
@@ -1278,8 +1356,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
1278
1356
|
# "testnet": False
|
1279
1357
|
# }
|
1280
1358
|
#
|
1281
|
-
result = self.
|
1282
|
-
tickers = {}
|
1359
|
+
result = self.safe_list(response, 'result', [])
|
1360
|
+
tickers: dict = {}
|
1283
1361
|
for i in range(0, len(result)):
|
1284
1362
|
ticker = self.parse_ticker(result[i])
|
1285
1363
|
symbol = ticker['symbol']
|
@@ -1289,17 +1367,25 @@ class deribit(Exchange, ImplicitAPI):
|
|
1289
1367
|
async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
1290
1368
|
"""
|
1291
1369
|
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
1292
|
-
|
1370
|
+
|
1371
|
+
https://docs.deribit.com/#public-get_tradingview_chart_data
|
1372
|
+
|
1293
1373
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
1294
1374
|
:param str timeframe: the length of time each candle represents
|
1295
1375
|
:param int [since]: timestamp in ms of the earliest candle to fetch
|
1296
1376
|
:param int [limit]: the maximum amount of candles to fetch
|
1297
1377
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1378
|
+
:param boolean [params.paginate]: whether to paginate the results, set to False by default
|
1379
|
+
:param int [params.until]: the latest time in ms to fetch ohlcv for
|
1298
1380
|
:returns int[][]: A list of candles ordered, open, high, low, close, volume
|
1299
1381
|
"""
|
1300
1382
|
await self.load_markets()
|
1383
|
+
paginate = False
|
1384
|
+
paginate, params = self.handle_option_and_params(params, 'fetchOHLCV', 'paginate')
|
1385
|
+
if paginate:
|
1386
|
+
return await self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 5000)
|
1301
1387
|
market = self.market(symbol)
|
1302
|
-
request = {
|
1388
|
+
request: dict = {
|
1303
1389
|
'instrument_name': market['id'],
|
1304
1390
|
'resolution': self.safe_string(self.timeframes, timeframe, timeframe),
|
1305
1391
|
}
|
@@ -1317,6 +1403,10 @@ class deribit(Exchange, ImplicitAPI):
|
|
1317
1403
|
request['end_timestamp'] = now
|
1318
1404
|
else:
|
1319
1405
|
request['end_timestamp'] = self.sum(since, limit * duration * 1000)
|
1406
|
+
until = self.safe_integer(params, 'until')
|
1407
|
+
if until is not None:
|
1408
|
+
params = self.omit(params, 'until')
|
1409
|
+
request['end_timestamp'] = until
|
1320
1410
|
response = await self.publicGetGetTradingviewChartData(self.extend(request, params))
|
1321
1411
|
#
|
1322
1412
|
# {
|
@@ -1341,7 +1431,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1341
1431
|
ohlcvs = self.convert_trading_view_to_ohlcv(result, 'ticks', 'open', 'high', 'low', 'close', 'volume', True)
|
1342
1432
|
return self.parse_ohlcvs(ohlcvs, market, timeframe, since, limit)
|
1343
1433
|
|
1344
|
-
def parse_trade(self, trade, market: Market = None) -> Trade:
|
1434
|
+
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
1345
1435
|
#
|
1346
1436
|
# fetchTrades(public)
|
1347
1437
|
#
|
@@ -1429,18 +1519,21 @@ class deribit(Exchange, ImplicitAPI):
|
|
1429
1519
|
|
1430
1520
|
async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
1431
1521
|
"""
|
1432
|
-
|
1433
|
-
|
1522
|
+
|
1523
|
+
https://docs.deribit.com/#public-get_last_trades_by_instrument
|
1524
|
+
https://docs.deribit.com/#public-get_last_trades_by_instrument_and_time
|
1525
|
+
|
1434
1526
|
get the list of most recent trades for a particular symbol.
|
1435
1527
|
:param str symbol: unified symbol of the market to fetch trades for
|
1436
1528
|
:param int [since]: timestamp in ms of the earliest trade to fetch
|
1437
1529
|
:param int [limit]: the maximum amount of trades to fetch
|
1438
1530
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1531
|
+
:param int [params.until]: the latest time in ms to fetch trades for
|
1439
1532
|
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
|
1440
1533
|
"""
|
1441
1534
|
await self.load_markets()
|
1442
1535
|
market = self.market(symbol)
|
1443
|
-
request = {
|
1536
|
+
request: dict = {
|
1444
1537
|
'instrument_name': market['id'],
|
1445
1538
|
'include_old': True,
|
1446
1539
|
}
|
@@ -1448,8 +1541,12 @@ class deribit(Exchange, ImplicitAPI):
|
|
1448
1541
|
request['start_timestamp'] = since
|
1449
1542
|
if limit is not None:
|
1450
1543
|
request['count'] = min(limit, 1000) # default 10
|
1544
|
+
until = self.safe_integer_2(params, 'until', 'end_timestamp')
|
1545
|
+
if until is not None:
|
1546
|
+
params = self.omit(params, ['until'])
|
1547
|
+
request['end_timestamp'] = until
|
1451
1548
|
response = None
|
1452
|
-
if since is None:
|
1549
|
+
if (since is None) and not ('end_timestamp' in request):
|
1453
1550
|
response = await self.publicGetGetLastTradesByInstrument(self.extend(request, params))
|
1454
1551
|
else:
|
1455
1552
|
response = await self.publicGetGetLastTradesByInstrumentAndTime(self.extend(request, params))
|
@@ -1479,20 +1576,22 @@ class deribit(Exchange, ImplicitAPI):
|
|
1479
1576
|
# }
|
1480
1577
|
#
|
1481
1578
|
result = self.safe_value(response, 'result', {})
|
1482
|
-
trades = self.
|
1579
|
+
trades = self.safe_list(result, 'trades', [])
|
1483
1580
|
return self.parse_trades(trades, market, since, limit)
|
1484
1581
|
|
1485
|
-
async def fetch_trading_fees(self, params={}):
|
1582
|
+
async def fetch_trading_fees(self, params={}) -> TradingFees:
|
1486
1583
|
"""
|
1487
1584
|
fetch the trading fees for multiple markets
|
1488
|
-
|
1585
|
+
|
1586
|
+
https://docs.deribit.com/#private-get_account_summary
|
1587
|
+
|
1489
1588
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1490
1589
|
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
|
1491
1590
|
"""
|
1492
1591
|
await self.load_markets()
|
1493
1592
|
code = self.code_from_options('fetchTradingFees', params)
|
1494
1593
|
currency = self.currency(code)
|
1495
|
-
request = {
|
1594
|
+
request: dict = {
|
1496
1595
|
'currency': currency['id'],
|
1497
1596
|
'extended': True,
|
1498
1597
|
}
|
@@ -1548,9 +1647,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
1548
1647
|
#
|
1549
1648
|
result = self.safe_value(response, 'result', {})
|
1550
1649
|
fees = self.safe_value(result, 'fees', [])
|
1551
|
-
perpetualFee = {}
|
1552
|
-
futureFee = {}
|
1553
|
-
optionFee = {}
|
1650
|
+
perpetualFee: dict = {}
|
1651
|
+
futureFee: dict = {}
|
1652
|
+
optionFee: dict = {}
|
1554
1653
|
for i in range(0, len(fees)):
|
1555
1654
|
fee = fees[i]
|
1556
1655
|
instrumentType = self.safe_string(fee, 'instrument_type')
|
@@ -1572,11 +1671,11 @@ class deribit(Exchange, ImplicitAPI):
|
|
1572
1671
|
'maker': self.safe_number(fee, 'maker_fee'),
|
1573
1672
|
'taker': self.safe_number(fee, 'taker_fee'),
|
1574
1673
|
}
|
1575
|
-
parsedFees = {}
|
1674
|
+
parsedFees: dict = {}
|
1576
1675
|
for i in range(0, len(self.symbols)):
|
1577
1676
|
symbol = self.symbols[i]
|
1578
1677
|
market = self.market(symbol)
|
1579
|
-
fee = {
|
1678
|
+
fee: dict = {
|
1580
1679
|
'info': market,
|
1581
1680
|
'symbol': symbol,
|
1582
1681
|
'percentage': True,
|
@@ -1596,7 +1695,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
1596
1695
|
async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
1597
1696
|
"""
|
1598
1697
|
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
1599
|
-
|
1698
|
+
|
1699
|
+
https://docs.deribit.com/#public-get_order_book
|
1700
|
+
|
1600
1701
|
:param str symbol: unified symbol of the market to fetch the order book for
|
1601
1702
|
:param int [limit]: the maximum amount of order book entries to return
|
1602
1703
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -1604,7 +1705,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1604
1705
|
"""
|
1605
1706
|
await self.load_markets()
|
1606
1707
|
market = self.market(symbol)
|
1607
|
-
request = {
|
1708
|
+
request: dict = {
|
1608
1709
|
'instrument_name': market['id'],
|
1609
1710
|
}
|
1610
1711
|
if limit is not None:
|
@@ -1656,8 +1757,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
1656
1757
|
orderbook['nonce'] = nonce
|
1657
1758
|
return orderbook
|
1658
1759
|
|
1659
|
-
def parse_order_status(self, status):
|
1660
|
-
statuses = {
|
1760
|
+
def parse_order_status(self, status: Str):
|
1761
|
+
statuses: dict = {
|
1661
1762
|
'open': 'open',
|
1662
1763
|
'cancelled': 'canceled',
|
1663
1764
|
'filled': 'closed',
|
@@ -1666,8 +1767,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
1666
1767
|
}
|
1667
1768
|
return self.safe_string(statuses, status, status)
|
1668
1769
|
|
1669
|
-
def parse_time_in_force(self, timeInForce):
|
1670
|
-
timeInForces = {
|
1770
|
+
def parse_time_in_force(self, timeInForce: Str):
|
1771
|
+
timeInForces: dict = {
|
1671
1772
|
'good_til_cancelled': 'GTC',
|
1672
1773
|
'fill_or_kill': 'FOK',
|
1673
1774
|
'immediate_or_cancel': 'IOC',
|
@@ -1675,7 +1776,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1675
1776
|
return self.safe_string(timeInForces, timeInForce, timeInForce)
|
1676
1777
|
|
1677
1778
|
def parse_order_type(self, orderType):
|
1678
|
-
orderTypes = {
|
1779
|
+
orderTypes: dict = {
|
1679
1780
|
'stop_limit': 'limit',
|
1680
1781
|
'take_limit': 'limit',
|
1681
1782
|
'stop_market': 'market',
|
@@ -1683,7 +1784,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1683
1784
|
}
|
1684
1785
|
return self.safe_string(orderTypes, orderType, orderType)
|
1685
1786
|
|
1686
|
-
def parse_order(self, order, market: Market = None) -> Order:
|
1787
|
+
def parse_order(self, order: dict, market: Market = None) -> Order:
|
1687
1788
|
#
|
1688
1789
|
# createOrder
|
1689
1790
|
#
|
@@ -1725,7 +1826,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1725
1826
|
filledString = self.safe_string(order, 'filled_amount')
|
1726
1827
|
amount = self.safe_string(order, 'amount')
|
1727
1828
|
cost = Precise.string_mul(filledString, averageString)
|
1728
|
-
if market
|
1829
|
+
if self.safe_bool(market, 'inverse'):
|
1729
1830
|
if averageString != '0':
|
1730
1831
|
cost = Precise.string_div(amount, averageString)
|
1731
1832
|
lastTradeTimestamp = None
|
@@ -1748,7 +1849,6 @@ class deribit(Exchange, ImplicitAPI):
|
|
1748
1849
|
# injected in createOrder
|
1749
1850
|
trades = self.safe_value(order, 'trades')
|
1750
1851
|
timeInForce = self.parse_time_in_force(self.safe_string(order, 'time_in_force'))
|
1751
|
-
stopPrice = self.safe_value(order, 'stop_price')
|
1752
1852
|
postOnly = self.safe_value(order, 'post_only')
|
1753
1853
|
return self.safe_order({
|
1754
1854
|
'info': order,
|
@@ -1763,8 +1863,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1763
1863
|
'postOnly': postOnly,
|
1764
1864
|
'side': side,
|
1765
1865
|
'price': priceString,
|
1766
|
-
'
|
1767
|
-
'triggerPrice': stopPrice,
|
1866
|
+
'triggerPrice': self.safe_value(order, 'stop_price'),
|
1768
1867
|
'amount': amount,
|
1769
1868
|
'cost': cost,
|
1770
1869
|
'average': averageString,
|
@@ -1778,13 +1877,16 @@ class deribit(Exchange, ImplicitAPI):
|
|
1778
1877
|
async def fetch_order(self, id: str, symbol: Str = None, params={}):
|
1779
1878
|
"""
|
1780
1879
|
fetches information on an order made by the user
|
1781
|
-
|
1880
|
+
|
1881
|
+
https://docs.deribit.com/#private-get_order_state
|
1882
|
+
|
1883
|
+
:param str id: order id
|
1782
1884
|
:param str symbol: unified symbol of the market the order was made in
|
1783
1885
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1784
1886
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1785
1887
|
"""
|
1786
1888
|
await self.load_markets()
|
1787
|
-
request = {
|
1889
|
+
request: dict = {
|
1788
1890
|
'order_id': id,
|
1789
1891
|
}
|
1790
1892
|
market = None
|
@@ -1819,19 +1921,21 @@ class deribit(Exchange, ImplicitAPI):
|
|
1819
1921
|
# }
|
1820
1922
|
# }
|
1821
1923
|
#
|
1822
|
-
result = self.
|
1924
|
+
result = self.safe_dict(response, 'result')
|
1823
1925
|
return self.parse_order(result, market)
|
1824
1926
|
|
1825
1927
|
async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
1826
1928
|
"""
|
1827
1929
|
create a trade order
|
1828
|
-
|
1829
|
-
|
1930
|
+
|
1931
|
+
https://docs.deribit.com/#private-buy
|
1932
|
+
https://docs.deribit.com/#private-sell
|
1933
|
+
|
1830
1934
|
:param str symbol: unified symbol of the market to create an order in
|
1831
1935
|
:param str type: 'market' or 'limit'
|
1832
1936
|
: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
|
1937
|
+
: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.
|
1938
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1835
1939
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1836
1940
|
:param str [params.trigger]: the trigger type 'index_price', 'mark_price', or 'last_price', default is 'last_price'
|
1837
1941
|
:param float [params.trailingAmount]: the quote amount to trail away from the current market price
|
@@ -1839,7 +1943,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1839
1943
|
"""
|
1840
1944
|
await self.load_markets()
|
1841
1945
|
market = self.market(symbol)
|
1842
|
-
request = {
|
1946
|
+
request: dict = {
|
1843
1947
|
'instrument_name': market['id'],
|
1844
1948
|
'amount': self.amount_to_precision(symbol, amount),
|
1845
1949
|
'type': type, # limit, stop_limit, market, stop_market, default is limit
|
@@ -1982,13 +2086,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
1982
2086
|
async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
|
1983
2087
|
"""
|
1984
2088
|
edit a trade order
|
1985
|
-
|
2089
|
+
|
2090
|
+
https://docs.deribit.com/#private-edit
|
2091
|
+
|
1986
2092
|
:param str id: edit order id
|
1987
2093
|
:param str [symbol]: unified symbol of the market to edit an order in
|
1988
2094
|
:param str [type]: 'market' or 'limit'
|
1989
2095
|
: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
|
2096
|
+
: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.
|
2097
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1992
2098
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1993
2099
|
:param float [params.trailingAmount]: the quote amount to trail away from the current market price
|
1994
2100
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
@@ -1996,7 +2102,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
1996
2102
|
if amount is None:
|
1997
2103
|
raise ArgumentsRequired(self.id + ' editOrder() requires an amount argument')
|
1998
2104
|
await self.load_markets()
|
1999
|
-
request = {
|
2105
|
+
request: dict = {
|
2000
2106
|
'order_id': id,
|
2001
2107
|
'amount': self.amount_to_precision(symbol, amount),
|
2002
2108
|
# '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 +2128,35 @@ class deribit(Exchange, ImplicitAPI):
|
|
2022
2128
|
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
2023
2129
|
"""
|
2024
2130
|
cancels an open order
|
2025
|
-
|
2131
|
+
|
2132
|
+
https://docs.deribit.com/#private-cancel
|
2133
|
+
|
2026
2134
|
:param str id: order id
|
2027
2135
|
:param str symbol: not used by deribit cancelOrder()
|
2028
2136
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2029
2137
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2030
2138
|
"""
|
2031
2139
|
await self.load_markets()
|
2032
|
-
request = {
|
2140
|
+
request: dict = {
|
2033
2141
|
'order_id': id,
|
2034
2142
|
}
|
2035
2143
|
response = await self.privateGetCancel(self.extend(request, params))
|
2036
|
-
result = self.
|
2144
|
+
result = self.safe_dict(response, 'result', {})
|
2037
2145
|
return self.parse_order(result)
|
2038
2146
|
|
2039
2147
|
async def cancel_all_orders(self, symbol: Str = None, params={}):
|
2040
2148
|
"""
|
2041
2149
|
cancel all open orders
|
2042
|
-
|
2043
|
-
|
2150
|
+
|
2151
|
+
https://docs.deribit.com/#private-cancel_all
|
2152
|
+
https://docs.deribit.com/#private-cancel_all_by_instrument
|
2153
|
+
|
2044
2154
|
:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
|
2045
2155
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2046
2156
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2047
2157
|
"""
|
2048
2158
|
await self.load_markets()
|
2049
|
-
request = {}
|
2159
|
+
request: dict = {}
|
2050
2160
|
response = None
|
2051
2161
|
if symbol is None:
|
2052
2162
|
response = await self.privateGetCancelAll(self.extend(request, params))
|
@@ -2054,13 +2164,29 @@ class deribit(Exchange, ImplicitAPI):
|
|
2054
2164
|
market = self.market(symbol)
|
2055
2165
|
request['instrument_name'] = market['id']
|
2056
2166
|
response = await self.privateGetCancelAllByInstrument(self.extend(request, params))
|
2057
|
-
|
2167
|
+
#
|
2168
|
+
# {
|
2169
|
+
# jsonrpc: '2.0',
|
2170
|
+
# result: '1',
|
2171
|
+
# usIn: '1720508354127369',
|
2172
|
+
# usOut: '1720508354133603',
|
2173
|
+
# usDiff: '6234',
|
2174
|
+
# testnet: True
|
2175
|
+
# }
|
2176
|
+
#
|
2177
|
+
return [
|
2178
|
+
self.safe_order({
|
2179
|
+
'info': response,
|
2180
|
+
}),
|
2181
|
+
]
|
2058
2182
|
|
2059
2183
|
async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
2060
2184
|
"""
|
2061
2185
|
fetch all unfilled currently open orders
|
2062
|
-
|
2063
|
-
|
2186
|
+
|
2187
|
+
https://docs.deribit.com/#private-get_open_orders_by_currency
|
2188
|
+
https://docs.deribit.com/#private-get_open_orders_by_instrument
|
2189
|
+
|
2064
2190
|
:param str symbol: unified market symbol
|
2065
2191
|
:param int [since]: the earliest time in ms to fetch open orders for
|
2066
2192
|
:param int [limit]: the maximum number of open orders structures to retrieve
|
@@ -2068,7 +2194,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2068
2194
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2069
2195
|
"""
|
2070
2196
|
await self.load_markets()
|
2071
|
-
request = {}
|
2197
|
+
request: dict = {}
|
2072
2198
|
market = None
|
2073
2199
|
response = None
|
2074
2200
|
if symbol is None:
|
@@ -2080,14 +2206,16 @@ class deribit(Exchange, ImplicitAPI):
|
|
2080
2206
|
market = self.market(symbol)
|
2081
2207
|
request['instrument_name'] = market['id']
|
2082
2208
|
response = await self.privateGetGetOpenOrdersByInstrument(self.extend(request, params))
|
2083
|
-
result = self.
|
2209
|
+
result = self.safe_list(response, 'result', [])
|
2084
2210
|
return self.parse_orders(result, market, since, limit)
|
2085
2211
|
|
2086
2212
|
async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
2087
2213
|
"""
|
2088
2214
|
fetches information on multiple closed orders made by the user
|
2089
|
-
|
2090
|
-
|
2215
|
+
|
2216
|
+
https://docs.deribit.com/#private-get_order_history_by_currency
|
2217
|
+
https://docs.deribit.com/#private-get_order_history_by_instrument
|
2218
|
+
|
2091
2219
|
:param str symbol: unified market symbol of the market orders were made in
|
2092
2220
|
:param int [since]: the earliest time in ms to fetch orders for
|
2093
2221
|
:param int [limit]: the maximum number of order structures to retrieve
|
@@ -2095,7 +2223,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2095
2223
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2096
2224
|
"""
|
2097
2225
|
await self.load_markets()
|
2098
|
-
request = {}
|
2226
|
+
request: dict = {}
|
2099
2227
|
market = None
|
2100
2228
|
response = None
|
2101
2229
|
if symbol is None:
|
@@ -2107,13 +2235,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2107
2235
|
market = self.market(symbol)
|
2108
2236
|
request['instrument_name'] = market['id']
|
2109
2237
|
response = await self.privateGetGetOrderHistoryByInstrument(self.extend(request, params))
|
2110
|
-
result = self.
|
2238
|
+
result = self.safe_list(response, 'result', [])
|
2111
2239
|
return self.parse_orders(result, market, since, limit)
|
2112
2240
|
|
2113
2241
|
async def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2114
2242
|
"""
|
2115
2243
|
fetch all the trades made from a single order
|
2116
|
-
|
2244
|
+
|
2245
|
+
https://docs.deribit.com/#private-get_user_trades_by_order
|
2246
|
+
|
2117
2247
|
:param str id: order id
|
2118
2248
|
:param str symbol: unified market symbol
|
2119
2249
|
:param int [since]: the earliest time in ms to fetch trades for
|
@@ -2122,7 +2252,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2122
2252
|
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
2123
2253
|
"""
|
2124
2254
|
await self.load_markets()
|
2125
|
-
request = {
|
2255
|
+
request: dict = {
|
2126
2256
|
'order_id': id,
|
2127
2257
|
}
|
2128
2258
|
response = await self.privateGetGetUserTradesByOrder(self.extend(request, params))
|
@@ -2159,16 +2289,18 @@ class deribit(Exchange, ImplicitAPI):
|
|
2159
2289
|
# }
|
2160
2290
|
# }
|
2161
2291
|
#
|
2162
|
-
result = self.
|
2292
|
+
result = self.safe_list(response, 'result', [])
|
2163
2293
|
return self.parse_trades(result, None, since, limit)
|
2164
2294
|
|
2165
2295
|
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2166
2296
|
"""
|
2167
2297
|
fetch all trades made by the user
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2298
|
+
|
2299
|
+
https://docs.deribit.com/#private-get_user_trades_by_currency
|
2300
|
+
https://docs.deribit.com/#private-get_user_trades_by_currency_and_time
|
2301
|
+
https://docs.deribit.com/#private-get_user_trades_by_instrument
|
2302
|
+
https://docs.deribit.com/#private-get_user_trades_by_instrument_and_time
|
2303
|
+
|
2172
2304
|
:param str symbol: unified market symbol
|
2173
2305
|
:param int [since]: the earliest time in ms to fetch trades for
|
2174
2306
|
:param int [limit]: the maximum number of trades structures to retrieve
|
@@ -2176,7 +2308,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2176
2308
|
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
2177
2309
|
"""
|
2178
2310
|
await self.load_markets()
|
2179
|
-
request = {
|
2311
|
+
request: dict = {
|
2180
2312
|
'include_old': True,
|
2181
2313
|
}
|
2182
2314
|
market = None
|
@@ -2234,13 +2366,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2234
2366
|
# }
|
2235
2367
|
#
|
2236
2368
|
result = self.safe_value(response, 'result', {})
|
2237
|
-
trades = self.
|
2369
|
+
trades = self.safe_list(result, 'trades', [])
|
2238
2370
|
return self.parse_trades(trades, market, since, limit)
|
2239
2371
|
|
2240
2372
|
async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
2241
2373
|
"""
|
2242
2374
|
fetch all deposits made to an account
|
2243
|
-
|
2375
|
+
|
2376
|
+
https://docs.deribit.com/#private-get_deposits
|
2377
|
+
|
2244
2378
|
:param str code: unified currency code
|
2245
2379
|
:param int [since]: the earliest time in ms to fetch deposits for
|
2246
2380
|
:param int [limit]: the maximum number of deposits structures to retrieve
|
@@ -2251,7 +2385,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2251
2385
|
raise ArgumentsRequired(self.id + ' fetchDeposits() requires a currency code argument')
|
2252
2386
|
await self.load_markets()
|
2253
2387
|
currency = self.currency(code)
|
2254
|
-
request = {
|
2388
|
+
request: dict = {
|
2255
2389
|
'currency': currency['id'],
|
2256
2390
|
}
|
2257
2391
|
if limit is not None:
|
@@ -2278,13 +2412,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2278
2412
|
# }
|
2279
2413
|
#
|
2280
2414
|
result = self.safe_value(response, 'result', {})
|
2281
|
-
data = self.
|
2415
|
+
data = self.safe_list(result, 'data', [])
|
2282
2416
|
return self.parse_transactions(data, currency, since, limit, params)
|
2283
2417
|
|
2284
2418
|
async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
2285
2419
|
"""
|
2286
2420
|
fetch all withdrawals made from an account
|
2287
|
-
|
2421
|
+
|
2422
|
+
https://docs.deribit.com/#private-get_withdrawals
|
2423
|
+
|
2288
2424
|
:param str code: unified currency code
|
2289
2425
|
:param int [since]: the earliest time in ms to fetch withdrawals for
|
2290
2426
|
:param int [limit]: the maximum number of withdrawals structures to retrieve
|
@@ -2295,7 +2431,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2295
2431
|
raise ArgumentsRequired(self.id + ' fetchWithdrawals() requires a currency code argument')
|
2296
2432
|
await self.load_markets()
|
2297
2433
|
currency = self.currency(code)
|
2298
|
-
request = {
|
2434
|
+
request: dict = {
|
2299
2435
|
'currency': currency['id'],
|
2300
2436
|
}
|
2301
2437
|
if limit is not None:
|
@@ -2326,17 +2462,17 @@ class deribit(Exchange, ImplicitAPI):
|
|
2326
2462
|
# }
|
2327
2463
|
#
|
2328
2464
|
result = self.safe_value(response, 'result', {})
|
2329
|
-
data = self.
|
2465
|
+
data = self.safe_list(result, 'data', [])
|
2330
2466
|
return self.parse_transactions(data, currency, since, limit, params)
|
2331
2467
|
|
2332
|
-
def parse_transaction_status(self, status):
|
2333
|
-
statuses = {
|
2468
|
+
def parse_transaction_status(self, status: Str):
|
2469
|
+
statuses: dict = {
|
2334
2470
|
'completed': 'ok',
|
2335
2471
|
'unconfirmed': 'pending',
|
2336
2472
|
}
|
2337
2473
|
return self.safe_string(statuses, status, status)
|
2338
2474
|
|
2339
|
-
def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
|
2475
|
+
def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
|
2340
2476
|
#
|
2341
2477
|
# fetchWithdrawals
|
2342
2478
|
#
|
@@ -2404,7 +2540,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2404
2540
|
'fee': fee,
|
2405
2541
|
}
|
2406
2542
|
|
2407
|
-
def parse_position(self, position, market: Market = None):
|
2543
|
+
def parse_position(self, position: dict, market: Market = None):
|
2408
2544
|
#
|
2409
2545
|
# {
|
2410
2546
|
# "jsonrpc": "2.0",
|
@@ -2473,14 +2609,16 @@ class deribit(Exchange, ImplicitAPI):
|
|
2473
2609
|
async def fetch_position(self, symbol: str, params={}):
|
2474
2610
|
"""
|
2475
2611
|
fetch data on a single open contract trade position
|
2476
|
-
|
2612
|
+
|
2613
|
+
https://docs.deribit.com/#private-get_position
|
2614
|
+
|
2477
2615
|
:param str symbol: unified market symbol of the market the position is held in, default is None
|
2478
2616
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2479
2617
|
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
2480
2618
|
"""
|
2481
2619
|
await self.load_markets()
|
2482
2620
|
market = self.market(symbol)
|
2483
|
-
request = {
|
2621
|
+
request: dict = {
|
2484
2622
|
'instrument_name': market['id'],
|
2485
2623
|
}
|
2486
2624
|
response = await self.privateGetGetPosition(self.extend(request, params))
|
@@ -2510,13 +2648,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2510
2648
|
# }
|
2511
2649
|
# }
|
2512
2650
|
#
|
2513
|
-
result = self.
|
2651
|
+
result = self.safe_dict(response, 'result')
|
2514
2652
|
return self.parse_position(result)
|
2515
2653
|
|
2516
2654
|
async def fetch_positions(self, symbols: Strings = None, params={}):
|
2517
2655
|
"""
|
2518
2656
|
fetch all open positions
|
2519
|
-
|
2657
|
+
|
2658
|
+
https://docs.deribit.com/#private-get_positions
|
2659
|
+
|
2520
2660
|
:param str[]|None symbols: list of unified market symbols
|
2521
2661
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2522
2662
|
:param str [params.kind]: market type filter for positions 'future', 'option', 'spot', 'future_combo' or 'option_combo'
|
@@ -2540,7 +2680,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2540
2680
|
code = settle if (settle is not None) else market['base']
|
2541
2681
|
kind = market['info']['kind']
|
2542
2682
|
currency = self.currency(code)
|
2543
|
-
request = {
|
2683
|
+
request: dict = {
|
2544
2684
|
'currency': currency['id'],
|
2545
2685
|
}
|
2546
2686
|
if kind is not None:
|
@@ -2575,20 +2715,22 @@ class deribit(Exchange, ImplicitAPI):
|
|
2575
2715
|
# ]
|
2576
2716
|
# }
|
2577
2717
|
#
|
2578
|
-
result = self.
|
2718
|
+
result = self.safe_list(response, 'result')
|
2579
2719
|
return self.parse_positions(result, symbols)
|
2580
2720
|
|
2581
2721
|
async def fetch_volatility_history(self, code: str, params={}):
|
2582
2722
|
"""
|
2583
2723
|
fetch the historical volatility of an option market based on an underlying asset
|
2584
|
-
|
2724
|
+
|
2725
|
+
https://docs.deribit.com/#public-get_historical_volatility
|
2726
|
+
|
2585
2727
|
:param str code: unified currency code
|
2586
2728
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2587
2729
|
:returns dict[]: a list of `volatility history objects <https://docs.ccxt.com/#/?id=volatility-structure>`
|
2588
2730
|
"""
|
2589
2731
|
await self.load_markets()
|
2590
2732
|
currency = self.currency(code)
|
2591
|
-
request = {
|
2733
|
+
request: dict = {
|
2592
2734
|
'currency': currency['id'],
|
2593
2735
|
}
|
2594
2736
|
response = await self.publicGetGetHistoricalVolatility(self.extend(request, params))
|
@@ -2636,10 +2778,12 @@ class deribit(Exchange, ImplicitAPI):
|
|
2636
2778
|
})
|
2637
2779
|
return result
|
2638
2780
|
|
2639
|
-
async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
2781
|
+
async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
|
2640
2782
|
"""
|
2641
2783
|
fetch a history of internal transfers made on an account
|
2642
|
-
|
2784
|
+
|
2785
|
+
https://docs.deribit.com/#private-get_transfers
|
2786
|
+
|
2643
2787
|
:param str code: unified currency code of the currency transferred
|
2644
2788
|
:param int [since]: the earliest time in ms to fetch transfers for
|
2645
2789
|
:param int [limit]: the maximum number of transfers structures to retrieve
|
@@ -2650,7 +2794,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2650
2794
|
raise ArgumentsRequired(self.id + ' fetchTransfers() requires a currency code argument')
|
2651
2795
|
await self.load_markets()
|
2652
2796
|
currency = self.currency(code)
|
2653
|
-
request = {
|
2797
|
+
request: dict = {
|
2654
2798
|
'currency': currency['id'],
|
2655
2799
|
}
|
2656
2800
|
if limit is not None:
|
@@ -2690,14 +2834,16 @@ class deribit(Exchange, ImplicitAPI):
|
|
2690
2834
|
# }
|
2691
2835
|
#
|
2692
2836
|
result = self.safe_value(response, 'result', {})
|
2693
|
-
transfers = self.
|
2837
|
+
transfers = self.safe_list(result, 'data', [])
|
2694
2838
|
return self.parse_transfers(transfers, currency, since, limit, params)
|
2695
2839
|
|
2696
2840
|
async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
|
2697
2841
|
"""
|
2698
2842
|
transfer currency internally between wallets on the same account
|
2699
|
-
|
2700
|
-
|
2843
|
+
|
2844
|
+
https://docs.deribit.com/#private-submit_transfer_to_user
|
2845
|
+
https://docs.deribit.com/#private-submit_transfer_to_subaccount
|
2846
|
+
|
2701
2847
|
:param str code: unified currency code
|
2702
2848
|
:param float amount: amount to transfer
|
2703
2849
|
:param str fromAccount: account to transfer from
|
@@ -2707,7 +2853,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2707
2853
|
"""
|
2708
2854
|
await self.load_markets()
|
2709
2855
|
currency = self.currency(code)
|
2710
|
-
request = {
|
2856
|
+
request: dict = {
|
2711
2857
|
'amount': amount,
|
2712
2858
|
'currency': currency['id'],
|
2713
2859
|
'destination': toAccount,
|
@@ -2739,10 +2885,10 @@ class deribit(Exchange, ImplicitAPI):
|
|
2739
2885
|
# }
|
2740
2886
|
# }
|
2741
2887
|
#
|
2742
|
-
result = self.
|
2888
|
+
result = self.safe_dict(response, 'result', {})
|
2743
2889
|
return self.parse_transfer(result, currency)
|
2744
2890
|
|
2745
|
-
def parse_transfer(self, transfer, currency: Currency = None):
|
2891
|
+
def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
|
2746
2892
|
#
|
2747
2893
|
# {
|
2748
2894
|
# "updated_timestamp": 1550232862350,
|
@@ -2766,15 +2912,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2766
2912
|
'id': self.safe_string(transfer, 'id'),
|
2767
2913
|
'status': self.parse_transfer_status(status),
|
2768
2914
|
'amount': self.safe_number(transfer, 'amount'),
|
2769
|
-
'
|
2915
|
+
'currency': self.safe_currency_code(currencyId, currency),
|
2770
2916
|
'fromAccount': direction != account if 'payment' else None,
|
2771
2917
|
'toAccount': direction == account if 'payment' else None,
|
2772
2918
|
'timestamp': timestamp,
|
2773
2919
|
'datetime': self.iso8601(timestamp),
|
2774
2920
|
}
|
2775
2921
|
|
2776
|
-
def parse_transfer_status(self, status):
|
2777
|
-
statuses = {
|
2922
|
+
def parse_transfer_status(self, status: Str) -> Str:
|
2923
|
+
statuses: dict = {
|
2778
2924
|
'prepared': 'pending',
|
2779
2925
|
'confirmed': 'ok',
|
2780
2926
|
'cancelled': 'cancelled',
|
@@ -2782,10 +2928,12 @@ class deribit(Exchange, ImplicitAPI):
|
|
2782
2928
|
}
|
2783
2929
|
return self.safe_string(statuses, status, status)
|
2784
2930
|
|
2785
|
-
async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
|
2931
|
+
async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
|
2786
2932
|
"""
|
2787
2933
|
make a withdrawal
|
2788
|
-
|
2934
|
+
|
2935
|
+
https://docs.deribit.com/#private-withdraw
|
2936
|
+
|
2789
2937
|
:param str code: unified currency code
|
2790
2938
|
:param float amount: the amount to withdraw
|
2791
2939
|
:param str address: the address to withdraw to
|
@@ -2797,7 +2945,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2797
2945
|
self.check_address(address)
|
2798
2946
|
await self.load_markets()
|
2799
2947
|
currency = self.currency(code)
|
2800
|
-
request = {
|
2948
|
+
request: dict = {
|
2801
2949
|
'currency': currency['id'],
|
2802
2950
|
'address': address, # must be in the address book
|
2803
2951
|
'amount': amount,
|
@@ -2838,7 +2986,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
2838
2986
|
async def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
|
2839
2987
|
"""
|
2840
2988
|
fetch deposit and withdraw fees
|
2841
|
-
|
2989
|
+
|
2990
|
+
https://docs.deribit.com/#public-get_currencies
|
2991
|
+
|
2842
2992
|
:param str[]|None codes: list of unified currency codes
|
2843
2993
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2844
2994
|
:returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
|
@@ -2867,13 +3017,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2867
3017
|
# "testnet": True
|
2868
3018
|
# }
|
2869
3019
|
#
|
2870
|
-
data = self.
|
3020
|
+
data = self.safe_list(response, 'result', [])
|
2871
3021
|
return self.parse_deposit_withdraw_fees(data, codes, 'currency')
|
2872
3022
|
|
2873
|
-
async def fetch_funding_rate(self, symbol: str, params={}):
|
3023
|
+
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
2874
3024
|
"""
|
2875
3025
|
fetch the current funding rate
|
2876
|
-
|
3026
|
+
|
3027
|
+
https://docs.deribit.com/#public-get_funding_rate_value
|
3028
|
+
|
2877
3029
|
:param str symbol: unified market symbol
|
2878
3030
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2879
3031
|
:param int [params.start_timestamp]: fetch funding rate starting from self timestamp
|
@@ -2883,7 +3035,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2883
3035
|
await self.load_markets()
|
2884
3036
|
market = self.market(symbol)
|
2885
3037
|
time = self.milliseconds()
|
2886
|
-
request = {
|
3038
|
+
request: dict = {
|
2887
3039
|
'instrument_name': market['id'],
|
2888
3040
|
'start_timestamp': time - (8 * 60 * 60 * 1000), # 8h ago,
|
2889
3041
|
'end_timestamp': time,
|
@@ -2904,8 +3056,12 @@ class deribit(Exchange, ImplicitAPI):
|
|
2904
3056
|
async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2905
3057
|
"""
|
2906
3058
|
fetch the current funding rate
|
2907
|
-
|
3059
|
+
|
3060
|
+
https://docs.deribit.com/#public-get_funding_rate_history
|
3061
|
+
|
2908
3062
|
:param str symbol: unified market symbol
|
3063
|
+
:param int [since]: the earliest time in ms to fetch funding rate history for
|
3064
|
+
:param int [limit]: the maximum number of entries to retrieve
|
2909
3065
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2910
3066
|
:param int [params.end_timestamp]: fetch funding rate ending at self timestamp
|
2911
3067
|
: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 +3077,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2921
3077
|
month = 30 * 24 * 60 * 60 * 1000
|
2922
3078
|
if since is None:
|
2923
3079
|
since = time - month
|
2924
|
-
request = {
|
3080
|
+
request: dict = {
|
2925
3081
|
'instrument_name': market['id'],
|
2926
3082
|
'start_timestamp': since - 1,
|
2927
3083
|
'end_timestamp': time,
|
@@ -2950,7 +3106,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2950
3106
|
rates.append(rate)
|
2951
3107
|
return self.filter_by_symbol_since_limit(rates, symbol, since, limit)
|
2952
3108
|
|
2953
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
3109
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
2954
3110
|
#
|
2955
3111
|
# {
|
2956
3112
|
# "jsonrpc":"2.0",
|
@@ -2990,12 +3146,15 @@ class deribit(Exchange, ImplicitAPI):
|
|
2990
3146
|
'previousFundingRate': None,
|
2991
3147
|
'previousFundingTimestamp': None,
|
2992
3148
|
'previousFundingDatetime': None,
|
3149
|
+
'interval': '8h',
|
2993
3150
|
}
|
2994
3151
|
|
2995
3152
|
async def fetch_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
|
2996
3153
|
"""
|
2997
3154
|
retrieves the public liquidations of a trading pair
|
2998
|
-
|
3155
|
+
|
3156
|
+
https://docs.deribit.com/#public-get_last_settlements_by_currency
|
3157
|
+
|
2999
3158
|
:param str symbol: unified CCXT market symbol
|
3000
3159
|
:param int [since]: the earliest time in ms to fetch liquidations for
|
3001
3160
|
:param int [limit]: the maximum number of liquidation structures to retrieve
|
@@ -3011,7 +3170,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3011
3170
|
market = self.market(symbol)
|
3012
3171
|
if market['spot']:
|
3013
3172
|
raise NotSupported(self.id + ' fetchLiquidations() does not support ' + market['type'] + ' markets')
|
3014
|
-
request = {
|
3173
|
+
request: dict = {
|
3015
3174
|
'instrument_name': market['id'],
|
3016
3175
|
'type': 'bankruptcy',
|
3017
3176
|
}
|
@@ -3065,7 +3224,9 @@ class deribit(Exchange, ImplicitAPI):
|
|
3065
3224
|
async def fetch_my_liquidations(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3066
3225
|
"""
|
3067
3226
|
retrieves the users liquidated positions
|
3068
|
-
|
3227
|
+
|
3228
|
+
https://docs.deribit.com/#private-get_settlement_history_by_instrument
|
3229
|
+
|
3069
3230
|
:param str symbol: unified CCXT market symbol
|
3070
3231
|
:param int [since]: the earliest time in ms to fetch liquidations for
|
3071
3232
|
:param int [limit]: the maximum number of liquidation structures to retrieve
|
@@ -3078,7 +3239,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3078
3239
|
market = self.market(symbol)
|
3079
3240
|
if market['spot']:
|
3080
3241
|
raise NotSupported(self.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' markets')
|
3081
|
-
request = {
|
3242
|
+
request: dict = {
|
3082
3243
|
'instrument_name': market['id'],
|
3083
3244
|
'type': 'bankruptcy',
|
3084
3245
|
}
|
@@ -3112,7 +3273,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3112
3273
|
# }
|
3113
3274
|
#
|
3114
3275
|
result = self.safe_value(response, 'result', {})
|
3115
|
-
settlements = self.
|
3276
|
+
settlements = self.safe_list(result, 'settlements', [])
|
3116
3277
|
return self.parse_liquidations(settlements, market, since, limit)
|
3117
3278
|
|
3118
3279
|
def parse_liquidation(self, liquidation, market: Market = None):
|
@@ -3144,14 +3305,16 @@ class deribit(Exchange, ImplicitAPI):
|
|
3144
3305
|
async def fetch_greeks(self, symbol: str, params={}) -> Greeks:
|
3145
3306
|
"""
|
3146
3307
|
fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
3147
|
-
|
3308
|
+
|
3309
|
+
https://docs.deribit.com/#public-ticker
|
3310
|
+
|
3148
3311
|
:param str symbol: unified symbol of the market to fetch greeks for
|
3149
3312
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3150
3313
|
:returns dict: a `greeks structure <https://docs.ccxt.com/#/?id=greeks-structure>`
|
3151
3314
|
"""
|
3152
3315
|
await self.load_markets()
|
3153
3316
|
market = self.market(symbol)
|
3154
|
-
request = {
|
3317
|
+
request: dict = {
|
3155
3318
|
'instrument_name': market['id'],
|
3156
3319
|
}
|
3157
3320
|
response = await self.publicGetTicker(self.extend(request, params))
|
@@ -3204,7 +3367,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3204
3367
|
result = self.safe_value(response, 'result', {})
|
3205
3368
|
return self.parse_greeks(result, market)
|
3206
3369
|
|
3207
|
-
def parse_greeks(self, greeks, market: Market = None):
|
3370
|
+
def parse_greeks(self, greeks: dict, market: Market = None) -> Greeks:
|
3208
3371
|
#
|
3209
3372
|
# {
|
3210
3373
|
# "estimated_delivery_price": 36552.72,
|
@@ -3270,6 +3433,159 @@ class deribit(Exchange, ImplicitAPI):
|
|
3270
3433
|
'info': greeks,
|
3271
3434
|
}
|
3272
3435
|
|
3436
|
+
async def fetch_option(self, symbol: str, params={}) -> Option:
|
3437
|
+
"""
|
3438
|
+
fetches option data that is commonly found in an option chain
|
3439
|
+
|
3440
|
+
https://docs.deribit.com/#public-get_book_summary_by_instrument
|
3441
|
+
|
3442
|
+
:param str symbol: unified market symbol
|
3443
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3444
|
+
:returns dict: an `option chain structure <https://docs.ccxt.com/#/?id=option-chain-structure>`
|
3445
|
+
"""
|
3446
|
+
await self.load_markets()
|
3447
|
+
market = self.market(symbol)
|
3448
|
+
request: dict = {
|
3449
|
+
'instrument_name': market['id'],
|
3450
|
+
}
|
3451
|
+
response = await self.publicGetGetBookSummaryByInstrument(self.extend(request, params))
|
3452
|
+
#
|
3453
|
+
# {
|
3454
|
+
# "jsonrpc": "2.0",
|
3455
|
+
# "result": [
|
3456
|
+
# {
|
3457
|
+
# "mid_price": 0.04025,
|
3458
|
+
# "volume_usd": 11045.12,
|
3459
|
+
# "quote_currency": "BTC",
|
3460
|
+
# "estimated_delivery_price": 65444.72,
|
3461
|
+
# "creation_timestamp": 1711100949273,
|
3462
|
+
# "base_currency": "BTC",
|
3463
|
+
# "underlying_index": "BTC-27DEC24",
|
3464
|
+
# "underlying_price": 73742.14,
|
3465
|
+
# "volume": 4.0,
|
3466
|
+
# "interest_rate": 0.0,
|
3467
|
+
# "price_change": -6.9767,
|
3468
|
+
# "open_interest": 274.2,
|
3469
|
+
# "ask_price": 0.042,
|
3470
|
+
# "bid_price": 0.0385,
|
3471
|
+
# "instrument_name": "BTC-27DEC24-240000-C",
|
3472
|
+
# "mark_price": 0.04007735,
|
3473
|
+
# "last": 0.04,
|
3474
|
+
# "low": 0.04,
|
3475
|
+
# "high": 0.043
|
3476
|
+
# }
|
3477
|
+
# ],
|
3478
|
+
# "usIn": 1711100949273223,
|
3479
|
+
# "usOut": 1711100949273580,
|
3480
|
+
# "usDiff": 357,
|
3481
|
+
# "testnet": False
|
3482
|
+
# }
|
3483
|
+
#
|
3484
|
+
result = self.safe_list(response, 'result', [])
|
3485
|
+
chain = self.safe_dict(result, 0, {})
|
3486
|
+
return self.parse_option(chain, None, market)
|
3487
|
+
|
3488
|
+
async def fetch_option_chain(self, code: str, params={}) -> OptionChain:
|
3489
|
+
"""
|
3490
|
+
fetches data for an underlying asset that is commonly found in an option chain
|
3491
|
+
|
3492
|
+
https://docs.deribit.com/#public-get_book_summary_by_currency
|
3493
|
+
|
3494
|
+
:param str code: base currency to fetch an option chain for
|
3495
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3496
|
+
:returns dict: a list of `option chain structures <https://docs.ccxt.com/#/?id=option-chain-structure>`
|
3497
|
+
"""
|
3498
|
+
await self.load_markets()
|
3499
|
+
currency = self.currency(code)
|
3500
|
+
request: dict = {
|
3501
|
+
'currency': currency['id'],
|
3502
|
+
'kind': 'option',
|
3503
|
+
}
|
3504
|
+
response = await self.publicGetGetBookSummaryByCurrency(self.extend(request, params))
|
3505
|
+
#
|
3506
|
+
# {
|
3507
|
+
# "jsonrpc": "2.0",
|
3508
|
+
# "result": [
|
3509
|
+
# {
|
3510
|
+
# "mid_price": 0.4075,
|
3511
|
+
# "volume_usd": 2836.83,
|
3512
|
+
# "quote_currency": "BTC",
|
3513
|
+
# "estimated_delivery_price": 65479.26,
|
3514
|
+
# "creation_timestamp": 1711101594477,
|
3515
|
+
# "base_currency": "BTC",
|
3516
|
+
# "underlying_index": "BTC-28JUN24",
|
3517
|
+
# "underlying_price": 68827.27,
|
3518
|
+
# "volume": 0.1,
|
3519
|
+
# "interest_rate": 0.0,
|
3520
|
+
# "price_change": 0.0,
|
3521
|
+
# "open_interest": 364.1,
|
3522
|
+
# "ask_price": 0.411,
|
3523
|
+
# "bid_price": 0.404,
|
3524
|
+
# "instrument_name": "BTC-28JUN24-42000-C",
|
3525
|
+
# "mark_price": 0.40752052,
|
3526
|
+
# "last": 0.423,
|
3527
|
+
# "low": 0.423,
|
3528
|
+
# "high": 0.423
|
3529
|
+
# }
|
3530
|
+
# ],
|
3531
|
+
# "usIn": 1711101594456388,
|
3532
|
+
# "usOut": 1711101594484065,
|
3533
|
+
# "usDiff": 27677,
|
3534
|
+
# "testnet": False
|
3535
|
+
# }
|
3536
|
+
#
|
3537
|
+
result = self.safe_list(response, 'result', [])
|
3538
|
+
return self.parse_option_chain(result, 'base_currency', 'instrument_name')
|
3539
|
+
|
3540
|
+
def parse_option(self, chain: dict, currency: Currency = None, market: Market = None) -> Option:
|
3541
|
+
#
|
3542
|
+
# {
|
3543
|
+
# "mid_price": 0.04025,
|
3544
|
+
# "volume_usd": 11045.12,
|
3545
|
+
# "quote_currency": "BTC",
|
3546
|
+
# "estimated_delivery_price": 65444.72,
|
3547
|
+
# "creation_timestamp": 1711100949273,
|
3548
|
+
# "base_currency": "BTC",
|
3549
|
+
# "underlying_index": "BTC-27DEC24",
|
3550
|
+
# "underlying_price": 73742.14,
|
3551
|
+
# "volume": 4.0,
|
3552
|
+
# "interest_rate": 0.0,
|
3553
|
+
# "price_change": -6.9767,
|
3554
|
+
# "open_interest": 274.2,
|
3555
|
+
# "ask_price": 0.042,
|
3556
|
+
# "bid_price": 0.0385,
|
3557
|
+
# "instrument_name": "BTC-27DEC24-240000-C",
|
3558
|
+
# "mark_price": 0.04007735,
|
3559
|
+
# "last": 0.04,
|
3560
|
+
# "low": 0.04,
|
3561
|
+
# "high": 0.043
|
3562
|
+
# }
|
3563
|
+
#
|
3564
|
+
marketId = self.safe_string(chain, 'instrument_name')
|
3565
|
+
market = self.safe_market(marketId, market)
|
3566
|
+
currencyId = self.safe_string(chain, 'base_currency')
|
3567
|
+
code = self.safe_currency_code(currencyId, currency)
|
3568
|
+
timestamp = self.safe_integer(chain, 'timestamp')
|
3569
|
+
return {
|
3570
|
+
'info': chain,
|
3571
|
+
'currency': code,
|
3572
|
+
'symbol': market['symbol'],
|
3573
|
+
'timestamp': timestamp,
|
3574
|
+
'datetime': self.iso8601(timestamp),
|
3575
|
+
'impliedVolatility': None,
|
3576
|
+
'openInterest': self.safe_number(chain, 'open_interest'),
|
3577
|
+
'bidPrice': self.safe_number(chain, 'bid_price'),
|
3578
|
+
'askPrice': self.safe_number(chain, 'ask_price'),
|
3579
|
+
'midPrice': self.safe_number(chain, 'mid_price'),
|
3580
|
+
'markPrice': self.safe_number(chain, 'mark_price'),
|
3581
|
+
'lastPrice': self.safe_number(chain, 'last'),
|
3582
|
+
'underlyingPrice': self.safe_number(chain, 'underlying_price'),
|
3583
|
+
'change': None,
|
3584
|
+
'percentage': self.safe_number(chain, 'price_change'),
|
3585
|
+
'baseVolume': self.safe_number(chain, 'volume'),
|
3586
|
+
'quoteVolume': self.safe_number(chain, 'volume_usd'),
|
3587
|
+
}
|
3588
|
+
|
3273
3589
|
def nonce(self):
|
3274
3590
|
return self.milliseconds()
|
3275
3591
|
|
@@ -3294,7 +3610,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3294
3610
|
url = self.urls['api']['rest'] + request
|
3295
3611
|
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
3296
3612
|
|
3297
|
-
def handle_errors(self, httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody):
|
3613
|
+
def handle_errors(self, httpCode: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
|
3298
3614
|
if not response:
|
3299
3615
|
return None # fallback to default error handler
|
3300
3616
|
#
|