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
ccxt/vertex.py
ADDED
@@ -0,0 +1,2983 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
4
|
+
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
5
|
+
|
6
|
+
from ccxt.base.exchange import Exchange
|
7
|
+
from ccxt.abstract.vertex import ImplicitAPI
|
8
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees, 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 InsufficientFunds
|
16
|
+
from ccxt.base.errors import InvalidOrder
|
17
|
+
from ccxt.base.errors import NotSupported
|
18
|
+
from ccxt.base.errors import RateLimitExceeded
|
19
|
+
from ccxt.base.decimal_to_precision import TICK_SIZE
|
20
|
+
from ccxt.base.precise import Precise
|
21
|
+
|
22
|
+
|
23
|
+
class vertex(Exchange, ImplicitAPI):
|
24
|
+
|
25
|
+
def describe(self):
|
26
|
+
return self.deep_extend(super(vertex, self).describe(), {
|
27
|
+
'id': 'vertex',
|
28
|
+
'name': 'Vertex',
|
29
|
+
'countries': [],
|
30
|
+
'version': 'v1',
|
31
|
+
'rateLimit': 50,
|
32
|
+
'certified': False,
|
33
|
+
'pro': True,
|
34
|
+
'dex': True,
|
35
|
+
'has': {
|
36
|
+
'CORS': None,
|
37
|
+
'spot': True,
|
38
|
+
'margin': False,
|
39
|
+
'swap': True,
|
40
|
+
'future': True,
|
41
|
+
'option': False,
|
42
|
+
'addMargin': False,
|
43
|
+
'borrowCrossMargin': False,
|
44
|
+
'borrowIsolatedMargin': False,
|
45
|
+
'cancelAllOrders': True,
|
46
|
+
'cancelAllOrdersAfter': False,
|
47
|
+
'cancelOrder': True,
|
48
|
+
'cancelOrders': True,
|
49
|
+
'cancelOrdersForSymbols': False,
|
50
|
+
'closeAllPositions': False,
|
51
|
+
'closePosition': False,
|
52
|
+
'createMarketBuyOrderWithCost': False,
|
53
|
+
'createMarketOrderWithCost': False,
|
54
|
+
'createMarketSellOrderWithCost': False,
|
55
|
+
'createOrder': True,
|
56
|
+
'createOrders': True,
|
57
|
+
'createReduceOnlyOrder': True,
|
58
|
+
'createStopOrder': True,
|
59
|
+
'createTriggerOrder': True,
|
60
|
+
'editOrder': False,
|
61
|
+
'fetchAccounts': False,
|
62
|
+
'fetchBalance': True,
|
63
|
+
'fetchBorrowInterest': False,
|
64
|
+
'fetchBorrowRateHistories': False,
|
65
|
+
'fetchBorrowRateHistory': False,
|
66
|
+
'fetchCanceledOrders': False,
|
67
|
+
'fetchClosedOrders': False,
|
68
|
+
'fetchCrossBorrowRate': False,
|
69
|
+
'fetchCrossBorrowRates': False,
|
70
|
+
'fetchCurrencies': True,
|
71
|
+
'fetchDepositAddress': False,
|
72
|
+
'fetchDepositAddresses': False,
|
73
|
+
'fetchDeposits': False,
|
74
|
+
'fetchDepositWithdrawFee': False,
|
75
|
+
'fetchDepositWithdrawFees': False,
|
76
|
+
'fetchFundingHistory': False,
|
77
|
+
'fetchFundingRate': True,
|
78
|
+
'fetchFundingRateHistory': False,
|
79
|
+
'fetchFundingRates': True,
|
80
|
+
'fetchIndexOHLCV': False,
|
81
|
+
'fetchIsolatedBorrowRate': False,
|
82
|
+
'fetchIsolatedBorrowRates': False,
|
83
|
+
'fetchLedger': False,
|
84
|
+
'fetchLeverage': False,
|
85
|
+
'fetchLeverageTiers': False,
|
86
|
+
'fetchLiquidations': False,
|
87
|
+
'fetchMarginMode': None,
|
88
|
+
'fetchMarketLeverageTiers': False,
|
89
|
+
'fetchMarkets': True,
|
90
|
+
'fetchMarkOHLCV': False,
|
91
|
+
'fetchMyLiquidations': False,
|
92
|
+
'fetchMyTrades': True,
|
93
|
+
'fetchOHLCV': True,
|
94
|
+
'fetchOpenInterest': True,
|
95
|
+
'fetchOpenInterestHistory': False,
|
96
|
+
'fetchOpenInterests': True,
|
97
|
+
'fetchOpenOrders': True,
|
98
|
+
'fetchOrder': True,
|
99
|
+
'fetchOrderBook': True,
|
100
|
+
'fetchOrders': True,
|
101
|
+
'fetchOrderTrades': False,
|
102
|
+
'fetchPosition': False,
|
103
|
+
'fetchPositionMode': False,
|
104
|
+
'fetchPositions': True,
|
105
|
+
'fetchPositionsRisk': False,
|
106
|
+
'fetchPremiumIndexOHLCV': False,
|
107
|
+
'fetchStatus': True,
|
108
|
+
'fetchTicker': False,
|
109
|
+
'fetchTickers': True,
|
110
|
+
'fetchTime': True,
|
111
|
+
'fetchTrades': True,
|
112
|
+
'fetchTradingFee': False,
|
113
|
+
'fetchTradingFees': True,
|
114
|
+
'fetchTransfer': False,
|
115
|
+
'fetchTransfers': False,
|
116
|
+
'fetchWithdrawal': False,
|
117
|
+
'fetchWithdrawals': False,
|
118
|
+
'reduceMargin': False,
|
119
|
+
'repayCrossMargin': False,
|
120
|
+
'repayIsolatedMargin': False,
|
121
|
+
'sandbox': True,
|
122
|
+
'setLeverage': False,
|
123
|
+
'setMarginMode': False,
|
124
|
+
'setPositionMode': False,
|
125
|
+
'transfer': False,
|
126
|
+
'withdraw': True,
|
127
|
+
},
|
128
|
+
'timeframes': {
|
129
|
+
'1m': 60,
|
130
|
+
'5m': 300,
|
131
|
+
'15m': 900,
|
132
|
+
'1h': 3600,
|
133
|
+
'2h': 7200,
|
134
|
+
'4h': 14400,
|
135
|
+
'1d': 86400,
|
136
|
+
'1w': 604800,
|
137
|
+
'1M': 604800,
|
138
|
+
},
|
139
|
+
'hostname': 'vertexprotocol.com',
|
140
|
+
'urls': {
|
141
|
+
'logo': 'https://github.com/ccxt/ccxt/assets/43336371/bd04a0fa-3b48-47b6-9d8b-124954d520a8',
|
142
|
+
'api': {
|
143
|
+
'v1': {
|
144
|
+
'archive': 'https://archive.prod.{hostname}/v1',
|
145
|
+
'gateway': 'https://gateway.prod.{hostname}/v1',
|
146
|
+
'trigger': 'https://trigger.prod.{hostname}/v1',
|
147
|
+
},
|
148
|
+
'v2': {
|
149
|
+
'archive': 'https://archive.prod.{hostname}/v2',
|
150
|
+
'gateway': 'https://gateway.prod.{hostname}/v2',
|
151
|
+
},
|
152
|
+
},
|
153
|
+
'test': {
|
154
|
+
'v1': {
|
155
|
+
'archive': 'https://archive.sepolia-test.{hostname}/v1',
|
156
|
+
'gateway': 'https://gateway.sepolia-test.{hostname}/v1',
|
157
|
+
'trigger': 'https://trigger.sepolia-test.{hostname}/v1',
|
158
|
+
},
|
159
|
+
'v2': {
|
160
|
+
'archive': 'https://archive.sepolia-test.{hostname}/v2',
|
161
|
+
'gateway': 'https://gateway.sepolia-test.{hostname}/v2',
|
162
|
+
},
|
163
|
+
},
|
164
|
+
'www': 'https://vertexprotocol.com/',
|
165
|
+
'doc': 'https://docs.vertexprotocol.com/',
|
166
|
+
'fees': 'https://docs.vertexprotocol.com/basics/fees',
|
167
|
+
'referral': 'https://app.vertexprotocol.com?referrer=0xCfC9BaB96a2eA3d3c3F031c005e82E1D9F295aC1',
|
168
|
+
},
|
169
|
+
'api': {
|
170
|
+
'v1': {
|
171
|
+
'archive': {
|
172
|
+
'post': {
|
173
|
+
'': 1,
|
174
|
+
},
|
175
|
+
},
|
176
|
+
'gateway': {
|
177
|
+
'get': {
|
178
|
+
'query': 1,
|
179
|
+
'symbols': 1,
|
180
|
+
'time': 1,
|
181
|
+
},
|
182
|
+
'post': {
|
183
|
+
'query': 1,
|
184
|
+
'execute': 1,
|
185
|
+
},
|
186
|
+
},
|
187
|
+
'trigger': {
|
188
|
+
'post': {
|
189
|
+
'execute': 1,
|
190
|
+
'query': 1,
|
191
|
+
},
|
192
|
+
},
|
193
|
+
},
|
194
|
+
'v2': {
|
195
|
+
'archive': {
|
196
|
+
'get': {
|
197
|
+
'tickers': 1,
|
198
|
+
'contracts': 1,
|
199
|
+
'trades': 1,
|
200
|
+
'vrtx': 1,
|
201
|
+
},
|
202
|
+
},
|
203
|
+
'gateway': {
|
204
|
+
'get': {
|
205
|
+
'assets': 0.6667,
|
206
|
+
'pairs': 1,
|
207
|
+
'orderbook': 1,
|
208
|
+
},
|
209
|
+
},
|
210
|
+
},
|
211
|
+
},
|
212
|
+
'fees': {
|
213
|
+
'swap': {
|
214
|
+
'taker': self.parse_number('0.0002'),
|
215
|
+
'maker': self.parse_number('0.0002'),
|
216
|
+
},
|
217
|
+
'spot': {
|
218
|
+
'taker': self.parse_number('0.0002'),
|
219
|
+
'maker': self.parse_number('0.0002'),
|
220
|
+
},
|
221
|
+
},
|
222
|
+
'requiredCredentials': {
|
223
|
+
'apiKey': False,
|
224
|
+
'secret': False,
|
225
|
+
'walletAddress': True,
|
226
|
+
'privateKey': True,
|
227
|
+
},
|
228
|
+
'exceptions': {
|
229
|
+
'exact': {
|
230
|
+
'1000': RateLimitExceeded,
|
231
|
+
'1015': RateLimitExceeded,
|
232
|
+
'1001': PermissionDenied,
|
233
|
+
'1002': PermissionDenied,
|
234
|
+
'1003': PermissionDenied,
|
235
|
+
'2000': InvalidOrder,
|
236
|
+
'2001': InvalidOrder,
|
237
|
+
'2002': InvalidOrder,
|
238
|
+
'2003': InvalidOrder,
|
239
|
+
'2004': InvalidOrder,
|
240
|
+
'2005': InvalidOrder,
|
241
|
+
'2006': InvalidOrder,
|
242
|
+
'2007': InvalidOrder,
|
243
|
+
'2008': InvalidOrder,
|
244
|
+
'2009': InvalidOrder,
|
245
|
+
'2010': InvalidOrder,
|
246
|
+
'2011': BadRequest,
|
247
|
+
'2012': BadRequest,
|
248
|
+
'2013': InvalidOrder,
|
249
|
+
'2014': PermissionDenied,
|
250
|
+
'2015': InvalidOrder,
|
251
|
+
'2016': InvalidOrder,
|
252
|
+
'2017': InvalidOrder,
|
253
|
+
'2019': InvalidOrder,
|
254
|
+
'2020': InvalidOrder,
|
255
|
+
'2021': InvalidOrder,
|
256
|
+
'2022': InvalidOrder,
|
257
|
+
'2023': InvalidOrder,
|
258
|
+
'2024': InsufficientFunds,
|
259
|
+
'2025': InsufficientFunds,
|
260
|
+
'2026': BadRequest,
|
261
|
+
'2027': AuthenticationError,
|
262
|
+
'2028': AuthenticationError,
|
263
|
+
'2029': AuthenticationError,
|
264
|
+
'2030': BadRequest,
|
265
|
+
'2031': InvalidOrder,
|
266
|
+
'2033': InvalidOrder,
|
267
|
+
'2034': InvalidOrder,
|
268
|
+
'2035': InvalidOrder,
|
269
|
+
'2036': InvalidOrder,
|
270
|
+
'2037': InvalidOrder,
|
271
|
+
'2038': InvalidOrder,
|
272
|
+
'2039': InvalidOrder,
|
273
|
+
'2040': InvalidOrder,
|
274
|
+
'2041': InvalidOrder,
|
275
|
+
'2042': InvalidOrder,
|
276
|
+
'2043': InvalidOrder,
|
277
|
+
'2044': InvalidOrder,
|
278
|
+
'2045': InvalidOrder,
|
279
|
+
'2046': InvalidOrder,
|
280
|
+
'2047': InvalidOrder,
|
281
|
+
'2048': InvalidOrder,
|
282
|
+
'2049': ExchangeError,
|
283
|
+
'2050': PermissionDenied,
|
284
|
+
'2051': InvalidOrder,
|
285
|
+
'2052': InvalidOrder,
|
286
|
+
'2053': InvalidOrder,
|
287
|
+
'2054': InvalidOrder,
|
288
|
+
'2055': InvalidOrder,
|
289
|
+
'2056': InvalidOrder,
|
290
|
+
'2057': InvalidOrder,
|
291
|
+
'2058': InvalidOrder,
|
292
|
+
'2059': InvalidOrder,
|
293
|
+
'2060': InvalidOrder,
|
294
|
+
'2061': InvalidOrder,
|
295
|
+
'2062': InvalidOrder,
|
296
|
+
'2063': InvalidOrder,
|
297
|
+
'2064': InvalidOrder,
|
298
|
+
'2065': InvalidOrder,
|
299
|
+
'2066': InvalidOrder,
|
300
|
+
'2067': InvalidOrder,
|
301
|
+
'2068': InvalidOrder,
|
302
|
+
'2069': InvalidOrder,
|
303
|
+
'2070': InvalidOrder,
|
304
|
+
'2071': InvalidOrder,
|
305
|
+
'2072': InvalidOrder,
|
306
|
+
'2073': InvalidOrder,
|
307
|
+
'2074': InvalidOrder,
|
308
|
+
'2075': InvalidOrder,
|
309
|
+
'2076': InvalidOrder,
|
310
|
+
'3000': BadRequest,
|
311
|
+
'3001': BadRequest,
|
312
|
+
'3002': BadRequest,
|
313
|
+
'3003': BadRequest,
|
314
|
+
'4000': BadRequest,
|
315
|
+
'4001': ExchangeError,
|
316
|
+
'4002': ExchangeError,
|
317
|
+
'4003': ExchangeError,
|
318
|
+
'4004': InvalidOrder,
|
319
|
+
'5000': ExchangeError,
|
320
|
+
},
|
321
|
+
'broad': {
|
322
|
+
},
|
323
|
+
},
|
324
|
+
'precisionMode': TICK_SIZE,
|
325
|
+
'commonCurrencies': {
|
326
|
+
},
|
327
|
+
'options': {
|
328
|
+
'defaultType': 'swap',
|
329
|
+
'sandboxMode': False,
|
330
|
+
'timeDifference': 0, # the difference between system clock and exchange server clock
|
331
|
+
'brokerId': 5930043274845996,
|
332
|
+
},
|
333
|
+
})
|
334
|
+
|
335
|
+
def set_sandbox_mode(self, enabled):
|
336
|
+
super(vertex, self).set_sandbox_mode(enabled)
|
337
|
+
self.options['sandboxMode'] = enabled
|
338
|
+
|
339
|
+
def convert_to_x18(self, num):
|
340
|
+
if isinstance(num, str):
|
341
|
+
return Precise.string_mul(num, '1000000000000000000')
|
342
|
+
numStr = self.number_to_string(num)
|
343
|
+
return Precise.string_mul(numStr, '1000000000000000000')
|
344
|
+
|
345
|
+
def convert_from_x18(self, num):
|
346
|
+
if isinstance(num, str):
|
347
|
+
return Precise.string_div(num, '1000000000000000000')
|
348
|
+
numStr = self.number_to_string(num)
|
349
|
+
return Precise.string_div(numStr, '1000000000000000000')
|
350
|
+
|
351
|
+
def fetch_currencies(self, params={}) -> Currencies:
|
352
|
+
"""
|
353
|
+
fetches all available currencies on an exchange
|
354
|
+
|
355
|
+
https://docs.vertexprotocol.com/developer-resources/api/v2/assets
|
356
|
+
|
357
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
358
|
+
:returns dict: an associative dictionary of currencies
|
359
|
+
"""
|
360
|
+
request = {}
|
361
|
+
response = self.v2GatewayGetAssets(self.extend(request, params))
|
362
|
+
#
|
363
|
+
# [
|
364
|
+
# {
|
365
|
+
# "product_id": 2,
|
366
|
+
# "ticker_id": "BTC-PERP_USDC",
|
367
|
+
# "market_type": "perp",
|
368
|
+
# "name": "Bitcoin Perp",
|
369
|
+
# "symbol": "BTC-PERP",
|
370
|
+
# "maker_fee": 0.0002,
|
371
|
+
# "taker_fee": 0,
|
372
|
+
# "can_withdraw": False,
|
373
|
+
# "can_deposit": False
|
374
|
+
# },
|
375
|
+
# {
|
376
|
+
# "product_id": 1,
|
377
|
+
# "ticker_id": "BTC_USDC",
|
378
|
+
# "market_type": "spot",
|
379
|
+
# "name": "Bitcoin",
|
380
|
+
# "symbol": "BTC",
|
381
|
+
# "taker_fee": 0.0003,
|
382
|
+
# "maker_fee": 0,
|
383
|
+
# "can_withdraw": True,
|
384
|
+
# "can_deposit": True
|
385
|
+
# }
|
386
|
+
# ]
|
387
|
+
#
|
388
|
+
result = {}
|
389
|
+
for i in range(0, len(response)):
|
390
|
+
data = self.safe_dict(response, i, {})
|
391
|
+
tickerId = self.safe_string(data, 'ticker_id')
|
392
|
+
if (tickerId is not None) and (tickerId.find('PERP') > 0):
|
393
|
+
continue
|
394
|
+
id = self.safe_string(data, 'product_id')
|
395
|
+
name = self.safe_string(data, 'symbol')
|
396
|
+
code = self.safe_currency_code(name)
|
397
|
+
result[code] = {
|
398
|
+
'id': id,
|
399
|
+
'name': name,
|
400
|
+
'code': code,
|
401
|
+
'precision': None,
|
402
|
+
'info': data,
|
403
|
+
'active': None,
|
404
|
+
'deposit': self.safe_bool(data, 'can_deposit'),
|
405
|
+
'withdraw': self.safe_bool(data, 'can_withdraw'),
|
406
|
+
'networks': None,
|
407
|
+
'fee': None,
|
408
|
+
'limits': {
|
409
|
+
'amount': {
|
410
|
+
'min': None,
|
411
|
+
'max': None,
|
412
|
+
},
|
413
|
+
'withdraw': {
|
414
|
+
'min': None,
|
415
|
+
'max': None,
|
416
|
+
},
|
417
|
+
},
|
418
|
+
}
|
419
|
+
return result
|
420
|
+
|
421
|
+
def parse_market(self, market) -> Market:
|
422
|
+
#
|
423
|
+
# {
|
424
|
+
# "type": "spot",
|
425
|
+
# "product_id": 3,
|
426
|
+
# "symbol": "WETH",
|
427
|
+
# "price_increment_x18": "100000000000000000",
|
428
|
+
# "size_increment": "10000000000000000",
|
429
|
+
# "min_size": "100000000000000000",
|
430
|
+
# "min_depth_x18": "5000000000000000000000",
|
431
|
+
# "max_spread_rate_x18": "2000000000000000",
|
432
|
+
# "maker_fee_rate_x18": "0",
|
433
|
+
# "taker_fee_rate_x18": "300000000000000",
|
434
|
+
# "long_weight_initial_x18": "900000000000000000",
|
435
|
+
# "long_weight_maintenance_x18": "950000000000000000"
|
436
|
+
# }
|
437
|
+
#
|
438
|
+
marketType = self.safe_string(market, 'type')
|
439
|
+
quoteId = 'USDC'
|
440
|
+
quote = self.safe_currency_code(quoteId)
|
441
|
+
baseId = self.safe_string(market, 'symbol')
|
442
|
+
base = self.safe_currency_code(baseId)
|
443
|
+
settleId = quoteId
|
444
|
+
settle = self.safe_currency_code(settleId)
|
445
|
+
symbol = base + '/' + quote
|
446
|
+
spot = marketType == 'spot'
|
447
|
+
contract = not spot
|
448
|
+
swap = not spot
|
449
|
+
if swap:
|
450
|
+
splitSymbol = base.split('-')
|
451
|
+
symbol = splitSymbol[0] + '/' + quote + ':' + settle
|
452
|
+
priceIncrementX18 = self.safe_string(market, 'price_increment_x18')
|
453
|
+
sizeIncrementX18 = self.safe_string(market, 'size_increment')
|
454
|
+
minSizeX18 = self.safe_string(market, 'min_size')
|
455
|
+
takerX18 = self.safe_number(market, 'taker_fee_rate_x18')
|
456
|
+
makerX18 = self.safe_number(market, 'maker_fee_rate_x18')
|
457
|
+
isInverse = None if (spot) else False
|
458
|
+
isLinear = None if (spot) else True
|
459
|
+
contractSize = None if (spot) else self.parse_number('1')
|
460
|
+
return {
|
461
|
+
'id': self.safe_string(market, 'product_id'),
|
462
|
+
'symbol': symbol,
|
463
|
+
'base': base,
|
464
|
+
'quote': quote,
|
465
|
+
'settle': None if (spot) else settle,
|
466
|
+
'baseId': baseId,
|
467
|
+
'quoteId': quoteId,
|
468
|
+
'settleId': None if (spot) else settleId,
|
469
|
+
'type': 'spot' if (spot) else 'swap',
|
470
|
+
'spot': spot,
|
471
|
+
'margin': None,
|
472
|
+
'swap': swap,
|
473
|
+
'future': False,
|
474
|
+
'option': False,
|
475
|
+
'active': True,
|
476
|
+
'contract': contract,
|
477
|
+
'linear': isLinear,
|
478
|
+
'inverse': isInverse,
|
479
|
+
'taker': self.parse_number(self.convert_from_x18(takerX18)),
|
480
|
+
'maker': self.parse_number(self.convert_from_x18(makerX18)),
|
481
|
+
'contractSize': contractSize,
|
482
|
+
'expiry': None,
|
483
|
+
'expiryDatetime': None,
|
484
|
+
'strike': None,
|
485
|
+
'optionType': None,
|
486
|
+
'precision': {
|
487
|
+
'amount': self.parse_number(self.convert_from_x18(sizeIncrementX18)),
|
488
|
+
'price': self.parse_number(self.convert_from_x18(priceIncrementX18)),
|
489
|
+
},
|
490
|
+
'limits': {
|
491
|
+
'leverage': {
|
492
|
+
'min': None,
|
493
|
+
'max': None,
|
494
|
+
},
|
495
|
+
'amount': {
|
496
|
+
'min': self.parse_number(self.convert_from_x18(minSizeX18)),
|
497
|
+
'max': None,
|
498
|
+
},
|
499
|
+
'price': {
|
500
|
+
'min': None,
|
501
|
+
'max': None,
|
502
|
+
},
|
503
|
+
'cost': {
|
504
|
+
'min': None,
|
505
|
+
'max': None,
|
506
|
+
},
|
507
|
+
},
|
508
|
+
'created': None,
|
509
|
+
'info': market,
|
510
|
+
}
|
511
|
+
|
512
|
+
def fetch_markets(self, params={}) -> List[Market]:
|
513
|
+
"""
|
514
|
+
retrieves data on all markets for vertex
|
515
|
+
|
516
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/symbols
|
517
|
+
|
518
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
519
|
+
:returns dict[]: an array of objects representing market data
|
520
|
+
"""
|
521
|
+
request = {
|
522
|
+
'type': 'symbols',
|
523
|
+
}
|
524
|
+
response = self.v1GatewayGetQuery(self.extend(request, params))
|
525
|
+
#
|
526
|
+
# {
|
527
|
+
# "status": "success",
|
528
|
+
# "data": {
|
529
|
+
# "symbols": {
|
530
|
+
# "WETH": {
|
531
|
+
# "type": "spot",
|
532
|
+
# "product_id": 3,
|
533
|
+
# "symbol": "WETH",
|
534
|
+
# "price_increment_x18": "100000000000000000",
|
535
|
+
# "size_increment": "10000000000000000",
|
536
|
+
# "min_size": "100000000000000000",
|
537
|
+
# "min_depth_x18": "5000000000000000000000",
|
538
|
+
# "max_spread_rate_x18": "2000000000000000",
|
539
|
+
# "maker_fee_rate_x18": "0",
|
540
|
+
# "taker_fee_rate_x18": "300000000000000",
|
541
|
+
# "long_weight_initial_x18": "900000000000000000",
|
542
|
+
# "long_weight_maintenance_x18": "950000000000000000"
|
543
|
+
# }
|
544
|
+
# }
|
545
|
+
# },
|
546
|
+
# "request_type": "query_symbols"
|
547
|
+
# }
|
548
|
+
#
|
549
|
+
data = self.safe_dict(response, 'data', {})
|
550
|
+
markets = self.safe_dict(data, 'symbols', {})
|
551
|
+
symbols = list(markets.keys())
|
552
|
+
result = []
|
553
|
+
for i in range(0, len(symbols)):
|
554
|
+
symbol = symbols[i]
|
555
|
+
rawMarket = self.safe_dict(markets, symbol, {})
|
556
|
+
result.append(self.parse_market(rawMarket))
|
557
|
+
return result
|
558
|
+
|
559
|
+
def fetch_time(self, params={}):
|
560
|
+
"""
|
561
|
+
fetches the current integer timestamp in milliseconds from the exchange server
|
562
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
563
|
+
:returns int: the current integer timestamp in milliseconds from the exchange server
|
564
|
+
"""
|
565
|
+
response = self.v1GatewayGetTime(params)
|
566
|
+
# 1717481623452
|
567
|
+
return self.parse_number(response)
|
568
|
+
|
569
|
+
def fetch_status(self, params={}):
|
570
|
+
"""
|
571
|
+
the latest known information on the availability of the exchange API
|
572
|
+
|
573
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/status
|
574
|
+
|
575
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
576
|
+
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
|
577
|
+
"""
|
578
|
+
request = {
|
579
|
+
'type': 'status',
|
580
|
+
}
|
581
|
+
response = self.v1GatewayGetQuery(self.extend(request, params))
|
582
|
+
#
|
583
|
+
# {
|
584
|
+
# "status": "success",
|
585
|
+
# "data": "active",
|
586
|
+
# "request_type": "query_status",
|
587
|
+
# }
|
588
|
+
#
|
589
|
+
status = self.safe_string(response, 'data')
|
590
|
+
if status == 'active':
|
591
|
+
status = 'ok'
|
592
|
+
else:
|
593
|
+
status = 'error'
|
594
|
+
return {
|
595
|
+
'status': status,
|
596
|
+
'updated': None,
|
597
|
+
'eta': None,
|
598
|
+
'url': None,
|
599
|
+
'info': response,
|
600
|
+
}
|
601
|
+
|
602
|
+
def parse_trade(self, trade, market: Market = None) -> Trade:
|
603
|
+
#
|
604
|
+
# {
|
605
|
+
# "ticker_id": "ARB_USDC",
|
606
|
+
# "trade_id": 999994,
|
607
|
+
# "price": 1.1366122408151016,
|
608
|
+
# "base_filled": 175,
|
609
|
+
# "quote_filled": -198.90714214264278,
|
610
|
+
# "timestamp": 1691068943,
|
611
|
+
# "trade_type": "buy"
|
612
|
+
# }
|
613
|
+
# fetchMytrades
|
614
|
+
# {
|
615
|
+
# "digest": "0x80ce789702b670b7d33f2aa67e12c85f124395c3f9acdb422dde3b4973ccd50c",
|
616
|
+
# "order": {
|
617
|
+
# "sender": "0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000",
|
618
|
+
# "priceX18": "27544000000000000000000",
|
619
|
+
# "amount": "2000000000000000000",
|
620
|
+
# "expiration": "4611686020107119633",
|
621
|
+
# "nonce": "1761322608857448448"
|
622
|
+
# },
|
623
|
+
# "base_filled": "736000000000000000",
|
624
|
+
# "quote_filled": "-20276464287857571514302",
|
625
|
+
# "fee": "4055287857571514302",
|
626
|
+
# "sequencer_fee": "0"
|
627
|
+
# "cumulative_fee": "4055287857571514302",
|
628
|
+
# "cumulative_base_filled": "736000000000000000",
|
629
|
+
# "cumulative_quote_filled": "-20276464287857571514302",
|
630
|
+
# "submission_idx": "563012",
|
631
|
+
# "pre_balance": {
|
632
|
+
# "base": {
|
633
|
+
# "perp": {
|
634
|
+
# "product_id": 2,
|
635
|
+
# "lp_balance": {
|
636
|
+
# "amount": "0",
|
637
|
+
# "last_cumulative_funding_x18": "1823351297710837"
|
638
|
+
# },
|
639
|
+
# "balance": {
|
640
|
+
# "amount": "2686684000000000000000",
|
641
|
+
# "v_quote_balance": "-76348662407149297671587247",
|
642
|
+
# "last_cumulative_funding_x18": "134999841911604906604576"
|
643
|
+
# }
|
644
|
+
# }
|
645
|
+
# },
|
646
|
+
# "quote": null
|
647
|
+
# },
|
648
|
+
# "post_balance": {
|
649
|
+
# "base": {
|
650
|
+
# "perp": {
|
651
|
+
# "product_id": 2,
|
652
|
+
# "lp_balance": {
|
653
|
+
# "amount": "0",
|
654
|
+
# "last_cumulative_funding_x18": "1823351297710837"
|
655
|
+
# },
|
656
|
+
# "balance": {
|
657
|
+
# "amount": "2686013000000000000000",
|
658
|
+
# "v_quote_balance": "-76328351274188497671587247",
|
659
|
+
# "last_cumulative_funding_x18": "134999841911604906604576"
|
660
|
+
# }
|
661
|
+
# }
|
662
|
+
# },
|
663
|
+
# "quote": null
|
664
|
+
# }
|
665
|
+
# }
|
666
|
+
price = None
|
667
|
+
amount = None
|
668
|
+
side = None
|
669
|
+
fee = None
|
670
|
+
feeCost = self.convert_from_x18(self.safe_string(trade, 'fee'))
|
671
|
+
if feeCost is not None:
|
672
|
+
fee = {
|
673
|
+
'cost': feeCost,
|
674
|
+
'currency': None,
|
675
|
+
}
|
676
|
+
id = self.safe_string_2(trade, 'trade_id', 'submission_idx')
|
677
|
+
order = self.safe_string(trade, 'digest')
|
678
|
+
timestamp = self.safe_timestamp(trade, 'timestamp')
|
679
|
+
if timestamp is None:
|
680
|
+
# fetchMyTrades
|
681
|
+
baseBalance = self.safe_dict(self.safe_dict(trade, 'pre_balance', {}), 'base', {})
|
682
|
+
marketId = None
|
683
|
+
if 'perp' in baseBalance:
|
684
|
+
marketId = self.safe_string(self.safe_dict(baseBalance, 'perp', {}), 'product_id')
|
685
|
+
else:
|
686
|
+
marketId = self.safe_string(self.safe_dict(baseBalance, 'spot', {}), 'product_id')
|
687
|
+
market = self.safe_market(marketId)
|
688
|
+
subOrder = self.safe_dict(trade, 'order', {})
|
689
|
+
price = self.convert_from_x18(self.safe_string(subOrder, 'priceX18'))
|
690
|
+
amount = self.convert_from_x18(self.safe_string(trade, 'base_filled'))
|
691
|
+
if Precise.string_lt(amount, '0'):
|
692
|
+
side = 'sell'
|
693
|
+
else:
|
694
|
+
side = 'buy'
|
695
|
+
else:
|
696
|
+
tickerId = self.safe_string(trade, 'ticker_id')
|
697
|
+
splitTickerId = tickerId.split('_')
|
698
|
+
splitSymbol = splitTickerId[0].split('-')
|
699
|
+
marketId = splitSymbol[0] + splitTickerId[1]
|
700
|
+
market = self.safe_market(marketId, market)
|
701
|
+
price = self.safe_string(trade, 'price')
|
702
|
+
amount = self.safe_string(trade, 'base_filled')
|
703
|
+
side = self.safe_string_lower(trade, 'trade_type')
|
704
|
+
amount = Precise.string_abs(amount)
|
705
|
+
symbol = market['symbol']
|
706
|
+
return self.safe_trade({
|
707
|
+
'id': id,
|
708
|
+
'timestamp': timestamp,
|
709
|
+
'datetime': self.iso8601(timestamp),
|
710
|
+
'symbol': symbol,
|
711
|
+
'side': side,
|
712
|
+
'price': price,
|
713
|
+
'amount': amount,
|
714
|
+
'cost': None,
|
715
|
+
'order': order,
|
716
|
+
'takerOrMaker': None,
|
717
|
+
'type': None,
|
718
|
+
'fee': fee,
|
719
|
+
'info': trade,
|
720
|
+
}, market)
|
721
|
+
|
722
|
+
def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
723
|
+
"""
|
724
|
+
get the list of most recent trades for a particular symbol
|
725
|
+
|
726
|
+
https://docs.vertexprotocol.com/developer-resources/api/v2/trades
|
727
|
+
|
728
|
+
:param str symbol: unified symbol of the market to fetch trades for
|
729
|
+
:param int [since]: timestamp in ms of the earliest trade to fetch
|
730
|
+
:param int [limit]: the maximum amount of trades to fetch
|
731
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
732
|
+
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
|
733
|
+
"""
|
734
|
+
self.load_markets()
|
735
|
+
market = self.market(symbol)
|
736
|
+
marketId = market['baseId'] + '_USDC'
|
737
|
+
request = {
|
738
|
+
'ticker_id': marketId,
|
739
|
+
}
|
740
|
+
if limit is not None:
|
741
|
+
request['limit'] = limit
|
742
|
+
response = self.v2ArchiveGetTrades(self.extend(request, params))
|
743
|
+
#
|
744
|
+
# [
|
745
|
+
# {
|
746
|
+
# "ticker_id": "ARB_USDC",
|
747
|
+
# "trade_id": 999994,
|
748
|
+
# "price": 1.1366122408151016,
|
749
|
+
# "base_filled": 175,
|
750
|
+
# "quote_filled": -198.90714214264278,
|
751
|
+
# "timestamp": 1691068943,
|
752
|
+
# "trade_type": "buy"
|
753
|
+
# },
|
754
|
+
# {
|
755
|
+
# "ticker_id": "ARB_USDC",
|
756
|
+
# "trade_id": 999978,
|
757
|
+
# "price": 1.136512210806099,
|
758
|
+
# "base_filled": 175,
|
759
|
+
# "quote_filled": -198.8896368910673,
|
760
|
+
# "timestamp": 1691068882,
|
761
|
+
# "trade_type": "buy"
|
762
|
+
# }
|
763
|
+
# ]
|
764
|
+
#
|
765
|
+
return self.parse_trades(response, market, since, limit)
|
766
|
+
|
767
|
+
def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
768
|
+
"""
|
769
|
+
fetch all trades made by the user
|
770
|
+
|
771
|
+
https://docs.vertexprotocol.com/developer-resources/api/archive-indexer/matches
|
772
|
+
|
773
|
+
:param str symbol: unified market symbol
|
774
|
+
:param int [since]: the earliest time in ms to fetch trades for
|
775
|
+
:param int [limit]: the maximum number of trades structures to retrieve
|
776
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
777
|
+
:param str [params.user]: user address, will default to self.walletAddress if not provided
|
778
|
+
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
779
|
+
"""
|
780
|
+
self.load_markets()
|
781
|
+
userAddress = None
|
782
|
+
userAddress, params = self.handle_public_address('fetchMyTrades', params)
|
783
|
+
market: Market = None
|
784
|
+
matchesRequest = {
|
785
|
+
'subaccount': self.convert_address_to_sender(userAddress),
|
786
|
+
}
|
787
|
+
if symbol is not None:
|
788
|
+
market = self.market(symbol)
|
789
|
+
matchesRequest['product_ids'] = [self.parse_to_numeric(market['id'])]
|
790
|
+
until = self.safe_integer(params, 'until')
|
791
|
+
if until is not None:
|
792
|
+
params = self.omit(params, 'until')
|
793
|
+
matchesRequest['max_time'] = until
|
794
|
+
if limit is not None:
|
795
|
+
matchesRequest['limit'] = limit
|
796
|
+
request = {
|
797
|
+
'matches': matchesRequest,
|
798
|
+
}
|
799
|
+
response = self.v1ArchivePost(self.extend(request, params))
|
800
|
+
#
|
801
|
+
# {
|
802
|
+
# "matches": [
|
803
|
+
# {
|
804
|
+
# "digest": "0x80ce789702b670b7d33f2aa67e12c85f124395c3f9acdb422dde3b4973ccd50c",
|
805
|
+
# "order": {
|
806
|
+
# "sender": "0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000",
|
807
|
+
# "priceX18": "27544000000000000000000",
|
808
|
+
# "amount": "2000000000000000000",
|
809
|
+
# "expiration": "4611686020107119633",
|
810
|
+
# "nonce": "1761322608857448448"
|
811
|
+
# },
|
812
|
+
# "base_filled": "736000000000000000",
|
813
|
+
# "quote_filled": "-20276464287857571514302",
|
814
|
+
# "fee": "4055287857571514302",
|
815
|
+
# "sequencer_fee": "0"
|
816
|
+
# "cumulative_fee": "4055287857571514302",
|
817
|
+
# "cumulative_base_filled": "736000000000000000",
|
818
|
+
# "cumulative_quote_filled": "-20276464287857571514302",
|
819
|
+
# "submission_idx": "563012",
|
820
|
+
# "pre_balance": {
|
821
|
+
# "base": {
|
822
|
+
# "perp": {
|
823
|
+
# "product_id": 2,
|
824
|
+
# "lp_balance": {
|
825
|
+
# "amount": "0",
|
826
|
+
# "last_cumulative_funding_x18": "1823351297710837"
|
827
|
+
# },
|
828
|
+
# "balance": {
|
829
|
+
# "amount": "2686684000000000000000",
|
830
|
+
# "v_quote_balance": "-76348662407149297671587247",
|
831
|
+
# "last_cumulative_funding_x18": "134999841911604906604576"
|
832
|
+
# }
|
833
|
+
# }
|
834
|
+
# },
|
835
|
+
# "quote": null
|
836
|
+
# },
|
837
|
+
# "post_balance": {
|
838
|
+
# "base": {
|
839
|
+
# "perp": {
|
840
|
+
# "product_id": 2,
|
841
|
+
# "lp_balance": {
|
842
|
+
# "amount": "0",
|
843
|
+
# "last_cumulative_funding_x18": "1823351297710837"
|
844
|
+
# },
|
845
|
+
# "balance": {
|
846
|
+
# "amount": "2686013000000000000000",
|
847
|
+
# "v_quote_balance": "-76328351274188497671587247",
|
848
|
+
# "last_cumulative_funding_x18": "134999841911604906604576"
|
849
|
+
# }
|
850
|
+
# }
|
851
|
+
# },
|
852
|
+
# "quote": null
|
853
|
+
# }
|
854
|
+
# },
|
855
|
+
# {
|
856
|
+
# "digest": "0x0f6e5a0434e36d8e6d4fed950d3624b0d8c91a8a84efd156bb25c1382561c0c2",
|
857
|
+
# "order": {
|
858
|
+
# "sender": "0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000",
|
859
|
+
# "priceX18": "27540000000000000000000",
|
860
|
+
# "amount": "2000000000000000000",
|
861
|
+
# "expiration": "4611686020107119623",
|
862
|
+
# "nonce": "1761322602510417920"
|
863
|
+
# },
|
864
|
+
# "base_filled": "723999999999999999",
|
865
|
+
# "quote_filled": "-19944943483044913474043",
|
866
|
+
# "fee": "5983483044913474042",
|
867
|
+
# "cumulative_fee": "11958484645393618085",
|
868
|
+
# "cumulative_base_filled": "1446999999999999998",
|
869
|
+
# "cumulative_quote_filled": "-39861640484645393618087",
|
870
|
+
# "submission_idx": "563011",
|
871
|
+
# "pre_balance": {
|
872
|
+
# "base": {
|
873
|
+
# "perp": {
|
874
|
+
# "product_id": 2,
|
875
|
+
# "lp_balance": {
|
876
|
+
# "amount": "0",
|
877
|
+
# "last_cumulative_funding_x18": "1823351297710837"
|
878
|
+
# },
|
879
|
+
# "balance": {
|
880
|
+
# "amount": "2686684000000000000000",
|
881
|
+
# "v_quote_balance": "-76348662407149297671587247",
|
882
|
+
# "last_cumulative_funding_x18": "134999841911604906604576"
|
883
|
+
# }
|
884
|
+
# }
|
885
|
+
# },
|
886
|
+
# "quote": null
|
887
|
+
# },
|
888
|
+
# "post_balance": {
|
889
|
+
# "base": {
|
890
|
+
# "perp": {
|
891
|
+
# "product_id": 2,
|
892
|
+
# "lp_balance": {
|
893
|
+
# "amount": "0",
|
894
|
+
# "last_cumulative_funding_x18": "1823351297710837"
|
895
|
+
# },
|
896
|
+
# "balance": {
|
897
|
+
# "amount": "2686013000000000000000",
|
898
|
+
# "v_quote_balance": "-76328351274188497671587247",
|
899
|
+
# "last_cumulative_funding_x18": "134999841911604906604576"
|
900
|
+
# }
|
901
|
+
# }
|
902
|
+
# },
|
903
|
+
# "quote": null
|
904
|
+
# }
|
905
|
+
# }
|
906
|
+
# ],
|
907
|
+
# "txs": [
|
908
|
+
# {
|
909
|
+
# "tx": {
|
910
|
+
# "match_orders": {
|
911
|
+
# "product_id": 2,
|
912
|
+
# "amm": True,
|
913
|
+
# "taker": {
|
914
|
+
# "order": {
|
915
|
+
# "sender": "0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000",
|
916
|
+
# "price_x18": "27544000000000000000000",
|
917
|
+
# "amount": "2000000000000000000",
|
918
|
+
# "expiration": 4611686020107120000,
|
919
|
+
# "nonce": 1761322608857448400
|
920
|
+
# },
|
921
|
+
# "signature": "0xe8fa7151bde348afa3b46dc52798046b7c8318f1b0a7f689710debbc094658cc1bf5a7e478ccc8278b625da0b9402c86b580d2e31e13831337dfd6153f4b37811b"
|
922
|
+
# },
|
923
|
+
# "maker": {
|
924
|
+
# "order": {
|
925
|
+
# "sender": "0xebdbbcdbd2646c5f23a1e0806027eee5f71b074664656661756c740000000000",
|
926
|
+
# "price_x18": "27544000000000000000000",
|
927
|
+
# "amount": "-736000000000000000",
|
928
|
+
# "expiration": 1679731669,
|
929
|
+
# "nonce": 1761322585591644200
|
930
|
+
# },
|
931
|
+
# "signature": "0x47f9d47f0777f3ca0b13f07b7682dbeea098c0e377b87dcb025754fe34c900e336b8c7744e021fb9c46a4f8c6a1478bafa28bf0d023ae496aa3efa4d8e81df181c"
|
932
|
+
# }
|
933
|
+
# }
|
934
|
+
# },
|
935
|
+
# "submission_idx": "563012",
|
936
|
+
# "timestamp": "1679728133"
|
937
|
+
# },
|
938
|
+
# {
|
939
|
+
# "tx": {
|
940
|
+
# "match_orders": {
|
941
|
+
# "product_id": 1,
|
942
|
+
# "amm": True,
|
943
|
+
# "taker": {
|
944
|
+
# "order": {
|
945
|
+
# "sender": "0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000",
|
946
|
+
# "price_x18": "27540000000000000000000",
|
947
|
+
# "amount": "2000000000000000000",
|
948
|
+
# "expiration": 4611686020107120000,
|
949
|
+
# "nonce": 1761322602510418000
|
950
|
+
# },
|
951
|
+
# "signature": "0x826c68f1a3f76d9ffbe8041f8d45e969d31f1ab6f2ae2f6379d1493e479e56436091d6cf4c72e212dd2f1d2fa17c627c4c21bd6d281c77172b8af030488478b71c"
|
952
|
+
# },
|
953
|
+
# "maker": {
|
954
|
+
# "order": {
|
955
|
+
# "sender": "0xf8d240d9514c9a4715d66268d7af3b53d619642564656661756c740000000000",
|
956
|
+
# "price_x18": "27540000000000000000000",
|
957
|
+
# "amount": "-724000000000000000",
|
958
|
+
# "expiration": 1679731656,
|
959
|
+
# "nonce": 1761322565506171000
|
960
|
+
# },
|
961
|
+
# "signature": "0xd8b6505b8d9b8c3cbfe793080976388035682c02a27893fb26b48a5b2bfe943f4162dea3a42e24e0dff5e2f74fbf77e33d83619140a2a581117c55e6cc236bdb1c"
|
962
|
+
# }
|
963
|
+
# }
|
964
|
+
# },
|
965
|
+
# "submission_idx": "563011",
|
966
|
+
# "timestamp": "1679728127"
|
967
|
+
# }
|
968
|
+
# ]
|
969
|
+
# }
|
970
|
+
#
|
971
|
+
trades = self.safe_list(response, 'matches', [])
|
972
|
+
return self.parse_trades(trades, market, since, limit, params)
|
973
|
+
|
974
|
+
def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
975
|
+
"""
|
976
|
+
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
977
|
+
|
978
|
+
https://docs.vertexprotocol.com/developer-resources/api/v2/orderbook
|
979
|
+
|
980
|
+
:param str symbol: unified symbol of the market to fetch the order book for
|
981
|
+
:param int [limit]: the maximum amount of order book entries to return
|
982
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
983
|
+
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
|
984
|
+
"""
|
985
|
+
self.load_markets()
|
986
|
+
market = self.market(symbol)
|
987
|
+
marketId = market['baseId'] + '_USDC'
|
988
|
+
if limit is None:
|
989
|
+
limit = 100
|
990
|
+
request = {
|
991
|
+
'ticker_id': marketId,
|
992
|
+
'depth': limit,
|
993
|
+
}
|
994
|
+
response = self.v2GatewayGetOrderbook(self.extend(request, params))
|
995
|
+
#
|
996
|
+
# {
|
997
|
+
# "ticker_id": "ETH-PERP_USDC",
|
998
|
+
# "bids": [
|
999
|
+
# [
|
1000
|
+
# 1612.3,
|
1001
|
+
# 0.31
|
1002
|
+
# ],
|
1003
|
+
# [
|
1004
|
+
# 1612.0,
|
1005
|
+
# 0.93
|
1006
|
+
# ],
|
1007
|
+
# [
|
1008
|
+
# 1611.5,
|
1009
|
+
# 1.55
|
1010
|
+
# ],
|
1011
|
+
# [
|
1012
|
+
# 1610.8,
|
1013
|
+
# 2.17
|
1014
|
+
# ]
|
1015
|
+
# ],
|
1016
|
+
# "asks": [
|
1017
|
+
# [
|
1018
|
+
# 1612.9,
|
1019
|
+
# 0.93
|
1020
|
+
# ],
|
1021
|
+
# [
|
1022
|
+
# 1613.4,
|
1023
|
+
# 1.55
|
1024
|
+
# ],
|
1025
|
+
# [
|
1026
|
+
# 1614.1,
|
1027
|
+
# 2.17
|
1028
|
+
# ]
|
1029
|
+
# ],
|
1030
|
+
# "timestamp": 1694375362016
|
1031
|
+
# }
|
1032
|
+
#
|
1033
|
+
timestamp = self.safe_integer(response, 'timestamp')
|
1034
|
+
return self.parse_order_book(response, symbol, timestamp, 'bids', 'asks')
|
1035
|
+
|
1036
|
+
def fetch_trading_fees(self, params={}) -> TradingFees:
|
1037
|
+
"""
|
1038
|
+
fetch the trading fees for multiple markets
|
1039
|
+
|
1040
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/fee-rates
|
1041
|
+
|
1042
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1043
|
+
:param str [params.user]: user address, will default to self.walletAddress if not provided
|
1044
|
+
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
|
1045
|
+
"""
|
1046
|
+
self.load_markets()
|
1047
|
+
userAddress = None
|
1048
|
+
userAddress, params = self.handle_public_address('fetchTradingFees', params)
|
1049
|
+
request = {
|
1050
|
+
'type': 'fee_rates',
|
1051
|
+
'sender': self.convert_address_to_sender(userAddress),
|
1052
|
+
}
|
1053
|
+
response = self.v1GatewayGetQuery(self.extend(request, params))
|
1054
|
+
#
|
1055
|
+
# {
|
1056
|
+
# "status": "success",
|
1057
|
+
# "data": {
|
1058
|
+
# "taker_fee_rates_x18": [
|
1059
|
+
# "0",
|
1060
|
+
# "300000000000000",
|
1061
|
+
# "200000000000000",
|
1062
|
+
# "300000000000000",
|
1063
|
+
# "200000000000000"
|
1064
|
+
# ],
|
1065
|
+
# "maker_fee_rates_x18": [
|
1066
|
+
# "0",
|
1067
|
+
# "0",
|
1068
|
+
# "0",
|
1069
|
+
# "0",
|
1070
|
+
# "0"
|
1071
|
+
# ],
|
1072
|
+
# "liquidation_sequencer_fee": "250000000000000000",
|
1073
|
+
# "health_check_sequencer_fee": "100000000000000000",
|
1074
|
+
# "taker_sequencer_fee": "25000000000000000",
|
1075
|
+
# "withdraw_sequencer_fees": [
|
1076
|
+
# "10000000000000000",
|
1077
|
+
# "40000000000000",
|
1078
|
+
# "0",
|
1079
|
+
# "600000000000000",
|
1080
|
+
# "0"
|
1081
|
+
# ]
|
1082
|
+
# },
|
1083
|
+
# "request_type": "query_fee_rates",
|
1084
|
+
# }
|
1085
|
+
#
|
1086
|
+
data = self.safe_dict(response, 'data', {})
|
1087
|
+
maker = self.safe_list(data, 'maker_fee_rates_x18', [])
|
1088
|
+
taker = self.safe_list(data, 'taker_fee_rates_x18', [])
|
1089
|
+
result = {}
|
1090
|
+
for i in range(0, len(taker)):
|
1091
|
+
market = self.safe_market(self.number_to_string(i))
|
1092
|
+
if market['id'] is None:
|
1093
|
+
continue
|
1094
|
+
symbol = market['symbol']
|
1095
|
+
result[symbol] = {
|
1096
|
+
'info': response,
|
1097
|
+
'symbol': symbol,
|
1098
|
+
'maker': self.parse_number(self.convert_from_x18(maker[i])),
|
1099
|
+
'taker': self.parse_number(self.convert_from_x18(taker[i])),
|
1100
|
+
'percentage': True,
|
1101
|
+
'tierBased': False,
|
1102
|
+
}
|
1103
|
+
return result
|
1104
|
+
|
1105
|
+
def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
|
1106
|
+
# example response in fetchOHLCV
|
1107
|
+
return [
|
1108
|
+
self.safe_timestamp(ohlcv, 'timestamp'),
|
1109
|
+
self.parse_number(self.convert_from_x18(self.safe_string(ohlcv, 'open_x18'))),
|
1110
|
+
self.parse_number(self.convert_from_x18(self.safe_string(ohlcv, 'high_x18'))),
|
1111
|
+
self.parse_number(self.convert_from_x18(self.safe_string(ohlcv, 'low_x18'))),
|
1112
|
+
self.parse_number(self.convert_from_x18(self.safe_string(ohlcv, 'close_x18'))),
|
1113
|
+
self.parse_number(self.convert_from_x18(self.safe_string(ohlcv, 'volume'))),
|
1114
|
+
]
|
1115
|
+
|
1116
|
+
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
1117
|
+
"""
|
1118
|
+
|
1119
|
+
https://docs.vertexprotocol.com/developer-resources/api/archive-indexer/candlesticks
|
1120
|
+
|
1121
|
+
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
1122
|
+
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
1123
|
+
:param str timeframe: the length of time each candle represents
|
1124
|
+
:param int [since]: timestamp in ms of the earliest candle to fetch
|
1125
|
+
:param int [limit]: max=1000, max=100 when since is defined and is less than(now - (999 * (timeframe in ms)))
|
1126
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1127
|
+
:returns int[][]: A list of candles ordered, open, high, low, close, volume
|
1128
|
+
"""
|
1129
|
+
self.load_markets()
|
1130
|
+
market = self.market(symbol)
|
1131
|
+
ohlcvRequest = {
|
1132
|
+
'product_id': self.parse_to_int(market['id']),
|
1133
|
+
'granularity': self.safe_integer(self.timeframes, timeframe),
|
1134
|
+
}
|
1135
|
+
until = self.safe_integer(params, 'until')
|
1136
|
+
if until is not None:
|
1137
|
+
params = self.omit(params, 'until')
|
1138
|
+
ohlcvRequest['max_time'] = until
|
1139
|
+
if limit is not None:
|
1140
|
+
ohlcvRequest['limit'] = min(limit, 1000)
|
1141
|
+
request = {
|
1142
|
+
'candlesticks': ohlcvRequest,
|
1143
|
+
}
|
1144
|
+
response = self.v1ArchivePost(self.extend(request, params))
|
1145
|
+
#
|
1146
|
+
# {
|
1147
|
+
# "candlesticks": [
|
1148
|
+
# {
|
1149
|
+
# "product_id": 1,
|
1150
|
+
# "granularity": 60,
|
1151
|
+
# "submission_idx": "627709",
|
1152
|
+
# "timestamp": "1680118140",
|
1153
|
+
# "open_x18": "27235000000000000000000",
|
1154
|
+
# "high_x18": "27298000000000000000000",
|
1155
|
+
# "low_x18": "27235000000000000000000",
|
1156
|
+
# "close_x18": "27298000000000000000000",
|
1157
|
+
# "volume": "1999999999999999998"
|
1158
|
+
# },
|
1159
|
+
# {
|
1160
|
+
# "product_id": 1,
|
1161
|
+
# "granularity": 60,
|
1162
|
+
# "submission_idx": "627699",
|
1163
|
+
# "timestamp": "1680118080",
|
1164
|
+
# "open_x18": "27218000000000000000000",
|
1165
|
+
# "high_x18": "27245000000000000000000",
|
1166
|
+
# "low_x18": "27218000000000000000000",
|
1167
|
+
# "close_x18": "27245000000000000000000",
|
1168
|
+
# "volume": "11852999999999999995"
|
1169
|
+
# }
|
1170
|
+
# ]
|
1171
|
+
# }
|
1172
|
+
#
|
1173
|
+
rows = self.safe_list(response, 'candlesticks', [])
|
1174
|
+
return self.parse_ohlcvs(rows, market, timeframe, since, limit)
|
1175
|
+
|
1176
|
+
def parse_funding_rate(self, ticker, market: Market = None) -> FundingRate:
|
1177
|
+
#
|
1178
|
+
# {
|
1179
|
+
# "product_id": 4,
|
1180
|
+
# "funding_rate_x18": "2447900598160952",
|
1181
|
+
# "update_time": "1680116326"
|
1182
|
+
# }
|
1183
|
+
#
|
1184
|
+
# {
|
1185
|
+
# "ETH-PERP_USDC": {
|
1186
|
+
# "ticker_id": "ETH-PERP_USDC",
|
1187
|
+
# "base_currency": "ETH-PERP",
|
1188
|
+
# "quote_currency": "USDC",
|
1189
|
+
# "last_price": 1620.3,
|
1190
|
+
# "base_volume": 1309.2,
|
1191
|
+
# "quote_volume": 2117828.093867611,
|
1192
|
+
# "product_type": "perpetual",
|
1193
|
+
# "contract_price": 1620.372642114429,
|
1194
|
+
# "contract_price_currency": "USD",
|
1195
|
+
# "open_interest": 1635.2,
|
1196
|
+
# "open_interest_usd": 2649633.3443855145,
|
1197
|
+
# "index_price": 1623.293496279935,
|
1198
|
+
# "mark_price": 1623.398589416731,
|
1199
|
+
# "funding_rate": 0.000068613217104332,
|
1200
|
+
# "next_funding_rate_timestamp": 1694379600,
|
1201
|
+
# "price_change_percent_24h": -0.6348599635253989
|
1202
|
+
# }
|
1203
|
+
# }
|
1204
|
+
#
|
1205
|
+
fundingRate = self.safe_number(ticker, 'funding_rate')
|
1206
|
+
if fundingRate is None:
|
1207
|
+
fundingRateX18 = self.safe_string(ticker, 'funding_rate_x18')
|
1208
|
+
fundingRate = self.parse_number(self.convert_from_x18(fundingRateX18))
|
1209
|
+
fundingTimestamp = self.safe_timestamp_2(ticker, 'update_time', 'next_funding_rate_timestamp')
|
1210
|
+
markPrice = self.safe_number(ticker, 'mark_price')
|
1211
|
+
indexPrice = self.safe_number(ticker, 'index_price')
|
1212
|
+
return {
|
1213
|
+
'info': ticker,
|
1214
|
+
'symbol': market['symbol'],
|
1215
|
+
'markPrice': markPrice,
|
1216
|
+
'indexPrice': indexPrice,
|
1217
|
+
'interestRate': None,
|
1218
|
+
'estimatedSettlePrice': None,
|
1219
|
+
'timestamp': None,
|
1220
|
+
'datetime': None,
|
1221
|
+
'fundingRate': fundingRate,
|
1222
|
+
'fundingTimestamp': fundingTimestamp,
|
1223
|
+
'fundingDatetime': self.iso8601(fundingTimestamp),
|
1224
|
+
'nextFundingRate': None,
|
1225
|
+
'nextFundingTimestamp': None,
|
1226
|
+
'nextFundingDatetime': None,
|
1227
|
+
'previousFundingRate': None,
|
1228
|
+
'previousFundingTimestamp': None,
|
1229
|
+
'previousFundingDatetime': None,
|
1230
|
+
'interval': None,
|
1231
|
+
}
|
1232
|
+
|
1233
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
1234
|
+
"""
|
1235
|
+
fetch the current funding rate
|
1236
|
+
|
1237
|
+
https://docs.vertexprotocol.com/developer-resources/api/archive-indexer/funding-rate
|
1238
|
+
|
1239
|
+
:param str symbol: unified market symbol
|
1240
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1241
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
1242
|
+
"""
|
1243
|
+
self.load_markets()
|
1244
|
+
market = self.market(symbol)
|
1245
|
+
request = {
|
1246
|
+
'funding_rate': {
|
1247
|
+
'product_id': self.parse_to_int(market['id']),
|
1248
|
+
},
|
1249
|
+
}
|
1250
|
+
response = self.v1ArchivePost(self.extend(request, params))
|
1251
|
+
#
|
1252
|
+
# {
|
1253
|
+
# "product_id": 4,
|
1254
|
+
# "funding_rate_x18": "2447900598160952",
|
1255
|
+
# "update_time": "1680116326"
|
1256
|
+
# }
|
1257
|
+
#
|
1258
|
+
return self.parse_funding_rate(response, market)
|
1259
|
+
|
1260
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
1261
|
+
"""
|
1262
|
+
fetches funding rates for multiple markets
|
1263
|
+
|
1264
|
+
https://docs.vertexprotocol.com/developer-resources/api/v2/contracts
|
1265
|
+
|
1266
|
+
:param str[] symbols: unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
|
1267
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1268
|
+
:returns dict[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
1269
|
+
"""
|
1270
|
+
self.load_markets()
|
1271
|
+
request = {}
|
1272
|
+
if symbols is not None:
|
1273
|
+
symbols = self.market_symbols(symbols)
|
1274
|
+
response = self.v2ArchiveGetContracts(self.extend(request, params))
|
1275
|
+
#
|
1276
|
+
# {
|
1277
|
+
# "ETH-PERP_USDC": {
|
1278
|
+
# "ticker_id": "ETH-PERP_USDC",
|
1279
|
+
# "base_currency": "ETH-PERP",
|
1280
|
+
# "quote_currency": "USDC",
|
1281
|
+
# "last_price": 1620.3,
|
1282
|
+
# "base_volume": 1309.2,
|
1283
|
+
# "quote_volume": 2117828.093867611,
|
1284
|
+
# "product_type": "perpetual",
|
1285
|
+
# "contract_price": 1620.372642114429,
|
1286
|
+
# "contract_price_currency": "USD",
|
1287
|
+
# "open_interest": 1635.2,
|
1288
|
+
# "open_interest_usd": 2649633.3443855145,
|
1289
|
+
# "index_price": 1623.293496279935,
|
1290
|
+
# "mark_price": 1623.398589416731,
|
1291
|
+
# "funding_rate": 0.000068613217104332,
|
1292
|
+
# "next_funding_rate_timestamp": 1694379600,
|
1293
|
+
# "price_change_percent_24h": -0.6348599635253989
|
1294
|
+
# }
|
1295
|
+
# }
|
1296
|
+
#
|
1297
|
+
keys = list(response.keys())
|
1298
|
+
fundingRates = {}
|
1299
|
+
for i in range(0, len(keys)):
|
1300
|
+
tickerId = keys[i]
|
1301
|
+
parsedTickerId = tickerId.split('-')
|
1302
|
+
data = response[tickerId]
|
1303
|
+
marketId = parsedTickerId[0] + '/USDC:USDC'
|
1304
|
+
market = self.market(marketId)
|
1305
|
+
ticker = self.parse_funding_rate(data, market)
|
1306
|
+
symbol = ticker['symbol']
|
1307
|
+
fundingRates[symbol] = ticker
|
1308
|
+
return self.filter_by_array(fundingRates, 'symbol', symbols)
|
1309
|
+
|
1310
|
+
def parse_open_interest(self, interest, market: Market = None):
|
1311
|
+
#
|
1312
|
+
# {
|
1313
|
+
# "ETH-PERP_USDC": {
|
1314
|
+
# "ticker_id": "ETH-PERP_USDC",
|
1315
|
+
# "base_currency": "ETH-PERP",
|
1316
|
+
# "quote_currency": "USDC",
|
1317
|
+
# "last_price": 1620.3,
|
1318
|
+
# "base_volume": 1309.2,
|
1319
|
+
# "quote_volume": 2117828.093867611,
|
1320
|
+
# "product_type": "perpetual",
|
1321
|
+
# "contract_price": 1620.372642114429,
|
1322
|
+
# "contract_price_currency": "USD",
|
1323
|
+
# "open_interest": 1635.2,
|
1324
|
+
# "open_interest_usd": 2649633.3443855145,
|
1325
|
+
# "index_price": 1623.293496279935,
|
1326
|
+
# "mark_price": 1623.398589416731,
|
1327
|
+
# "funding_rate": 0.000068613217104332,
|
1328
|
+
# "next_funding_rate_timestamp": 1694379600,
|
1329
|
+
# "price_change_percent_24h": -0.6348599635253989
|
1330
|
+
# }
|
1331
|
+
# }
|
1332
|
+
#
|
1333
|
+
marketId = self.safe_string(interest, 'ticker_id')
|
1334
|
+
return self.safe_open_interest({
|
1335
|
+
'symbol': self.safe_symbol(marketId, market),
|
1336
|
+
'openInterestAmount': self.safe_number(interest, 'open_interest'),
|
1337
|
+
'openInterestValue': self.safe_number(interest, 'open_interest_usd'),
|
1338
|
+
'timestamp': None,
|
1339
|
+
'datetime': None,
|
1340
|
+
'info': interest,
|
1341
|
+
}, market)
|
1342
|
+
|
1343
|
+
def fetch_open_interests(self, symbols: Strings = None, params={}):
|
1344
|
+
"""
|
1345
|
+
Retrieves the open interest for a list of symbols
|
1346
|
+
|
1347
|
+
https://docs.vertexprotocol.com/developer-resources/api/v2/contracts
|
1348
|
+
|
1349
|
+
:param str[] [symbols]: a list of unified CCXT market symbols
|
1350
|
+
:param dict [params]: exchange specific parameters
|
1351
|
+
:returns dict[]: a list of `open interest structures <https://docs.ccxt.com/#/?id=open-interest-structure>`
|
1352
|
+
"""
|
1353
|
+
self.load_markets()
|
1354
|
+
symbols = self.market_symbols(symbols)
|
1355
|
+
response = self.v2ArchiveGetContracts(params)
|
1356
|
+
#
|
1357
|
+
# {
|
1358
|
+
# "ADA-PERP_USDC": {
|
1359
|
+
# "ticker_id": "ADA-PERP_USDC",
|
1360
|
+
# "base_currency": "ADA-PERP",
|
1361
|
+
# "quote_currency": "USDC",
|
1362
|
+
# "last_price": 0.85506,
|
1363
|
+
# "base_volume": 1241320.0,
|
1364
|
+
# "quote_volume": 1122670.9080057142,
|
1365
|
+
# "product_type": "perpetual",
|
1366
|
+
# "contract_price": 0.8558601432685385,
|
1367
|
+
# "contract_price_currency": "USD",
|
1368
|
+
# "open_interest": 104040.0,
|
1369
|
+
# "open_interest_usd": 89043.68930565874,
|
1370
|
+
# "index_price": 0.8561952606869176,
|
1371
|
+
# "mark_price": 0.856293781088936,
|
1372
|
+
# "funding_rate": 0.000116153806226841,
|
1373
|
+
# "next_funding_rate_timestamp": 1734685200,
|
1374
|
+
# "price_change_percent_24h": -12.274325340321374
|
1375
|
+
# },
|
1376
|
+
# }
|
1377
|
+
#
|
1378
|
+
parsedSymbols = []
|
1379
|
+
results = []
|
1380
|
+
markets = list(response.keys())
|
1381
|
+
if symbols is None:
|
1382
|
+
symbols = []
|
1383
|
+
for y in range(0, len(markets)):
|
1384
|
+
tickerId = markets[y]
|
1385
|
+
parsedTickerId = tickerId.split('-')
|
1386
|
+
currentSymbol = parsedTickerId[0] + '/USDC:USDC'
|
1387
|
+
if not self.in_array(currentSymbol, symbols):
|
1388
|
+
symbols.append(currentSymbol)
|
1389
|
+
for i in range(0, len(markets)):
|
1390
|
+
marketId = markets[i]
|
1391
|
+
marketInner = self.safe_market(marketId)
|
1392
|
+
openInterest = self.safe_dict(response, marketId, {})
|
1393
|
+
for j in range(0, len(symbols)):
|
1394
|
+
market = self.market(symbols[j])
|
1395
|
+
tickerId = market['base'] + '_USDC'
|
1396
|
+
if marketInner['marketId'] == tickerId:
|
1397
|
+
parsedSymbols.append(market['symbol'])
|
1398
|
+
results.append(self.parse_open_interest(openInterest, market))
|
1399
|
+
return self.filter_by_array(results, 'symbol', parsedSymbols)
|
1400
|
+
|
1401
|
+
def fetch_open_interest(self, symbol: str, params={}):
|
1402
|
+
"""
|
1403
|
+
Retrieves the open interest of a derivative trading pair
|
1404
|
+
|
1405
|
+
https://docs.vertexprotocol.com/developer-resources/api/v2/contracts
|
1406
|
+
|
1407
|
+
:param str symbol: Unified CCXT market symbol
|
1408
|
+
:param dict [params]: exchange specific parameters
|
1409
|
+
:returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
|
1410
|
+
"""
|
1411
|
+
self.load_markets()
|
1412
|
+
market = self.market(symbol)
|
1413
|
+
if not market['contract']:
|
1414
|
+
raise BadRequest(self.id + ' fetchOpenInterest() supports contract markets only')
|
1415
|
+
request = {}
|
1416
|
+
response = self.v2ArchiveGetContracts(self.extend(request, params))
|
1417
|
+
#
|
1418
|
+
# {
|
1419
|
+
# "ETH-PERP_USDC": {
|
1420
|
+
# "ticker_id": "ETH-PERP_USDC",
|
1421
|
+
# "base_currency": "ETH-PERP",
|
1422
|
+
# "quote_currency": "USDC",
|
1423
|
+
# "last_price": 1620.3,
|
1424
|
+
# "base_volume": 1309.2,
|
1425
|
+
# "quote_volume": 2117828.093867611,
|
1426
|
+
# "product_type": "perpetual",
|
1427
|
+
# "contract_price": 1620.372642114429,
|
1428
|
+
# "contract_price_currency": "USD",
|
1429
|
+
# "open_interest": 1635.2,
|
1430
|
+
# "open_interest_usd": 2649633.3443855145,
|
1431
|
+
# "index_price": 1623.293496279935,
|
1432
|
+
# "mark_price": 1623.398589416731,
|
1433
|
+
# "funding_rate": 0.000068613217104332,
|
1434
|
+
# "next_funding_rate_timestamp": 1694379600,
|
1435
|
+
# "price_change_percent_24h": -0.6348599635253989
|
1436
|
+
# }
|
1437
|
+
# }
|
1438
|
+
#
|
1439
|
+
tickerId = market['base'] + '_USDC'
|
1440
|
+
openInterest = self.safe_dict(response, tickerId, {})
|
1441
|
+
return self.parse_open_interest(openInterest, market)
|
1442
|
+
|
1443
|
+
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
1444
|
+
#
|
1445
|
+
# {
|
1446
|
+
# "ticker_id": "BTC_USDC",
|
1447
|
+
# "base_currency": "BTC",
|
1448
|
+
# "quote_currency": "USDC",
|
1449
|
+
# "last_price": 25728.0,
|
1450
|
+
# "base_volume": 552.048,
|
1451
|
+
# "quote_volume": 14238632.207250029,
|
1452
|
+
# "price_change_percent_24h": -0.6348599635253989
|
1453
|
+
# }
|
1454
|
+
#
|
1455
|
+
base = self.safe_string(ticker, 'base_currency')
|
1456
|
+
quote = self.safe_string(ticker, 'quote_currency')
|
1457
|
+
marketId = base + '/' + quote
|
1458
|
+
if base.find('PERP') > 0:
|
1459
|
+
marketId = marketId.replace('-PERP', '') + ':USDC'
|
1460
|
+
market = self.market(marketId)
|
1461
|
+
last = self.safe_string(ticker, 'last_price')
|
1462
|
+
return self.safe_ticker({
|
1463
|
+
'symbol': market['symbol'],
|
1464
|
+
'timestamp': None,
|
1465
|
+
'datetime': None,
|
1466
|
+
'high': None,
|
1467
|
+
'low': None,
|
1468
|
+
'bid': None,
|
1469
|
+
'bidVolume': None,
|
1470
|
+
'ask': None,
|
1471
|
+
'askVolume': None,
|
1472
|
+
'vwap': None,
|
1473
|
+
'open': None,
|
1474
|
+
'close': last,
|
1475
|
+
'last': last,
|
1476
|
+
'previousClose': None,
|
1477
|
+
'change': None,
|
1478
|
+
'percentage': self.safe_string(ticker, 'price_change_percent_24h'),
|
1479
|
+
'average': None,
|
1480
|
+
'baseVolume': self.safe_string(ticker, 'base_volume'),
|
1481
|
+
'quoteVolume': self.safe_string(ticker, 'quote_volume'),
|
1482
|
+
'info': ticker,
|
1483
|
+
}, market)
|
1484
|
+
|
1485
|
+
def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
1486
|
+
"""
|
1487
|
+
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
1488
|
+
|
1489
|
+
https://docs.vertexprotocol.com/developer-resources/api/v2/tickers
|
1490
|
+
|
1491
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
1492
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1493
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1494
|
+
"""
|
1495
|
+
self.load_markets()
|
1496
|
+
symbols = self.market_symbols(symbols, None, True, True, True)
|
1497
|
+
request = {}
|
1498
|
+
response = self.v2ArchiveGetTickers(self.extend(request, params))
|
1499
|
+
#
|
1500
|
+
# {
|
1501
|
+
# "ETH_USDC": {
|
1502
|
+
# "ticker_id": "ETH_USDC",
|
1503
|
+
# "base_currency": "ETH",
|
1504
|
+
# "quote_currency": "USDC",
|
1505
|
+
# "last_price": 1619.1,
|
1506
|
+
# "base_volume": 1428.32,
|
1507
|
+
# "quote_volume": 2310648.316391866,
|
1508
|
+
# "price_change_percent_24h": -1.0509394462969588
|
1509
|
+
# },
|
1510
|
+
# "BTC_USDC": {
|
1511
|
+
# "ticker_id": "BTC_USDC",
|
1512
|
+
# "base_currency": "BTC",
|
1513
|
+
# "quote_currency": "USDC",
|
1514
|
+
# "last_price": 25728.0,
|
1515
|
+
# "base_volume": 552.048,
|
1516
|
+
# "quote_volume": 14238632.207250029,
|
1517
|
+
# "price_change_percent_24h": -0.6348599635253989
|
1518
|
+
# }
|
1519
|
+
# }
|
1520
|
+
#
|
1521
|
+
tickers = list(response.values())
|
1522
|
+
return self.parse_tickers(tickers, symbols)
|
1523
|
+
|
1524
|
+
def query_contracts(self, params={}) -> Currencies:
|
1525
|
+
# query contract addresses for sending order
|
1526
|
+
cachedContracts = self.safe_dict(self.options, 'v1contracts')
|
1527
|
+
if cachedContracts is not None:
|
1528
|
+
return cachedContracts
|
1529
|
+
request = {
|
1530
|
+
'type': 'contracts',
|
1531
|
+
}
|
1532
|
+
response = self.v1GatewayGetQuery(self.extend(request, params))
|
1533
|
+
data = self.safe_dict(response, 'data', {})
|
1534
|
+
self.options['v1contracts'] = data
|
1535
|
+
return data
|
1536
|
+
|
1537
|
+
def nonce(self):
|
1538
|
+
return self.milliseconds() - self.options['timeDifference']
|
1539
|
+
|
1540
|
+
def hash_message(self, message):
|
1541
|
+
return '0x' + self.hash(message, 'keccak', 'hex')
|
1542
|
+
|
1543
|
+
def sign_hash(self, hash, privateKey):
|
1544
|
+
signature = self.ecdsa(hash[-64:], privateKey[-64:], 'secp256k1', None)
|
1545
|
+
r = signature['r']
|
1546
|
+
s = signature['s']
|
1547
|
+
v = self.int_to_base16(self.sum(27, signature['v']))
|
1548
|
+
return '0x' + r.rjust(64, '0') + s.rjust(64, '0') + v
|
1549
|
+
|
1550
|
+
def sign_message(self, message, privateKey):
|
1551
|
+
return self.sign_hash(self.hash_message(message), privateKey[-64:])
|
1552
|
+
|
1553
|
+
def build_sig(self, chainId, messageTypes, message, verifyingContractAddress=''):
|
1554
|
+
domain = {
|
1555
|
+
'chainId': chainId,
|
1556
|
+
'name': 'Vertex',
|
1557
|
+
'verifyingContract': verifyingContractAddress,
|
1558
|
+
'version': '0.0.1',
|
1559
|
+
}
|
1560
|
+
msg = self.eth_encode_structured_data(domain, messageTypes, message)
|
1561
|
+
signature = self.sign_message(msg, self.privateKey)
|
1562
|
+
return signature
|
1563
|
+
|
1564
|
+
def build_create_order_sig(self, message, chainId, verifyingContractAddress):
|
1565
|
+
messageTypes = {
|
1566
|
+
'Order': [
|
1567
|
+
{'name': 'sender', 'type': 'bytes32'},
|
1568
|
+
{'name': 'priceX18', 'type': 'int128'},
|
1569
|
+
{'name': 'amount', 'type': 'int128'},
|
1570
|
+
{'name': 'expiration', 'type': 'uint64'},
|
1571
|
+
{'name': 'nonce', 'type': 'uint64'},
|
1572
|
+
],
|
1573
|
+
}
|
1574
|
+
return self.build_sig(chainId, messageTypes, message, verifyingContractAddress)
|
1575
|
+
|
1576
|
+
def build_list_trigger_tx_sig(self, message, chainId, verifyingContractAddress):
|
1577
|
+
messageTypes = {
|
1578
|
+
'ListTriggerOrders': [
|
1579
|
+
{'name': 'sender', 'type': 'bytes32'},
|
1580
|
+
{'name': 'recvTime', 'type': 'uint64'},
|
1581
|
+
],
|
1582
|
+
}
|
1583
|
+
return self.build_sig(chainId, messageTypes, message, verifyingContractAddress)
|
1584
|
+
|
1585
|
+
def build_cancel_all_orders_sig(self, message, chainId, verifyingContractAddress):
|
1586
|
+
messageTypes = {
|
1587
|
+
'CancellationProducts': [
|
1588
|
+
{'name': 'sender', 'type': 'bytes32'},
|
1589
|
+
{'name': 'productIds', 'type': 'uint32[]'},
|
1590
|
+
{'name': 'nonce', 'type': 'uint64'},
|
1591
|
+
],
|
1592
|
+
}
|
1593
|
+
return self.build_sig(chainId, messageTypes, message, verifyingContractAddress)
|
1594
|
+
|
1595
|
+
def build_cancel_orders_sig(self, message, chainId, verifyingContractAddress):
|
1596
|
+
messageTypes = {
|
1597
|
+
'Cancellation': [
|
1598
|
+
{'name': 'sender', 'type': 'bytes32'},
|
1599
|
+
{'name': 'productIds', 'type': 'uint32[]'},
|
1600
|
+
{'name': 'digests', 'type': 'bytes32[]'},
|
1601
|
+
{'name': 'nonce', 'type': 'uint64'},
|
1602
|
+
],
|
1603
|
+
}
|
1604
|
+
return self.build_sig(chainId, messageTypes, message, verifyingContractAddress)
|
1605
|
+
|
1606
|
+
def build_withdraw_sig(self, message, chainId, verifyingContractAddress):
|
1607
|
+
messageTypes = {
|
1608
|
+
'WithdrawCollateral': [
|
1609
|
+
{'name': 'sender', 'type': 'bytes32'},
|
1610
|
+
{'name': 'productId', 'type': 'uint32'},
|
1611
|
+
{'name': 'amount', 'type': 'uint128'},
|
1612
|
+
{'name': 'nonce', 'type': 'uint64'},
|
1613
|
+
],
|
1614
|
+
}
|
1615
|
+
return self.build_sig(chainId, messageTypes, message, verifyingContractAddress)
|
1616
|
+
|
1617
|
+
def convert_address_to_sender(self, address: str):
|
1618
|
+
sender = address + '64656661756c74'
|
1619
|
+
return sender.ljust(66, '0')
|
1620
|
+
|
1621
|
+
def get_nonce(self, now, expiration):
|
1622
|
+
if now is None:
|
1623
|
+
now = self.nonce()
|
1624
|
+
# nonce = ((now + expiration) << 20) + 1000
|
1625
|
+
# 1 << 20 = 1048576
|
1626
|
+
return Precise.string_add(Precise.string_mul(Precise.string_add(self.number_to_string(now), self.number_to_string(expiration)), '1048576'), '1000')
|
1627
|
+
|
1628
|
+
def get_expiration(self, now, timeInForce, postOnly, reduceOnly):
|
1629
|
+
expiration = Precise.string_add(self.number_to_string(now), '86400')
|
1630
|
+
if timeInForce == 'ioc':
|
1631
|
+
# 1 << 62 = 4611686018427387904
|
1632
|
+
expiration = Precise.string_or(expiration, '4611686018427387904')
|
1633
|
+
elif timeInForce == 'fok':
|
1634
|
+
# 2 << 62 = 9223372036854775808
|
1635
|
+
expiration = Precise.string_or(expiration, '9223372036854775808')
|
1636
|
+
elif postOnly:
|
1637
|
+
# 3 << 62 = 13835058055282163712
|
1638
|
+
expiration = Precise.string_or(expiration, '13835058055282163712')
|
1639
|
+
if reduceOnly:
|
1640
|
+
# 1 << 61 = 2305843009213693952
|
1641
|
+
expiration = Precise.string_or(expiration, '2305843009213693952')
|
1642
|
+
return expiration
|
1643
|
+
|
1644
|
+
def get_amount(self, amount, side):
|
1645
|
+
amountString = self.number_to_string(amount)
|
1646
|
+
if side == 'sell':
|
1647
|
+
if amount > 0:
|
1648
|
+
# amount *= -1
|
1649
|
+
amountString = Precise.string_mul(amountString, '-1')
|
1650
|
+
else:
|
1651
|
+
if amount < 0:
|
1652
|
+
# amount *= -1
|
1653
|
+
amountString = Precise.string_mul(amountString, '-1')
|
1654
|
+
return amountString
|
1655
|
+
|
1656
|
+
def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
1657
|
+
"""
|
1658
|
+
create a trade order
|
1659
|
+
|
1660
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/executes/place-order
|
1661
|
+
https://docs.vertexprotocol.com/developer-resources/api/trigger/executes/place-order
|
1662
|
+
|
1663
|
+
:param str symbol: unified symbol of the market to create an order in
|
1664
|
+
:param str type: 'market' or 'limit'
|
1665
|
+
:param str side: 'buy' or 'sell'
|
1666
|
+
:param float amount: how much of currency you want to trade in units of base currency
|
1667
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1668
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1669
|
+
:param str [params.timeInForce]: ioc, fok
|
1670
|
+
:param bool [params.postOnly]: True or False whether the order is post-only
|
1671
|
+
:param bool [params.reduceOnly]: True or False whether the order is reduce-only, only works for ioc and fok order
|
1672
|
+
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
|
1673
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1674
|
+
"""
|
1675
|
+
self.check_required_credentials()
|
1676
|
+
marketType = type.lower()
|
1677
|
+
isMarketOrder = marketType == 'market'
|
1678
|
+
if isMarketOrder and price is None:
|
1679
|
+
raise ArgumentsRequired(self.id + ' createOrder() requires a price argument for market order')
|
1680
|
+
self.load_markets()
|
1681
|
+
market = self.market(symbol)
|
1682
|
+
marketId = self.parse_to_int(market['id'])
|
1683
|
+
contracts = self.query_contracts()
|
1684
|
+
chainId = self.safe_string(contracts, 'chain_id')
|
1685
|
+
bookAddresses = self.safe_list(contracts, 'book_addrs', [])
|
1686
|
+
verifyingContractAddress = self.safe_string(bookAddresses, marketId)
|
1687
|
+
defaultTimeInForce = 'fok' if (isMarketOrder) else None
|
1688
|
+
timeInForce = self.safe_string_lower(params, 'timeInForce', defaultTimeInForce)
|
1689
|
+
postOnly = self.safe_bool(params, 'postOnly', False)
|
1690
|
+
reduceOnly = self.safe_bool(params, 'reduceOnly', False)
|
1691
|
+
triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
|
1692
|
+
stopLossPrice = self.safe_string(params, 'stopLossPrice', triggerPrice)
|
1693
|
+
takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
|
1694
|
+
isTrigger = (stopLossPrice or takeProfitPrice)
|
1695
|
+
now = self.nonce()
|
1696
|
+
nonce = self.get_nonce(now, 90000)
|
1697
|
+
if postOnly and reduceOnly:
|
1698
|
+
raise NotSupported(self.id + ' reduceOnly not supported when postOnly is enabled')
|
1699
|
+
expiration = self.get_expiration(now, timeInForce, postOnly, reduceOnly)
|
1700
|
+
if isTrigger:
|
1701
|
+
# 1 << 63 = 9223372036854775808
|
1702
|
+
nonce = Precise.string_or(nonce, '9223372036854775808')
|
1703
|
+
amountString = self.get_amount(amount, side)
|
1704
|
+
order = {
|
1705
|
+
'sender': self.convert_address_to_sender(self.walletAddress),
|
1706
|
+
'priceX18': self.convert_to_x18(self.price_to_precision(symbol, price)),
|
1707
|
+
'amount': self.convert_to_x18(self.amount_to_precision(symbol, amountString)),
|
1708
|
+
'expiration': expiration,
|
1709
|
+
'nonce': nonce,
|
1710
|
+
}
|
1711
|
+
request = {
|
1712
|
+
'place_order': {
|
1713
|
+
'product_id': marketId,
|
1714
|
+
'order': {
|
1715
|
+
'sender': order['sender'],
|
1716
|
+
'priceX18': order['priceX18'],
|
1717
|
+
'amount': order['amount'],
|
1718
|
+
'expiration': self.number_to_string(order['expiration']),
|
1719
|
+
'nonce': order['nonce'],
|
1720
|
+
},
|
1721
|
+
'signature': self.build_create_order_sig(order, chainId, verifyingContractAddress),
|
1722
|
+
'id': self.safe_integer(self.options, 'brokerId', 5930043274845996),
|
1723
|
+
},
|
1724
|
+
}
|
1725
|
+
params = self.omit(params, ['timeInForce', 'reduceOnly', 'postOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice'])
|
1726
|
+
response = None
|
1727
|
+
if isTrigger:
|
1728
|
+
trigger = {}
|
1729
|
+
if stopLossPrice is not None:
|
1730
|
+
trigger['last_price_below'] = self.convert_to_x18(stopLossPrice)
|
1731
|
+
elif takeProfitPrice is not None:
|
1732
|
+
trigger['last_price_above'] = self.convert_to_x18(takeProfitPrice)
|
1733
|
+
request['place_order']['trigger'] = trigger
|
1734
|
+
response = self.v1TriggerPostExecute(self.extend(request, params))
|
1735
|
+
else:
|
1736
|
+
response = self.v1GatewayPostExecute(self.extend(request, params))
|
1737
|
+
#
|
1738
|
+
# {
|
1739
|
+
# "status": "success",
|
1740
|
+
# "signature": {signature},
|
1741
|
+
# "data": {
|
1742
|
+
# "digest": {order digest}
|
1743
|
+
# },
|
1744
|
+
# "request_type": "execute_place_order"
|
1745
|
+
# "id": 100
|
1746
|
+
# }
|
1747
|
+
#
|
1748
|
+
data = self.safe_dict(response, 'data', {})
|
1749
|
+
return self.safe_order({
|
1750
|
+
'id': self.safe_string(data, 'digest'),
|
1751
|
+
})
|
1752
|
+
|
1753
|
+
def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
|
1754
|
+
"""
|
1755
|
+
edit a trade order
|
1756
|
+
|
1757
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/executes/cancel-and-place
|
1758
|
+
|
1759
|
+
:param str id: cancel order id
|
1760
|
+
:param str symbol: unified symbol of the market to create an order in
|
1761
|
+
:param str type: 'market' or 'limit'
|
1762
|
+
:param str side: 'buy' or 'sell'
|
1763
|
+
:param float amount: how much of currency you want to trade in units of base currency
|
1764
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1765
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1766
|
+
:param str [params.timeInForce]: ioc, fok
|
1767
|
+
:param bool [params.postOnly]: True or False whether the order is post-only
|
1768
|
+
:param bool [params.reduceOnly]: True or False whether the order is reduce-only, only works for ioc and fok order
|
1769
|
+
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
|
1770
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1771
|
+
"""
|
1772
|
+
self.check_required_credentials()
|
1773
|
+
marketType = type.lower()
|
1774
|
+
isMarketOrder = marketType == 'market'
|
1775
|
+
if isMarketOrder and price is None:
|
1776
|
+
raise ArgumentsRequired(self.id + ' editOrder() requires a price argument for market order')
|
1777
|
+
self.load_markets()
|
1778
|
+
market = self.market(symbol)
|
1779
|
+
marketId = self.parse_to_int(market['id'])
|
1780
|
+
defaultTimeInForce = 'fok' if (isMarketOrder) else None
|
1781
|
+
timeInForce = self.safe_string_lower(params, 'timeInForce', defaultTimeInForce)
|
1782
|
+
postOnly = self.safe_bool(params, 'postOnly', False)
|
1783
|
+
reduceOnly = self.safe_bool(params, 'reduceOnly', False)
|
1784
|
+
triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
|
1785
|
+
stopLossPrice = self.safe_string(params, 'stopLossPrice', triggerPrice)
|
1786
|
+
takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
|
1787
|
+
isTrigger = (stopLossPrice or takeProfitPrice)
|
1788
|
+
contracts = self.query_contracts()
|
1789
|
+
chainId = self.safe_string(contracts, 'chain_id')
|
1790
|
+
bookAddresses = self.safe_list(contracts, 'book_addrs', [])
|
1791
|
+
verifyingContractAddressOrder = self.safe_string(bookAddresses, marketId)
|
1792
|
+
verifyingContractAddressCancel = self.safe_string(contracts, 'endpoint_addr')
|
1793
|
+
now = self.nonce()
|
1794
|
+
nonce = self.get_nonce(now, 90000)
|
1795
|
+
sender = self.convert_address_to_sender(self.walletAddress)
|
1796
|
+
if postOnly and reduceOnly:
|
1797
|
+
raise NotSupported(self.id + ' reduceOnly not supported when postOnly is enabled')
|
1798
|
+
if isTrigger:
|
1799
|
+
raise NotSupported(self.id + ' editOrder() not supported for trigger order')
|
1800
|
+
expiration = self.get_expiration(now, timeInForce, postOnly, reduceOnly)
|
1801
|
+
amountString = self.get_amount(amount, side)
|
1802
|
+
order = {
|
1803
|
+
'sender': sender,
|
1804
|
+
'priceX18': self.convert_to_x18(self.price_to_precision(symbol, price)),
|
1805
|
+
'amount': self.convert_to_x18(self.amount_to_precision(symbol, amountString)),
|
1806
|
+
'expiration': expiration,
|
1807
|
+
'nonce': nonce,
|
1808
|
+
}
|
1809
|
+
cancels = {
|
1810
|
+
'sender': sender,
|
1811
|
+
'productIds': [marketId],
|
1812
|
+
'digests': [id],
|
1813
|
+
'nonce': nonce,
|
1814
|
+
}
|
1815
|
+
request = {
|
1816
|
+
'cancel_and_place': {
|
1817
|
+
'cancel_tx': {
|
1818
|
+
'sender': cancels['sender'],
|
1819
|
+
'productIds': cancels['productIds'],
|
1820
|
+
'digests': cancels['digests'],
|
1821
|
+
'nonce': self.number_to_string(cancels['nonce']),
|
1822
|
+
},
|
1823
|
+
'cancel_signature': self.build_cancel_orders_sig(cancels, chainId, verifyingContractAddressCancel),
|
1824
|
+
'place_order': {
|
1825
|
+
'product_id': marketId,
|
1826
|
+
'order': {
|
1827
|
+
'sender': order['sender'],
|
1828
|
+
'priceX18': order['priceX18'],
|
1829
|
+
'amount': order['amount'],
|
1830
|
+
'expiration': self.number_to_string(order['expiration']),
|
1831
|
+
'nonce': order['nonce'],
|
1832
|
+
},
|
1833
|
+
'signature': self.build_create_order_sig(order, chainId, verifyingContractAddressOrder),
|
1834
|
+
'id': self.safe_integer(self.options, 'brokerId', 5930043274845996),
|
1835
|
+
},
|
1836
|
+
},
|
1837
|
+
}
|
1838
|
+
params = self.omit(params, ['timeInForce', 'reduceOnly', 'postOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice'])
|
1839
|
+
response = self.v1GatewayPostExecute(self.extend(request, params))
|
1840
|
+
#
|
1841
|
+
# {
|
1842
|
+
# "status": "success",
|
1843
|
+
# "signature": {signature},
|
1844
|
+
# "data": {
|
1845
|
+
# "digest": {order digest}
|
1846
|
+
# },
|
1847
|
+
# "request_type": "execute_cancel_and_place"
|
1848
|
+
# }
|
1849
|
+
#
|
1850
|
+
data = self.safe_dict(response, 'data', {})
|
1851
|
+
return self.safe_order({
|
1852
|
+
'id': self.safe_string(data, 'digest'),
|
1853
|
+
})
|
1854
|
+
|
1855
|
+
def parse_order_status(self, status):
|
1856
|
+
if status is not None:
|
1857
|
+
statuses = {
|
1858
|
+
'pending': 'open',
|
1859
|
+
}
|
1860
|
+
if isinstance(status, str):
|
1861
|
+
return self.safe_string(statuses, status, status)
|
1862
|
+
statusCancelled = self.safe_dict(status, 'cancelled')
|
1863
|
+
if statusCancelled is not None:
|
1864
|
+
return 'canceled'
|
1865
|
+
statusTriggered = self.safe_dict(status, 'triggered', {})
|
1866
|
+
triggeredStatus = self.safe_string(statusTriggered, 'status', 'failure')
|
1867
|
+
if triggeredStatus == 'success':
|
1868
|
+
return 'closed'
|
1869
|
+
return 'canceled'
|
1870
|
+
return status
|
1871
|
+
|
1872
|
+
def parse_order(self, order, market: Market = None) -> Order:
|
1873
|
+
#
|
1874
|
+
# {
|
1875
|
+
# "product_id": 1,
|
1876
|
+
# "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
|
1877
|
+
# "price_x18": "1000000000000000000",
|
1878
|
+
# "amount": "1000000000000000000",
|
1879
|
+
# "expiration": "2000000000",
|
1880
|
+
# "nonce": "1",
|
1881
|
+
# "unfilled_amount": "1000000000000000000",
|
1882
|
+
# "digest": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
1883
|
+
# "placed_at": 1681951347,
|
1884
|
+
# "order_type": "ioc"
|
1885
|
+
# }
|
1886
|
+
# stop order
|
1887
|
+
# {
|
1888
|
+
# "order": {
|
1889
|
+
# "order": {
|
1890
|
+
# "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
|
1891
|
+
# "priceX18": "1000000000000000000",
|
1892
|
+
# "amount": "1000000000000000000",
|
1893
|
+
# "expiration": "2000000000",
|
1894
|
+
# "nonce": "1",
|
1895
|
+
# },
|
1896
|
+
# "signature": "0x...",
|
1897
|
+
# "product_id": 1,
|
1898
|
+
# "spot_leverage": True,
|
1899
|
+
# "trigger": {
|
1900
|
+
# "price_above": "1000000000000000000"
|
1901
|
+
# },
|
1902
|
+
# "digest": "0x..."
|
1903
|
+
# },
|
1904
|
+
# "status": "pending",
|
1905
|
+
# "updated_at": 1688768157050
|
1906
|
+
# }
|
1907
|
+
#
|
1908
|
+
marketId = self.safe_string(order, 'product_id')
|
1909
|
+
timestamp = self.safe_timestamp(order, 'placed_at')
|
1910
|
+
amount = self.safe_string(order, 'amount')
|
1911
|
+
price = self.safe_string(order, 'price_x18')
|
1912
|
+
remaining = self.safe_string(order, 'unfilled_amount')
|
1913
|
+
triggerPriceNum = None
|
1914
|
+
status = self.safe_value(order, 'status')
|
1915
|
+
if status is not None:
|
1916
|
+
# trigger order
|
1917
|
+
outerOrder = self.safe_dict(order, 'order', {})
|
1918
|
+
innerOrder = self.safe_dict(outerOrder, 'order', {})
|
1919
|
+
marketId = self.safe_string(outerOrder, 'product_id')
|
1920
|
+
amount = self.safe_string(innerOrder, 'amount')
|
1921
|
+
price = self.safe_string(innerOrder, 'priceX18')
|
1922
|
+
timestamp = self.safe_timestamp(order, 'updated_at')
|
1923
|
+
trigger = self.safe_dict(outerOrder, 'trigger', {})
|
1924
|
+
triggerPrice = self.safe_string_n(trigger, ['price_above', 'price_below', 'last_price_above', 'last_price_below'])
|
1925
|
+
if triggerPrice is not None:
|
1926
|
+
triggerPriceNum = self.parse_to_numeric(self.convert_from_x18(triggerPrice))
|
1927
|
+
market = self.safe_market(marketId, market)
|
1928
|
+
symbol = market['symbol']
|
1929
|
+
priceNum = None
|
1930
|
+
if price is not None:
|
1931
|
+
priceNum = self.parse_to_numeric(self.convert_from_x18(price))
|
1932
|
+
amountNum = None
|
1933
|
+
if amount is not None:
|
1934
|
+
amountNum = self.parse_to_numeric(self.convert_from_x18(amount))
|
1935
|
+
remainingNum = None
|
1936
|
+
if remaining is not None:
|
1937
|
+
remainingNum = self.parse_to_numeric(self.convert_from_x18(remaining))
|
1938
|
+
side = None
|
1939
|
+
if amountNum is not None and remainingNum is not None:
|
1940
|
+
side = 'sell' if (amountNum < 0 or remainingNum < 0) else 'buy'
|
1941
|
+
tif = self.parse_time_in_force(self.safe_string(order, 'order_type'))
|
1942
|
+
isPostOnly = (tif == 'PO')
|
1943
|
+
return self.safe_order({
|
1944
|
+
'info': order,
|
1945
|
+
'id': self.safe_string(order, 'digest'),
|
1946
|
+
'clientOrderId': None,
|
1947
|
+
'timestamp': timestamp,
|
1948
|
+
'datetime': self.iso8601(timestamp),
|
1949
|
+
'lastTradeTimestamp': None,
|
1950
|
+
'lastUpdateTimestamp': None,
|
1951
|
+
'symbol': symbol,
|
1952
|
+
'type': None,
|
1953
|
+
'timeInForce': tif,
|
1954
|
+
'postOnly': isPostOnly,
|
1955
|
+
'reduceOnly': None,
|
1956
|
+
'side': side,
|
1957
|
+
'price': priceNum,
|
1958
|
+
'triggerPrice': triggerPriceNum,
|
1959
|
+
'amount': amountNum,
|
1960
|
+
'cost': None,
|
1961
|
+
'average': None,
|
1962
|
+
'filled': None,
|
1963
|
+
'remaining': remainingNum,
|
1964
|
+
'status': self.parse_order_status(status),
|
1965
|
+
'fee': None,
|
1966
|
+
'trades': None,
|
1967
|
+
}, market)
|
1968
|
+
|
1969
|
+
def parse_time_in_force(self, timeInForce):
|
1970
|
+
timeInForces = {
|
1971
|
+
'POST_ONLY': 'PO',
|
1972
|
+
}
|
1973
|
+
return self.safe_string_upper(timeInForces, timeInForce, timeInForce)
|
1974
|
+
|
1975
|
+
def fetch_order(self, id: str, symbol: Str = None, params={}):
|
1976
|
+
"""
|
1977
|
+
fetches information on an order made by the user
|
1978
|
+
|
1979
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/order
|
1980
|
+
|
1981
|
+
:param str id: the order id
|
1982
|
+
:param str symbol: unified symbol of the market the order was made in
|
1983
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1984
|
+
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1985
|
+
"""
|
1986
|
+
self.load_markets()
|
1987
|
+
market = self.market(symbol)
|
1988
|
+
request = {
|
1989
|
+
'type': 'order',
|
1990
|
+
'product_id': self.parse_to_int(market['id']),
|
1991
|
+
'digest': id,
|
1992
|
+
}
|
1993
|
+
response = self.v1GatewayGetQuery(self.extend(request, params))
|
1994
|
+
#
|
1995
|
+
# {
|
1996
|
+
# "status": "success",
|
1997
|
+
# "data": {
|
1998
|
+
# "product_id": 1,
|
1999
|
+
# "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
|
2000
|
+
# "price_x18": "1000000000000000000",
|
2001
|
+
# "amount": "1000000000000000000",
|
2002
|
+
# "expiration": "2000000000",
|
2003
|
+
# "nonce": "1",
|
2004
|
+
# "unfilled_amount": "1000000000000000000",
|
2005
|
+
# "digest": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
2006
|
+
# "placed_at": 1681951347,
|
2007
|
+
# "order_type": "ioc"
|
2008
|
+
# },
|
2009
|
+
# "request_type": "query_order",
|
2010
|
+
# }
|
2011
|
+
#
|
2012
|
+
data = self.safe_dict(response, 'data')
|
2013
|
+
return self.parse_order(data, market)
|
2014
|
+
|
2015
|
+
def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
2016
|
+
"""
|
2017
|
+
fetch all unfilled currently open orders
|
2018
|
+
|
2019
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/orders
|
2020
|
+
https://docs.vertexprotocol.com/developer-resources/api/trigger/queries/list-trigger-orders
|
2021
|
+
|
2022
|
+
:param str symbol: unified market symbol
|
2023
|
+
:param int [since]: the earliest time in ms to fetch open orders for
|
2024
|
+
:param int [limit]: the maximum number of open orders structures to retrieve
|
2025
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2026
|
+
:param boolean [params.trigger]: whether the order is a trigger/algo order
|
2027
|
+
:param str [params.user]: user address, will default to self.walletAddress if not provided
|
2028
|
+
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2029
|
+
"""
|
2030
|
+
self.check_required_credentials()
|
2031
|
+
self.load_markets()
|
2032
|
+
userAddress = None
|
2033
|
+
userAddress, params = self.handle_public_address('fetchOpenOrders', params)
|
2034
|
+
request = {}
|
2035
|
+
market: Market = None
|
2036
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
2037
|
+
params = self.omit(params, ['stop', 'trigger'])
|
2038
|
+
if symbol is not None:
|
2039
|
+
market = self.market(symbol)
|
2040
|
+
request['product_id'] = self.parse_to_numeric(market['id'])
|
2041
|
+
response = None
|
2042
|
+
if trigger:
|
2043
|
+
contracts = self.query_contracts()
|
2044
|
+
chainId = self.safe_string(contracts, 'chain_id')
|
2045
|
+
verifyingContractAddress = self.safe_string(contracts, 'endpoint_addr')
|
2046
|
+
tx = {
|
2047
|
+
'sender': self.convert_address_to_sender(userAddress),
|
2048
|
+
'recvTime': self.nonce() + 90000,
|
2049
|
+
}
|
2050
|
+
request['signature'] = self.build_list_trigger_tx_sig(tx, chainId, verifyingContractAddress)
|
2051
|
+
request['tx'] = {
|
2052
|
+
'sender': tx['sender'],
|
2053
|
+
'recvTime': self.number_to_string(tx['recvTime']),
|
2054
|
+
}
|
2055
|
+
request['type'] = 'list_trigger_orders'
|
2056
|
+
request['pending'] = True
|
2057
|
+
until = self.safe_integer(params, 'until')
|
2058
|
+
params = self.omit(params, 'until')
|
2059
|
+
if until is not None:
|
2060
|
+
request['max_update_time'] = until
|
2061
|
+
if limit is not None:
|
2062
|
+
request['limit'] = limit
|
2063
|
+
response = self.v1TriggerPostQuery(self.extend(request, params))
|
2064
|
+
#
|
2065
|
+
# {
|
2066
|
+
# "status": "success",
|
2067
|
+
# "data": {
|
2068
|
+
# "orders": [
|
2069
|
+
# {
|
2070
|
+
# "order": {
|
2071
|
+
# "order": {
|
2072
|
+
# "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
|
2073
|
+
# "priceX18": "1000000000000000000",
|
2074
|
+
# "amount": "1000000000000000000",
|
2075
|
+
# "expiration": "2000000000",
|
2076
|
+
# "nonce": "1",
|
2077
|
+
# },
|
2078
|
+
# "signature": "0x...",
|
2079
|
+
# "product_id": 1,
|
2080
|
+
# "spot_leverage": True,
|
2081
|
+
# "trigger": {
|
2082
|
+
# "price_above": "1000000000000000000"
|
2083
|
+
# },
|
2084
|
+
# "digest": "0x..."
|
2085
|
+
# },
|
2086
|
+
# "status": "pending",
|
2087
|
+
# "updated_at": 1688768157050
|
2088
|
+
# }
|
2089
|
+
# ]
|
2090
|
+
# },
|
2091
|
+
# "request_type": "query_list_trigger_orders"
|
2092
|
+
# }
|
2093
|
+
#
|
2094
|
+
else:
|
2095
|
+
self.check_required_argument('fetchOpenOrders', symbol, 'symbol')
|
2096
|
+
request['type'] = 'subaccount_orders'
|
2097
|
+
request['sender'] = self.convert_address_to_sender(userAddress)
|
2098
|
+
response = self.v1GatewayPostQuery(self.extend(request, params))
|
2099
|
+
#
|
2100
|
+
# {
|
2101
|
+
# "status": "success",
|
2102
|
+
# "data": {
|
2103
|
+
# "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
|
2104
|
+
# "product_id": 1,
|
2105
|
+
# "orders": [
|
2106
|
+
# {
|
2107
|
+
# "product_id": 1,
|
2108
|
+
# "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
|
2109
|
+
# "price_x18": "1000000000000000000",
|
2110
|
+
# "amount": "1000000000000000000",
|
2111
|
+
# "expiration": "2000000000",
|
2112
|
+
# "nonce": "1",
|
2113
|
+
# "order_type": "default",
|
2114
|
+
# "unfilled_amount": "1000000000000000000",
|
2115
|
+
# "digest": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
2116
|
+
# "placed_at": 1682437739,
|
2117
|
+
# "order_type": "ioc"
|
2118
|
+
# }
|
2119
|
+
# ]
|
2120
|
+
# },
|
2121
|
+
# "request_type": "query_subaccount_orders"
|
2122
|
+
# }
|
2123
|
+
#
|
2124
|
+
data = self.safe_dict(response, 'data', {})
|
2125
|
+
orders = self.safe_list(data, 'orders')
|
2126
|
+
return self.parse_orders(orders, market, since, limit)
|
2127
|
+
|
2128
|
+
def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
2129
|
+
"""
|
2130
|
+
fetches information on multiple orders made by the user
|
2131
|
+
|
2132
|
+
https://docs.vertexprotocol.com/developer-resources/api/trigger/queries/list-trigger-orders
|
2133
|
+
|
2134
|
+
:param str symbol: unified market symbol
|
2135
|
+
:param int [since]: the earliest time in ms to fetch open orders for
|
2136
|
+
:param int [limit]: the maximum number of open orders structures to retrieve
|
2137
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2138
|
+
:param boolean [params.trigger]: whether the order is a trigger/algo order
|
2139
|
+
:param str [params.user]: user address, will default to self.walletAddress if not provided
|
2140
|
+
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2141
|
+
"""
|
2142
|
+
self.check_required_credentials()
|
2143
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
2144
|
+
params = self.omit(params, ['stop', 'trigger'])
|
2145
|
+
if not trigger:
|
2146
|
+
raise NotSupported(self.id + ' fetchOrders only support trigger orders')
|
2147
|
+
userAddress = None
|
2148
|
+
userAddress, params = self.handle_public_address('fetchOrders', params)
|
2149
|
+
self.load_markets()
|
2150
|
+
market: Market = None
|
2151
|
+
request = {
|
2152
|
+
'type': 'list_trigger_orders',
|
2153
|
+
'pending': False,
|
2154
|
+
}
|
2155
|
+
if symbol is not None:
|
2156
|
+
market = self.market(symbol)
|
2157
|
+
request['product_id'] = self.parse_to_numeric(market['id'])
|
2158
|
+
contracts = self.query_contracts()
|
2159
|
+
chainId = self.safe_string(contracts, 'chain_id')
|
2160
|
+
verifyingContractAddress = self.safe_string(contracts, 'endpoint_addr')
|
2161
|
+
tx = {
|
2162
|
+
'sender': self.convert_address_to_sender(userAddress),
|
2163
|
+
'recvTime': self.nonce() + 90000,
|
2164
|
+
}
|
2165
|
+
request['signature'] = self.build_list_trigger_tx_sig(tx, chainId, verifyingContractAddress)
|
2166
|
+
request['tx'] = {
|
2167
|
+
'sender': tx['sender'],
|
2168
|
+
'recvTime': self.number_to_string(tx['recvTime']),
|
2169
|
+
}
|
2170
|
+
until = self.safe_integer(params, 'until')
|
2171
|
+
params = self.omit(params, 'until')
|
2172
|
+
if until is not None:
|
2173
|
+
request['max_update_time'] = until
|
2174
|
+
if limit is not None:
|
2175
|
+
request['limit'] = limit
|
2176
|
+
response = self.v1TriggerPostQuery(self.extend(request, params))
|
2177
|
+
#
|
2178
|
+
# {
|
2179
|
+
# "status": "success",
|
2180
|
+
# "data": {
|
2181
|
+
# "orders": [
|
2182
|
+
# {
|
2183
|
+
# "order": {
|
2184
|
+
# "order": {
|
2185
|
+
# "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
|
2186
|
+
# "priceX18": "1000000000000000000",
|
2187
|
+
# "amount": "1000000000000000000",
|
2188
|
+
# "expiration": "2000000000",
|
2189
|
+
# "nonce": "1",
|
2190
|
+
# },
|
2191
|
+
# "signature": "0x...",
|
2192
|
+
# "product_id": 1,
|
2193
|
+
# "spot_leverage": True,
|
2194
|
+
# "trigger": {
|
2195
|
+
# "price_above": "1000000000000000000"
|
2196
|
+
# },
|
2197
|
+
# "digest": "0x..."
|
2198
|
+
# },
|
2199
|
+
# "status": "pending",
|
2200
|
+
# "updated_at": 1688768157050
|
2201
|
+
# }
|
2202
|
+
# ]
|
2203
|
+
# },
|
2204
|
+
# "request_type": "query_list_trigger_orders"
|
2205
|
+
# }
|
2206
|
+
#
|
2207
|
+
data = self.safe_dict(response, 'data', {})
|
2208
|
+
orders = self.safe_list(data, 'orders')
|
2209
|
+
return self.parse_orders(orders, market, since, limit)
|
2210
|
+
|
2211
|
+
def cancel_all_orders(self, symbol: Str = None, params={}):
|
2212
|
+
"""
|
2213
|
+
|
2214
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/executes/cancel-product-orders
|
2215
|
+
https://docs.vertexprotocol.com/developer-resources/api/trigger/executes/cancel-product-orders
|
2216
|
+
|
2217
|
+
cancel all open orders in a market
|
2218
|
+
:param str symbol: unified market symbol
|
2219
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2220
|
+
:param boolean [params.trigger]: whether the order is a trigger/algo order
|
2221
|
+
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2222
|
+
"""
|
2223
|
+
self.check_required_credentials()
|
2224
|
+
self.load_markets()
|
2225
|
+
if symbol is None:
|
2226
|
+
raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
|
2227
|
+
market = self.market(symbol)
|
2228
|
+
marketId = market['id']
|
2229
|
+
contracts = self.query_contracts()
|
2230
|
+
chainId = self.safe_string(contracts, 'chain_id')
|
2231
|
+
verifyingContractAddress = self.safe_string(contracts, 'endpoint_addr')
|
2232
|
+
now = self.nonce()
|
2233
|
+
nonce = self.get_nonce(now, 90000)
|
2234
|
+
cancels = {
|
2235
|
+
'sender': self.convert_address_to_sender(self.walletAddress),
|
2236
|
+
'productIds': [
|
2237
|
+
self.parse_to_numeric(marketId),
|
2238
|
+
],
|
2239
|
+
'nonce': nonce,
|
2240
|
+
}
|
2241
|
+
request = {
|
2242
|
+
'cancel_product_orders': {
|
2243
|
+
'tx': {
|
2244
|
+
'sender': cancels['sender'],
|
2245
|
+
'productIds': cancels['productIds'],
|
2246
|
+
'nonce': self.number_to_string(cancels['nonce']),
|
2247
|
+
},
|
2248
|
+
'signature': self.build_cancel_all_orders_sig(cancels, chainId, verifyingContractAddress),
|
2249
|
+
},
|
2250
|
+
}
|
2251
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
2252
|
+
params = self.omit(params, ['stop', 'trigger'])
|
2253
|
+
response = None
|
2254
|
+
if trigger:
|
2255
|
+
response = self.v1TriggerPostExecute(self.extend(request, params))
|
2256
|
+
#
|
2257
|
+
# {
|
2258
|
+
# "status": "success",
|
2259
|
+
# "signature": {signature},
|
2260
|
+
# "request_type": "execute_cancel_product_orders"
|
2261
|
+
# }
|
2262
|
+
#
|
2263
|
+
else:
|
2264
|
+
response = self.v1GatewayPostExecute(self.extend(request, params))
|
2265
|
+
#
|
2266
|
+
# {
|
2267
|
+
# "status": "success",
|
2268
|
+
# "signature": {signature},
|
2269
|
+
# "data": {
|
2270
|
+
# "cancelled_orders": [
|
2271
|
+
# {
|
2272
|
+
# "product_id": 2,
|
2273
|
+
# "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
|
2274
|
+
# "price_x18": "20000000000000000000000",
|
2275
|
+
# "amount": "-100000000000000000",
|
2276
|
+
# "expiration": "1686332748",
|
2277
|
+
# "order_type": "post_only",
|
2278
|
+
# "nonce": "1768248100142339392",
|
2279
|
+
# "unfilled_amount": "-100000000000000000",
|
2280
|
+
# "digest": "0x3195a7929feb8307edecf9c045j5ced68925108f0aa305f0ee5773854159377c",
|
2281
|
+
# "placed_at": 1686332708
|
2282
|
+
# },
|
2283
|
+
# ...
|
2284
|
+
# ]
|
2285
|
+
# },
|
2286
|
+
# "request_type": "execute_cancel_product_orders"
|
2287
|
+
# }
|
2288
|
+
#
|
2289
|
+
return response
|
2290
|
+
|
2291
|
+
def cancel_order(self, id: str, symbol: Str = None, params={}):
|
2292
|
+
"""
|
2293
|
+
cancels an open order
|
2294
|
+
|
2295
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/executes/cancel-orders
|
2296
|
+
https://docs.vertexprotocol.com/developer-resources/api/trigger/executes/cancel-orders
|
2297
|
+
|
2298
|
+
:param str id: order id
|
2299
|
+
:param str symbol: unified symbol of the market the order was made in
|
2300
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2301
|
+
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2302
|
+
"""
|
2303
|
+
return self.cancel_orders([id], symbol, params)
|
2304
|
+
|
2305
|
+
def cancel_orders(self, ids: List[str], symbol: Str = None, params={}):
|
2306
|
+
"""
|
2307
|
+
cancel multiple orders
|
2308
|
+
|
2309
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/executes/cancel-orders
|
2310
|
+
https://docs.vertexprotocol.com/developer-resources/api/trigger/executes/cancel-orders
|
2311
|
+
|
2312
|
+
:param str[] ids: order ids
|
2313
|
+
:param str [symbol]: unified market symbol
|
2314
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2315
|
+
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2316
|
+
"""
|
2317
|
+
self.check_required_credentials()
|
2318
|
+
if symbol is None:
|
2319
|
+
raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
|
2320
|
+
self.load_markets()
|
2321
|
+
market = self.market(symbol)
|
2322
|
+
marketId = market['id']
|
2323
|
+
contracts = self.query_contracts()
|
2324
|
+
chainId = self.safe_string(contracts, 'chain_id')
|
2325
|
+
verifyingContractAddress = self.safe_string(contracts, 'endpoint_addr')
|
2326
|
+
now = self.nonce()
|
2327
|
+
nonce = self.get_nonce(now, 90000)
|
2328
|
+
cancels = {
|
2329
|
+
'sender': self.convert_address_to_sender(self.walletAddress),
|
2330
|
+
'productIds': [],
|
2331
|
+
'digests': ids,
|
2332
|
+
'nonce': nonce,
|
2333
|
+
}
|
2334
|
+
marketIdNum = self.parse_to_numeric(marketId)
|
2335
|
+
for i in range(0, len(ids)):
|
2336
|
+
cancels['productIds'].append(marketIdNum)
|
2337
|
+
request = {
|
2338
|
+
'cancel_orders': {
|
2339
|
+
'tx': {
|
2340
|
+
'sender': cancels['sender'],
|
2341
|
+
'productIds': cancels['productIds'],
|
2342
|
+
'digests': cancels['digests'],
|
2343
|
+
'nonce': self.number_to_string(cancels['nonce']),
|
2344
|
+
},
|
2345
|
+
'signature': self.build_cancel_orders_sig(cancels, chainId, verifyingContractAddress),
|
2346
|
+
},
|
2347
|
+
}
|
2348
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
2349
|
+
params = self.omit(params, ['stop', 'trigger'])
|
2350
|
+
response = None
|
2351
|
+
if trigger:
|
2352
|
+
response = self.v1TriggerPostExecute(self.extend(request, params))
|
2353
|
+
#
|
2354
|
+
# {
|
2355
|
+
# "status": "success",
|
2356
|
+
# "signature": {signature},
|
2357
|
+
# "request_type": "execute_cancel_orders"
|
2358
|
+
# }
|
2359
|
+
#
|
2360
|
+
else:
|
2361
|
+
response = self.v1GatewayPostExecute(self.extend(request, params))
|
2362
|
+
#
|
2363
|
+
# {
|
2364
|
+
# "status": "success",
|
2365
|
+
# "signature": {signature},
|
2366
|
+
# "data": {
|
2367
|
+
# "cancelled_orders": [
|
2368
|
+
# {
|
2369
|
+
# "product_id": 2,
|
2370
|
+
# "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
|
2371
|
+
# "price_x18": "20000000000000000000000",
|
2372
|
+
# "amount": "-100000000000000000",
|
2373
|
+
# "expiration": "1686332748",
|
2374
|
+
# "order_type": "post_only",
|
2375
|
+
# "nonce": "1768248100142339392",
|
2376
|
+
# "unfilled_amount": "-100000000000000000",
|
2377
|
+
# "digest": "0x3195a7929feb8307edecf9c045j5ced68925108f0aa305f0ee5773854159377c",
|
2378
|
+
# "placed_at": 1686332708
|
2379
|
+
# },
|
2380
|
+
# ...
|
2381
|
+
# ]
|
2382
|
+
# },
|
2383
|
+
# "request_type": "execute_cancel_orders"
|
2384
|
+
# }
|
2385
|
+
#
|
2386
|
+
return response
|
2387
|
+
|
2388
|
+
def fetch_balance(self, params={}) -> Balances:
|
2389
|
+
"""
|
2390
|
+
query for balance and get the amount of funds available for trading or funds locked in orders
|
2391
|
+
|
2392
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/subaccount-info
|
2393
|
+
|
2394
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2395
|
+
:param str [params.user]: user address, will default to self.walletAddress if not provided
|
2396
|
+
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
2397
|
+
"""
|
2398
|
+
userAddress = None
|
2399
|
+
userAddress, params = self.handle_public_address('fetchBalance', params)
|
2400
|
+
request = {
|
2401
|
+
'type': 'subaccount_info',
|
2402
|
+
'subaccount': self.convert_address_to_sender(userAddress),
|
2403
|
+
}
|
2404
|
+
response = self.v1GatewayGetQuery(self.extend(request, params))
|
2405
|
+
#
|
2406
|
+
# {
|
2407
|
+
# "status": "success",
|
2408
|
+
# "data": {
|
2409
|
+
# "subaccount": "0x265167ddfac55365d6ff07fc5943276319aa6b9f64656661756c740000000000",
|
2410
|
+
# "exists": True,
|
2411
|
+
# "healths": [
|
2412
|
+
# {
|
2413
|
+
# "assets": "75323297691833342306",
|
2414
|
+
# "liabilities": "46329556869051092241",
|
2415
|
+
# "health": "28993740822782250065"
|
2416
|
+
# },
|
2417
|
+
# {
|
2418
|
+
# "assets": "75323297691833342306",
|
2419
|
+
# "liabilities": "35968911700887320741",
|
2420
|
+
# "health": "39354385990946021565"
|
2421
|
+
# },
|
2422
|
+
# {
|
2423
|
+
# "assets": "80796966663601107565",
|
2424
|
+
# "liabilities": "0",
|
2425
|
+
# "health": "80796966663601107565"
|
2426
|
+
# }
|
2427
|
+
# ],
|
2428
|
+
# "health_contributions": [
|
2429
|
+
# [
|
2430
|
+
# "75323297691833340000",
|
2431
|
+
# "75323297691833340000",
|
2432
|
+
# "75323297691833340000"
|
2433
|
+
# ],
|
2434
|
+
# [
|
2435
|
+
# "0",
|
2436
|
+
# "0",
|
2437
|
+
# "0"
|
2438
|
+
# ],
|
2439
|
+
# [
|
2440
|
+
# "0",
|
2441
|
+
# "0",
|
2442
|
+
# "0"
|
2443
|
+
# ],
|
2444
|
+
# [
|
2445
|
+
# "0",
|
2446
|
+
# "0",
|
2447
|
+
# "0"
|
2448
|
+
# ],
|
2449
|
+
# [
|
2450
|
+
# "-46329556869051090000",
|
2451
|
+
# "-35968911700887323000",
|
2452
|
+
# "5473668971767765000"
|
2453
|
+
# ]
|
2454
|
+
# ],
|
2455
|
+
# "spot_count": 3,
|
2456
|
+
# "perp_count": 2,
|
2457
|
+
# "spot_balances": [
|
2458
|
+
# {
|
2459
|
+
# "product_id": 1,
|
2460
|
+
# "lp_balance": {
|
2461
|
+
# "amount": "0"
|
2462
|
+
# },
|
2463
|
+
# "balance": {
|
2464
|
+
# "amount": "0",
|
2465
|
+
# "last_cumulative_multiplier_x18": "1003419811982007193"
|
2466
|
+
# }
|
2467
|
+
# },
|
2468
|
+
# {
|
2469
|
+
# "product_id": 3,
|
2470
|
+
# "lp_balance": {
|
2471
|
+
# "amount": "0"
|
2472
|
+
# },
|
2473
|
+
# "balance": {
|
2474
|
+
# "amount": "0",
|
2475
|
+
# "last_cumulative_multiplier_x18": "1007584195035969404"
|
2476
|
+
# }
|
2477
|
+
# },
|
2478
|
+
# {
|
2479
|
+
# "product_id": 0,
|
2480
|
+
# "lp_balance": {
|
2481
|
+
# "amount": "0"
|
2482
|
+
# },
|
2483
|
+
# "balance": {
|
2484
|
+
# "amount": "75323297691833342306",
|
2485
|
+
# "last_cumulative_multiplier_x18": "1000000002391497578"
|
2486
|
+
# }
|
2487
|
+
# }
|
2488
|
+
# ],
|
2489
|
+
# "perp_balances": [
|
2490
|
+
# {
|
2491
|
+
# "product_id": 2,
|
2492
|
+
# "lp_balance": {
|
2493
|
+
# "amount": "0",
|
2494
|
+
# "last_cumulative_funding_x18": "-284321955122859921"
|
2495
|
+
# },
|
2496
|
+
# "balance": {
|
2497
|
+
# "amount": "0",
|
2498
|
+
# "v_quote_balance": "0",
|
2499
|
+
# "last_cumulative_funding_x18": "6363466629611946777168"
|
2500
|
+
# }
|
2501
|
+
# },
|
2502
|
+
# {
|
2503
|
+
# "product_id": 4,
|
2504
|
+
# "lp_balance": {
|
2505
|
+
# "amount": "0",
|
2506
|
+
# "last_cumulative_funding_x18": "-90979748449893411"
|
2507
|
+
# },
|
2508
|
+
# "balance": {
|
2509
|
+
# "amount": "-200000000000000000",
|
2510
|
+
# "v_quote_balance": "419899475698318625259",
|
2511
|
+
# "last_cumulative_funding_x18": "141182516563970577208"
|
2512
|
+
# }
|
2513
|
+
# }
|
2514
|
+
# ],
|
2515
|
+
# "spot_products": [
|
2516
|
+
# {
|
2517
|
+
# "product_id": 1,
|
2518
|
+
# "oracle_price_x18": "30217830336443750750000",
|
2519
|
+
# "risk": {
|
2520
|
+
# "long_weight_initial_x18": "750000000000000000",
|
2521
|
+
# "short_weight_initial_x18": "1250000000000000000",
|
2522
|
+
# "long_weight_maintenance_x18": "800000000000000000",
|
2523
|
+
# "short_weight_maintenance_x18": "1200000000000000000",
|
2524
|
+
# "large_position_penalty_x18": "0"
|
2525
|
+
# },
|
2526
|
+
# "config": {
|
2527
|
+
# "token": "0x5cc7c91690b2cbaee19a513473d73403e13fb431",
|
2528
|
+
# "interest_inflection_util_x18": "800000000000000000",
|
2529
|
+
# "interest_floor_x18": "10000000000000000",
|
2530
|
+
# "interest_small_cap_x18": "40000000000000000",
|
2531
|
+
# "interest_large_cap_x18": "1000000000000000000"
|
2532
|
+
# },
|
2533
|
+
# "state": {
|
2534
|
+
# "cumulative_deposits_multiplier_x18": "1001304691727847318",
|
2535
|
+
# "cumulative_borrows_multiplier_x18": "1003419811982007193",
|
2536
|
+
# "total_deposits_normalized": "213107447159798397806318",
|
2537
|
+
# "total_borrows_normalized": "4907820740150097483532"
|
2538
|
+
# },
|
2539
|
+
# "lp_state": {
|
2540
|
+
# "supply": "1304981417419495030893348",
|
2541
|
+
# "quote": {
|
2542
|
+
# "amount": "2048495687410669565222259",
|
2543
|
+
# "last_cumulative_multiplier_x18": "1000000002391497578"
|
2544
|
+
# },
|
2545
|
+
# "base": {
|
2546
|
+
# "amount": "67623029247538886515",
|
2547
|
+
# "last_cumulative_multiplier_x18": "1001304691727847318"
|
2548
|
+
# }
|
2549
|
+
# },
|
2550
|
+
# "book_info": {
|
2551
|
+
# "size_increment": "1000000000000000",
|
2552
|
+
# "price_increment_x18": "1000000000000000000",
|
2553
|
+
# "min_size": "10000000000000000",
|
2554
|
+
# "collected_fees": "8865582805773573662738183",
|
2555
|
+
# "lp_spread_x18": "3000000000000000"
|
2556
|
+
# }
|
2557
|
+
# },
|
2558
|
+
# {
|
2559
|
+
# "product_id": 3,
|
2560
|
+
# "oracle_price_x18": "2075217009708333333333",
|
2561
|
+
# "risk": {
|
2562
|
+
# "long_weight_initial_x18": "750000000000000000",
|
2563
|
+
# "short_weight_initial_x18": "1250000000000000000",
|
2564
|
+
# "long_weight_maintenance_x18": "800000000000000000",
|
2565
|
+
# "short_weight_maintenance_x18": "1200000000000000000",
|
2566
|
+
# "large_position_penalty_x18": "0"
|
2567
|
+
# },
|
2568
|
+
# "config": {
|
2569
|
+
# "token": "0xcc59686e3a32fb104c8ff84dd895676265efb8a6",
|
2570
|
+
# "interest_inflection_util_x18": "800000000000000000",
|
2571
|
+
# "interest_floor_x18": "10000000000000000",
|
2572
|
+
# "interest_small_cap_x18": "40000000000000000",
|
2573
|
+
# "interest_large_cap_x18": "1000000000000000000"
|
2574
|
+
# },
|
2575
|
+
# "state": {
|
2576
|
+
# "cumulative_deposits_multiplier_x18": "1003722507760089346",
|
2577
|
+
# "cumulative_borrows_multiplier_x18": "1007584195035969404",
|
2578
|
+
# "total_deposits_normalized": "232750303205807326418622",
|
2579
|
+
# "total_borrows_normalized": "110730726549469855171025"
|
2580
|
+
# },
|
2581
|
+
# "lp_state": {
|
2582
|
+
# "supply": "902924999999999999774268",
|
2583
|
+
# "quote": {
|
2584
|
+
# "amount": "1165328092090344104989049",
|
2585
|
+
# "last_cumulative_multiplier_x18": "1000000002391497578"
|
2586
|
+
# },
|
2587
|
+
# "base": {
|
2588
|
+
# "amount": "563265647183403990588",
|
2589
|
+
# "last_cumulative_multiplier_x18": "1003722507760089346"
|
2590
|
+
# }
|
2591
|
+
# },
|
2592
|
+
# "book_info": {
|
2593
|
+
# "size_increment": "10000000000000000",
|
2594
|
+
# "price_increment_x18": "100000000000000000",
|
2595
|
+
# "min_size": "100000000000000000",
|
2596
|
+
# "collected_fees": "1801521329724633001446457",
|
2597
|
+
# "lp_spread_x18": "3000000000000000"
|
2598
|
+
# }
|
2599
|
+
# },
|
2600
|
+
# {
|
2601
|
+
# "product_id": 0,
|
2602
|
+
# "oracle_price_x18": "1000000000000000000",
|
2603
|
+
# "risk": {
|
2604
|
+
# "long_weight_initial_x18": "1000000000000000000",
|
2605
|
+
# "short_weight_initial_x18": "1000000000000000000",
|
2606
|
+
# "long_weight_maintenance_x18": "1000000000000000000",
|
2607
|
+
# "short_weight_maintenance_x18": "1000000000000000000",
|
2608
|
+
# "large_position_penalty_x18": "0"
|
2609
|
+
# },
|
2610
|
+
# "config": {
|
2611
|
+
# "token": "0x179522635726710dd7d2035a81d856de4aa7836c",
|
2612
|
+
# "interest_inflection_util_x18": "800000000000000000",
|
2613
|
+
# "interest_floor_x18": "10000000000000000",
|
2614
|
+
# "interest_small_cap_x18": "40000000000000000",
|
2615
|
+
# "interest_large_cap_x18": "1000000000000000000"
|
2616
|
+
# },
|
2617
|
+
# "state": {
|
2618
|
+
# "cumulative_deposits_multiplier_x18": "1000000002391497578",
|
2619
|
+
# "cumulative_borrows_multiplier_x18": "1001593395547514024",
|
2620
|
+
# "total_deposits_normalized": "60000256267437588885818752247843",
|
2621
|
+
# "total_borrows_normalized": "391445043137305055810336885"
|
2622
|
+
# },
|
2623
|
+
# "lp_state": {
|
2624
|
+
# "supply": "0",
|
2625
|
+
# "quote": {
|
2626
|
+
# "amount": "0",
|
2627
|
+
# "last_cumulative_multiplier_x18": "0"
|
2628
|
+
# },
|
2629
|
+
# "base": {
|
2630
|
+
# "amount": "0",
|
2631
|
+
# "last_cumulative_multiplier_x18": "0"
|
2632
|
+
# }
|
2633
|
+
# },
|
2634
|
+
# "book_info": {
|
2635
|
+
# "size_increment": "0",
|
2636
|
+
# "price_increment_x18": "0",
|
2637
|
+
# "min_size": "0",
|
2638
|
+
# "collected_fees": "0",
|
2639
|
+
# "lp_spread_x18": "0"
|
2640
|
+
# }
|
2641
|
+
# }
|
2642
|
+
# ],
|
2643
|
+
# "perp_products": [
|
2644
|
+
# {
|
2645
|
+
# "product_id": 2,
|
2646
|
+
# "oracle_price_x18": "30219079716463070000000",
|
2647
|
+
# "risk": {
|
2648
|
+
# "long_weight_initial_x18": "875000000000000000",
|
2649
|
+
# "short_weight_initial_x18": "1125000000000000000",
|
2650
|
+
# "long_weight_maintenance_x18": "900000000000000000",
|
2651
|
+
# "short_weight_maintenance_x18": "1100000000000000000",
|
2652
|
+
# "large_position_penalty_x18": "0"
|
2653
|
+
# },
|
2654
|
+
# "state": {
|
2655
|
+
# "cumulative_funding_long_x18": "6363466629611946777168",
|
2656
|
+
# "cumulative_funding_short_x18": "6363466629611946777168",
|
2657
|
+
# "available_settle": "100612314098927536086702448",
|
2658
|
+
# "open_interest": "57975708279961875623240"
|
2659
|
+
# },
|
2660
|
+
# "lp_state": {
|
2661
|
+
# "supply": "783207415944433511804197",
|
2662
|
+
# "last_cumulative_funding_x18": "6363466629611946777168",
|
2663
|
+
# "cumulative_funding_per_lp_x18": "-284321955122859921",
|
2664
|
+
# "base": "37321000000000000000",
|
2665
|
+
# "quote": "1150991638943862165224593"
|
2666
|
+
# },
|
2667
|
+
# "book_info": {
|
2668
|
+
# "size_increment": "1000000000000000",
|
2669
|
+
# "price_increment_x18": "1000000000000000000",
|
2670
|
+
# "min_size": "10000000000000000",
|
2671
|
+
# "collected_fees": "7738341933653651206856235",
|
2672
|
+
# "lp_spread_x18": "3000000000000000"
|
2673
|
+
# }
|
2674
|
+
# },
|
2675
|
+
# {
|
2676
|
+
# "product_id": 4,
|
2677
|
+
# "oracle_price_x18": "2072129033632754300000",
|
2678
|
+
# "risk": {
|
2679
|
+
# "long_weight_initial_x18": "875000000000000000",
|
2680
|
+
# "short_weight_initial_x18": "1125000000000000000",
|
2681
|
+
# "long_weight_maintenance_x18": "900000000000000000",
|
2682
|
+
# "short_weight_maintenance_x18": "1100000000000000000",
|
2683
|
+
# "large_position_penalty_x18": "0"
|
2684
|
+
# },
|
2685
|
+
# "state": {
|
2686
|
+
# "cumulative_funding_long_x18": "141182516563970577208",
|
2687
|
+
# "cumulative_funding_short_x18": "141182516563970577208",
|
2688
|
+
# "available_settle": "33807443862986950288685582",
|
2689
|
+
# "open_interest": "316343836992291503987611"
|
2690
|
+
# },
|
2691
|
+
# "lp_state": {
|
2692
|
+
# "supply": "541756546038144467864559",
|
2693
|
+
# "last_cumulative_funding_x18": "141182516563970577208",
|
2694
|
+
# "cumulative_funding_per_lp_x18": "-90979748449893411",
|
2695
|
+
# "base": "362320000000000000000",
|
2696
|
+
# "quote": "750080187685127907834038"
|
2697
|
+
# },
|
2698
|
+
# "book_info": {
|
2699
|
+
# "size_increment": "10000000000000000",
|
2700
|
+
# "price_increment_x18": "100000000000000000",
|
2701
|
+
# "min_size": "100000000000000000",
|
2702
|
+
# "collected_fees": "1893278317732551619694831",
|
2703
|
+
# "lp_spread_x18": "3000000000000000"
|
2704
|
+
# }
|
2705
|
+
# }
|
2706
|
+
# ]
|
2707
|
+
# },
|
2708
|
+
# "request_type": "query_subaccount_info"
|
2709
|
+
# }
|
2710
|
+
#
|
2711
|
+
data = self.safe_dict(response, 'data', {})
|
2712
|
+
balances = self.safe_list(data, 'spot_balances', [])
|
2713
|
+
result = {'info': response}
|
2714
|
+
for i in range(0, len(balances)):
|
2715
|
+
balance = balances[i]
|
2716
|
+
marketId = self.safe_string(balance, 'product_id')
|
2717
|
+
market = self.safe_market(marketId)
|
2718
|
+
isUsdcMarketId = marketId == '0'
|
2719
|
+
if market['id'] is None and not isUsdcMarketId:
|
2720
|
+
continue
|
2721
|
+
baseId = 'USDC' if (isUsdcMarketId) else self.safe_string(market, 'baseId')
|
2722
|
+
code = self.safe_currency_code(baseId)
|
2723
|
+
account = self.account()
|
2724
|
+
tokenBalance = self.safe_dict(balance, 'balance', {})
|
2725
|
+
total = self.convert_from_x18(self.safe_string(tokenBalance, 'amount'))
|
2726
|
+
account['total'] = total
|
2727
|
+
result[code] = account
|
2728
|
+
return self.safe_balance(result)
|
2729
|
+
|
2730
|
+
def parse_position(self, position, market: Market = None):
|
2731
|
+
#
|
2732
|
+
# {
|
2733
|
+
# "product_id": 2,
|
2734
|
+
# "lp_balance": {
|
2735
|
+
# "amount": "0",
|
2736
|
+
# "last_cumulative_funding_x18": "-284321955122859921"
|
2737
|
+
# },
|
2738
|
+
# "balance": {
|
2739
|
+
# "amount": "0",
|
2740
|
+
# "v_quote_balance": "0",
|
2741
|
+
# "last_cumulative_funding_x18": "6363466629611946777168"
|
2742
|
+
# }
|
2743
|
+
# },
|
2744
|
+
# {
|
2745
|
+
# "product_id": 4,
|
2746
|
+
# "lp_balance": {
|
2747
|
+
# "amount": "0",
|
2748
|
+
# "last_cumulative_funding_x18": "-90979748449893411"
|
2749
|
+
# },
|
2750
|
+
# "balance": {
|
2751
|
+
# "amount": "-200000000000000000",
|
2752
|
+
# "v_quote_balance": "419899475698318625259",
|
2753
|
+
# "last_cumulative_funding_x18": "141182516563970577208"
|
2754
|
+
# }
|
2755
|
+
# }
|
2756
|
+
#
|
2757
|
+
marketId = self.safe_string(position, 'product_id')
|
2758
|
+
market = self.safe_market(marketId)
|
2759
|
+
balance = self.safe_dict(position, 'balance', {})
|
2760
|
+
contractSize = self.convert_from_x18(self.safe_string(balance, 'amount'))
|
2761
|
+
side = 'buy'
|
2762
|
+
if Precise.string_lt(contractSize, '1'):
|
2763
|
+
side = 'sell'
|
2764
|
+
return self.safe_position({
|
2765
|
+
'info': position,
|
2766
|
+
'id': None,
|
2767
|
+
'symbol': self.safe_string(market, 'symbol'),
|
2768
|
+
'timestamp': None,
|
2769
|
+
'datetime': None,
|
2770
|
+
'lastUpdateTimestamp': None,
|
2771
|
+
'initialMargin': None,
|
2772
|
+
'initialMarginPercentage': None,
|
2773
|
+
'maintenanceMargin': None,
|
2774
|
+
'maintenanceMarginPercentage': None,
|
2775
|
+
'entryPrice': None,
|
2776
|
+
'notional': None,
|
2777
|
+
'leverage': None,
|
2778
|
+
'unrealizedPnl': None,
|
2779
|
+
'contracts': None,
|
2780
|
+
'contractSize': self.parse_to_numeric(contractSize),
|
2781
|
+
'marginRatio': None,
|
2782
|
+
'liquidationPrice': None,
|
2783
|
+
'markPrice': None,
|
2784
|
+
'lastPrice': None,
|
2785
|
+
'collateral': None,
|
2786
|
+
'marginMode': 'cross',
|
2787
|
+
'marginType': None,
|
2788
|
+
'side': side,
|
2789
|
+
'percentage': None,
|
2790
|
+
'hedged': None,
|
2791
|
+
'stopLossPrice': None,
|
2792
|
+
'takeProfitPrice': None,
|
2793
|
+
})
|
2794
|
+
|
2795
|
+
def fetch_positions(self, symbols: Strings = None, params={}):
|
2796
|
+
"""
|
2797
|
+
fetch all open positions
|
2798
|
+
|
2799
|
+
https://docs.vertexprotocol.com/developer-resources/api/gateway/queries/subaccount-info
|
2800
|
+
|
2801
|
+
:param str[] [symbols]: list of unified market symbols
|
2802
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2803
|
+
:param str [params.user]: user address, will default to self.walletAddress if not provided
|
2804
|
+
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
2805
|
+
"""
|
2806
|
+
userAddress = None
|
2807
|
+
userAddress, params = self.handle_public_address('fetchPositions', params)
|
2808
|
+
request = {
|
2809
|
+
'type': 'subaccount_info',
|
2810
|
+
'subaccount': self.convert_address_to_sender(userAddress),
|
2811
|
+
}
|
2812
|
+
response = self.v1GatewayGetQuery(self.extend(request, params))
|
2813
|
+
# the response is the same
|
2814
|
+
data = self.safe_dict(response, 'data', {})
|
2815
|
+
positions = self.safe_list(data, 'perp_balances', [])
|
2816
|
+
symbols = self.market_symbols(symbols)
|
2817
|
+
result = []
|
2818
|
+
for i in range(0, len(positions)):
|
2819
|
+
position = self.extend(self.parse_position(positions[i], None), params)
|
2820
|
+
if position['contractSize'] == 0:
|
2821
|
+
continue
|
2822
|
+
result.append(position)
|
2823
|
+
return self.filter_by_array_positions(result, 'symbol', symbols, False)
|
2824
|
+
|
2825
|
+
def query_nonces(self):
|
2826
|
+
request = {
|
2827
|
+
'type': 'nonces',
|
2828
|
+
'address': self.walletAddress,
|
2829
|
+
}
|
2830
|
+
response = self.v1GatewayGetQuery(request)
|
2831
|
+
#
|
2832
|
+
# {
|
2833
|
+
# "status":"success",
|
2834
|
+
# "data":{
|
2835
|
+
# "tx_nonce": 0,
|
2836
|
+
# "order_nonce": 1753048133299863552
|
2837
|
+
# },
|
2838
|
+
# "request_type": "query_nonces",
|
2839
|
+
# }
|
2840
|
+
#
|
2841
|
+
return self.safe_dict(response, 'data', {})
|
2842
|
+
|
2843
|
+
def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
|
2844
|
+
"""
|
2845
|
+
make a withdrawal
|
2846
|
+
|
2847
|
+
https://docs.vertexprotocol.com/developer-resources/api/withdrawing-on-chain
|
2848
|
+
|
2849
|
+
:param str code: unified currency code
|
2850
|
+
:param float amount: the amount to withdraw
|
2851
|
+
:param str address: the address to withdraw to
|
2852
|
+
:param str tag:
|
2853
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2854
|
+
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
|
2855
|
+
"""
|
2856
|
+
self.check_required_credentials()
|
2857
|
+
self.load_markets()
|
2858
|
+
currency = self.currency(code)
|
2859
|
+
contracts = self.query_contracts()
|
2860
|
+
chainId = self.safe_string(contracts, 'chain_id')
|
2861
|
+
verifyingContractAddress = self.safe_string(contracts, 'endpoint_addr')
|
2862
|
+
nonces = self.query_nonces()
|
2863
|
+
nonce = self.safe_number(nonces, 'tx_nonce')
|
2864
|
+
withdraw = {
|
2865
|
+
'sender': self.convert_address_to_sender(self.walletAddress),
|
2866
|
+
'productId': self.parse_to_numeric(currency['id']),
|
2867
|
+
'amount': str(amount),
|
2868
|
+
'nonce': nonce,
|
2869
|
+
}
|
2870
|
+
request = {
|
2871
|
+
'withdraw_collateral': {
|
2872
|
+
'tx': {
|
2873
|
+
'sender': withdraw['sender'],
|
2874
|
+
'productId': withdraw['productId'],
|
2875
|
+
'amount': withdraw['amount'],
|
2876
|
+
'nonce': self.number_to_string(withdraw['nonce']),
|
2877
|
+
},
|
2878
|
+
'signature': self.build_withdraw_sig(withdraw, chainId, verifyingContractAddress),
|
2879
|
+
},
|
2880
|
+
}
|
2881
|
+
response = self.v1GatewayPostExecute(self.extend(request, params))
|
2882
|
+
#
|
2883
|
+
# {
|
2884
|
+
# "status": "success",
|
2885
|
+
# "signature": {signature},
|
2886
|
+
# "request_type": "execute_withdraw_collateral"
|
2887
|
+
# }
|
2888
|
+
#
|
2889
|
+
transaction = self.parse_transaction(response, currency)
|
2890
|
+
return self.extend(transaction, {
|
2891
|
+
'amount': amount,
|
2892
|
+
'address': address,
|
2893
|
+
})
|
2894
|
+
|
2895
|
+
def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
|
2896
|
+
#
|
2897
|
+
# {
|
2898
|
+
# "status": "success",
|
2899
|
+
# "signature": {signature},
|
2900
|
+
# "request_type": "execute_withdraw_collateral"
|
2901
|
+
# }
|
2902
|
+
#
|
2903
|
+
code = None
|
2904
|
+
if currency is not None:
|
2905
|
+
code = currency['code']
|
2906
|
+
return {
|
2907
|
+
'info': transaction,
|
2908
|
+
'id': None,
|
2909
|
+
'txid': None,
|
2910
|
+
'timestamp': None,
|
2911
|
+
'datetime': None,
|
2912
|
+
'addressFrom': None,
|
2913
|
+
'address': None,
|
2914
|
+
'addressTo': None,
|
2915
|
+
'tagFrom': None,
|
2916
|
+
'tag': None,
|
2917
|
+
'tagTo': None,
|
2918
|
+
'type': 'withdrawal',
|
2919
|
+
'amount': None,
|
2920
|
+
'currency': code,
|
2921
|
+
'status': self.parse_transaction_status(self.safe_string(transaction, 'status')),
|
2922
|
+
'updated': None,
|
2923
|
+
'network': None,
|
2924
|
+
'comment': None,
|
2925
|
+
'internal': None,
|
2926
|
+
'fee': None,
|
2927
|
+
}
|
2928
|
+
|
2929
|
+
def parse_transaction_status(self, status: Str):
|
2930
|
+
statuses: dict = {
|
2931
|
+
'success': 'ok',
|
2932
|
+
}
|
2933
|
+
return self.safe_string(statuses, status, status)
|
2934
|
+
|
2935
|
+
def handle_public_address(self, methodName: str, params: dict):
|
2936
|
+
userAux = None
|
2937
|
+
userAux, params = self.handle_option_and_params(params, methodName, 'user')
|
2938
|
+
user = userAux
|
2939
|
+
user, params = self.handle_option_and_params(params, methodName, 'address', userAux)
|
2940
|
+
if (user is not None) and (user != ''):
|
2941
|
+
return [user, params]
|
2942
|
+
if (self.walletAddress is not None) and (self.walletAddress != ''):
|
2943
|
+
return [self.walletAddress, params]
|
2944
|
+
raise ArgumentsRequired(self.id + ' ' + methodName + '() requires a user parameter inside \'params\' or the wallet address set')
|
2945
|
+
|
2946
|
+
def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
|
2947
|
+
if not response:
|
2948
|
+
return None # fallback to default error handler
|
2949
|
+
#
|
2950
|
+
#
|
2951
|
+
status = self.safe_string(response, 'status', '')
|
2952
|
+
if status == 'failure':
|
2953
|
+
message = self.safe_string(response, 'error')
|
2954
|
+
feedback = self.id + ' ' + body
|
2955
|
+
errorCode = self.safe_string(response, 'error_code')
|
2956
|
+
self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
|
2957
|
+
self.throw_broadly_matched_exception(self.exceptions['broad'], message, feedback)
|
2958
|
+
raise ExchangeError(feedback)
|
2959
|
+
return None
|
2960
|
+
|
2961
|
+
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
2962
|
+
version = self.safe_string(api, 0)
|
2963
|
+
type = self.safe_string(api, 1)
|
2964
|
+
url = self.implode_hostname(self.urls['api'][version][type])
|
2965
|
+
if version != 'v1' or type != 'archive':
|
2966
|
+
url = url + '/' + path
|
2967
|
+
if method == 'POST':
|
2968
|
+
headers = {
|
2969
|
+
'Content-Type': 'application/json',
|
2970
|
+
}
|
2971
|
+
body = self.json(params)
|
2972
|
+
else:
|
2973
|
+
if params:
|
2974
|
+
url += '?' + self.urlencode(params)
|
2975
|
+
if path != 'execute':
|
2976
|
+
# required encoding for public methods
|
2977
|
+
if headers is not None:
|
2978
|
+
headers['Accept-Encoding'] = 'gzip'
|
2979
|
+
else:
|
2980
|
+
headers = {
|
2981
|
+
'Accept-Encoding': 'gzip',
|
2982
|
+
}
|
2983
|
+
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|