ccxt 4.2.76__py2.py3-none-any.whl → 4.4.48__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccxt/__init__.py +36 -14
- ccxt/abstract/alpaca.py +4 -0
- ccxt/abstract/bigone.py +1 -1
- ccxt/abstract/binance.py +112 -48
- ccxt/abstract/binancecoinm.py +112 -48
- ccxt/abstract/binanceus.py +147 -83
- ccxt/abstract/binanceusdm.py +112 -48
- ccxt/abstract/bingx.py +133 -78
- ccxt/abstract/bitbank.py +5 -0
- ccxt/abstract/bitfinex.py +136 -65
- ccxt/abstract/bitfinex1.py +69 -0
- ccxt/abstract/bitflyer.py +1 -0
- ccxt/abstract/bitget.py +8 -1
- ccxt/abstract/bitmart.py +13 -1
- ccxt/abstract/bitopro.py +1 -0
- ccxt/abstract/bitpanda.py +0 -12
- ccxt/abstract/bitrue.py +3 -3
- ccxt/abstract/bitstamp.py +26 -3
- ccxt/abstract/blofin.py +24 -0
- ccxt/abstract/btcbox.py +1 -0
- ccxt/abstract/bybit.py +29 -14
- ccxt/abstract/cex.py +28 -29
- ccxt/abstract/coinbase.py +6 -0
- ccxt/abstract/coinbaseadvanced.py +94 -0
- ccxt/abstract/{coinbasepro.py → coinbaseexchange.py} +1 -0
- ccxt/abstract/coinbaseinternational.py +1 -1
- ccxt/abstract/coincatch.py +94 -0
- ccxt/abstract/coinex.py +233 -123
- ccxt/abstract/coinmetro.py +1 -0
- ccxt/abstract/cryptocom.py +14 -0
- ccxt/abstract/defx.py +69 -0
- ccxt/abstract/deribit.py +1 -0
- ccxt/abstract/digifinex.py +1 -0
- ccxt/abstract/ellipx.py +25 -0
- ccxt/abstract/gate.py +20 -0
- ccxt/abstract/gateio.py +20 -0
- ccxt/abstract/gemini.py +1 -0
- ccxt/abstract/hashkey.py +67 -0
- ccxt/abstract/hyperliquid.py +1 -1
- ccxt/abstract/independentreserve.py +6 -0
- ccxt/abstract/kraken.py +4 -3
- ccxt/abstract/krakenfutures.py +4 -0
- ccxt/abstract/kucoin.py +25 -0
- ccxt/abstract/kucoinfutures.py +35 -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 +3513 -1511
- 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 +3105 -881
- 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 +239 -50
- ccxt/async_support/bitget.py +1513 -563
- ccxt/async_support/bithumb.py +201 -67
- 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 +403 -150
- 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 +2326 -1255
- ccxt/async_support/cex.py +1409 -1329
- ccxt/async_support/coinbase.py +1455 -288
- ccxt/async_support/coinbaseadvanced.py +17 -0
- ccxt/async_support/{coinbasepro.py → coinbaseexchange.py} +233 -99
- ccxt/async_support/coinbaseinternational.py +428 -88
- ccxt/async_support/coincatch.py +5152 -0
- ccxt/async_support/coincheck.py +121 -38
- ccxt/async_support/coinex.py +4020 -3339
- ccxt/async_support/coinlist.py +273 -116
- ccxt/async_support/coinmate.py +204 -97
- ccxt/async_support/coinmetro.py +203 -110
- ccxt/async_support/coinone.py +142 -68
- ccxt/async_support/coinsph.py +206 -89
- ccxt/async_support/coinspot.py +137 -62
- ccxt/async_support/cryptocom.py +515 -185
- ccxt/async_support/currencycom.py +203 -85
- ccxt/async_support/defx.py +2066 -0
- ccxt/async_support/delta.py +467 -158
- ccxt/async_support/deribit.py +558 -324
- ccxt/async_support/digifinex.py +340 -223
- ccxt/async_support/ellipx.py +1826 -0
- ccxt/async_support/exmo.py +259 -128
- ccxt/async_support/gate.py +1473 -464
- ccxt/async_support/gemini.py +206 -84
- ccxt/async_support/hashkey.py +4164 -0
- ccxt/async_support/hitbtc.py +334 -178
- ccxt/async_support/hollaex.py +134 -83
- ccxt/async_support/htx.py +1095 -563
- ccxt/async_support/huobijp.py +105 -56
- ccxt/async_support/hyperliquid.py +1634 -269
- ccxt/async_support/idex.py +148 -95
- ccxt/async_support/independentreserve.py +236 -31
- ccxt/async_support/indodax.py +165 -62
- ccxt/async_support/kraken.py +871 -354
- ccxt/async_support/krakenfutures.py +324 -100
- ccxt/async_support/kucoin.py +1050 -355
- ccxt/async_support/kucoinfutures.py +1004 -149
- ccxt/async_support/kuna.py +138 -106
- ccxt/async_support/latoken.py +135 -79
- ccxt/async_support/lbank.py +290 -113
- ccxt/async_support/luno.py +112 -62
- ccxt/async_support/lykke.py +104 -55
- ccxt/async_support/mercado.py +36 -29
- ccxt/async_support/mexc.py +995 -429
- ccxt/async_support/myokx.py +43 -0
- ccxt/async_support/ndax.py +163 -82
- ccxt/async_support/novadax.py +121 -75
- ccxt/async_support/oceanex.py +175 -59
- ccxt/async_support/okcoin.py +222 -163
- ccxt/async_support/okx.py +1777 -455
- ccxt/async_support/onetrading.py +132 -414
- ccxt/async_support/oxfun.py +2832 -0
- ccxt/async_support/p2b.py +79 -51
- ccxt/async_support/paradex.py +2017 -0
- ccxt/async_support/paymium.py +56 -32
- ccxt/async_support/phemex.py +572 -196
- ccxt/async_support/poloniex.py +218 -95
- ccxt/async_support/poloniexfutures.py +260 -92
- ccxt/async_support/probit.py +143 -110
- ccxt/async_support/timex.py +123 -70
- ccxt/async_support/tokocrypto.py +129 -93
- ccxt/async_support/tradeogre.py +39 -25
- ccxt/async_support/upbit.py +322 -113
- ccxt/async_support/vertex.py +2983 -0
- ccxt/async_support/wavesexchange.py +227 -173
- ccxt/async_support/wazirx.py +145 -65
- ccxt/async_support/whitebit.py +533 -138
- ccxt/async_support/woo.py +1155 -295
- 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 +1729 -482
- 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 +3513 -1511
- ccxt/binancecoinm.py +2 -1
- ccxt/binanceus.py +12 -1
- ccxt/binanceusdm.py +3 -1
- ccxt/bingx.py +3105 -881
- 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 +239 -50
- ccxt/bitget.py +1513 -563
- ccxt/bithumb.py +200 -67
- 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 +403 -150
- ccxt/btcalpha.py +161 -55
- ccxt/btcbox.py +250 -34
- ccxt/btcmarkets.py +232 -85
- ccxt/btcturk.py +159 -60
- ccxt/bybit.py +2326 -1255
- ccxt/cex.py +1408 -1329
- ccxt/coinbase.py +1455 -288
- ccxt/coinbaseadvanced.py +17 -0
- ccxt/{coinbasepro.py → coinbaseexchange.py} +233 -99
- ccxt/coinbaseinternational.py +428 -88
- ccxt/coincatch.py +5152 -0
- ccxt/coincheck.py +121 -38
- ccxt/coinex.py +4020 -3339
- ccxt/coinlist.py +273 -116
- ccxt/coinmate.py +204 -97
- ccxt/coinmetro.py +203 -110
- ccxt/coinone.py +142 -68
- ccxt/coinsph.py +206 -89
- ccxt/coinspot.py +137 -62
- ccxt/cryptocom.py +515 -185
- ccxt/currencycom.py +203 -85
- ccxt/defx.py +2065 -0
- ccxt/delta.py +467 -158
- ccxt/deribit.py +558 -324
- ccxt/digifinex.py +340 -223
- ccxt/ellipx.py +1826 -0
- ccxt/exmo.py +259 -128
- ccxt/gate.py +1473 -464
- ccxt/gemini.py +206 -84
- ccxt/hashkey.py +4164 -0
- ccxt/hitbtc.py +334 -178
- ccxt/hollaex.py +134 -83
- ccxt/htx.py +1095 -563
- ccxt/huobijp.py +105 -56
- ccxt/hyperliquid.py +1633 -269
- ccxt/idex.py +148 -95
- ccxt/independentreserve.py +235 -31
- ccxt/indodax.py +165 -62
- ccxt/kraken.py +871 -354
- ccxt/krakenfutures.py +324 -100
- ccxt/kucoin.py +1050 -355
- ccxt/kucoinfutures.py +1004 -149
- ccxt/kuna.py +138 -106
- ccxt/latoken.py +135 -79
- ccxt/lbank.py +290 -113
- ccxt/luno.py +112 -62
- ccxt/lykke.py +104 -55
- ccxt/mercado.py +36 -29
- ccxt/mexc.py +994 -429
- ccxt/myokx.py +43 -0
- ccxt/ndax.py +163 -82
- ccxt/novadax.py +121 -75
- ccxt/oceanex.py +175 -59
- ccxt/okcoin.py +222 -163
- ccxt/okx.py +1777 -455
- ccxt/onetrading.py +132 -414
- ccxt/oxfun.py +2831 -0
- ccxt/p2b.py +79 -51
- ccxt/paradex.py +2017 -0
- ccxt/paymium.py +56 -32
- ccxt/phemex.py +572 -196
- ccxt/poloniex.py +218 -95
- ccxt/poloniexfutures.py +260 -92
- ccxt/pro/__init__.py +29 -5
- ccxt/pro/alpaca.py +32 -17
- ccxt/pro/ascendex.py +63 -15
- ccxt/pro/bequant.py +4 -0
- ccxt/pro/binance.py +1596 -329
- ccxt/pro/binancecoinm.py +1 -0
- ccxt/pro/binanceus.py +2 -9
- ccxt/pro/binanceusdm.py +2 -0
- ccxt/pro/bingx.py +527 -134
- ccxt/pro/bitcoincom.py +4 -1
- ccxt/pro/bitfinex.py +731 -266
- ccxt/pro/bitfinex1.py +635 -0
- ccxt/pro/bitget.py +726 -357
- ccxt/pro/bithumb.py +380 -0
- ccxt/pro/bitmart.py +138 -39
- ccxt/pro/bitmex.py +199 -40
- ccxt/pro/bitopro.py +25 -13
- ccxt/pro/bitrue.py +31 -32
- ccxt/pro/bitstamp.py +7 -6
- ccxt/pro/bitvavo.py +204 -82
- 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 +967 -661
- 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 +168 -32
- ccxt/pro/exmo.py +253 -21
- 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 +93 -34
- ccxt/pro/poloniex.py +129 -50
- ccxt/pro/poloniexfutures.py +53 -32
- ccxt/pro/probit.py +93 -86
- 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 +486 -70
- 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} +465 -407
- ccxt/test/tests_helpers.py +285 -0
- ccxt/test/tests_init.py +39 -0
- ccxt/test/{test_sync.py → tests_sync.py} +465 -409
- 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 +1155 -295
- ccxt/woofipro.py +2716 -0
- ccxt/xt.py +4627 -0
- ccxt/yobit.py +159 -92
- ccxt/zaif.py +80 -33
- ccxt/zonda.py +140 -69
- ccxt-4.4.48.dist-info/LICENSE.txt +21 -0
- ccxt-4.4.48.dist-info/METADATA +646 -0
- ccxt-4.4.48.dist-info/RECORD +669 -0
- {ccxt-4.2.76.dist-info → ccxt-4.4.48.dist-info}/WHEEL +1 -1
- ccxt/abstract/bitbay.py +0 -47
- ccxt/abstract/bitfinex2.py +0 -139
- ccxt/abstract/hitbtc3.py +0 -115
- ccxt/async_support/bitbay.py +0 -17
- ccxt/async_support/bitfinex2.py +0 -3496
- ccxt/async_support/flowbtc.py +0 -34
- ccxt/bitbay.py +0 -17
- ccxt/bitfinex2.py +0 -3496
- ccxt/flowbtc.py +0 -34
- ccxt/hitbtc3.py +0 -16
- ccxt/pro/bitfinex2.py +0 -1081
- ccxt/test/base/__init__.py +0 -28
- ccxt/test/base/test_account.py +0 -26
- ccxt/test/base/test_balance.py +0 -56
- ccxt/test/base/test_borrow_interest.py +0 -35
- ccxt/test/base/test_borrow_rate.py +0 -32
- ccxt/test/base/test_calculate_fee.py +0 -51
- ccxt/test/base/test_crypto.py +0 -127
- ccxt/test/base/test_currency.py +0 -76
- ccxt/test/base/test_datetime.py +0 -103
- ccxt/test/base/test_decimal_to_precision.py +0 -392
- ccxt/test/base/test_deep_extend.py +0 -68
- ccxt/test/base/test_deposit_withdrawal.py +0 -50
- ccxt/test/base/test_exchange_datetime_functions.py +0 -76
- ccxt/test/base/test_funding_rate_history.py +0 -29
- ccxt/test/base/test_last_price.py +0 -32
- ccxt/test/base/test_ledger_entry.py +0 -45
- ccxt/test/base/test_ledger_item.py +0 -48
- ccxt/test/base/test_leverage_tier.py +0 -33
- ccxt/test/base/test_margin_mode.py +0 -24
- ccxt/test/base/test_margin_modification.py +0 -35
- ccxt/test/base/test_market.py +0 -190
- ccxt/test/base/test_number.py +0 -411
- ccxt/test/base/test_ohlcv.py +0 -32
- ccxt/test/base/test_open_interest.py +0 -32
- ccxt/test/base/test_order.py +0 -64
- ccxt/test/base/test_order_book.py +0 -63
- ccxt/test/base/test_position.py +0 -60
- ccxt/test/base/test_shared_methods.py +0 -345
- ccxt/test/base/test_status.py +0 -24
- ccxt/test/base/test_throttle.py +0 -126
- ccxt/test/base/test_ticker.py +0 -86
- ccxt/test/base/test_trade.py +0 -47
- ccxt/test/base/test_trading_fee.py +0 -26
- ccxt/test/base/test_transaction.py +0 -39
- ccxt-4.2.76.dist-info/METADATA +0 -626
- ccxt-4.2.76.dist-info/RECORD +0 -534
- {ccxt-4.2.76.dist-info → ccxt-4.4.48.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,2017 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
4
|
+
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
5
|
+
|
6
|
+
from ccxt.async_support.base.exchange import Exchange
|
7
|
+
from ccxt.abstract.paradex import ImplicitAPI
|
8
|
+
from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
|
9
|
+
from typing import List
|
10
|
+
from ccxt.base.errors import ExchangeError
|
11
|
+
from ccxt.base.errors import AuthenticationError
|
12
|
+
from ccxt.base.errors import PermissionDenied
|
13
|
+
from ccxt.base.errors import ArgumentsRequired
|
14
|
+
from ccxt.base.errors import BadRequest
|
15
|
+
from ccxt.base.errors import OperationRejected
|
16
|
+
from ccxt.base.errors import InvalidOrder
|
17
|
+
from ccxt.base.decimal_to_precision import TICK_SIZE
|
18
|
+
from ccxt.base.precise import Precise
|
19
|
+
|
20
|
+
|
21
|
+
class paradex(Exchange, ImplicitAPI):
|
22
|
+
|
23
|
+
def describe(self):
|
24
|
+
return self.deep_extend(super(paradex, self).describe(), {
|
25
|
+
'id': 'paradex',
|
26
|
+
'name': 'Paradex',
|
27
|
+
'countries': [],
|
28
|
+
'version': 'v1',
|
29
|
+
'rateLimit': 50,
|
30
|
+
'certified': False,
|
31
|
+
'pro': True,
|
32
|
+
'dex': True,
|
33
|
+
'has': {
|
34
|
+
'CORS': None,
|
35
|
+
'spot': False,
|
36
|
+
'margin': False,
|
37
|
+
'swap': True,
|
38
|
+
'future': False,
|
39
|
+
'option': False,
|
40
|
+
'addMargin': False,
|
41
|
+
'borrowCrossMargin': False,
|
42
|
+
'borrowIsolatedMargin': False,
|
43
|
+
'cancelAllOrders': True,
|
44
|
+
'cancelAllOrdersAfter': False,
|
45
|
+
'cancelOrder': False,
|
46
|
+
'cancelOrders': False,
|
47
|
+
'cancelOrdersForSymbols': False,
|
48
|
+
'closeAllPositions': False,
|
49
|
+
'closePosition': False,
|
50
|
+
'createMarketBuyOrderWithCost': False,
|
51
|
+
'createMarketOrderWithCost': False,
|
52
|
+
'createMarketSellOrderWithCost': False,
|
53
|
+
'createOrder': True,
|
54
|
+
'createOrders': False,
|
55
|
+
'createReduceOnlyOrder': False,
|
56
|
+
'createStopOrder': True,
|
57
|
+
'createTriggerOrder': True,
|
58
|
+
'editOrder': False,
|
59
|
+
'fetchAccounts': False,
|
60
|
+
'fetchBalance': True,
|
61
|
+
'fetchBorrowInterest': False,
|
62
|
+
'fetchBorrowRateHistories': False,
|
63
|
+
'fetchBorrowRateHistory': False,
|
64
|
+
'fetchCanceledOrders': False,
|
65
|
+
'fetchClosedOrders': False,
|
66
|
+
'fetchCrossBorrowRate': False,
|
67
|
+
'fetchCrossBorrowRates': False,
|
68
|
+
'fetchCurrencies': False,
|
69
|
+
'fetchDepositAddress': False,
|
70
|
+
'fetchDepositAddresses': False,
|
71
|
+
'fetchDeposits': True,
|
72
|
+
'fetchDepositWithdrawFee': False,
|
73
|
+
'fetchDepositWithdrawFees': False,
|
74
|
+
'fetchFundingHistory': False,
|
75
|
+
'fetchFundingRate': False,
|
76
|
+
'fetchFundingRateHistory': False,
|
77
|
+
'fetchFundingRates': False,
|
78
|
+
'fetchIndexOHLCV': False,
|
79
|
+
'fetchIsolatedBorrowRate': False,
|
80
|
+
'fetchIsolatedBorrowRates': False,
|
81
|
+
'fetchLedger': False,
|
82
|
+
'fetchLeverage': False,
|
83
|
+
'fetchLeverageTiers': False,
|
84
|
+
'fetchLiquidations': True,
|
85
|
+
'fetchMarginMode': None,
|
86
|
+
'fetchMarketLeverageTiers': False,
|
87
|
+
'fetchMarkets': True,
|
88
|
+
'fetchMarkOHLCV': False,
|
89
|
+
'fetchMyLiquidations': False,
|
90
|
+
'fetchMyTrades': True,
|
91
|
+
'fetchOHLCV': True,
|
92
|
+
'fetchOpenInterest': True,
|
93
|
+
'fetchOpenInterestHistory': False,
|
94
|
+
'fetchOpenOrders': True,
|
95
|
+
'fetchOrder': True,
|
96
|
+
'fetchOrderBook': True,
|
97
|
+
'fetchOrders': True,
|
98
|
+
'fetchOrderTrades': False,
|
99
|
+
'fetchPosition': True,
|
100
|
+
'fetchPositionMode': False,
|
101
|
+
'fetchPositions': True,
|
102
|
+
'fetchPositionsRisk': False,
|
103
|
+
'fetchPremiumIndexOHLCV': False,
|
104
|
+
'fetchStatus': True,
|
105
|
+
'fetchTicker': True,
|
106
|
+
'fetchTickers': True,
|
107
|
+
'fetchTime': True,
|
108
|
+
'fetchTrades': True,
|
109
|
+
'fetchTradingFee': False,
|
110
|
+
'fetchTradingFees': False,
|
111
|
+
'fetchTransfer': False,
|
112
|
+
'fetchTransfers': False,
|
113
|
+
'fetchWithdrawal': False,
|
114
|
+
'fetchWithdrawals': True,
|
115
|
+
'reduceMargin': False,
|
116
|
+
'repayCrossMargin': False,
|
117
|
+
'repayIsolatedMargin': False,
|
118
|
+
'sandbox': True,
|
119
|
+
'setLeverage': False,
|
120
|
+
'setMarginMode': False,
|
121
|
+
'setPositionMode': False,
|
122
|
+
'transfer': False,
|
123
|
+
'withdraw': False,
|
124
|
+
},
|
125
|
+
'timeframes': {
|
126
|
+
'1m': 1,
|
127
|
+
'3m': 3,
|
128
|
+
'5m': 5,
|
129
|
+
'15m': 15,
|
130
|
+
'30m': 30,
|
131
|
+
'1h': 60,
|
132
|
+
},
|
133
|
+
'hostname': 'paradex.trade',
|
134
|
+
'urls': {
|
135
|
+
'logo': 'https://github.com/user-attachments/assets/84628770-784e-4ec4-a759-ec2fbb2244ea',
|
136
|
+
'api': {
|
137
|
+
'v1': 'https://api.prod.{hostname}/v1',
|
138
|
+
},
|
139
|
+
'test': {
|
140
|
+
'v1': 'https://api.testnet.{hostname}/v1',
|
141
|
+
},
|
142
|
+
'www': 'https://www.paradex.trade/',
|
143
|
+
'doc': 'https://docs.api.testnet.paradex.trade/',
|
144
|
+
'fees': 'https://docs.paradex.trade/getting-started/trading-fees',
|
145
|
+
'referral': 'https://app.paradex.trade/r/ccxt24',
|
146
|
+
},
|
147
|
+
'api': {
|
148
|
+
'public': {
|
149
|
+
'get': {
|
150
|
+
'bbo/{market}': 1,
|
151
|
+
'funding/data': 1,
|
152
|
+
'markets': 1,
|
153
|
+
'markets/klines': 1,
|
154
|
+
'markets/summary': 1,
|
155
|
+
'orderbook/{market}': 1,
|
156
|
+
'insurance': 1,
|
157
|
+
'referrals/config': 1,
|
158
|
+
'system/config': 1,
|
159
|
+
'system/state': 1,
|
160
|
+
'system/time': 1,
|
161
|
+
'trades': 1,
|
162
|
+
},
|
163
|
+
},
|
164
|
+
'private': {
|
165
|
+
'get': {
|
166
|
+
'account': 1,
|
167
|
+
'account/profile': 1,
|
168
|
+
'balance': 1,
|
169
|
+
'fills': 1,
|
170
|
+
'funding/payments': 1,
|
171
|
+
'positions': 1,
|
172
|
+
'tradebusts': 1,
|
173
|
+
'transactions': 1,
|
174
|
+
'liquidations': 1,
|
175
|
+
'orders': 1,
|
176
|
+
'orders-history': 1,
|
177
|
+
'orders/by_client_id/{client_id}': 1,
|
178
|
+
'orders/{order_id}': 1,
|
179
|
+
'points_data/{market}/{program}': 1,
|
180
|
+
'referrals/summary': 1,
|
181
|
+
'transfers': 1,
|
182
|
+
},
|
183
|
+
'post': {
|
184
|
+
'account/profile/referral_code': 1,
|
185
|
+
'account/profile/username': 1,
|
186
|
+
'auth': 1,
|
187
|
+
'onboarding': 1,
|
188
|
+
'orders': 1,
|
189
|
+
},
|
190
|
+
'delete': {
|
191
|
+
'orders': 1,
|
192
|
+
'orders/by_client_id/{client_id}': 1,
|
193
|
+
'orders/{order_id}': 1,
|
194
|
+
},
|
195
|
+
},
|
196
|
+
},
|
197
|
+
'fees': {
|
198
|
+
'swap': {
|
199
|
+
'taker': self.parse_number('0.0002'),
|
200
|
+
'maker': self.parse_number('0.0002'),
|
201
|
+
},
|
202
|
+
'spot': {
|
203
|
+
'taker': self.parse_number('0.0002'),
|
204
|
+
'maker': self.parse_number('0.0002'),
|
205
|
+
},
|
206
|
+
},
|
207
|
+
'requiredCredentials': {
|
208
|
+
'apiKey': False,
|
209
|
+
'secret': False,
|
210
|
+
'walletAddress': True,
|
211
|
+
'privateKey': True,
|
212
|
+
},
|
213
|
+
'exceptions': {
|
214
|
+
'exact': {
|
215
|
+
'VALIDATION_ERROR': AuthenticationError,
|
216
|
+
'BINDING_ERROR': OperationRejected,
|
217
|
+
'INTERNAL_ERROR': ExchangeError,
|
218
|
+
'NOT_FOUND': BadRequest,
|
219
|
+
'SERVICE_UNAVAILABLE': ExchangeError,
|
220
|
+
'INVALID_REQUEST_PARAMETER': BadRequest,
|
221
|
+
'ORDER_ID_NOT_FOUND': InvalidOrder,
|
222
|
+
'ORDER_IS_CLOSED': InvalidOrder,
|
223
|
+
'ORDER_IS_NOT_OPEN_YET': InvalidOrder,
|
224
|
+
'CLIENT_ORDER_ID_NOT_FOUND': InvalidOrder,
|
225
|
+
'DUPLICATED_CLIENT_ID': InvalidOrder,
|
226
|
+
'INVALID_PRICE_PRECISION': OperationRejected,
|
227
|
+
'INVALID_SYMBOL': OperationRejected,
|
228
|
+
'INVALID_TOKEN': OperationRejected,
|
229
|
+
'INVALID_ETHEREUM_ADDRESS': OperationRejected,
|
230
|
+
'INVALID_ETHEREUM_SIGNATURE': OperationRejected,
|
231
|
+
'INVALID_STARKNET_ADDRESS': OperationRejected,
|
232
|
+
'INVALID_STARKNET_SIGNATURE': OperationRejected,
|
233
|
+
'STARKNET_SIGNATURE_VERIFICATION_FAILED': AuthenticationError,
|
234
|
+
'BAD_STARKNET_REQUEST': BadRequest,
|
235
|
+
'ETHEREUM_SIGNER_MISMATCH': BadRequest,
|
236
|
+
'ETHEREUM_HASH_MISMATCH': BadRequest,
|
237
|
+
'NOT_ONBOARDED': BadRequest,
|
238
|
+
'INVALID_TIMESTAMP': BadRequest,
|
239
|
+
'INVALID_SIGNATURE_EXPIRATION': AuthenticationError,
|
240
|
+
'ACCOUNT_NOT_FOUND': AuthenticationError,
|
241
|
+
'INVALID_ORDER_SIGNATURE': AuthenticationError,
|
242
|
+
'PUBLIC_KEY_INVALID': BadRequest,
|
243
|
+
'UNAUTHORIZED_ETHEREUM_ADDRESS': BadRequest,
|
244
|
+
'ETHEREUM_ADDRESS_ALREADY_ONBOARDED': BadRequest,
|
245
|
+
'MARKET_NOT_FOUND': BadRequest,
|
246
|
+
'ALLOWLIST_ENTRY_NOT_FOUND': BadRequest,
|
247
|
+
'USERNAME_IN_USE': AuthenticationError,
|
248
|
+
'GEO_IP_BLOCK': PermissionDenied,
|
249
|
+
'ETHEREUM_ADDRESS_BLOCKED': PermissionDenied,
|
250
|
+
'PROGRAM_NOT_FOUND': BadRequest,
|
251
|
+
'INVALID_DASHBOARD': OperationRejected,
|
252
|
+
'MARKET_NOT_OPEN': BadRequest,
|
253
|
+
'INVALID_REFERRAL_CODE': OperationRejected,
|
254
|
+
'PARENT_ADDRESS_ALREADY_ONBOARDED': BadRequest,
|
255
|
+
'INVALID_PARENT_ACCOUNT': OperationRejected,
|
256
|
+
'INVALID_VAULT_OPERATOR_CHAIN': OperationRejected,
|
257
|
+
'VAULT_OPERATOR_ALREADY_ONBOARDED': OperationRejected,
|
258
|
+
'VAULT_NAME_IN_USE': OperationRejected,
|
259
|
+
'BATCH_SIZE_OUT_OF_RANGE': OperationRejected,
|
260
|
+
'ISOLATED_MARKET_ACCOUNT_MISMATCH': OperationRejected,
|
261
|
+
'POINTS_SUMMARY_NOT_FOUND': OperationRejected,
|
262
|
+
'-32700': BadRequest, # Parse error
|
263
|
+
'-32600': BadRequest, # Invalid request
|
264
|
+
'-32601': BadRequest, # Method not found
|
265
|
+
'-32602': BadRequest, # Invalid parameterss
|
266
|
+
'-32603': ExchangeError, # Internal error
|
267
|
+
'100': BadRequest, # Method error
|
268
|
+
'40110': AuthenticationError, # Malformed Bearer Token
|
269
|
+
'40111': AuthenticationError, # Invalid Bearer Token
|
270
|
+
'40112': PermissionDenied, # Geo IP blocked
|
271
|
+
},
|
272
|
+
'broad': {
|
273
|
+
'missing or malformed jwt': AuthenticationError,
|
274
|
+
},
|
275
|
+
},
|
276
|
+
'precisionMode': TICK_SIZE,
|
277
|
+
'commonCurrencies': {
|
278
|
+
},
|
279
|
+
'options': {
|
280
|
+
'paradexAccount': None, # add {"privateKey": A, "publicKey": B, "address": C}
|
281
|
+
'broker': 'CCXT',
|
282
|
+
},
|
283
|
+
})
|
284
|
+
|
285
|
+
async def fetch_time(self, params={}):
|
286
|
+
"""
|
287
|
+
fetches the current integer timestamp in milliseconds from the exchange server
|
288
|
+
|
289
|
+
https://docs.api.testnet.paradex.trade/#get-system-time-unix-milliseconds
|
290
|
+
|
291
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
292
|
+
:returns int: the current integer timestamp in milliseconds from the exchange server
|
293
|
+
"""
|
294
|
+
response = await self.publicGetSystemTime(params)
|
295
|
+
#
|
296
|
+
# {
|
297
|
+
# "server_time": "1681493415023"
|
298
|
+
# }
|
299
|
+
#
|
300
|
+
return self.safe_integer(response, 'server_time')
|
301
|
+
|
302
|
+
async def fetch_status(self, params={}):
|
303
|
+
"""
|
304
|
+
the latest known information on the availability of the exchange API
|
305
|
+
|
306
|
+
https://docs.api.testnet.paradex.trade/#get-system-state
|
307
|
+
|
308
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
309
|
+
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
|
310
|
+
"""
|
311
|
+
response = await self.publicGetSystemState(params)
|
312
|
+
#
|
313
|
+
# {
|
314
|
+
# "status": "ok"
|
315
|
+
# }
|
316
|
+
#
|
317
|
+
status = self.safe_string(response, 'status')
|
318
|
+
return {
|
319
|
+
'status': 'ok' if (status == 'ok') else 'maintenance',
|
320
|
+
'updated': None,
|
321
|
+
'eta': None,
|
322
|
+
'url': None,
|
323
|
+
'info': response,
|
324
|
+
}
|
325
|
+
|
326
|
+
async def fetch_markets(self, params={}) -> List[Market]:
|
327
|
+
"""
|
328
|
+
retrieves data on all markets for bitget
|
329
|
+
|
330
|
+
https://docs.api.testnet.paradex.trade/#list-available-markets
|
331
|
+
|
332
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
333
|
+
:returns dict[]: an array of objects representing market data
|
334
|
+
"""
|
335
|
+
response = await self.publicGetMarkets(params)
|
336
|
+
#
|
337
|
+
# {
|
338
|
+
# "results": [
|
339
|
+
# {
|
340
|
+
# "symbol": "BODEN-USD-PERP",
|
341
|
+
# "base_currency": "BODEN",
|
342
|
+
# "quote_currency": "USD",
|
343
|
+
# "settlement_currency": "USDC",
|
344
|
+
# "order_size_increment": "1",
|
345
|
+
# "price_tick_size": "0.00001",
|
346
|
+
# "min_notional": "200",
|
347
|
+
# "open_at": 1717065600000,
|
348
|
+
# "expiry_at": 0,
|
349
|
+
# "asset_kind": "PERP",
|
350
|
+
# "position_limit": "2000000",
|
351
|
+
# "price_bands_width": "0.2",
|
352
|
+
# "max_open_orders": 50,
|
353
|
+
# "max_funding_rate": "0.05",
|
354
|
+
# "delta1_cross_margin_params": {
|
355
|
+
# "imf_base": "0.2",
|
356
|
+
# "imf_shift": "180000",
|
357
|
+
# "imf_factor": "0.00071",
|
358
|
+
# "mmf_factor": "0.5"
|
359
|
+
# },
|
360
|
+
# "price_feed_id": "9LScEHse1ioZt2rUuhwiN6bmYnqpMqvZkQJDNUpxVHN5",
|
361
|
+
# "oracle_ewma_factor": "0.14999987905913592",
|
362
|
+
# "max_order_size": "520000",
|
363
|
+
# "max_funding_rate_change": "0.0005",
|
364
|
+
# "max_tob_spread": "0.2"
|
365
|
+
# }
|
366
|
+
# ]
|
367
|
+
# }
|
368
|
+
#
|
369
|
+
data = self.safe_list(response, 'results')
|
370
|
+
return self.parse_markets(data)
|
371
|
+
|
372
|
+
def parse_market(self, market: dict) -> Market:
|
373
|
+
#
|
374
|
+
# {
|
375
|
+
# "symbol": "BODEN-USD-PERP",
|
376
|
+
# "base_currency": "BODEN",
|
377
|
+
# "quote_currency": "USD",
|
378
|
+
# "settlement_currency": "USDC",
|
379
|
+
# "order_size_increment": "1",
|
380
|
+
# "price_tick_size": "0.00001",
|
381
|
+
# "min_notional": "200",
|
382
|
+
# "open_at": 1717065600000,
|
383
|
+
# "expiry_at": 0,
|
384
|
+
# "asset_kind": "PERP",
|
385
|
+
# "position_limit": "2000000",
|
386
|
+
# "price_bands_width": "0.2",
|
387
|
+
# "max_open_orders": 50,
|
388
|
+
# "max_funding_rate": "0.05",
|
389
|
+
# "delta1_cross_margin_params": {
|
390
|
+
# "imf_base": "0.2",
|
391
|
+
# "imf_shift": "180000",
|
392
|
+
# "imf_factor": "0.00071",
|
393
|
+
# "mmf_factor": "0.5"
|
394
|
+
# },
|
395
|
+
# "price_feed_id": "9LScEHse1ioZt2rUuhwiN6bmYnqpMqvZkQJDNUpxVHN5",
|
396
|
+
# "oracle_ewma_factor": "0.14999987905913592",
|
397
|
+
# "max_order_size": "520000",
|
398
|
+
# "max_funding_rate_change": "0.0005",
|
399
|
+
# "max_tob_spread": "0.2"
|
400
|
+
# }
|
401
|
+
#
|
402
|
+
marketId = self.safe_string(market, 'symbol')
|
403
|
+
quoteId = self.safe_string(market, 'quote_currency')
|
404
|
+
baseId = self.safe_string(market, 'base_currency')
|
405
|
+
quote = self.safe_currency_code(quoteId)
|
406
|
+
base = self.safe_currency_code(baseId)
|
407
|
+
settleId = self.safe_string(market, 'settlement_currency')
|
408
|
+
settle = self.safe_currency_code(settleId)
|
409
|
+
symbol = base + '/' + quote + ':' + settle
|
410
|
+
expiry = self.safe_integer(market, 'expiry_at')
|
411
|
+
takerFee = self.parse_number('0.0003')
|
412
|
+
makerFee = self.parse_number('-0.00005')
|
413
|
+
return self.safe_market_structure({
|
414
|
+
'id': marketId,
|
415
|
+
'symbol': symbol,
|
416
|
+
'base': base,
|
417
|
+
'quote': quote,
|
418
|
+
'settle': settle,
|
419
|
+
'baseId': baseId,
|
420
|
+
'quoteId': quoteId,
|
421
|
+
'settleId': settleId,
|
422
|
+
'type': 'swap',
|
423
|
+
'spot': False,
|
424
|
+
'margin': None,
|
425
|
+
'swap': True,
|
426
|
+
'future': False,
|
427
|
+
'option': False,
|
428
|
+
'active': self.safe_bool(market, 'enableTrading'),
|
429
|
+
'contract': True,
|
430
|
+
'linear': True,
|
431
|
+
'inverse': None,
|
432
|
+
'taker': takerFee,
|
433
|
+
'maker': makerFee,
|
434
|
+
'contractSize': self.parse_number('1'),
|
435
|
+
'expiry': None if (expiry == 0) else expiry,
|
436
|
+
'expiryDatetime': None if (expiry == 0) else self.iso8601(expiry),
|
437
|
+
'strike': None,
|
438
|
+
'optionType': None,
|
439
|
+
'precision': {
|
440
|
+
'amount': self.safe_number(market, 'order_size_increment'),
|
441
|
+
'price': self.safe_number(market, 'price_tick_size'),
|
442
|
+
},
|
443
|
+
'limits': {
|
444
|
+
'leverage': {
|
445
|
+
'min': None,
|
446
|
+
'max': None,
|
447
|
+
},
|
448
|
+
'amount': {
|
449
|
+
'min': None,
|
450
|
+
'max': self.safe_number(market, 'max_order_size'),
|
451
|
+
},
|
452
|
+
'price': {
|
453
|
+
'min': None,
|
454
|
+
'max': None,
|
455
|
+
},
|
456
|
+
'cost': {
|
457
|
+
'min': self.safe_number(market, 'min_notional'),
|
458
|
+
'max': None,
|
459
|
+
},
|
460
|
+
},
|
461
|
+
'created': None,
|
462
|
+
'info': market,
|
463
|
+
})
|
464
|
+
|
465
|
+
async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
466
|
+
"""
|
467
|
+
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
468
|
+
|
469
|
+
https://docs.api.testnet.paradex.trade/#ohlcv-for-a-symbol
|
470
|
+
|
471
|
+
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
472
|
+
:param str timeframe: the length of time each candle represents
|
473
|
+
:param int [since]: timestamp in ms of the earliest candle to fetch
|
474
|
+
:param int [limit]: the maximum amount of candles to fetch
|
475
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
476
|
+
:param int [params.until]: timestamp in ms of the latest candle to fetch
|
477
|
+
:returns int[][]: A list of candles ordered, open, high, low, close, volume
|
478
|
+
"""
|
479
|
+
await self.load_markets()
|
480
|
+
market = self.market(symbol)
|
481
|
+
request: dict = {
|
482
|
+
'resolution': self.safe_string(self.timeframes, timeframe, timeframe),
|
483
|
+
'symbol': market['id'],
|
484
|
+
}
|
485
|
+
now = self.milliseconds()
|
486
|
+
duration = self.parse_timeframe(timeframe)
|
487
|
+
until = self.safe_integer_2(params, 'until', 'till', now)
|
488
|
+
params = self.omit(params, ['until', 'till'])
|
489
|
+
if since is not None:
|
490
|
+
request['start_at'] = since
|
491
|
+
if limit is not None:
|
492
|
+
request['end_at'] = self.sum(since, duration * (limit + 1) * 1000) - 1
|
493
|
+
else:
|
494
|
+
request['end_at'] = until
|
495
|
+
else:
|
496
|
+
request['end_at'] = until
|
497
|
+
if limit is not None:
|
498
|
+
request['start_at'] = until - duration * (limit + 1) * 1000 + 1
|
499
|
+
else:
|
500
|
+
request['start_at'] = until - duration * 101 * 1000 + 1
|
501
|
+
response = await self.publicGetMarketsKlines(self.extend(request, params))
|
502
|
+
#
|
503
|
+
# {
|
504
|
+
# "results": [
|
505
|
+
# [
|
506
|
+
# 1720071900000,
|
507
|
+
# 58961.3,
|
508
|
+
# 58961.3,
|
509
|
+
# 58961.3,
|
510
|
+
# 58961.3,
|
511
|
+
# 1591
|
512
|
+
# ]
|
513
|
+
# ]
|
514
|
+
# }
|
515
|
+
#
|
516
|
+
data = self.safe_list(response, 'results', [])
|
517
|
+
return self.parse_ohlcvs(data, market, timeframe, since, limit)
|
518
|
+
|
519
|
+
def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
|
520
|
+
#
|
521
|
+
# [
|
522
|
+
# 1720071900000,
|
523
|
+
# 58961.3,
|
524
|
+
# 58961.3,
|
525
|
+
# 58961.3,
|
526
|
+
# 58961.3,
|
527
|
+
# 1591
|
528
|
+
# ]
|
529
|
+
#
|
530
|
+
return [
|
531
|
+
self.safe_integer(ohlcv, 0),
|
532
|
+
self.safe_number(ohlcv, 1),
|
533
|
+
self.safe_number(ohlcv, 2),
|
534
|
+
self.safe_number(ohlcv, 3),
|
535
|
+
self.safe_number(ohlcv, 4),
|
536
|
+
self.safe_number(ohlcv, 5),
|
537
|
+
]
|
538
|
+
|
539
|
+
async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
540
|
+
"""
|
541
|
+
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
542
|
+
|
543
|
+
https://docs.api.testnet.paradex.trade/#list-available-markets-summary
|
544
|
+
|
545
|
+
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
546
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
547
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
548
|
+
"""
|
549
|
+
await self.load_markets()
|
550
|
+
symbols = self.market_symbols(symbols)
|
551
|
+
request: dict = {}
|
552
|
+
if symbols is not None:
|
553
|
+
if isinstance(symbols, list):
|
554
|
+
request['market'] = self.market_id(symbols[0])
|
555
|
+
else:
|
556
|
+
request['market'] = self.market_id(symbols)
|
557
|
+
else:
|
558
|
+
request['market'] = 'ALL'
|
559
|
+
response = await self.publicGetMarketsSummary(self.extend(request, params))
|
560
|
+
#
|
561
|
+
# {
|
562
|
+
# "results": [
|
563
|
+
# {
|
564
|
+
# "symbol": "BTC-USD-PERP",
|
565
|
+
# "oracle_price": "68465.17449906",
|
566
|
+
# "mark_price": "68465.17449906",
|
567
|
+
# "last_traded_price": "68495.1",
|
568
|
+
# "bid": "68477.6",
|
569
|
+
# "ask": "69578.2",
|
570
|
+
# "volume_24h": "5815541.397939004",
|
571
|
+
# "total_volume": "584031465.525259686",
|
572
|
+
# "created_at": 1718170156580,
|
573
|
+
# "underlying_price": "67367.37268422",
|
574
|
+
# "open_interest": "162.272",
|
575
|
+
# "funding_rate": "0.01629574927887",
|
576
|
+
# "price_change_rate_24h": "0.009032"
|
577
|
+
# }
|
578
|
+
# ]
|
579
|
+
# }
|
580
|
+
#
|
581
|
+
data = self.safe_list(response, 'results', [])
|
582
|
+
return self.parse_tickers(data, symbols)
|
583
|
+
|
584
|
+
async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
585
|
+
"""
|
586
|
+
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
587
|
+
|
588
|
+
https://docs.api.testnet.paradex.trade/#list-available-markets-summary
|
589
|
+
|
590
|
+
:param str symbol: unified symbol of the market to fetch the ticker for
|
591
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
592
|
+
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
593
|
+
"""
|
594
|
+
await self.load_markets()
|
595
|
+
market = self.market(symbol)
|
596
|
+
request: dict = {
|
597
|
+
'market': market['id'],
|
598
|
+
}
|
599
|
+
response = await self.publicGetMarketsSummary(self.extend(request, params))
|
600
|
+
#
|
601
|
+
# {
|
602
|
+
# "results": [
|
603
|
+
# {
|
604
|
+
# "symbol": "BTC-USD-PERP",
|
605
|
+
# "oracle_price": "68465.17449906",
|
606
|
+
# "mark_price": "68465.17449906",
|
607
|
+
# "last_traded_price": "68495.1",
|
608
|
+
# "bid": "68477.6",
|
609
|
+
# "ask": "69578.2",
|
610
|
+
# "volume_24h": "5815541.397939004",
|
611
|
+
# "total_volume": "584031465.525259686",
|
612
|
+
# "created_at": 1718170156580,
|
613
|
+
# "underlying_price": "67367.37268422",
|
614
|
+
# "open_interest": "162.272",
|
615
|
+
# "funding_rate": "0.01629574927887",
|
616
|
+
# "price_change_rate_24h": "0.009032"
|
617
|
+
# }
|
618
|
+
# ]
|
619
|
+
# }
|
620
|
+
#
|
621
|
+
data = self.safe_list(response, 'results', [])
|
622
|
+
ticker = self.safe_dict(data, 0, {})
|
623
|
+
return self.parse_ticker(ticker, market)
|
624
|
+
|
625
|
+
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
626
|
+
#
|
627
|
+
# {
|
628
|
+
# "symbol": "BTC-USD-PERP",
|
629
|
+
# "oracle_price": "68465.17449906",
|
630
|
+
# "mark_price": "68465.17449906",
|
631
|
+
# "last_traded_price": "68495.1",
|
632
|
+
# "bid": "68477.6",
|
633
|
+
# "ask": "69578.2",
|
634
|
+
# "volume_24h": "5815541.397939004",
|
635
|
+
# "total_volume": "584031465.525259686",
|
636
|
+
# "created_at": 1718170156580,
|
637
|
+
# "underlying_price": "67367.37268422",
|
638
|
+
# "open_interest": "162.272",
|
639
|
+
# "funding_rate": "0.01629574927887",
|
640
|
+
# "price_change_rate_24h": "0.009032"
|
641
|
+
# }
|
642
|
+
#
|
643
|
+
percentage = self.safe_string(ticker, 'price_change_rate_24h')
|
644
|
+
if percentage is not None:
|
645
|
+
percentage = Precise.string_mul(percentage, '100')
|
646
|
+
last = self.safe_string(ticker, 'last_traded_price')
|
647
|
+
marketId = self.safe_string(ticker, 'symbol')
|
648
|
+
market = self.safe_market(marketId, market)
|
649
|
+
symbol = market['symbol']
|
650
|
+
timestamp = self.safe_integer(ticker, 'created_at')
|
651
|
+
return self.safe_ticker({
|
652
|
+
'symbol': symbol,
|
653
|
+
'timestamp': timestamp,
|
654
|
+
'datetime': self.iso8601(timestamp),
|
655
|
+
'high': None,
|
656
|
+
'low': None,
|
657
|
+
'bid': self.safe_string(ticker, 'bid'),
|
658
|
+
'bidVolume': None,
|
659
|
+
'ask': self.safe_string(ticker, 'ask'),
|
660
|
+
'askVolume': None,
|
661
|
+
'vwap': None,
|
662
|
+
'open': None,
|
663
|
+
'close': last,
|
664
|
+
'last': last,
|
665
|
+
'previousClose': None,
|
666
|
+
'change': None,
|
667
|
+
'percentage': percentage,
|
668
|
+
'average': None,
|
669
|
+
'baseVolume': None,
|
670
|
+
'quoteVolume': self.safe_string(ticker, 'volume_24h'),
|
671
|
+
'markPrice': self.safe_string(ticker, 'mark_price'),
|
672
|
+
'info': ticker,
|
673
|
+
}, market)
|
674
|
+
|
675
|
+
async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
676
|
+
"""
|
677
|
+
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
678
|
+
|
679
|
+
https://docs.api.testnet.paradex.trade/#get-market-orderbook
|
680
|
+
|
681
|
+
:param str symbol: unified symbol of the market to fetch the order book for
|
682
|
+
:param int [limit]: the maximum amount of order book entries to return
|
683
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
684
|
+
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
|
685
|
+
"""
|
686
|
+
await self.load_markets()
|
687
|
+
market = self.market(symbol)
|
688
|
+
request: dict = {'market': market['id']}
|
689
|
+
response = await self.publicGetOrderbookMarket(self.extend(request, params))
|
690
|
+
#
|
691
|
+
# {
|
692
|
+
# "market": "BTC-USD-PERP",
|
693
|
+
# "seq_no": 14115975,
|
694
|
+
# "last_updated_at": 1718172538340,
|
695
|
+
# "asks": [
|
696
|
+
# [
|
697
|
+
# "69578.2",
|
698
|
+
# "3.019"
|
699
|
+
# ]
|
700
|
+
# ],
|
701
|
+
# "bids": [
|
702
|
+
# [
|
703
|
+
# "68477.6",
|
704
|
+
# "0.1"
|
705
|
+
# ]
|
706
|
+
# ]
|
707
|
+
# }
|
708
|
+
#
|
709
|
+
if limit is not None:
|
710
|
+
request['depth'] = limit
|
711
|
+
timestamp = self.safe_integer(response, 'last_updated_at')
|
712
|
+
orderbook = self.parse_order_book(response, market['symbol'], timestamp)
|
713
|
+
orderbook['nonce'] = self.safe_integer(response, 'seq_no')
|
714
|
+
return orderbook
|
715
|
+
|
716
|
+
async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
717
|
+
"""
|
718
|
+
get the list of most recent trades for a particular symbol
|
719
|
+
|
720
|
+
https://docs.api.testnet.paradex.trade/#trade-tape
|
721
|
+
|
722
|
+
:param str symbol: unified symbol of the market to fetch trades for
|
723
|
+
:param int [since]: timestamp in ms of the earliest trade to fetch
|
724
|
+
:param int [limit]: the maximum amount of trades to fetch
|
725
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
726
|
+
:param int [params.until]: the latest time in ms to fetch trades for
|
727
|
+
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times
|
728
|
+
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
|
729
|
+
"""
|
730
|
+
await self.load_markets()
|
731
|
+
paginate = False
|
732
|
+
paginate, params = self.handle_option_and_params(params, 'fetchTrades', 'paginate')
|
733
|
+
if paginate:
|
734
|
+
return await self.fetch_paginated_call_cursor('fetchTrades', symbol, since, limit, params, 'next', 'cursor', None, 100)
|
735
|
+
market = self.market(symbol)
|
736
|
+
request: dict = {
|
737
|
+
'market': market['id'],
|
738
|
+
}
|
739
|
+
if limit is not None:
|
740
|
+
request['page_size'] = limit
|
741
|
+
if since is not None:
|
742
|
+
request['start_at'] = since
|
743
|
+
request, params = self.handle_until_option('end_at', request, params)
|
744
|
+
response = await self.publicGetTrades(self.extend(request, params))
|
745
|
+
#
|
746
|
+
# {
|
747
|
+
# "next": "...",
|
748
|
+
# "prev": "...",
|
749
|
+
# "results": [
|
750
|
+
# {
|
751
|
+
# "id": "1718154353750201703989430001",
|
752
|
+
# "market": "BTC-USD-PERP",
|
753
|
+
# "side": "BUY",
|
754
|
+
# "size": "0.026",
|
755
|
+
# "price": "69578.2",
|
756
|
+
# "created_at": 1718154353750,
|
757
|
+
# "trade_type": "FILL"
|
758
|
+
# }
|
759
|
+
# ]
|
760
|
+
# }
|
761
|
+
#
|
762
|
+
trades = self.safe_list(response, 'results', [])
|
763
|
+
for i in range(0, len(trades)):
|
764
|
+
trades[i]['next'] = self.safe_string(response, 'next')
|
765
|
+
return self.parse_trades(trades, market, since, limit)
|
766
|
+
|
767
|
+
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
768
|
+
#
|
769
|
+
# fetchTrades(public)
|
770
|
+
#
|
771
|
+
# {
|
772
|
+
# "id": "1718154353750201703989430001",
|
773
|
+
# "market": "BTC-USD-PERP",
|
774
|
+
# "side": "BUY",
|
775
|
+
# "size": "0.026",
|
776
|
+
# "price": "69578.2",
|
777
|
+
# "created_at": 1718154353750,
|
778
|
+
# "trade_type": "FILL"
|
779
|
+
# }
|
780
|
+
#
|
781
|
+
# fetchMyTrades(private)
|
782
|
+
#
|
783
|
+
# {
|
784
|
+
# "id": "1718947571560201703986670001",
|
785
|
+
# "side": "BUY",
|
786
|
+
# "liquidity": "TAKER",
|
787
|
+
# "market": "BTC-USD-PERP",
|
788
|
+
# "order_id": "1718947571540201703992340000",
|
789
|
+
# "price": "64852.9",
|
790
|
+
# "size": "0.01",
|
791
|
+
# "fee": "0.1945587",
|
792
|
+
# "fee_currency": "USDC",
|
793
|
+
# "created_at": 1718947571569,
|
794
|
+
# "remaining_size": "0",
|
795
|
+
# "client_id": "",
|
796
|
+
# "fill_type": "FILL"
|
797
|
+
# }
|
798
|
+
#
|
799
|
+
marketId = self.safe_string(trade, 'market')
|
800
|
+
market = self.safe_market(marketId, market)
|
801
|
+
id = self.safe_string(trade, 'id')
|
802
|
+
timestamp = self.safe_integer(trade, 'created_at')
|
803
|
+
priceString = self.safe_string(trade, 'price')
|
804
|
+
amountString = self.safe_string(trade, 'size')
|
805
|
+
side = self.safe_string_lower(trade, 'side')
|
806
|
+
liability = self.safe_string_lower(trade, 'liquidity', 'taker')
|
807
|
+
isTaker = liability == 'taker'
|
808
|
+
takerOrMaker = 'taker' if (isTaker) else 'maker'
|
809
|
+
currencyId = self.safe_string(trade, 'fee_currency')
|
810
|
+
code = self.safe_currency_code(currencyId)
|
811
|
+
return self.safe_trade({
|
812
|
+
'info': trade,
|
813
|
+
'id': id,
|
814
|
+
'order': self.safe_string(trade, 'order_id'),
|
815
|
+
'timestamp': timestamp,
|
816
|
+
'datetime': self.iso8601(timestamp),
|
817
|
+
'symbol': market['symbol'],
|
818
|
+
'type': None,
|
819
|
+
'takerOrMaker': takerOrMaker,
|
820
|
+
'side': side,
|
821
|
+
'price': priceString,
|
822
|
+
'amount': amountString,
|
823
|
+
'cost': None,
|
824
|
+
'fee': {
|
825
|
+
'cost': self.safe_string(trade, 'fee'),
|
826
|
+
'currency': code,
|
827
|
+
'rate': None,
|
828
|
+
},
|
829
|
+
}, market)
|
830
|
+
|
831
|
+
async def fetch_open_interest(self, symbol: str, params={}):
|
832
|
+
"""
|
833
|
+
retrieves the open interest of a contract trading pair
|
834
|
+
|
835
|
+
https://docs.api.testnet.paradex.trade/#list-available-markets-summary
|
836
|
+
|
837
|
+
:param str symbol: unified CCXT market symbol
|
838
|
+
:param dict [params]: exchange specific parameters
|
839
|
+
:returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
|
840
|
+
"""
|
841
|
+
await self.load_markets()
|
842
|
+
market = self.market(symbol)
|
843
|
+
if not market['contract']:
|
844
|
+
raise BadRequest(self.id + ' fetchOpenInterest() supports contract markets only')
|
845
|
+
request: dict = {
|
846
|
+
'market': market['id'],
|
847
|
+
}
|
848
|
+
response = await self.publicGetMarketsSummary(self.extend(request, params))
|
849
|
+
#
|
850
|
+
# {
|
851
|
+
# "results": [
|
852
|
+
# {
|
853
|
+
# "symbol": "BTC-USD-PERP",
|
854
|
+
# "oracle_price": "68465.17449906",
|
855
|
+
# "mark_price": "68465.17449906",
|
856
|
+
# "last_traded_price": "68495.1",
|
857
|
+
# "bid": "68477.6",
|
858
|
+
# "ask": "69578.2",
|
859
|
+
# "volume_24h": "5815541.397939004",
|
860
|
+
# "total_volume": "584031465.525259686",
|
861
|
+
# "created_at": 1718170156580,
|
862
|
+
# "underlying_price": "67367.37268422",
|
863
|
+
# "open_interest": "162.272",
|
864
|
+
# "funding_rate": "0.01629574927887",
|
865
|
+
# "price_change_rate_24h": "0.009032"
|
866
|
+
# }
|
867
|
+
# ]
|
868
|
+
# }
|
869
|
+
#
|
870
|
+
data = self.safe_list(response, 'results', [])
|
871
|
+
interest = self.safe_dict(data, 0, {})
|
872
|
+
return self.parse_open_interest(interest, market)
|
873
|
+
|
874
|
+
def parse_open_interest(self, interest, market: Market = None):
|
875
|
+
#
|
876
|
+
# {
|
877
|
+
# "symbol": "BTC-USD-PERP",
|
878
|
+
# "oracle_price": "68465.17449906",
|
879
|
+
# "mark_price": "68465.17449906",
|
880
|
+
# "last_traded_price": "68495.1",
|
881
|
+
# "bid": "68477.6",
|
882
|
+
# "ask": "69578.2",
|
883
|
+
# "volume_24h": "5815541.397939004",
|
884
|
+
# "total_volume": "584031465.525259686",
|
885
|
+
# "created_at": 1718170156580,
|
886
|
+
# "underlying_price": "67367.37268422",
|
887
|
+
# "open_interest": "162.272",
|
888
|
+
# "funding_rate": "0.01629574927887",
|
889
|
+
# "price_change_rate_24h": "0.009032"
|
890
|
+
# }
|
891
|
+
#
|
892
|
+
timestamp = self.safe_integer(interest, 'created_at')
|
893
|
+
marketId = self.safe_string(interest, 'symbol')
|
894
|
+
market = self.safe_market(marketId, market)
|
895
|
+
symbol = market['symbol']
|
896
|
+
return self.safe_open_interest({
|
897
|
+
'symbol': symbol,
|
898
|
+
'openInterestAmount': self.safe_string(interest, 'open_interest'),
|
899
|
+
'openInterestValue': None,
|
900
|
+
'timestamp': timestamp,
|
901
|
+
'datetime': self.iso8601(timestamp),
|
902
|
+
'info': interest,
|
903
|
+
}, market)
|
904
|
+
|
905
|
+
def hash_message(self, message):
|
906
|
+
return '0x' + self.hash(message, 'keccak', 'hex')
|
907
|
+
|
908
|
+
def sign_hash(self, hash, privateKey):
|
909
|
+
signature = self.ecdsa(hash[-64:], privateKey[-64:], 'secp256k1', None)
|
910
|
+
r = signature['r']
|
911
|
+
s = signature['s']
|
912
|
+
v = self.int_to_base16(self.sum(27, signature['v']))
|
913
|
+
return '0x' + r.rjust(64, '0') + s.rjust(64, '0') + v
|
914
|
+
|
915
|
+
def sign_message(self, message, privateKey):
|
916
|
+
return self.sign_hash(self.hash_message(message), privateKey[-64:])
|
917
|
+
|
918
|
+
async def get_system_config(self):
|
919
|
+
cachedConfig: dict = self.safe_dict(self.options, 'systemConfig')
|
920
|
+
if cachedConfig is not None:
|
921
|
+
return cachedConfig
|
922
|
+
response = await self.publicGetSystemConfig()
|
923
|
+
#
|
924
|
+
# {
|
925
|
+
# "starknet_gateway_url": "https://potc-testnet-sepolia.starknet.io",
|
926
|
+
# "starknet_fullnode_rpc_url": "https://pathfinder.api.testnet.paradex.trade/rpc/v0_7",
|
927
|
+
# "starknet_chain_id": "PRIVATE_SN_POTC_SEPOLIA",
|
928
|
+
# "block_explorer_url": "https://voyager.testnet.paradex.trade/",
|
929
|
+
# "paraclear_address": "0x286003f7c7bfc3f94e8f0af48b48302e7aee2fb13c23b141479ba00832ef2c6",
|
930
|
+
# "paraclear_decimals": 8,
|
931
|
+
# "paraclear_account_proxy_hash": "0x3530cc4759d78042f1b543bf797f5f3d647cde0388c33734cf91b7f7b9314a9",
|
932
|
+
# "paraclear_account_hash": "0x41cb0280ebadaa75f996d8d92c6f265f6d040bb3ba442e5f86a554f1765244e",
|
933
|
+
# "oracle_address": "0x2c6a867917ef858d6b193a0ff9e62b46d0dc760366920d631715d58baeaca1f",
|
934
|
+
# "bridged_tokens": [
|
935
|
+
# {
|
936
|
+
# "name": "TEST USDC",
|
937
|
+
# "symbol": "USDC",
|
938
|
+
# "decimals": 6,
|
939
|
+
# "l1_token_address": "0x29A873159D5e14AcBd63913D4A7E2df04570c666",
|
940
|
+
# "l1_bridge_address": "0x8586e05adc0C35aa11609023d4Ae6075Cb813b4C",
|
941
|
+
# "l2_token_address": "0x6f373b346561036d98ea10fb3e60d2f459c872b1933b50b21fe6ef4fda3b75e",
|
942
|
+
# "l2_bridge_address": "0x46e9237f5408b5f899e72125dd69bd55485a287aaf24663d3ebe00d237fc7ef"
|
943
|
+
# }
|
944
|
+
# ],
|
945
|
+
# "l1_core_contract_address": "0x582CC5d9b509391232cd544cDF9da036e55833Af",
|
946
|
+
# "l1_operator_address": "0x11bACdFbBcd3Febe5e8CEAa75E0Ef6444d9B45FB",
|
947
|
+
# "l1_chain_id": "11155111",
|
948
|
+
# "liquidation_fee": "0.2"
|
949
|
+
# }
|
950
|
+
#
|
951
|
+
self.options['systemConfig'] = response
|
952
|
+
return response
|
953
|
+
|
954
|
+
async def prepare_paradex_domain(self, l1=False):
|
955
|
+
systemConfig = await self.get_system_config()
|
956
|
+
if l1 is True:
|
957
|
+
return {
|
958
|
+
'name': 'Paradex',
|
959
|
+
'chainId': systemConfig['l1_chain_id'],
|
960
|
+
'version': '1',
|
961
|
+
}
|
962
|
+
return {
|
963
|
+
'name': 'Paradex',
|
964
|
+
'chainId': systemConfig['starknet_chain_id'],
|
965
|
+
'version': 1,
|
966
|
+
}
|
967
|
+
|
968
|
+
async def retrieve_account(self):
|
969
|
+
cachedAccount: dict = self.safe_dict(self.options, 'paradexAccount')
|
970
|
+
if cachedAccount is not None:
|
971
|
+
return cachedAccount
|
972
|
+
self.check_required_credentials()
|
973
|
+
systemConfig = await self.get_system_config()
|
974
|
+
domain = await self.prepare_paradex_domain(True)
|
975
|
+
messageTypes = {
|
976
|
+
'Constant': [
|
977
|
+
{'name': 'action', 'type': 'string'},
|
978
|
+
],
|
979
|
+
}
|
980
|
+
message = {
|
981
|
+
'action': 'STARK Key',
|
982
|
+
}
|
983
|
+
msg = self.eth_encode_structured_data(domain, messageTypes, message)
|
984
|
+
signature = self.sign_message(msg, self.privateKey)
|
985
|
+
account = self.retrieve_stark_account(
|
986
|
+
signature,
|
987
|
+
systemConfig['paraclear_account_hash'],
|
988
|
+
systemConfig['paraclear_account_proxy_hash']
|
989
|
+
)
|
990
|
+
self.options['paradexAccount'] = account
|
991
|
+
return account
|
992
|
+
|
993
|
+
async def onboarding(self, params={}):
|
994
|
+
account = await self.retrieve_account()
|
995
|
+
req = {
|
996
|
+
'action': 'Onboarding',
|
997
|
+
}
|
998
|
+
domain = await self.prepare_paradex_domain()
|
999
|
+
messageTypes = {
|
1000
|
+
'Constant': [
|
1001
|
+
{'name': 'action', 'type': 'felt'},
|
1002
|
+
],
|
1003
|
+
}
|
1004
|
+
msg = self.starknet_encode_structured_data(domain, messageTypes, req, account['address'])
|
1005
|
+
signature = self.starknet_sign(msg, account['privateKey'])
|
1006
|
+
params['signature'] = signature
|
1007
|
+
params['account'] = account['address']
|
1008
|
+
params['public_key'] = account['publicKey']
|
1009
|
+
response = await self.privatePostOnboarding(params)
|
1010
|
+
return response
|
1011
|
+
|
1012
|
+
async def authenticate_rest(self, params={}):
|
1013
|
+
cachedToken = self.safe_string(self.options, 'authToken')
|
1014
|
+
now = self.nonce()
|
1015
|
+
if cachedToken is not None:
|
1016
|
+
cachedExpires = self.safe_integer(self.options, 'expires')
|
1017
|
+
if now < cachedExpires:
|
1018
|
+
return cachedToken
|
1019
|
+
account = await self.retrieve_account()
|
1020
|
+
# https://docs.paradex.trade/api-reference/general-information/authentication
|
1021
|
+
expires = now + 180
|
1022
|
+
req = {
|
1023
|
+
'method': 'POST',
|
1024
|
+
'path': '/v1/auth',
|
1025
|
+
'body': '',
|
1026
|
+
'timestamp': now,
|
1027
|
+
'expiration': expires,
|
1028
|
+
}
|
1029
|
+
domain = await self.prepare_paradex_domain()
|
1030
|
+
messageTypes = {
|
1031
|
+
'Request': [
|
1032
|
+
{'name': 'method', 'type': 'felt'},
|
1033
|
+
{'name': 'path', 'type': 'felt'},
|
1034
|
+
{'name': 'body', 'type': 'felt'},
|
1035
|
+
{'name': 'timestamp', 'type': 'felt'},
|
1036
|
+
{'name': 'expiration', 'type': 'felt'},
|
1037
|
+
],
|
1038
|
+
}
|
1039
|
+
msg = self.starknet_encode_structured_data(domain, messageTypes, req, account['address'])
|
1040
|
+
signature = self.starknet_sign(msg, account['privateKey'])
|
1041
|
+
params['signature'] = signature
|
1042
|
+
params['account'] = account['address']
|
1043
|
+
params['timestamp'] = req['timestamp']
|
1044
|
+
params['expiration'] = req['expiration']
|
1045
|
+
response = await self.privatePostAuth(params)
|
1046
|
+
#
|
1047
|
+
# {
|
1048
|
+
# jwt_token: "ooooccxtooootoooootheoooomoonooooo"
|
1049
|
+
# }
|
1050
|
+
#
|
1051
|
+
token = self.safe_string(response, 'jwt_token')
|
1052
|
+
self.options['authToken'] = token
|
1053
|
+
self.options['expires'] = expires
|
1054
|
+
return token
|
1055
|
+
|
1056
|
+
def parse_order(self, order: dict, market: Market = None) -> Order:
|
1057
|
+
#
|
1058
|
+
# {
|
1059
|
+
# "account": "0x4638e3041366aa71720be63e32e53e1223316c7f0d56f7aa617542ed1e7512x",
|
1060
|
+
# "avg_fill_price": "26000",
|
1061
|
+
# "client_id": "x1234",
|
1062
|
+
# "cancel_reason": "NOT_ENOUGH_MARGIN",
|
1063
|
+
# "created_at": 1681493746016,
|
1064
|
+
# "flags": [
|
1065
|
+
# "REDUCE_ONLY"
|
1066
|
+
# ],
|
1067
|
+
# "id": "123456",
|
1068
|
+
# "instruction": "GTC",
|
1069
|
+
# "last_updated_at": 1681493746016,
|
1070
|
+
# "market": "BTC-USD-PERP",
|
1071
|
+
# "price": "26000",
|
1072
|
+
# "published_at": 1681493746016,
|
1073
|
+
# "received_at": 1681493746016,
|
1074
|
+
# "remaining_size": "0",
|
1075
|
+
# "seq_no": 1681471234972000000,
|
1076
|
+
# "side": "BUY",
|
1077
|
+
# "size": "0.05",
|
1078
|
+
# "status": "NEW",
|
1079
|
+
# "stp": "EXPIRE_MAKER",
|
1080
|
+
# "timestamp": 1681493746016,
|
1081
|
+
# "trigger_price": "26000",
|
1082
|
+
# "type": "MARKET"
|
1083
|
+
# }
|
1084
|
+
#
|
1085
|
+
timestamp = self.safe_integer(order, 'created_at')
|
1086
|
+
orderId = self.safe_string(order, 'id')
|
1087
|
+
clientOrderId = self.omit_zero(self.safe_string(order, 'client_id'))
|
1088
|
+
marketId = self.safe_string(order, 'market')
|
1089
|
+
market = self.safe_market(marketId, market)
|
1090
|
+
symbol = market['symbol']
|
1091
|
+
price = self.safe_string(order, 'price')
|
1092
|
+
amount = self.safe_string(order, 'size')
|
1093
|
+
orderType = self.safe_string(order, 'type')
|
1094
|
+
status = self.safe_string(order, 'status')
|
1095
|
+
side = self.safe_string_lower(order, 'side')
|
1096
|
+
average = self.omit_zero(self.safe_string(order, 'avg_fill_price'))
|
1097
|
+
remaining = self.omit_zero(self.safe_string(order, 'remaining_size'))
|
1098
|
+
lastUpdateTimestamp = self.safe_integer(order, 'last_updated_at')
|
1099
|
+
return self.safe_order({
|
1100
|
+
'id': orderId,
|
1101
|
+
'clientOrderId': clientOrderId,
|
1102
|
+
'timestamp': timestamp,
|
1103
|
+
'datetime': self.iso8601(timestamp),
|
1104
|
+
'lastTradeTimestamp': None,
|
1105
|
+
'lastUpdateTimestamp': lastUpdateTimestamp,
|
1106
|
+
'status': self.parse_order_status(status),
|
1107
|
+
'symbol': symbol,
|
1108
|
+
'type': self.parse_order_type(orderType),
|
1109
|
+
'timeInForce': self.parse_time_in_force(self.safe_string(order, 'instrunction')),
|
1110
|
+
'postOnly': None,
|
1111
|
+
'reduceOnly': None,
|
1112
|
+
'side': side,
|
1113
|
+
'price': price,
|
1114
|
+
'triggerPrice': self.safe_string(order, 'trigger_price'),
|
1115
|
+
'takeProfitPrice': None,
|
1116
|
+
'stopLossPrice': None,
|
1117
|
+
'average': average,
|
1118
|
+
'amount': amount,
|
1119
|
+
'filled': None,
|
1120
|
+
'remaining': remaining,
|
1121
|
+
'cost': None,
|
1122
|
+
'trades': None,
|
1123
|
+
'fee': {
|
1124
|
+
'cost': None,
|
1125
|
+
'currency': None,
|
1126
|
+
},
|
1127
|
+
'info': order,
|
1128
|
+
}, market)
|
1129
|
+
|
1130
|
+
def parse_time_in_force(self, timeInForce: Str):
|
1131
|
+
timeInForces: dict = {
|
1132
|
+
'IOC': 'IOC',
|
1133
|
+
'GTC': 'GTC',
|
1134
|
+
'POST_ONLY': 'PO',
|
1135
|
+
}
|
1136
|
+
return self.safe_string(timeInForces, timeInForce, None)
|
1137
|
+
|
1138
|
+
def parse_order_status(self, status: Str):
|
1139
|
+
if status is not None:
|
1140
|
+
statuses: dict = {
|
1141
|
+
'NEW': 'open',
|
1142
|
+
'UNTRIGGERED': 'open',
|
1143
|
+
'OPEN': 'open',
|
1144
|
+
'CLOSED': 'closed',
|
1145
|
+
}
|
1146
|
+
return self.safe_string(statuses, status, status)
|
1147
|
+
return status
|
1148
|
+
|
1149
|
+
def parse_order_type(self, type: Str):
|
1150
|
+
types: dict = {
|
1151
|
+
'LIMIT': 'limit',
|
1152
|
+
'MARKET': 'market',
|
1153
|
+
'STOP_LIMIT': 'limit',
|
1154
|
+
'STOP_MARKET': 'market',
|
1155
|
+
}
|
1156
|
+
return self.safe_string_lower(types, type, type)
|
1157
|
+
|
1158
|
+
def convert_short_string(self, str: str):
|
1159
|
+
# TODO: add stringToBase16 in exchange
|
1160
|
+
return '0x' + self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str)))
|
1161
|
+
|
1162
|
+
def scale_number(self, num: str):
|
1163
|
+
return Precise.string_mul(num, '100000000')
|
1164
|
+
|
1165
|
+
async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
1166
|
+
"""
|
1167
|
+
create a trade order
|
1168
|
+
|
1169
|
+
https://docs.api.prod.paradex.trade/#create-order
|
1170
|
+
|
1171
|
+
:param str symbol: unified symbol of the market to create an order in
|
1172
|
+
:param str type: 'market' or 'limit'
|
1173
|
+
:param str side: 'buy' or 'sell'
|
1174
|
+
:param float amount: how much of currency you want to trade in units of base currency
|
1175
|
+
:param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
1176
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1177
|
+
:param float [params.stopPrice]: alias for triggerPrice
|
1178
|
+
:param float [params.triggerPrice]: The price a trigger order is triggered at
|
1179
|
+
:param str [params.timeInForce]: "GTC", "IOC", or "POST_ONLY"
|
1180
|
+
:param bool [params.postOnly]: True or False
|
1181
|
+
:param bool [params.reduceOnly]: Ensures that the executed order does not flip the opened position.
|
1182
|
+
:param str [params.clientOrderId]: a unique id for the order
|
1183
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1184
|
+
"""
|
1185
|
+
await self.authenticate_rest()
|
1186
|
+
await self.load_markets()
|
1187
|
+
market = self.market(symbol)
|
1188
|
+
reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only')
|
1189
|
+
orderType = type.upper()
|
1190
|
+
orderSide = side.upper()
|
1191
|
+
request: dict = {
|
1192
|
+
'market': market['id'],
|
1193
|
+
'side': orderSide,
|
1194
|
+
'type': orderType, # LIMIT/MARKET/STOP_LIMIT/STOP_MARKET
|
1195
|
+
'size': self.amount_to_precision(symbol, amount),
|
1196
|
+
}
|
1197
|
+
triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
|
1198
|
+
isMarket = orderType == 'MARKET'
|
1199
|
+
timeInForce = self.safe_string_upper(params, 'timeInForce')
|
1200
|
+
postOnly = self.is_post_only(isMarket, None, params)
|
1201
|
+
if not isMarket:
|
1202
|
+
if postOnly:
|
1203
|
+
request['instruction'] = 'POST_ONLY'
|
1204
|
+
elif timeInForce == 'ioc':
|
1205
|
+
request['instruction'] = 'IOC'
|
1206
|
+
if reduceOnly:
|
1207
|
+
request['flags'] = [
|
1208
|
+
'REDUCE_ONLY',
|
1209
|
+
]
|
1210
|
+
if price is not None:
|
1211
|
+
request['price'] = self.price_to_precision(symbol, price)
|
1212
|
+
clientOrderId = self.safe_string_n(params, ['clOrdID', 'clientOrderId', 'client_order_id'])
|
1213
|
+
if clientOrderId is not None:
|
1214
|
+
request['client_id'] = clientOrderId
|
1215
|
+
if triggerPrice is not None:
|
1216
|
+
if isMarket:
|
1217
|
+
request['type'] = 'STOP_MARKET'
|
1218
|
+
else:
|
1219
|
+
request['type'] = 'STOP_LIMIT'
|
1220
|
+
request['trigger_price'] = self.price_to_precision(symbol, triggerPrice)
|
1221
|
+
params = self.omit(params, ['reduceOnly', 'reduce_only', 'clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice'])
|
1222
|
+
account = await self.retrieve_account()
|
1223
|
+
now = self.nonce()
|
1224
|
+
orderReq = {
|
1225
|
+
'timestamp': now * 1000,
|
1226
|
+
'market': self.convert_short_string(request['market']),
|
1227
|
+
'side': '1' if (orderSide == 'BUY') else '2',
|
1228
|
+
'orderType': self.convert_short_string(request['type']),
|
1229
|
+
'size': self.scale_number(request['size']),
|
1230
|
+
'price': '0' if (isMarket) else self.scale_number(request['price']),
|
1231
|
+
}
|
1232
|
+
domain = await self.prepare_paradex_domain()
|
1233
|
+
messageTypes = {
|
1234
|
+
'Order': [
|
1235
|
+
{'name': 'timestamp', 'type': 'felt'},
|
1236
|
+
{'name': 'market', 'type': 'felt'},
|
1237
|
+
{'name': 'side', 'type': 'felt'},
|
1238
|
+
{'name': 'orderType', 'type': 'felt'},
|
1239
|
+
{'name': 'size', 'type': 'felt'},
|
1240
|
+
{'name': 'price', 'type': 'felt'},
|
1241
|
+
],
|
1242
|
+
}
|
1243
|
+
msg = self.starknet_encode_structured_data(domain, messageTypes, orderReq, account['address'])
|
1244
|
+
signature = self.starknet_sign(msg, account['privateKey'])
|
1245
|
+
request['signature'] = signature
|
1246
|
+
request['signature_timestamp'] = orderReq['timestamp']
|
1247
|
+
response = await self.privatePostOrders(self.extend(request, params))
|
1248
|
+
#
|
1249
|
+
# {
|
1250
|
+
# "account": "0x4638e3041366aa71720be63e32e53e1223316c7f0d56f7aa617542ed1e7512x",
|
1251
|
+
# "avg_fill_price": "26000",
|
1252
|
+
# "cancel_reason": "NOT_ENOUGH_MARGIN",
|
1253
|
+
# "client_id": "x1234",
|
1254
|
+
# "created_at": 1681493746016,
|
1255
|
+
# "flags": [
|
1256
|
+
# "REDUCE_ONLY"
|
1257
|
+
# ],
|
1258
|
+
# "id": "123456",
|
1259
|
+
# "instruction": "GTC",
|
1260
|
+
# "last_updated_at": 1681493746016,
|
1261
|
+
# "market": "BTC-USD-PERP",
|
1262
|
+
# "price": "26000",
|
1263
|
+
# "published_at": 1681493746016,
|
1264
|
+
# "received_at": 1681493746016,
|
1265
|
+
# "remaining_size": "0",
|
1266
|
+
# "seq_no": 1681471234972000000,
|
1267
|
+
# "side": "BUY",
|
1268
|
+
# "size": "0.05",
|
1269
|
+
# "status": "NEW",
|
1270
|
+
# "stp": "EXPIRE_MAKER",
|
1271
|
+
# "timestamp": 1681493746016,
|
1272
|
+
# "trigger_price": "26000",
|
1273
|
+
# "type": "MARKET"
|
1274
|
+
# }
|
1275
|
+
#
|
1276
|
+
order = self.parse_order(response, market)
|
1277
|
+
return order
|
1278
|
+
|
1279
|
+
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
1280
|
+
"""
|
1281
|
+
cancels an open order
|
1282
|
+
|
1283
|
+
https://docs.api.prod.paradex.trade/#cancel-order
|
1284
|
+
https://docs.api.prod.paradex.trade/#cancel-open-order-by-client-order-id
|
1285
|
+
|
1286
|
+
:param str id: order id
|
1287
|
+
:param str symbol: unified symbol of the market the order was made in
|
1288
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1289
|
+
:param str [params.clientOrderId]: a unique id for the order
|
1290
|
+
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1291
|
+
"""
|
1292
|
+
await self.authenticate_rest()
|
1293
|
+
await self.load_markets()
|
1294
|
+
request: dict = {}
|
1295
|
+
clientOrderId = self.safe_string_n(params, ['clOrdID', 'clientOrderId', 'client_order_id'])
|
1296
|
+
response = None
|
1297
|
+
if clientOrderId is not None:
|
1298
|
+
request['client_id'] = clientOrderId
|
1299
|
+
response = await self.privateDeleteOrdersByClientIdClientId(self.extend(request, params))
|
1300
|
+
else:
|
1301
|
+
request['order_id'] = id
|
1302
|
+
response = await self.privateDeleteOrdersOrderId(self.extend(request, params))
|
1303
|
+
#
|
1304
|
+
# if success, no response...
|
1305
|
+
#
|
1306
|
+
return self.parse_order(response)
|
1307
|
+
|
1308
|
+
async def cancel_all_orders(self, symbol: Str = None, params={}):
|
1309
|
+
"""
|
1310
|
+
cancel all open orders in a market
|
1311
|
+
|
1312
|
+
https://docs.api.prod.paradex.trade/#cancel-all-open-orders
|
1313
|
+
|
1314
|
+
:param str symbol: unified market symbol of the market to cancel orders in
|
1315
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1316
|
+
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1317
|
+
"""
|
1318
|
+
if symbol is None:
|
1319
|
+
raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
|
1320
|
+
await self.authenticate_rest()
|
1321
|
+
await self.load_markets()
|
1322
|
+
market = self.market(symbol)
|
1323
|
+
request: dict = {
|
1324
|
+
'market': market['id'],
|
1325
|
+
}
|
1326
|
+
response = await self.privateDeleteOrders(self.extend(request, params))
|
1327
|
+
#
|
1328
|
+
# if success, no response...
|
1329
|
+
#
|
1330
|
+
return response
|
1331
|
+
|
1332
|
+
async def fetch_order(self, id: str, symbol: Str = None, params={}):
|
1333
|
+
"""
|
1334
|
+
fetches information on an order made by the user
|
1335
|
+
|
1336
|
+
https://docs.api.prod.paradex.trade/#get-order
|
1337
|
+
https://docs.api.prod.paradex.trade/#get-order-by-client-id
|
1338
|
+
|
1339
|
+
:param str id: the order id
|
1340
|
+
:param str symbol: unified symbol of the market the order was made in
|
1341
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1342
|
+
:param str [params.clientOrderId]: a unique id for the order
|
1343
|
+
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1344
|
+
"""
|
1345
|
+
await self.authenticate_rest()
|
1346
|
+
await self.load_markets()
|
1347
|
+
request: dict = {}
|
1348
|
+
clientOrderId = self.safe_string_n(params, ['clOrdID', 'clientOrderId', 'client_order_id'])
|
1349
|
+
params = self.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id'])
|
1350
|
+
response = None
|
1351
|
+
if clientOrderId is not None:
|
1352
|
+
request['client_id'] = clientOrderId
|
1353
|
+
response = await self.privateGetOrdersByClientIdClientId(self.extend(request, params))
|
1354
|
+
else:
|
1355
|
+
request['order_id'] = id
|
1356
|
+
response = await self.privateGetOrdersOrderId(self.extend(request, params))
|
1357
|
+
#
|
1358
|
+
# {
|
1359
|
+
# "id": "1718941725080201704028870000",
|
1360
|
+
# "account": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3",
|
1361
|
+
# "market": "BTC-USD-PERP",
|
1362
|
+
# "side": "SELL",
|
1363
|
+
# "type": "LIMIT",
|
1364
|
+
# "size": "10.153",
|
1365
|
+
# "remaining_size": "10.153",
|
1366
|
+
# "price": "70784.5",
|
1367
|
+
# "status": "CLOSED",
|
1368
|
+
# "created_at": 1718941725082,
|
1369
|
+
# "last_updated_at": 1718958002991,
|
1370
|
+
# "timestamp": 1718941724678,
|
1371
|
+
# "cancel_reason": "USER_CANCELED",
|
1372
|
+
# "client_id": "",
|
1373
|
+
# "seq_no": 1718958002991595738,
|
1374
|
+
# "instruction": "GTC",
|
1375
|
+
# "avg_fill_price": "",
|
1376
|
+
# "stp": "EXPIRE_TAKER",
|
1377
|
+
# "received_at": 1718958510959,
|
1378
|
+
# "published_at": 1718958510960,
|
1379
|
+
# "flags": [],
|
1380
|
+
# "trigger_price": "0"
|
1381
|
+
# }
|
1382
|
+
#
|
1383
|
+
return self.parse_order(response)
|
1384
|
+
|
1385
|
+
async def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
1386
|
+
"""
|
1387
|
+
fetches information on multiple orders made by the user
|
1388
|
+
|
1389
|
+
https://docs.api.prod.paradex.trade/#get-orders
|
1390
|
+
|
1391
|
+
:param str symbol: unified market symbol of the market orders were made in
|
1392
|
+
:param int [since]: the earliest time in ms to fetch orders for
|
1393
|
+
:param int [limit]: the maximum number of order structures to retrieve
|
1394
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1395
|
+
:param str [params.side]: 'buy' or 'sell'
|
1396
|
+
:param boolean [params.paginate]: set to True if you want to fetch orders with pagination
|
1397
|
+
:param int params['until']: timestamp in ms of the latest order to fetch
|
1398
|
+
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1399
|
+
"""
|
1400
|
+
await self.authenticate_rest()
|
1401
|
+
await self.load_markets()
|
1402
|
+
paginate = False
|
1403
|
+
paginate, params = self.handle_option_and_params(params, 'fetchOrders', 'paginate')
|
1404
|
+
if paginate:
|
1405
|
+
return await self.fetch_paginated_call_cursor('fetchOrders', symbol, since, limit, params, 'next', 'cursor', None, 50)
|
1406
|
+
request: dict = {}
|
1407
|
+
market: Market = None
|
1408
|
+
if symbol is not None:
|
1409
|
+
market = self.market(symbol)
|
1410
|
+
request['market'] = market['id']
|
1411
|
+
if since is not None:
|
1412
|
+
request['start_at'] = since
|
1413
|
+
if limit is not None:
|
1414
|
+
request['page_size'] = limit
|
1415
|
+
request, params = self.handle_until_option('end_at', request, params)
|
1416
|
+
response = await self.privateGetOrdersHistory(self.extend(request, params))
|
1417
|
+
#
|
1418
|
+
# {
|
1419
|
+
# "next": "eyJmaWx0ZXIiMsIm1hcmtlciI6eyJtYXJrZXIiOiIxNjc1NjUwMDE3NDMxMTAxNjk5N=",
|
1420
|
+
# "prev": "eyJmaWx0ZXIiOnsiTGltaXQiOjkwfSwidGltZSI6MTY4MTY3OTgzNzk3MTMwOTk1MywibWFya2VyIjp7Im1zMjExMD==",
|
1421
|
+
# "results": [
|
1422
|
+
# {
|
1423
|
+
# "account": "0x4638e3041366aa71720be63e32e53e1223316c7f0d56f7aa617542ed1e7512x",
|
1424
|
+
# "avg_fill_price": "26000",
|
1425
|
+
# "cancel_reason": "NOT_ENOUGH_MARGIN",
|
1426
|
+
# "client_id": "x1234",
|
1427
|
+
# "created_at": 1681493746016,
|
1428
|
+
# "flags": [
|
1429
|
+
# "REDUCE_ONLY"
|
1430
|
+
# ],
|
1431
|
+
# "id": "123456",
|
1432
|
+
# "instruction": "GTC",
|
1433
|
+
# "last_updated_at": 1681493746016,
|
1434
|
+
# "market": "BTC-USD-PERP",
|
1435
|
+
# "price": "26000",
|
1436
|
+
# "published_at": 1681493746016,
|
1437
|
+
# "received_at": 1681493746016,
|
1438
|
+
# "remaining_size": "0",
|
1439
|
+
# "seq_no": 1681471234972000000,
|
1440
|
+
# "side": "BUY",
|
1441
|
+
# "size": "0.05",
|
1442
|
+
# "status": "NEW",
|
1443
|
+
# "stp": "EXPIRE_MAKER",
|
1444
|
+
# "timestamp": 1681493746016,
|
1445
|
+
# "trigger_price": "26000",
|
1446
|
+
# "type": "MARKET"
|
1447
|
+
# }
|
1448
|
+
# ]
|
1449
|
+
# }
|
1450
|
+
#
|
1451
|
+
orders = self.safe_list(response, 'results', [])
|
1452
|
+
paginationCursor = self.safe_string(response, 'next')
|
1453
|
+
ordersLength = len(orders)
|
1454
|
+
if (paginationCursor is not None) and (ordersLength > 0):
|
1455
|
+
first = orders[0]
|
1456
|
+
first['next'] = paginationCursor
|
1457
|
+
orders[0] = first
|
1458
|
+
return self.parse_orders(orders, market, since, limit)
|
1459
|
+
|
1460
|
+
async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
1461
|
+
"""
|
1462
|
+
fetches information on multiple orders made by the user
|
1463
|
+
|
1464
|
+
https://docs.api.prod.paradex.trade/#paradex-rest-api-orders
|
1465
|
+
|
1466
|
+
:param str symbol: unified market symbol of the market orders were made in
|
1467
|
+
:param int [since]: the earliest time in ms to fetch orders for
|
1468
|
+
:param int [limit]: the maximum number of order structures to retrieve
|
1469
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1470
|
+
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1471
|
+
"""
|
1472
|
+
await self.authenticate_rest()
|
1473
|
+
await self.load_markets()
|
1474
|
+
request: dict = {}
|
1475
|
+
market: Market = None
|
1476
|
+
if symbol is not None:
|
1477
|
+
market = self.market(symbol)
|
1478
|
+
request['market'] = market['id']
|
1479
|
+
response = await self.privateGetOrders(self.extend(request, params))
|
1480
|
+
#
|
1481
|
+
# {
|
1482
|
+
# "results": [
|
1483
|
+
# {
|
1484
|
+
# "account": "0x4638e3041366aa71720be63e32e53e1223316c7f0d56f7aa617542ed1e7512x",
|
1485
|
+
# "avg_fill_price": "26000",
|
1486
|
+
# "client_id": "x1234",
|
1487
|
+
# "cancel_reason": "NOT_ENOUGH_MARGIN",
|
1488
|
+
# "created_at": 1681493746016,
|
1489
|
+
# "flags": [
|
1490
|
+
# "REDUCE_ONLY"
|
1491
|
+
# ],
|
1492
|
+
# "id": "123456",
|
1493
|
+
# "instruction": "GTC",
|
1494
|
+
# "last_updated_at": 1681493746016,
|
1495
|
+
# "market": "BTC-USD-PERP",
|
1496
|
+
# "price": "26000",
|
1497
|
+
# "published_at": 1681493746016,
|
1498
|
+
# "received_at": 1681493746016,
|
1499
|
+
# "remaining_size": "0",
|
1500
|
+
# "seq_no": 1681471234972000000,
|
1501
|
+
# "side": "BUY",
|
1502
|
+
# "size": "0.05",
|
1503
|
+
# "status": "NEW",
|
1504
|
+
# "stp": "EXPIRE_MAKER",
|
1505
|
+
# "timestamp": 1681493746016,
|
1506
|
+
# "trigger_price": "26000",
|
1507
|
+
# "type": "MARKET"
|
1508
|
+
# }
|
1509
|
+
# ]
|
1510
|
+
# }
|
1511
|
+
#
|
1512
|
+
orders = self.safe_list(response, 'results', [])
|
1513
|
+
return self.parse_orders(orders, market, since, limit)
|
1514
|
+
|
1515
|
+
async def fetch_balance(self, params={}) -> Balances:
|
1516
|
+
"""
|
1517
|
+
query for balance and get the amount of funds available for trading or funds locked in orders
|
1518
|
+
|
1519
|
+
https://docs.api.prod.paradex.trade/#list-balances
|
1520
|
+
|
1521
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1522
|
+
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
1523
|
+
"""
|
1524
|
+
await self.authenticate_rest()
|
1525
|
+
await self.load_markets()
|
1526
|
+
response = await self.privateGetBalance()
|
1527
|
+
#
|
1528
|
+
# {
|
1529
|
+
# "results": [
|
1530
|
+
# {
|
1531
|
+
# "token": "USDC",
|
1532
|
+
# "size": "99980.2382266290601",
|
1533
|
+
# "last_updated_at": 1718529757240
|
1534
|
+
# }
|
1535
|
+
# ]
|
1536
|
+
# }
|
1537
|
+
#
|
1538
|
+
data = self.safe_list(response, 'results', [])
|
1539
|
+
return self.parse_balance(data)
|
1540
|
+
|
1541
|
+
def parse_balance(self, response) -> Balances:
|
1542
|
+
result: dict = {'info': response}
|
1543
|
+
for i in range(0, len(response)):
|
1544
|
+
balance = self.safe_dict(response, i, {})
|
1545
|
+
currencyId = self.safe_string(balance, 'token')
|
1546
|
+
code = self.safe_currency_code(currencyId)
|
1547
|
+
account = self.account()
|
1548
|
+
account['total'] = self.safe_string(balance, 'size')
|
1549
|
+
result[code] = account
|
1550
|
+
return self.safe_balance(result)
|
1551
|
+
|
1552
|
+
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
1553
|
+
"""
|
1554
|
+
fetch all trades made by the user
|
1555
|
+
|
1556
|
+
https://docs.api.prod.paradex.trade/#list-fills
|
1557
|
+
|
1558
|
+
:param str symbol: unified market symbol
|
1559
|
+
:param int [since]: the earliest time in ms to fetch trades for
|
1560
|
+
:param int [limit]: the maximum number of trades structures to retrieve
|
1561
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1562
|
+
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
1563
|
+
:param int [params.until]: the latest time in ms to fetch entries for
|
1564
|
+
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
1565
|
+
"""
|
1566
|
+
await self.authenticate_rest()
|
1567
|
+
await self.load_markets()
|
1568
|
+
paginate = False
|
1569
|
+
paginate, params = self.handle_option_and_params(params, 'fetchMyTrades', 'paginate')
|
1570
|
+
if paginate:
|
1571
|
+
return await self.fetch_paginated_call_cursor('fetchMyTrades', symbol, since, limit, params, 'next', 'cursor', None, 100)
|
1572
|
+
request: dict = {}
|
1573
|
+
market: Market = None
|
1574
|
+
if symbol is not None:
|
1575
|
+
market = self.market(symbol)
|
1576
|
+
request['market'] = market['id']
|
1577
|
+
if limit is not None:
|
1578
|
+
request['page_size'] = limit
|
1579
|
+
if since is not None:
|
1580
|
+
request['start_at'] = since
|
1581
|
+
request, params = self.handle_until_option('end_at', request, params)
|
1582
|
+
response = await self.privateGetFills(self.extend(request, params))
|
1583
|
+
#
|
1584
|
+
# {
|
1585
|
+
# "next": null,
|
1586
|
+
# "prev": null,
|
1587
|
+
# "results": [
|
1588
|
+
# {
|
1589
|
+
# "id": "1718947571560201703986670001",
|
1590
|
+
# "side": "BUY",
|
1591
|
+
# "liquidity": "TAKER",
|
1592
|
+
# "market": "BTC-USD-PERP",
|
1593
|
+
# "order_id": "1718947571540201703992340000",
|
1594
|
+
# "price": "64852.9",
|
1595
|
+
# "size": "0.01",
|
1596
|
+
# "fee": "0.1945587",
|
1597
|
+
# "fee_currency": "USDC",
|
1598
|
+
# "created_at": 1718947571569,
|
1599
|
+
# "remaining_size": "0",
|
1600
|
+
# "client_id": "",
|
1601
|
+
# "fill_type": "FILL"
|
1602
|
+
# }
|
1603
|
+
# ]
|
1604
|
+
# }
|
1605
|
+
#
|
1606
|
+
trades = self.safe_list(response, 'results', [])
|
1607
|
+
for i in range(0, len(trades)):
|
1608
|
+
trades[i]['next'] = self.safe_string(response, 'next')
|
1609
|
+
return self.parse_trades(trades, market, since, limit)
|
1610
|
+
|
1611
|
+
async def fetch_position(self, symbol: str, params={}):
|
1612
|
+
"""
|
1613
|
+
fetch data on an open position
|
1614
|
+
|
1615
|
+
https://docs.api.prod.paradex.trade/#list-open-positions
|
1616
|
+
|
1617
|
+
:param str symbol: unified market symbol of the market the position is held in
|
1618
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1619
|
+
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
1620
|
+
"""
|
1621
|
+
await self.authenticate_rest()
|
1622
|
+
await self.load_markets()
|
1623
|
+
market = self.market(symbol)
|
1624
|
+
positions = await self.fetch_positions([market['symbol']], params)
|
1625
|
+
return self.safe_dict(positions, 0, {})
|
1626
|
+
|
1627
|
+
async def fetch_positions(self, symbols: Strings = None, params={}):
|
1628
|
+
"""
|
1629
|
+
fetch all open positions
|
1630
|
+
|
1631
|
+
https://docs.api.prod.paradex.trade/#list-open-positions
|
1632
|
+
|
1633
|
+
:param str[] [symbols]: list of unified market symbols
|
1634
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1635
|
+
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
1636
|
+
"""
|
1637
|
+
await self.authenticate_rest()
|
1638
|
+
await self.load_markets()
|
1639
|
+
symbols = self.market_symbols(symbols)
|
1640
|
+
response = await self.privateGetPositions()
|
1641
|
+
#
|
1642
|
+
# {
|
1643
|
+
# "results": [
|
1644
|
+
# {
|
1645
|
+
# "id": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3-BTC-USD-PERP",
|
1646
|
+
# "market": "BTC-USD-PERP",
|
1647
|
+
# "status": "OPEN",
|
1648
|
+
# "side": "LONG",
|
1649
|
+
# "size": "0.01",
|
1650
|
+
# "average_entry_price": "64839.96053748",
|
1651
|
+
# "average_entry_price_usd": "64852.9",
|
1652
|
+
# "realized_pnl": "0",
|
1653
|
+
# "unrealized_pnl": "-2.39677214",
|
1654
|
+
# "unrealized_funding_pnl": "-0.11214013",
|
1655
|
+
# "cost": "648.39960537",
|
1656
|
+
# "cost_usd": "648.529",
|
1657
|
+
# "cached_funding_index": "35202.1002351",
|
1658
|
+
# "last_updated_at": 1718950074249,
|
1659
|
+
# "last_fill_id": "1718947571560201703986670001",
|
1660
|
+
# "seq_no": 1718950074249176253,
|
1661
|
+
# "liquidation_price": ""
|
1662
|
+
# }
|
1663
|
+
# ]
|
1664
|
+
# }
|
1665
|
+
#
|
1666
|
+
data = self.safe_list(response, 'results', [])
|
1667
|
+
return self.parse_positions(data, symbols)
|
1668
|
+
|
1669
|
+
def parse_position(self, position: dict, market: Market = None):
|
1670
|
+
#
|
1671
|
+
# {
|
1672
|
+
# "id": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3-BTC-USD-PERP",
|
1673
|
+
# "market": "BTC-USD-PERP",
|
1674
|
+
# "status": "OPEN",
|
1675
|
+
# "side": "LONG",
|
1676
|
+
# "size": "0.01",
|
1677
|
+
# "average_entry_price": "64839.96053748",
|
1678
|
+
# "average_entry_price_usd": "64852.9",
|
1679
|
+
# "realized_pnl": "0",
|
1680
|
+
# "unrealized_pnl": "-2.39677214",
|
1681
|
+
# "unrealized_funding_pnl": "-0.11214013",
|
1682
|
+
# "cost": "648.39960537",
|
1683
|
+
# "cost_usd": "648.529",
|
1684
|
+
# "cached_funding_index": "35202.1002351",
|
1685
|
+
# "last_updated_at": 1718950074249,
|
1686
|
+
# "last_fill_id": "1718947571560201703986670001",
|
1687
|
+
# "seq_no": 1718950074249176253,
|
1688
|
+
# "liquidation_price": ""
|
1689
|
+
# }
|
1690
|
+
#
|
1691
|
+
marketId = self.safe_string(position, 'market')
|
1692
|
+
market = self.safe_market(marketId, market)
|
1693
|
+
symbol = market['symbol']
|
1694
|
+
side = self.safe_string_lower(position, 'side')
|
1695
|
+
quantity = self.safe_string(position, 'size')
|
1696
|
+
if side != 'long':
|
1697
|
+
quantity = Precise.string_mul('-1', quantity)
|
1698
|
+
timestamp = self.safe_integer(position, 'time')
|
1699
|
+
return self.safe_position({
|
1700
|
+
'info': position,
|
1701
|
+
'id': self.safe_string(position, 'id'),
|
1702
|
+
'symbol': symbol,
|
1703
|
+
'entryPrice': self.safe_string(position, 'average_entry_price'),
|
1704
|
+
'markPrice': None,
|
1705
|
+
'notional': None,
|
1706
|
+
'collateral': self.safe_string(position, 'cost'),
|
1707
|
+
'unrealizedPnl': self.safe_string(position, 'unrealized_pnl'),
|
1708
|
+
'side': side,
|
1709
|
+
'contracts': self.parse_number(quantity),
|
1710
|
+
'contractSize': None,
|
1711
|
+
'timestamp': timestamp,
|
1712
|
+
'datetime': self.iso8601(timestamp),
|
1713
|
+
'hedged': None,
|
1714
|
+
'maintenanceMargin': None,
|
1715
|
+
'maintenanceMarginPercentage': None,
|
1716
|
+
'initialMargin': None,
|
1717
|
+
'initialMarginPercentage': None,
|
1718
|
+
'leverage': None,
|
1719
|
+
'liquidationPrice': None,
|
1720
|
+
'marginRatio': None,
|
1721
|
+
'marginMode': None,
|
1722
|
+
'percentage': None,
|
1723
|
+
})
|
1724
|
+
|
1725
|
+
async def fetch_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
|
1726
|
+
"""
|
1727
|
+
retrieves the public liquidations of a trading pair
|
1728
|
+
|
1729
|
+
https://docs.api.prod.paradex.trade/#list-liquidations
|
1730
|
+
|
1731
|
+
:param str symbol: unified CCXT market symbol
|
1732
|
+
:param int [since]: the earliest time in ms to fetch liquidations for
|
1733
|
+
:param int [limit]: the maximum number of liquidation structures to retrieve
|
1734
|
+
:param dict [params]: exchange specific parameters for the huobi api endpoint
|
1735
|
+
:param int [params.until]: timestamp in ms of the latest liquidation
|
1736
|
+
:returns dict: an array of `liquidation structures <https://docs.ccxt.com/#/?id=liquidation-structure>`
|
1737
|
+
"""
|
1738
|
+
await self.authenticate_rest()
|
1739
|
+
request: dict = {}
|
1740
|
+
if since is not None:
|
1741
|
+
request['from'] = since
|
1742
|
+
else:
|
1743
|
+
request['from'] = 1
|
1744
|
+
market = self.market(symbol)
|
1745
|
+
request, params = self.handle_until_option('to', request, params)
|
1746
|
+
response = await self.privateGetLiquidations(self.extend(request, params))
|
1747
|
+
#
|
1748
|
+
# {
|
1749
|
+
# "results": [
|
1750
|
+
# {
|
1751
|
+
# "created_at": 1697213130097,
|
1752
|
+
# "id": "0x123456789"
|
1753
|
+
# }
|
1754
|
+
# ]
|
1755
|
+
# }
|
1756
|
+
#
|
1757
|
+
data = self.safe_list(response, 'results', [])
|
1758
|
+
return self.parse_liquidations(data, market, since, limit)
|
1759
|
+
|
1760
|
+
def parse_liquidation(self, liquidation, market: Market = None):
|
1761
|
+
#
|
1762
|
+
# {
|
1763
|
+
# "created_at": 1697213130097,
|
1764
|
+
# "id": "0x123456789"
|
1765
|
+
# }
|
1766
|
+
#
|
1767
|
+
timestamp = self.safe_integer(liquidation, 'created_at')
|
1768
|
+
return self.safe_liquidation({
|
1769
|
+
'info': liquidation,
|
1770
|
+
'symbol': None,
|
1771
|
+
'contracts': None,
|
1772
|
+
'contractSize': None,
|
1773
|
+
'price': None,
|
1774
|
+
'baseValue': None,
|
1775
|
+
'quoteValue': None,
|
1776
|
+
'timestamp': timestamp,
|
1777
|
+
'datetime': self.iso8601(timestamp),
|
1778
|
+
})
|
1779
|
+
|
1780
|
+
async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
1781
|
+
"""
|
1782
|
+
fetch all deposits made to an account
|
1783
|
+
|
1784
|
+
https://docs.api.prod.paradex.trade/#paradex-rest-api-transfers
|
1785
|
+
|
1786
|
+
:param str code: unified currency code
|
1787
|
+
:param int [since]: the earliest time in ms to fetch deposits for
|
1788
|
+
:param int [limit]: the maximum number of deposits structures to retrieve
|
1789
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1790
|
+
:param int [params.until]: the latest time in ms to fetch entries for
|
1791
|
+
: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)
|
1792
|
+
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
1793
|
+
"""
|
1794
|
+
await self.authenticate_rest()
|
1795
|
+
await self.load_markets()
|
1796
|
+
paginate = False
|
1797
|
+
paginate, params = self.handle_option_and_params(params, 'fetchDeposits', 'paginate')
|
1798
|
+
if paginate:
|
1799
|
+
return await self.fetch_paginated_call_cursor('fetchDeposits', code, since, limit, params, 'next', 'cursor', None, 100)
|
1800
|
+
request: dict = {}
|
1801
|
+
if limit is not None:
|
1802
|
+
request['page_size'] = limit
|
1803
|
+
if since is not None:
|
1804
|
+
request['start_at'] = since
|
1805
|
+
request, params = self.handle_until_option('end_at', request, params)
|
1806
|
+
response = await self.privateGetTransfers(self.extend(request, params))
|
1807
|
+
#
|
1808
|
+
# {
|
1809
|
+
# "next": null,
|
1810
|
+
# "prev": null,
|
1811
|
+
# "results": [
|
1812
|
+
# {
|
1813
|
+
# "id": "1718940471200201703989430000",
|
1814
|
+
# "account": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3",
|
1815
|
+
# "kind": "DEPOSIT",
|
1816
|
+
# "status": "COMPLETED",
|
1817
|
+
# "amount": "100000",
|
1818
|
+
# "token": "USDC",
|
1819
|
+
# "created_at": 1718940471208,
|
1820
|
+
# "last_updated_at": 1718941455546,
|
1821
|
+
# "txn_hash": "0x73a415ca558a97bbdcd1c43e52b45f1e0486a0a84b3bb4958035ad6c59cb866",
|
1822
|
+
# "external_txn_hash": "",
|
1823
|
+
# "socialized_loss_factor": ""
|
1824
|
+
# }
|
1825
|
+
# ]
|
1826
|
+
# }
|
1827
|
+
#
|
1828
|
+
rows = self.safe_list(response, 'results', [])
|
1829
|
+
deposits = []
|
1830
|
+
for i in range(0, len(rows)):
|
1831
|
+
row = rows[i]
|
1832
|
+
if row['kind'] == 'DEPOSIT':
|
1833
|
+
deposits.append(row)
|
1834
|
+
return self.parse_transactions(deposits, None, since, limit)
|
1835
|
+
|
1836
|
+
async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
1837
|
+
"""
|
1838
|
+
fetch all withdrawals made from an account
|
1839
|
+
|
1840
|
+
https://docs.api.prod.paradex.trade/#paradex-rest-api-transfers
|
1841
|
+
|
1842
|
+
:param str code: unified currency code
|
1843
|
+
:param int [since]: the earliest time in ms to fetch withdrawals for
|
1844
|
+
:param int [limit]: the maximum number of withdrawals structures to retrieve
|
1845
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1846
|
+
:param int [params.until]: the latest time in ms to fetch withdrawals for
|
1847
|
+
: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)
|
1848
|
+
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
1849
|
+
"""
|
1850
|
+
await self.authenticate_rest()
|
1851
|
+
await self.load_markets()
|
1852
|
+
paginate = False
|
1853
|
+
paginate, params = self.handle_option_and_params(params, 'fetchWithdrawals', 'paginate')
|
1854
|
+
if paginate:
|
1855
|
+
return await self.fetch_paginated_call_cursor('fetchWithdrawals', code, since, limit, params, 'next', 'cursor', None, 100)
|
1856
|
+
request: dict = {}
|
1857
|
+
if limit is not None:
|
1858
|
+
request['page_size'] = limit
|
1859
|
+
if since is not None:
|
1860
|
+
request['start_at'] = since
|
1861
|
+
request, params = self.handle_until_option('end_at', request, params)
|
1862
|
+
response = await self.privateGetTransfers(self.extend(request, params))
|
1863
|
+
#
|
1864
|
+
# {
|
1865
|
+
# "next": null,
|
1866
|
+
# "prev": null,
|
1867
|
+
# "results": [
|
1868
|
+
# {
|
1869
|
+
# "id": "1718940471200201703989430000",
|
1870
|
+
# "account": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3",
|
1871
|
+
# "kind": "DEPOSIT",
|
1872
|
+
# "status": "COMPLETED",
|
1873
|
+
# "amount": "100000",
|
1874
|
+
# "token": "USDC",
|
1875
|
+
# "created_at": 1718940471208,
|
1876
|
+
# "last_updated_at": 1718941455546,
|
1877
|
+
# "txn_hash": "0x73a415ca558a97bbdcd1c43e52b45f1e0486a0a84b3bb4958035ad6c59cb866",
|
1878
|
+
# "external_txn_hash": "",
|
1879
|
+
# "socialized_loss_factor": ""
|
1880
|
+
# }
|
1881
|
+
# ]
|
1882
|
+
# }
|
1883
|
+
#
|
1884
|
+
rows = self.safe_list(response, 'results', [])
|
1885
|
+
deposits = []
|
1886
|
+
for i in range(0, len(rows)):
|
1887
|
+
row = rows[i]
|
1888
|
+
if row['kind'] == 'WITHDRAWAL':
|
1889
|
+
deposits.append(row)
|
1890
|
+
return self.parse_transactions(deposits, None, since, limit)
|
1891
|
+
|
1892
|
+
def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
|
1893
|
+
#
|
1894
|
+
# fetchDeposits & fetchWithdrawals
|
1895
|
+
#
|
1896
|
+
# {
|
1897
|
+
# "id": "1718940471200201703989430000",
|
1898
|
+
# "account": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3",
|
1899
|
+
# "kind": "DEPOSIT",
|
1900
|
+
# "status": "COMPLETED",
|
1901
|
+
# "amount": "100000",
|
1902
|
+
# "token": "USDC",
|
1903
|
+
# "created_at": 1718940471208,
|
1904
|
+
# "last_updated_at": 1718941455546,
|
1905
|
+
# "txn_hash": "0x73a415ca558a97bbdcd1c43e52b45f1e0486a0a84b3bb4958035ad6c59cb866",
|
1906
|
+
# "external_txn_hash": "",
|
1907
|
+
# "socialized_loss_factor": ""
|
1908
|
+
# }
|
1909
|
+
#
|
1910
|
+
id = self.safe_string(transaction, 'id')
|
1911
|
+
address = self.safe_string(transaction, 'account')
|
1912
|
+
txid = self.safe_string(transaction, 'txn_hash')
|
1913
|
+
currencyId = self.safe_string(transaction, 'token')
|
1914
|
+
code = self.safe_currency_code(currencyId, currency)
|
1915
|
+
timestamp = self.safe_integer(transaction, 'created_at')
|
1916
|
+
updated = self.safe_integer(transaction, 'last_updated_at')
|
1917
|
+
type = self.safe_string(transaction, 'kind')
|
1918
|
+
type = 'deposit' if (type == 'DEPOSIT') else 'withdrawal'
|
1919
|
+
status = self.parse_transaction_status(self.safe_string(transaction, 'status'))
|
1920
|
+
amount = self.safe_number(transaction, 'amount')
|
1921
|
+
return {
|
1922
|
+
'info': transaction,
|
1923
|
+
'id': id,
|
1924
|
+
'txid': txid,
|
1925
|
+
'timestamp': timestamp,
|
1926
|
+
'datetime': self.iso8601(timestamp),
|
1927
|
+
'network': None,
|
1928
|
+
'address': address,
|
1929
|
+
'addressTo': address,
|
1930
|
+
'addressFrom': None,
|
1931
|
+
'tag': None,
|
1932
|
+
'tagTo': None,
|
1933
|
+
'tagFrom': None,
|
1934
|
+
'type': type,
|
1935
|
+
'amount': amount,
|
1936
|
+
'currency': code,
|
1937
|
+
'status': status,
|
1938
|
+
'updated': updated,
|
1939
|
+
'internal': None,
|
1940
|
+
'comment': None,
|
1941
|
+
'fee': None,
|
1942
|
+
}
|
1943
|
+
|
1944
|
+
def parse_transaction_status(self, status: Str):
|
1945
|
+
statuses: dict = {
|
1946
|
+
'PENDING': 'pending',
|
1947
|
+
'AVAILABLE': 'pending',
|
1948
|
+
'COMPLETED': 'ok',
|
1949
|
+
'FAILED': 'failed',
|
1950
|
+
}
|
1951
|
+
return self.safe_string(statuses, status, status)
|
1952
|
+
|
1953
|
+
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
1954
|
+
url = self.implode_hostname(self.urls['api'][self.version]) + '/' + self.implode_params(path, params)
|
1955
|
+
query = self.omit(params, self.extract_params(path))
|
1956
|
+
if api == 'public':
|
1957
|
+
if query:
|
1958
|
+
url += '?' + self.urlencode(query)
|
1959
|
+
elif api == 'private':
|
1960
|
+
headers = {
|
1961
|
+
'Accept': 'application/json',
|
1962
|
+
'PARADEX-PARTNER': self.safe_string(self.options, 'broker', 'CCXT'),
|
1963
|
+
}
|
1964
|
+
# TODO: optimize
|
1965
|
+
if path == 'auth':
|
1966
|
+
headers['PARADEX-STARKNET-ACCOUNT'] = query['account']
|
1967
|
+
headers['PARADEX-STARKNET-SIGNATURE'] = query['signature']
|
1968
|
+
headers['PARADEX-TIMESTAMP'] = str(query['timestamp'])
|
1969
|
+
headers['PARADEX-SIGNATURE-EXPIRATION'] = str(query['expiration'])
|
1970
|
+
elif path == 'onboarding':
|
1971
|
+
headers['PARADEX-ETHEREUM-ACCOUNT'] = self.walletAddress
|
1972
|
+
headers['PARADEX-STARKNET-ACCOUNT'] = query['account']
|
1973
|
+
headers['PARADEX-STARKNET-SIGNATURE'] = query['signature']
|
1974
|
+
headers['PARADEX-TIMESTAMP'] = str(self.nonce())
|
1975
|
+
headers['Content-Type'] = 'application/json'
|
1976
|
+
body = self.json({
|
1977
|
+
'public_key': query['public_key'],
|
1978
|
+
})
|
1979
|
+
else:
|
1980
|
+
token = self.options['authToken']
|
1981
|
+
headers['Authorization'] = 'Bearer ' + token
|
1982
|
+
if method == 'POST':
|
1983
|
+
headers['Content-Type'] = 'application/json'
|
1984
|
+
body = self.json(query)
|
1985
|
+
else:
|
1986
|
+
url = url + '?' + self.urlencode(query)
|
1987
|
+
# headers = {
|
1988
|
+
# 'Accept': 'application/json',
|
1989
|
+
# 'Authorization': 'Bearer ' + self.apiKey,
|
1990
|
+
# }
|
1991
|
+
# if method == 'POST':
|
1992
|
+
# body = self.json(query)
|
1993
|
+
# headers['Content-Type'] = 'application/json'
|
1994
|
+
# else:
|
1995
|
+
# if query:
|
1996
|
+
# url += '?' + self.urlencode(query)
|
1997
|
+
# }
|
1998
|
+
# }
|
1999
|
+
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
2000
|
+
|
2001
|
+
def handle_errors(self, httpCode: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
|
2002
|
+
if not response:
|
2003
|
+
return None # fallback to default error handler
|
2004
|
+
#
|
2005
|
+
# {
|
2006
|
+
# "data": null,
|
2007
|
+
# "error": "NOT_ONBOARDED",
|
2008
|
+
# "message": "User has never called /onboarding endpoint"
|
2009
|
+
# }
|
2010
|
+
#
|
2011
|
+
errorCode = self.safe_string(response, 'error')
|
2012
|
+
if errorCode is not None:
|
2013
|
+
feedback = self.id + ' ' + body
|
2014
|
+
self.throw_broadly_matched_exception(self.exceptions['broad'], body, feedback)
|
2015
|
+
self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
|
2016
|
+
raise ExchangeError(feedback) # unknown message
|
2017
|
+
return None
|