coinex-api 0.0.6__py3-none-any.whl → 0.0.8__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.
- {coinex_api-0.0.6.dist-info → coinex_api-0.0.8.dist-info}/METADATA +33 -14
- coinex_api-0.0.8.dist-info/RECORD +3 -0
- coinex_api/__init__.py +0 -7
- coinex_api/ccxt/__init__.py +0 -101
- coinex_api/ccxt/abstract/coinex.py +0 -237
- coinex_api/ccxt/async_support/__init__.py +0 -80
- coinex_api/ccxt/async_support/base/__init__.py +0 -1
- coinex_api/ccxt/async_support/base/exchange.py +0 -2100
- coinex_api/ccxt/async_support/base/throttler.py +0 -50
- coinex_api/ccxt/async_support/base/ws/__init__.py +0 -38
- coinex_api/ccxt/async_support/base/ws/aiohttp_client.py +0 -147
- coinex_api/ccxt/async_support/base/ws/cache.py +0 -213
- coinex_api/ccxt/async_support/base/ws/client.py +0 -214
- coinex_api/ccxt/async_support/base/ws/fast_client.py +0 -97
- coinex_api/ccxt/async_support/base/ws/functions.py +0 -59
- coinex_api/ccxt/async_support/base/ws/future.py +0 -69
- coinex_api/ccxt/async_support/base/ws/order_book.py +0 -78
- coinex_api/ccxt/async_support/base/ws/order_book_side.py +0 -174
- coinex_api/ccxt/async_support/coinex.py +0 -5833
- coinex_api/ccxt/base/__init__.py +0 -27
- coinex_api/ccxt/base/decimal_to_precision.py +0 -174
- coinex_api/ccxt/base/errors.py +0 -267
- coinex_api/ccxt/base/exchange.py +0 -6770
- coinex_api/ccxt/base/precise.py +0 -297
- coinex_api/ccxt/base/types.py +0 -577
- coinex_api/ccxt/coinex.py +0 -5832
- coinex_api/ccxt/pro/__init__.py +0 -21
- coinex_api/ccxt/pro/coinex.py +0 -1366
- coinex_api/ccxt/static_dependencies/README.md +0 -1
- coinex_api/ccxt/static_dependencies/__init__.py +0 -1
- coinex_api/ccxt/static_dependencies/ecdsa/__init__.py +0 -14
- coinex_api/ccxt/static_dependencies/ecdsa/_version.py +0 -520
- coinex_api/ccxt/static_dependencies/ecdsa/curves.py +0 -56
- coinex_api/ccxt/static_dependencies/ecdsa/der.py +0 -221
- coinex_api/ccxt/static_dependencies/ecdsa/ecdsa.py +0 -310
- coinex_api/ccxt/static_dependencies/ecdsa/ellipticcurve.py +0 -197
- coinex_api/ccxt/static_dependencies/ecdsa/keys.py +0 -332
- coinex_api/ccxt/static_dependencies/ecdsa/numbertheory.py +0 -531
- coinex_api/ccxt/static_dependencies/ecdsa/rfc6979.py +0 -100
- coinex_api/ccxt/static_dependencies/ecdsa/util.py +0 -266
- coinex_api/ccxt/static_dependencies/ethereum/__init__.py +0 -7
- coinex_api/ccxt/static_dependencies/ethereum/abi/__init__.py +0 -16
- coinex_api/ccxt/static_dependencies/ethereum/abi/abi.py +0 -19
- coinex_api/ccxt/static_dependencies/ethereum/abi/base.py +0 -152
- coinex_api/ccxt/static_dependencies/ethereum/abi/codec.py +0 -217
- coinex_api/ccxt/static_dependencies/ethereum/abi/constants.py +0 -3
- coinex_api/ccxt/static_dependencies/ethereum/abi/decoding.py +0 -565
- coinex_api/ccxt/static_dependencies/ethereum/abi/encoding.py +0 -720
- coinex_api/ccxt/static_dependencies/ethereum/abi/exceptions.py +0 -139
- coinex_api/ccxt/static_dependencies/ethereum/abi/grammar.py +0 -443
- coinex_api/ccxt/static_dependencies/ethereum/abi/packed.py +0 -13
- coinex_api/ccxt/static_dependencies/ethereum/abi/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/abi/registry.py +0 -643
- coinex_api/ccxt/static_dependencies/ethereum/abi/tools/__init__.py +0 -3
- coinex_api/ccxt/static_dependencies/ethereum/abi/tools/_strategies.py +0 -230
- coinex_api/ccxt/static_dependencies/ethereum/abi/utils/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/abi/utils/numeric.py +0 -83
- coinex_api/ccxt/static_dependencies/ethereum/abi/utils/padding.py +0 -27
- coinex_api/ccxt/static_dependencies/ethereum/abi/utils/string.py +0 -19
- coinex_api/ccxt/static_dependencies/ethereum/account/__init__.py +0 -3
- coinex_api/ccxt/static_dependencies/ethereum/account/encode_typed_data/__init__.py +0 -4
- coinex_api/ccxt/static_dependencies/ethereum/account/encode_typed_data/encoding_and_hashing.py +0 -239
- coinex_api/ccxt/static_dependencies/ethereum/account/encode_typed_data/helpers.py +0 -40
- coinex_api/ccxt/static_dependencies/ethereum/account/messages.py +0 -263
- coinex_api/ccxt/static_dependencies/ethereum/account/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/hexbytes/__init__.py +0 -5
- coinex_api/ccxt/static_dependencies/ethereum/hexbytes/_utils.py +0 -54
- coinex_api/ccxt/static_dependencies/ethereum/hexbytes/main.py +0 -65
- coinex_api/ccxt/static_dependencies/ethereum/hexbytes/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/typing/__init__.py +0 -63
- coinex_api/ccxt/static_dependencies/ethereum/typing/abi.py +0 -6
- coinex_api/ccxt/static_dependencies/ethereum/typing/bls.py +0 -7
- coinex_api/ccxt/static_dependencies/ethereum/typing/discovery.py +0 -5
- coinex_api/ccxt/static_dependencies/ethereum/typing/encoding.py +0 -7
- coinex_api/ccxt/static_dependencies/ethereum/typing/enums.py +0 -17
- coinex_api/ccxt/static_dependencies/ethereum/typing/ethpm.py +0 -9
- coinex_api/ccxt/static_dependencies/ethereum/typing/evm.py +0 -20
- coinex_api/ccxt/static_dependencies/ethereum/typing/networks.py +0 -1122
- coinex_api/ccxt/static_dependencies/ethereum/typing/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/utils/__init__.py +0 -115
- coinex_api/ccxt/static_dependencies/ethereum/utils/abi.py +0 -72
- coinex_api/ccxt/static_dependencies/ethereum/utils/address.py +0 -171
- coinex_api/ccxt/static_dependencies/ethereum/utils/applicators.py +0 -151
- coinex_api/ccxt/static_dependencies/ethereum/utils/conversions.py +0 -190
- coinex_api/ccxt/static_dependencies/ethereum/utils/currency.py +0 -107
- coinex_api/ccxt/static_dependencies/ethereum/utils/curried/__init__.py +0 -269
- coinex_api/ccxt/static_dependencies/ethereum/utils/debug.py +0 -20
- coinex_api/ccxt/static_dependencies/ethereum/utils/decorators.py +0 -132
- coinex_api/ccxt/static_dependencies/ethereum/utils/encoding.py +0 -6
- coinex_api/ccxt/static_dependencies/ethereum/utils/exceptions.py +0 -4
- coinex_api/ccxt/static_dependencies/ethereum/utils/functional.py +0 -75
- coinex_api/ccxt/static_dependencies/ethereum/utils/hexadecimal.py +0 -74
- coinex_api/ccxt/static_dependencies/ethereum/utils/humanize.py +0 -188
- coinex_api/ccxt/static_dependencies/ethereum/utils/logging.py +0 -159
- coinex_api/ccxt/static_dependencies/ethereum/utils/module_loading.py +0 -31
- coinex_api/ccxt/static_dependencies/ethereum/utils/numeric.py +0 -43
- coinex_api/ccxt/static_dependencies/ethereum/utils/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/utils/toolz.py +0 -76
- coinex_api/ccxt/static_dependencies/ethereum/utils/types.py +0 -54
- coinex_api/ccxt/static_dependencies/ethereum/utils/typing/__init__.py +0 -18
- coinex_api/ccxt/static_dependencies/ethereum/utils/typing/misc.py +0 -14
- coinex_api/ccxt/static_dependencies/ethereum/utils/units.py +0 -31
- coinex_api/ccxt/static_dependencies/keccak/__init__.py +0 -3
- coinex_api/ccxt/static_dependencies/keccak/keccak.py +0 -197
- coinex_api/ccxt/static_dependencies/lark/__init__.py +0 -38
- coinex_api/ccxt/static_dependencies/lark/__pyinstaller/__init__.py +0 -6
- coinex_api/ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +0 -14
- coinex_api/ccxt/static_dependencies/lark/ast_utils.py +0 -59
- coinex_api/ccxt/static_dependencies/lark/common.py +0 -86
- coinex_api/ccxt/static_dependencies/lark/exceptions.py +0 -292
- coinex_api/ccxt/static_dependencies/lark/grammar.py +0 -130
- coinex_api/ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/lark/grammars/common.lark +0 -59
- coinex_api/ccxt/static_dependencies/lark/grammars/lark.lark +0 -62
- coinex_api/ccxt/static_dependencies/lark/grammars/python.lark +0 -302
- coinex_api/ccxt/static_dependencies/lark/grammars/unicode.lark +0 -7
- coinex_api/ccxt/static_dependencies/lark/indenter.py +0 -143
- coinex_api/ccxt/static_dependencies/lark/lark.py +0 -658
- coinex_api/ccxt/static_dependencies/lark/lexer.py +0 -678
- coinex_api/ccxt/static_dependencies/lark/load_grammar.py +0 -1428
- coinex_api/ccxt/static_dependencies/lark/parse_tree_builder.py +0 -391
- coinex_api/ccxt/static_dependencies/lark/parser_frontends.py +0 -257
- coinex_api/ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/lark/parsers/cyk.py +0 -340
- coinex_api/ccxt/static_dependencies/lark/parsers/earley.py +0 -314
- coinex_api/ccxt/static_dependencies/lark/parsers/earley_common.py +0 -42
- coinex_api/ccxt/static_dependencies/lark/parsers/earley_forest.py +0 -801
- coinex_api/ccxt/static_dependencies/lark/parsers/grammar_analysis.py +0 -203
- coinex_api/ccxt/static_dependencies/lark/parsers/lalr_analysis.py +0 -332
- coinex_api/ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +0 -158
- coinex_api/ccxt/static_dependencies/lark/parsers/lalr_parser.py +0 -122
- coinex_api/ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +0 -110
- coinex_api/ccxt/static_dependencies/lark/parsers/xearley.py +0 -165
- coinex_api/ccxt/static_dependencies/lark/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/lark/reconstruct.py +0 -107
- coinex_api/ccxt/static_dependencies/lark/tools/__init__.py +0 -70
- coinex_api/ccxt/static_dependencies/lark/tools/nearley.py +0 -202
- coinex_api/ccxt/static_dependencies/lark/tools/serialize.py +0 -32
- coinex_api/ccxt/static_dependencies/lark/tools/standalone.py +0 -196
- coinex_api/ccxt/static_dependencies/lark/tree.py +0 -267
- coinex_api/ccxt/static_dependencies/lark/tree_matcher.py +0 -186
- coinex_api/ccxt/static_dependencies/lark/tree_templates.py +0 -180
- coinex_api/ccxt/static_dependencies/lark/utils.py +0 -343
- coinex_api/ccxt/static_dependencies/lark/visitors.py +0 -596
- coinex_api/ccxt/static_dependencies/marshmallow/__init__.py +0 -81
- coinex_api/ccxt/static_dependencies/marshmallow/base.py +0 -65
- coinex_api/ccxt/static_dependencies/marshmallow/class_registry.py +0 -94
- coinex_api/ccxt/static_dependencies/marshmallow/decorators.py +0 -231
- coinex_api/ccxt/static_dependencies/marshmallow/error_store.py +0 -60
- coinex_api/ccxt/static_dependencies/marshmallow/exceptions.py +0 -71
- coinex_api/ccxt/static_dependencies/marshmallow/fields.py +0 -2114
- coinex_api/ccxt/static_dependencies/marshmallow/orderedset.py +0 -89
- coinex_api/ccxt/static_dependencies/marshmallow/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/marshmallow/schema.py +0 -1228
- coinex_api/ccxt/static_dependencies/marshmallow/types.py +0 -12
- coinex_api/ccxt/static_dependencies/marshmallow/utils.py +0 -378
- coinex_api/ccxt/static_dependencies/marshmallow/validate.py +0 -678
- coinex_api/ccxt/static_dependencies/marshmallow/warnings.py +0 -2
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/__init__.py +0 -1047
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +0 -51
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +0 -45
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/mypy.py +0 -71
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/typing.py +0 -14
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/union_field.py +0 -82
- coinex_api/ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +0 -1
- coinex_api/ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +0 -193
- coinex_api/ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/msgpack/__init__.py +0 -55
- coinex_api/ccxt/static_dependencies/msgpack/_cmsgpack.pyx +0 -11
- coinex_api/ccxt/static_dependencies/msgpack/_packer.pyx +0 -374
- coinex_api/ccxt/static_dependencies/msgpack/_unpacker.pyx +0 -547
- coinex_api/ccxt/static_dependencies/msgpack/buff_converter.h +0 -8
- coinex_api/ccxt/static_dependencies/msgpack/exceptions.py +0 -48
- coinex_api/ccxt/static_dependencies/msgpack/ext.py +0 -168
- coinex_api/ccxt/static_dependencies/msgpack/fallback.py +0 -951
- coinex_api/ccxt/static_dependencies/msgpack/pack.h +0 -89
- coinex_api/ccxt/static_dependencies/msgpack/pack_template.h +0 -820
- coinex_api/ccxt/static_dependencies/msgpack/sysdep.h +0 -194
- coinex_api/ccxt/static_dependencies/msgpack/unpack.h +0 -391
- coinex_api/ccxt/static_dependencies/msgpack/unpack_define.h +0 -95
- coinex_api/ccxt/static_dependencies/msgpack/unpack_template.h +0 -464
- coinex_api/ccxt/static_dependencies/parsimonious/__init__.py +0 -10
- coinex_api/ccxt/static_dependencies/parsimonious/exceptions.py +0 -105
- coinex_api/ccxt/static_dependencies/parsimonious/expressions.py +0 -479
- coinex_api/ccxt/static_dependencies/parsimonious/grammar.py +0 -487
- coinex_api/ccxt/static_dependencies/parsimonious/nodes.py +0 -325
- coinex_api/ccxt/static_dependencies/parsimonious/utils.py +0 -40
- coinex_api/ccxt/static_dependencies/starknet/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/abi/v0/__init__.py +0 -2
- coinex_api/ccxt/static_dependencies/starknet/abi/v0/model.py +0 -44
- coinex_api/ccxt/static_dependencies/starknet/abi/v0/parser.py +0 -216
- coinex_api/ccxt/static_dependencies/starknet/abi/v0/schemas.py +0 -72
- coinex_api/ccxt/static_dependencies/starknet/abi/v0/shape.py +0 -63
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/__init__.py +0 -2
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/core_structures.json +0 -14
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/model.py +0 -39
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/parser.py +0 -220
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/parser_transformer.py +0 -179
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/schemas.py +0 -66
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/shape.py +0 -47
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/__init__.py +0 -2
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/model.py +0 -89
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/parser.py +0 -293
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/parser_transformer.py +0 -192
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/schemas.py +0 -132
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/shape.py +0 -107
- coinex_api/ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/cairo/data_types.py +0 -123
- coinex_api/ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +0 -77
- coinex_api/ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +0 -46
- coinex_api/ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +0 -138
- coinex_api/ccxt/static_dependencies/starknet/cairo/felt.py +0 -64
- coinex_api/ccxt/static_dependencies/starknet/cairo/type_parser.py +0 -121
- coinex_api/ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +0 -59
- coinex_api/ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +0 -77
- coinex_api/ccxt/static_dependencies/starknet/ccxt_utils.py +0 -7
- coinex_api/ccxt/static_dependencies/starknet/common.py +0 -15
- coinex_api/ccxt/static_dependencies/starknet/constants.py +0 -39
- coinex_api/ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/hash/address.py +0 -79
- coinex_api/ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +0 -111
- coinex_api/ccxt/static_dependencies/starknet/hash/selector.py +0 -16
- coinex_api/ccxt/static_dependencies/starknet/hash/storage.py +0 -12
- coinex_api/ccxt/static_dependencies/starknet/hash/utils.py +0 -78
- coinex_api/ccxt/static_dependencies/starknet/models/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/models/typed_data.py +0 -45
- coinex_api/ccxt/static_dependencies/starknet/serialization/__init__.py +0 -24
- coinex_api/ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +0 -40
- coinex_api/ccxt/static_dependencies/starknet/serialization/_context.py +0 -142
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +0 -10
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +0 -82
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +0 -43
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +0 -37
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +0 -66
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +0 -71
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +0 -71
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +0 -50
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +0 -58
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +0 -43
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +0 -40
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +0 -72
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +0 -36
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +0 -36
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +0 -76
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +0 -100
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +0 -32
- coinex_api/ccxt/static_dependencies/starknet/serialization/errors.py +0 -10
- coinex_api/ccxt/static_dependencies/starknet/serialization/factory.py +0 -229
- coinex_api/ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +0 -110
- coinex_api/ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +0 -59
- coinex_api/ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +0 -86
- coinex_api/ccxt/static_dependencies/starknet/utils/iterable.py +0 -13
- coinex_api/ccxt/static_dependencies/starknet/utils/schema.py +0 -13
- coinex_api/ccxt/static_dependencies/starknet/utils/typed_data.py +0 -182
- coinex_api/ccxt/static_dependencies/starkware/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +0 -50
- coinex_api/ccxt/static_dependencies/starkware/crypto/math_utils.py +0 -78
- coinex_api/ccxt/static_dependencies/starkware/crypto/signature.py +0 -2344
- coinex_api/ccxt/static_dependencies/starkware/crypto/utils.py +0 -63
- coinex_api/ccxt/static_dependencies/sympy/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/sympy/core/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/sympy/core/intfunc.py +0 -35
- coinex_api/ccxt/static_dependencies/sympy/external/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/sympy/external/gmpy.py +0 -345
- coinex_api/ccxt/static_dependencies/sympy/external/importtools.py +0 -187
- coinex_api/ccxt/static_dependencies/sympy/external/ntheory.py +0 -637
- coinex_api/ccxt/static_dependencies/sympy/external/pythonmpq.py +0 -341
- coinex_api/ccxt/static_dependencies/toolz/__init__.py +0 -26
- coinex_api/ccxt/static_dependencies/toolz/_signatures.py +0 -784
- coinex_api/ccxt/static_dependencies/toolz/_version.py +0 -520
- coinex_api/ccxt/static_dependencies/toolz/compatibility.py +0 -30
- coinex_api/ccxt/static_dependencies/toolz/curried/__init__.py +0 -101
- coinex_api/ccxt/static_dependencies/toolz/curried/exceptions.py +0 -22
- coinex_api/ccxt/static_dependencies/toolz/curried/operator.py +0 -22
- coinex_api/ccxt/static_dependencies/toolz/dicttoolz.py +0 -339
- coinex_api/ccxt/static_dependencies/toolz/functoolz.py +0 -1049
- coinex_api/ccxt/static_dependencies/toolz/itertoolz.py +0 -1057
- coinex_api/ccxt/static_dependencies/toolz/recipes.py +0 -46
- coinex_api/ccxt/static_dependencies/toolz/utils.py +0 -9
- coinex_api/ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/typing_inspect/typing_inspect.py +0 -851
- coinex_api-0.0.6.dist-info/RECORD +0 -288
- {coinex_api-0.0.6.dist-info → coinex_api-0.0.8.dist-info}/WHEEL +0 -0
coinex_api/ccxt/pro/coinex.py
DELETED
@@ -1,1366 +0,0 @@
|
|
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
|
-
import ccxt.async_support
|
7
|
-
from ccxt.async_support.base.ws.cache import ArrayCache, ArrayCacheBySymbolById
|
8
|
-
import hashlib
|
9
|
-
from ccxt.base.types import Any, Balances, Int, Order, OrderBook, Str, Strings, Ticker, Tickers, Trade
|
10
|
-
from ccxt.async_support.base.ws.client import Client
|
11
|
-
from typing import List
|
12
|
-
from ccxt.base.errors import ExchangeError
|
13
|
-
from ccxt.base.errors import AuthenticationError
|
14
|
-
from ccxt.base.errors import BadRequest
|
15
|
-
from ccxt.base.errors import NotSupported
|
16
|
-
from ccxt.base.errors import RateLimitExceeded
|
17
|
-
from ccxt.base.errors import ExchangeNotAvailable
|
18
|
-
from ccxt.base.errors import RequestTimeout
|
19
|
-
|
20
|
-
|
21
|
-
from ccxt.async_support import coinex as coinexAsync
|
22
|
-
|
23
|
-
|
24
|
-
class coinex(coinexAsync):
|
25
|
-
|
26
|
-
def describe(self) -> Any:
|
27
|
-
return self.deep_extend(super(coinex, self).describe(), {
|
28
|
-
'has': {
|
29
|
-
'ws': True,
|
30
|
-
'watchBalance': True,
|
31
|
-
'watchBidsAsks': True,
|
32
|
-
'watchTicker': True,
|
33
|
-
'watchTickers': True,
|
34
|
-
'watchTrades': True,
|
35
|
-
'watchTradesForSymbols': True,
|
36
|
-
'watchMyTrades': True,
|
37
|
-
'watchOrders': True,
|
38
|
-
'watchOrderBook': True,
|
39
|
-
'watchOrderBookForSymbols': True,
|
40
|
-
'watchOHLCV': False,
|
41
|
-
'fetchOHLCVWs': False,
|
42
|
-
},
|
43
|
-
'urls': {
|
44
|
-
'api': {
|
45
|
-
'ws': {
|
46
|
-
'spot': 'wss://socket.coinex.com/v2/spot/',
|
47
|
-
'swap': 'wss://socket.coinex.com/v2/futures/',
|
48
|
-
},
|
49
|
-
},
|
50
|
-
},
|
51
|
-
'options': {
|
52
|
-
'ws': {
|
53
|
-
'gunzip': True,
|
54
|
-
},
|
55
|
-
'timeframes': {
|
56
|
-
'1m': 60,
|
57
|
-
'3m': 180,
|
58
|
-
'5m': 300,
|
59
|
-
'15m': 900,
|
60
|
-
'30m': 1800,
|
61
|
-
'1h': 3600,
|
62
|
-
'2h': 7200,
|
63
|
-
'4h': 14400,
|
64
|
-
'6h': 21600,
|
65
|
-
'12h': 43200,
|
66
|
-
'1d': 86400,
|
67
|
-
'3d': 259200,
|
68
|
-
'1w': 604800,
|
69
|
-
},
|
70
|
-
'account': 'spot',
|
71
|
-
'watchOrderBook': {
|
72
|
-
'limits': [5, 10, 20, 50],
|
73
|
-
'defaultLimit': 50,
|
74
|
-
'aggregations': ['1000', '100', '10', '1', '0', '0.1', '0.01', '0.001', '0.0001', '0.00001', '0.000001', '0.0000001', '0.00000001', '0.000000001', '0.0000000001', '0.00000000001'],
|
75
|
-
'defaultAggregation': '0',
|
76
|
-
},
|
77
|
-
},
|
78
|
-
'streaming': {
|
79
|
-
},
|
80
|
-
'exceptions': {
|
81
|
-
'exact': {
|
82
|
-
'20001': BadRequest, # Invalid argument
|
83
|
-
'20002': NotSupported, # Method unavailable
|
84
|
-
'21001': AuthenticationError, # Authentication required
|
85
|
-
'21002': AuthenticationError, # Incorrect signature
|
86
|
-
'23001': RequestTimeout, # Request service timeout
|
87
|
-
'23002': RateLimitExceeded, # Requests too frequently
|
88
|
-
'24001': ExchangeError, # Internal error
|
89
|
-
'24002': ExchangeNotAvailable, # Service unavailable temporarily
|
90
|
-
'30001': BadRequest, # Invalid argument
|
91
|
-
'30002': NotSupported, # Method unavailable
|
92
|
-
'31001': AuthenticationError, # Authentication required
|
93
|
-
'31002': AuthenticationError, # Incorrect signature
|
94
|
-
'33001': RequestTimeout, # Request service timeout
|
95
|
-
'33002': RateLimitExceeded, # Requests too frequently
|
96
|
-
'34001': ExchangeError, # Internal error
|
97
|
-
'34002': ExchangeNotAvailable, # Service unavailable temporarily
|
98
|
-
},
|
99
|
-
'broad': {},
|
100
|
-
},
|
101
|
-
})
|
102
|
-
|
103
|
-
def request_id(self):
|
104
|
-
requestId = self.sum(self.safe_integer(self.options, 'requestId', 0), 1)
|
105
|
-
self.options['requestId'] = requestId
|
106
|
-
return requestId
|
107
|
-
|
108
|
-
def handle_ticker(self, client: Client, message):
|
109
|
-
#
|
110
|
-
# spot
|
111
|
-
#
|
112
|
-
# {
|
113
|
-
# "method": "state.update",
|
114
|
-
# "data": {
|
115
|
-
# "state_list": [
|
116
|
-
# {
|
117
|
-
# "market": "LATUSDT",
|
118
|
-
# "last": "0.008157",
|
119
|
-
# "open": "0.008286",
|
120
|
-
# "close": "0.008157",
|
121
|
-
# "high": "0.008390",
|
122
|
-
# "low": "0.008106",
|
123
|
-
# "volume": "807714.49139758",
|
124
|
-
# "volume_sell": "286170.69645599",
|
125
|
-
# "volume_buy": "266161.23236408",
|
126
|
-
# "value": "6689.21644207",
|
127
|
-
# "period": 86400
|
128
|
-
# },
|
129
|
-
# ]
|
130
|
-
# },
|
131
|
-
# "id": null
|
132
|
-
# }
|
133
|
-
#
|
134
|
-
# swap
|
135
|
-
#
|
136
|
-
# {
|
137
|
-
# "method": "state.update",
|
138
|
-
# "data": {
|
139
|
-
# "state_list": [
|
140
|
-
# {
|
141
|
-
# "market": "ETHUSD_SIGNPRICE",
|
142
|
-
# "last": "1892.29",
|
143
|
-
# "open": "1884.62",
|
144
|
-
# "close": "1892.29",
|
145
|
-
# "high": "1894.09",
|
146
|
-
# "low": "1863.72",
|
147
|
-
# "volume": "0",
|
148
|
-
# "value": "0",
|
149
|
-
# "volume_sell": "0",
|
150
|
-
# "volume_buy": "0",
|
151
|
-
# "open_interest_size": "0",
|
152
|
-
# "insurance_fund_size": "0",
|
153
|
-
# "latest_funding_rate": "0",
|
154
|
-
# "next_funding_rate": "0",
|
155
|
-
# "latest_funding_time": 0,
|
156
|
-
# "next_funding_time": 0,
|
157
|
-
# "period": 86400
|
158
|
-
# },
|
159
|
-
# ]
|
160
|
-
# ],
|
161
|
-
# "id": null
|
162
|
-
# }
|
163
|
-
#
|
164
|
-
defaultType = self.safe_string(self.options, 'defaultType')
|
165
|
-
data = self.safe_dict(message, 'data', {})
|
166
|
-
rawTickers = self.safe_list(data, 'state_list', [])
|
167
|
-
newTickers = []
|
168
|
-
for i in range(0, len(rawTickers)):
|
169
|
-
entry = rawTickers[i]
|
170
|
-
marketId = self.safe_string(entry, 'market')
|
171
|
-
symbol = self.safe_symbol(marketId, None, None, defaultType)
|
172
|
-
market = self.safe_market(marketId, None, None, defaultType)
|
173
|
-
parsedTicker = self.parse_ws_ticker(entry, market)
|
174
|
-
self.tickers[symbol] = parsedTicker
|
175
|
-
newTickers.append(parsedTicker)
|
176
|
-
messageHashes = self.find_message_hashes(client, 'tickers::')
|
177
|
-
for i in range(0, len(messageHashes)):
|
178
|
-
messageHash = messageHashes[i]
|
179
|
-
parts = messageHash.split('::')
|
180
|
-
symbolsString = parts[1]
|
181
|
-
symbols = symbolsString.split(',')
|
182
|
-
tickers = self.filter_by_array(newTickers, 'symbol', symbols)
|
183
|
-
tickersSymbols = list(tickers.keys())
|
184
|
-
numTickers = len(tickersSymbols)
|
185
|
-
if numTickers > 0:
|
186
|
-
client.resolve(tickers, messageHash)
|
187
|
-
client.resolve(newTickers, 'tickers')
|
188
|
-
|
189
|
-
def parse_ws_ticker(self, ticker, market=None):
|
190
|
-
#
|
191
|
-
# spot
|
192
|
-
#
|
193
|
-
# {
|
194
|
-
# "market": "LATUSDT",
|
195
|
-
# "last": "0.008157",
|
196
|
-
# "open": "0.008286",
|
197
|
-
# "close": "0.008157",
|
198
|
-
# "high": "0.008390",
|
199
|
-
# "low": "0.008106",
|
200
|
-
# "volume": "807714.49139758",
|
201
|
-
# "volume_sell": "286170.69645599",
|
202
|
-
# "volume_buy": "266161.23236408",
|
203
|
-
# "value": "6689.21644207",
|
204
|
-
# "period": 86400
|
205
|
-
# }
|
206
|
-
#
|
207
|
-
# swap
|
208
|
-
#
|
209
|
-
# {
|
210
|
-
# "market": "ETHUSD_SIGNPRICE",
|
211
|
-
# "last": "1892.29",
|
212
|
-
# "open": "1884.62",
|
213
|
-
# "close": "1892.29",
|
214
|
-
# "high": "1894.09",
|
215
|
-
# "low": "1863.72",
|
216
|
-
# "volume": "0",
|
217
|
-
# "value": "0",
|
218
|
-
# "volume_sell": "0",
|
219
|
-
# "volume_buy": "0",
|
220
|
-
# "open_interest_size": "0",
|
221
|
-
# "insurance_fund_size": "0",
|
222
|
-
# "latest_funding_rate": "0",
|
223
|
-
# "next_funding_rate": "0",
|
224
|
-
# "latest_funding_time": 0,
|
225
|
-
# "next_funding_time": 0,
|
226
|
-
# "period": 86400
|
227
|
-
# }
|
228
|
-
#
|
229
|
-
defaultType = self.safe_string(self.options, 'defaultType')
|
230
|
-
marketId = self.safe_string(ticker, 'market')
|
231
|
-
return self.safe_ticker({
|
232
|
-
'symbol': self.safe_symbol(marketId, market, None, defaultType),
|
233
|
-
'timestamp': None,
|
234
|
-
'datetime': None,
|
235
|
-
'high': self.safe_string(ticker, 'high'),
|
236
|
-
'low': self.safe_string(ticker, 'low'),
|
237
|
-
'bid': None,
|
238
|
-
'bidVolume': self.safe_string(ticker, 'volume_buy'),
|
239
|
-
'ask': None,
|
240
|
-
'askVolume': self.safe_string(ticker, 'volume_sell'),
|
241
|
-
'vwap': None,
|
242
|
-
'open': self.safe_string(ticker, 'open'),
|
243
|
-
'close': self.safe_string(ticker, 'close'),
|
244
|
-
'last': self.safe_string(ticker, 'last'),
|
245
|
-
'previousClose': None,
|
246
|
-
'change': None,
|
247
|
-
'percentage': None,
|
248
|
-
'average': None,
|
249
|
-
'baseVolume': self.safe_string(ticker, 'volume'),
|
250
|
-
'quoteVolume': self.safe_string(ticker, 'value'),
|
251
|
-
'info': ticker,
|
252
|
-
}, market)
|
253
|
-
|
254
|
-
async def watch_balance(self, params={}) -> Balances:
|
255
|
-
"""
|
256
|
-
watch balance and get the amount of funds available for trading or funds locked in orders
|
257
|
-
|
258
|
-
https://docs.coinex.com/api/v2/assets/balance/ws/spot_balance
|
259
|
-
https://docs.coinex.com/api/v2/assets/balance/ws/futures_balance
|
260
|
-
|
261
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
262
|
-
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
263
|
-
"""
|
264
|
-
await self.load_markets()
|
265
|
-
type = None
|
266
|
-
type, params = self.handle_market_type_and_params('watchBalance', None, params, 'spot')
|
267
|
-
await self.authenticate(type)
|
268
|
-
url = self.urls['api']['ws'][type]
|
269
|
-
# coinex throws a closes the websocket when subscribing over 1422 currencies, therefore we filter out inactive currencies
|
270
|
-
activeCurrencies = self.filter_by(self.currencies_by_id, 'active', True)
|
271
|
-
activeCurrenciesById = self.index_by(activeCurrencies, 'id')
|
272
|
-
currencies = list(activeCurrenciesById.keys())
|
273
|
-
if currencies is None:
|
274
|
-
currencies = []
|
275
|
-
messageHash = 'balances'
|
276
|
-
if type == 'spot':
|
277
|
-
messageHash += ':spot'
|
278
|
-
else:
|
279
|
-
messageHash += ':swap'
|
280
|
-
subscribe: dict = {
|
281
|
-
'method': 'balance.subscribe',
|
282
|
-
'params': {'ccy_list': currencies},
|
283
|
-
'id': self.request_id(),
|
284
|
-
}
|
285
|
-
request = self.deep_extend(subscribe, params)
|
286
|
-
return await self.watch(url, messageHash, request, messageHash)
|
287
|
-
|
288
|
-
def handle_balance(self, client: Client, message):
|
289
|
-
#
|
290
|
-
# spot
|
291
|
-
#
|
292
|
-
# {
|
293
|
-
# "method": "balance.update",
|
294
|
-
# "data": {
|
295
|
-
# "balance_list": [
|
296
|
-
# {
|
297
|
-
# "margin_market": "BTCUSDT",
|
298
|
-
# "ccy": "BTC",
|
299
|
-
# "available": "44.62207740",
|
300
|
-
# "frozen": "0.00000000",
|
301
|
-
# "updated_at": 1689152421692
|
302
|
-
# },
|
303
|
-
# ]
|
304
|
-
# },
|
305
|
-
# "id": null
|
306
|
-
# }
|
307
|
-
#
|
308
|
-
# swap
|
309
|
-
#
|
310
|
-
# {
|
311
|
-
# "method": "balance.update",
|
312
|
-
# "data": {
|
313
|
-
# "balance_list": [
|
314
|
-
# {
|
315
|
-
# "ccy": "USDT",
|
316
|
-
# "available": "97.92470982756335000001",
|
317
|
-
# "frozen": "0.00000000000000000000",
|
318
|
-
# "margin": "0.61442700000000000000",
|
319
|
-
# "transferrable": "97.92470982756335000001",
|
320
|
-
# "unrealized_pnl": "-0.00807000000000000000",
|
321
|
-
# "equity": "97.92470982756335000001"
|
322
|
-
# },
|
323
|
-
# ]
|
324
|
-
# },
|
325
|
-
# "id": null
|
326
|
-
# }
|
327
|
-
#
|
328
|
-
if self.balance is None:
|
329
|
-
self.balance = {}
|
330
|
-
data = self.safe_dict(message, 'data', {})
|
331
|
-
balances = self.safe_list(data, 'balance_list', [])
|
332
|
-
firstEntry = balances[0]
|
333
|
-
updated = self.safe_integer(firstEntry, 'updated_at')
|
334
|
-
unrealizedPnl = self.safe_string(firstEntry, 'unrealized_pnl')
|
335
|
-
isSpot = (updated is not None)
|
336
|
-
isSwap = (unrealizedPnl is not None)
|
337
|
-
info = None
|
338
|
-
account = None
|
339
|
-
rawBalances = []
|
340
|
-
if isSpot:
|
341
|
-
account = 'spot'
|
342
|
-
for i in range(0, len(balances)):
|
343
|
-
rawBalances = self.array_concat(rawBalances, balances)
|
344
|
-
info = rawBalances
|
345
|
-
if isSwap:
|
346
|
-
account = 'swap'
|
347
|
-
for i in range(0, len(balances)):
|
348
|
-
rawBalances = self.array_concat(rawBalances, balances)
|
349
|
-
info = rawBalances
|
350
|
-
for i in range(0, len(rawBalances)):
|
351
|
-
entry = rawBalances[i]
|
352
|
-
self.parse_ws_balance(entry, account)
|
353
|
-
messageHash = None
|
354
|
-
if account is not None:
|
355
|
-
if self.safe_value(self.balance, account) is None:
|
356
|
-
self.balance[account] = {}
|
357
|
-
self.balance[account]['info'] = info
|
358
|
-
self.balance[account] = self.safe_balance(self.balance[account])
|
359
|
-
messageHash = 'balances:' + account
|
360
|
-
client.resolve(self.balance[account], messageHash)
|
361
|
-
|
362
|
-
def parse_ws_balance(self, balance, accountType=None):
|
363
|
-
#
|
364
|
-
# spot
|
365
|
-
#
|
366
|
-
# {
|
367
|
-
# "margin_market": "BTCUSDT",
|
368
|
-
# "ccy": "BTC",
|
369
|
-
# "available": "44.62207740",
|
370
|
-
# "frozen": "0.00000000",
|
371
|
-
# "updated_at": 1689152421692
|
372
|
-
# }
|
373
|
-
#
|
374
|
-
# swap
|
375
|
-
#
|
376
|
-
# {
|
377
|
-
# "ccy": "USDT",
|
378
|
-
# "available": "97.92470982756335000001",
|
379
|
-
# "frozen": "0.00000000000000000000",
|
380
|
-
# "margin": "0.61442700000000000000",
|
381
|
-
# "transferrable": "97.92470982756335000001",
|
382
|
-
# "unrealized_pnl": "-0.00807000000000000000",
|
383
|
-
# "equity": "97.92470982756335000001"
|
384
|
-
# }
|
385
|
-
#
|
386
|
-
account = self.account()
|
387
|
-
currencyId = self.safe_string(balance, 'ccy')
|
388
|
-
code = self.safe_currency_code(currencyId)
|
389
|
-
account['free'] = self.safe_string(balance, 'available')
|
390
|
-
account['used'] = self.safe_string(balance, 'frozen')
|
391
|
-
if accountType is not None:
|
392
|
-
if self.safe_value(self.balance, accountType) is None:
|
393
|
-
self.balance[accountType] = {}
|
394
|
-
self.balance[accountType][code] = account
|
395
|
-
else:
|
396
|
-
self.balance[code] = account
|
397
|
-
|
398
|
-
async def watch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
399
|
-
"""
|
400
|
-
watches information on multiple trades made by the user
|
401
|
-
|
402
|
-
https://docs.coinex.com/api/v2/spot/deal/ws/user-deals
|
403
|
-
https://docs.coinex.com/api/v2/futures/deal/ws/user-deals
|
404
|
-
|
405
|
-
:param str [symbol]: unified symbol of the market the trades were made in
|
406
|
-
:param int [since]: the earliest time in ms to watch trades
|
407
|
-
:param int [limit]: the maximum number of trade structures to retrieve
|
408
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
409
|
-
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
410
|
-
"""
|
411
|
-
await self.load_markets()
|
412
|
-
market = None
|
413
|
-
if symbol is not None:
|
414
|
-
market = self.market(symbol)
|
415
|
-
symbol = market['symbol']
|
416
|
-
type = None
|
417
|
-
type, params = self.handle_market_type_and_params('watchMyTrades', market, params, 'spot')
|
418
|
-
await self.authenticate(type)
|
419
|
-
url = self.urls['api']['ws'][type]
|
420
|
-
subscribedSymbols = []
|
421
|
-
messageHash = 'myTrades'
|
422
|
-
if market is not None:
|
423
|
-
messageHash += ':' + symbol
|
424
|
-
subscribedSymbols.append(market['id'])
|
425
|
-
else:
|
426
|
-
if type == 'spot':
|
427
|
-
messageHash += ':spot'
|
428
|
-
else:
|
429
|
-
messageHash += ':swap'
|
430
|
-
message: dict = {
|
431
|
-
'method': 'user_deals.subscribe',
|
432
|
-
'params': {'market_list': subscribedSymbols},
|
433
|
-
'id': self.request_id(),
|
434
|
-
}
|
435
|
-
request = self.deep_extend(message, params)
|
436
|
-
trades = await self.watch(url, messageHash, request, messageHash)
|
437
|
-
if self.newUpdates:
|
438
|
-
limit = trades.getLimit(symbol, limit)
|
439
|
-
return self.filter_by_symbol_since_limit(trades, symbol, since, limit, True)
|
440
|
-
|
441
|
-
def handle_my_trades(self, client: Client, message):
|
442
|
-
#
|
443
|
-
# {
|
444
|
-
# "method": "user_deals.update",
|
445
|
-
# "data": {
|
446
|
-
# "deal_id": 3514376759,
|
447
|
-
# "created_at": 1689152421692,
|
448
|
-
# "market": "BTCUSDT",
|
449
|
-
# "side": "buy",
|
450
|
-
# "order_id": 8678890,
|
451
|
-
# "margin_market": "BTCUSDT",
|
452
|
-
# "price": "30718.42",
|
453
|
-
# "amount": "0.00000325",
|
454
|
-
# "role": "taker",
|
455
|
-
# "fee": "0.0299",
|
456
|
-
# "fee_ccy": "USDT"
|
457
|
-
# },
|
458
|
-
# "id": null
|
459
|
-
# }
|
460
|
-
#
|
461
|
-
data = self.safe_dict(message, 'data', {})
|
462
|
-
marketId = self.safe_string(data, 'market')
|
463
|
-
isSpot = client.url.find('spot') > -1
|
464
|
-
defaultType = 'spot' if isSpot else 'swap'
|
465
|
-
market = self.safe_market(marketId, None, None, defaultType)
|
466
|
-
symbol = market['symbol']
|
467
|
-
messageHash = 'myTrades:' + symbol
|
468
|
-
messageWithType = 'myTrades:' + market['type']
|
469
|
-
stored = self.safe_value(self.trades, symbol)
|
470
|
-
if stored is None:
|
471
|
-
limit = self.safe_integer(self.options, 'tradesLimit', 1000)
|
472
|
-
stored = ArrayCache(limit)
|
473
|
-
self.trades[symbol] = stored
|
474
|
-
parsed = self.parse_ws_trade(data, market)
|
475
|
-
stored.append(parsed)
|
476
|
-
self.trades[symbol] = stored
|
477
|
-
client.resolve(self.trades[symbol], messageWithType)
|
478
|
-
client.resolve(self.trades[symbol], messageHash)
|
479
|
-
|
480
|
-
def handle_trades(self, client: Client, message):
|
481
|
-
#
|
482
|
-
# spot
|
483
|
-
#
|
484
|
-
# {
|
485
|
-
# "method": "deals.update",
|
486
|
-
# "data": {
|
487
|
-
# "market": "BTCUSDT",
|
488
|
-
# "deal_list": [
|
489
|
-
# {
|
490
|
-
# "deal_id": 3514376759,
|
491
|
-
# "created_at": 1689152421692,
|
492
|
-
# "side": "buy",
|
493
|
-
# "price": "30718.42",
|
494
|
-
# "amount": "0.00000325"
|
495
|
-
# },
|
496
|
-
# ]
|
497
|
-
# },
|
498
|
-
# "id": null
|
499
|
-
# }
|
500
|
-
#
|
501
|
-
# swap
|
502
|
-
#
|
503
|
-
# {
|
504
|
-
# "method": "deals.update",
|
505
|
-
# "data": {
|
506
|
-
# "market": "BTCUSDT",
|
507
|
-
# "deal_list": [
|
508
|
-
# {
|
509
|
-
# "deal_id": 3514376759,
|
510
|
-
# "created_at": 1689152421692,
|
511
|
-
# "side": "buy",
|
512
|
-
# "price": "30718.42",
|
513
|
-
# "amount": "0.00000325"
|
514
|
-
# },
|
515
|
-
# ]
|
516
|
-
# },
|
517
|
-
# "id": null
|
518
|
-
# }
|
519
|
-
#
|
520
|
-
data = self.safe_dict(message, 'data', {})
|
521
|
-
trades = self.safe_list(data, 'deal_list', [])
|
522
|
-
marketId = self.safe_string(data, 'market')
|
523
|
-
isSpot = client.url.find('spot') > -1
|
524
|
-
defaultType = 'spot' if isSpot else 'swap'
|
525
|
-
market = self.safe_market(marketId, None, None, defaultType)
|
526
|
-
symbol = market['symbol']
|
527
|
-
messageHash = 'trades:' + symbol
|
528
|
-
stored = self.safe_value(self.trades, symbol)
|
529
|
-
if stored is None:
|
530
|
-
limit = self.safe_integer(self.options, 'tradesLimit', 1000)
|
531
|
-
stored = ArrayCache(limit)
|
532
|
-
self.trades[symbol] = stored
|
533
|
-
for i in range(0, len(trades)):
|
534
|
-
trade = trades[i]
|
535
|
-
parsed = self.parse_ws_trade(trade, market)
|
536
|
-
stored.append(parsed)
|
537
|
-
self.trades[symbol] = stored
|
538
|
-
client.resolve(self.trades[symbol], messageHash)
|
539
|
-
|
540
|
-
def parse_ws_trade(self, trade, market=None):
|
541
|
-
#
|
542
|
-
# spot watchTrades
|
543
|
-
#
|
544
|
-
# {
|
545
|
-
# "deal_id": 3514376759,
|
546
|
-
# "created_at": 1689152421692,
|
547
|
-
# "side": "buy",
|
548
|
-
# "price": "30718.42",
|
549
|
-
# "amount": "0.00000325"
|
550
|
-
# }
|
551
|
-
#
|
552
|
-
# swap watchTrades
|
553
|
-
#
|
554
|
-
# {
|
555
|
-
# "deal_id": 3514376759,
|
556
|
-
# "created_at": 1689152421692,
|
557
|
-
# "side": "buy",
|
558
|
-
# "price": "30718.42",
|
559
|
-
# "amount": "0.00000325"
|
560
|
-
# }
|
561
|
-
#
|
562
|
-
# spot and swap watchMyTrades
|
563
|
-
#
|
564
|
-
# {
|
565
|
-
# "deal_id": 3514376759,
|
566
|
-
# "created_at": 1689152421692,
|
567
|
-
# "market": "BTCUSDT",
|
568
|
-
# "side": "buy",
|
569
|
-
# "order_id": 8678890,
|
570
|
-
# "margin_market": "BTCUSDT",
|
571
|
-
# "price": "30718.42",
|
572
|
-
# "amount": "0.00000325",
|
573
|
-
# "role": "taker",
|
574
|
-
# "fee": "0.0299",
|
575
|
-
# "fee_ccy": "USDT"
|
576
|
-
# }
|
577
|
-
#
|
578
|
-
timestamp = self.safe_integer(trade, 'created_at')
|
579
|
-
isSpot = ('margin_market' in trade)
|
580
|
-
defaultType = 'spot' if isSpot else 'swap'
|
581
|
-
marketId = self.safe_string(trade, 'market')
|
582
|
-
market = self.safe_market(marketId, market, None, defaultType)
|
583
|
-
fee: dict = {}
|
584
|
-
feeCost = self.omit_zero(self.safe_string(trade, 'fee'))
|
585
|
-
if feeCost is not None:
|
586
|
-
feeCurrencyId = self.safe_string(trade, 'fee_ccy', market['quote'])
|
587
|
-
fee = {
|
588
|
-
'currency': self.safe_currency_code(feeCurrencyId),
|
589
|
-
'cost': feeCost,
|
590
|
-
}
|
591
|
-
return self.safe_trade({
|
592
|
-
'id': self.safe_string(trade, 'deal_id'),
|
593
|
-
'info': trade,
|
594
|
-
'timestamp': timestamp,
|
595
|
-
'datetime': self.iso8601(timestamp),
|
596
|
-
'symbol': self.safe_symbol(marketId, market, None, defaultType),
|
597
|
-
'order': self.safe_string(trade, 'order_id'),
|
598
|
-
'type': None,
|
599
|
-
'side': self.safe_string(trade, 'side'),
|
600
|
-
'takerOrMaker': self.safe_string(trade, 'role'),
|
601
|
-
'price': self.safe_string(trade, 'price'),
|
602
|
-
'amount': self.safe_string(trade, 'amount'),
|
603
|
-
'cost': None,
|
604
|
-
'fee': fee,
|
605
|
-
}, market)
|
606
|
-
|
607
|
-
async def watch_ticker(self, symbol: str, params={}) -> Ticker:
|
608
|
-
"""
|
609
|
-
watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
610
|
-
|
611
|
-
https://docs.coinex.com/api/v2/spot/market/ws/market
|
612
|
-
https://docs.coinex.com/api/v2/futures/market/ws/market-state
|
613
|
-
|
614
|
-
:param str symbol: unified symbol of the market to fetch the ticker for
|
615
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
616
|
-
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
617
|
-
"""
|
618
|
-
await self.load_markets()
|
619
|
-
market = self.market(symbol)
|
620
|
-
tickers = await self.watch_tickers([symbol], params)
|
621
|
-
return tickers[market['symbol']]
|
622
|
-
|
623
|
-
async def watch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
624
|
-
"""
|
625
|
-
watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
626
|
-
|
627
|
-
https://docs.coinex.com/api/v2/spot/market/ws/market
|
628
|
-
https://docs.coinex.com/api/v2/futures/market/ws/market-state
|
629
|
-
|
630
|
-
:param str[] symbols: unified symbol of the market to fetch the ticker for
|
631
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
632
|
-
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
633
|
-
"""
|
634
|
-
await self.load_markets()
|
635
|
-
marketIds = self.market_ids(symbols)
|
636
|
-
market = None
|
637
|
-
messageHashes = []
|
638
|
-
symbolsDefined = (symbols is not None)
|
639
|
-
if symbolsDefined:
|
640
|
-
for i in range(0, len(symbols)):
|
641
|
-
symbol = symbols[i]
|
642
|
-
market = self.market(symbol)
|
643
|
-
messageHashes.append('tickers::' + market['symbol'])
|
644
|
-
else:
|
645
|
-
messageHashes.append('tickers')
|
646
|
-
type = None
|
647
|
-
type, params = self.handle_market_type_and_params('watchTickers', market, params)
|
648
|
-
url = self.urls['api']['ws'][type]
|
649
|
-
subscriptionHashes = ['all@ticker']
|
650
|
-
subscribe: dict = {
|
651
|
-
'method': 'state.subscribe',
|
652
|
-
'params': {'market_list': marketIds},
|
653
|
-
'id': self.request_id(),
|
654
|
-
}
|
655
|
-
result = await self.watch_multiple(url, messageHashes, self.deep_extend(subscribe, params), subscriptionHashes)
|
656
|
-
if self.newUpdates:
|
657
|
-
return result
|
658
|
-
return self.filter_by_array(self.tickers, 'symbol', symbols)
|
659
|
-
|
660
|
-
async def watch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
661
|
-
"""
|
662
|
-
get the list of most recent trades for a particular symbol
|
663
|
-
|
664
|
-
https://docs.coinex.com/api/v2/spot/market/ws/market-deals
|
665
|
-
https://docs.coinex.com/api/v2/futures/market/ws/market-deals
|
666
|
-
|
667
|
-
:param str symbol: unified symbol of the market to fetch trades for
|
668
|
-
:param int [since]: timestamp in ms of the earliest trade to fetch
|
669
|
-
:param int [limit]: the maximum amount of trades to fetch
|
670
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
671
|
-
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
|
672
|
-
"""
|
673
|
-
params['callerMethodName'] = 'watchTrades'
|
674
|
-
return await self.watch_trades_for_symbols([symbol], since, limit, params)
|
675
|
-
|
676
|
-
async def watch_trades_for_symbols(self, symbols: List[str], since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
677
|
-
"""
|
678
|
-
watch the most recent trades for a list of symbols
|
679
|
-
|
680
|
-
https://docs.coinex.com/api/v2/spot/market/ws/market-deals
|
681
|
-
https://docs.coinex.com/api/v2/futures/market/ws/market-deals
|
682
|
-
|
683
|
-
:param str[] symbols: unified symbols of the markets to fetch trades for
|
684
|
-
:param int [since]: timestamp in ms of the earliest trade to fetch
|
685
|
-
:param int [limit]: the maximum amount of trades to fetch
|
686
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
687
|
-
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
|
688
|
-
"""
|
689
|
-
await self.load_markets()
|
690
|
-
subscribedSymbols = []
|
691
|
-
messageHashes = []
|
692
|
-
market = None
|
693
|
-
callerMethodName = None
|
694
|
-
callerMethodName, params = self.handle_param_string(params, 'callerMethodName', 'watchTradesForSymbols')
|
695
|
-
symbolsDefined = (symbols is not None)
|
696
|
-
if symbolsDefined:
|
697
|
-
for i in range(0, len(symbols)):
|
698
|
-
symbol = symbols[i]
|
699
|
-
market = self.market(symbol)
|
700
|
-
subscribedSymbols.append(market['id'])
|
701
|
-
messageHashes.append('trades:' + market['symbol'])
|
702
|
-
else:
|
703
|
-
messageHashes.append('trades')
|
704
|
-
type = None
|
705
|
-
type, params = self.handle_market_type_and_params(callerMethodName, market, params)
|
706
|
-
url = self.urls['api']['ws'][type]
|
707
|
-
subscriptionHashes = ['trades']
|
708
|
-
subscribe: dict = {
|
709
|
-
'method': 'deals.subscribe',
|
710
|
-
'params': {'market_list': subscribedSymbols},
|
711
|
-
'id': self.request_id(),
|
712
|
-
}
|
713
|
-
trades = await self.watch_multiple(url, messageHashes, self.deep_extend(subscribe, params), subscriptionHashes)
|
714
|
-
if self.newUpdates:
|
715
|
-
return trades
|
716
|
-
return self.filter_by_since_limit(trades, since, limit, 'timestamp', True)
|
717
|
-
|
718
|
-
async def watch_order_book_for_symbols(self, symbols: List[str], limit: Int = None, params={}) -> OrderBook:
|
719
|
-
"""
|
720
|
-
watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
721
|
-
|
722
|
-
https://docs.coinex.com/api/v2/spot/market/ws/market-depth
|
723
|
-
https://docs.coinex.com/api/v2/futures/market/ws/market-depth
|
724
|
-
|
725
|
-
:param str[] symbols: unified array of symbols
|
726
|
-
:param int [limit]: the maximum amount of order book entries to return
|
727
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
728
|
-
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
|
729
|
-
"""
|
730
|
-
await self.load_markets()
|
731
|
-
watchOrderBookSubscriptions: dict = {}
|
732
|
-
messageHashes = []
|
733
|
-
market = None
|
734
|
-
type = None
|
735
|
-
callerMethodName = None
|
736
|
-
callerMethodName, params = self.handle_param_string(params, 'callerMethodName', 'watchOrderBookForSymbols')
|
737
|
-
type, params = self.handle_market_type_and_params(callerMethodName, None, params)
|
738
|
-
options = self.safe_dict(self.options, 'watchOrderBook', {})
|
739
|
-
limits = self.safe_list(options, 'limits', [])
|
740
|
-
if limit is None:
|
741
|
-
limit = self.safe_integer(options, 'defaultLimit', 50)
|
742
|
-
if not self.in_array(limit, limits):
|
743
|
-
raise NotSupported(self.id + ' watchOrderBookForSymbols() limit must be one of ' + ', '.join(limits))
|
744
|
-
defaultAggregation = self.safe_string(options, 'defaultAggregation', '0')
|
745
|
-
aggregations = self.safe_list(options, 'aggregations', [])
|
746
|
-
aggregation = self.safe_string(params, 'aggregation', defaultAggregation)
|
747
|
-
if not self.in_array(aggregation, aggregations):
|
748
|
-
raise NotSupported(self.id + ' watchOrderBookForSymbols() aggregation must be one of ' + ', '.join(aggregations))
|
749
|
-
params = self.omit(params, 'aggregation')
|
750
|
-
symbolsDefined = (symbols is not None)
|
751
|
-
if symbolsDefined:
|
752
|
-
for i in range(0, len(symbols)):
|
753
|
-
symbol = symbols[i]
|
754
|
-
market = self.market(symbol)
|
755
|
-
messageHashes.append('orderbook:' + market['symbol'])
|
756
|
-
watchOrderBookSubscriptions[symbol] = [market['id'], limit, aggregation, True]
|
757
|
-
else:
|
758
|
-
messageHashes.append('orderbook')
|
759
|
-
marketList = list(watchOrderBookSubscriptions.values())
|
760
|
-
subscribe: dict = {
|
761
|
-
'method': 'depth.subscribe',
|
762
|
-
'params': {'market_list': marketList},
|
763
|
-
'id': self.request_id(),
|
764
|
-
}
|
765
|
-
subscriptionHashes = self.hash(self.encode(self.json(watchOrderBookSubscriptions)), 'sha256')
|
766
|
-
url = self.urls['api']['ws'][type]
|
767
|
-
orderbooks = await self.watch_multiple(url, messageHashes, self.deep_extend(subscribe, params), subscriptionHashes)
|
768
|
-
if self.newUpdates:
|
769
|
-
return orderbooks
|
770
|
-
return orderbooks.limit()
|
771
|
-
|
772
|
-
async def watch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
773
|
-
"""
|
774
|
-
watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
775
|
-
|
776
|
-
https://docs.coinex.com/api/v2/spot/market/ws/market-depth
|
777
|
-
https://docs.coinex.com/api/v2/futures/market/ws/market-depth
|
778
|
-
|
779
|
-
:param str symbol: unified symbol of the market to fetch the order book for
|
780
|
-
:param int [limit]: the maximum amount of order book entries to return
|
781
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
782
|
-
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
|
783
|
-
"""
|
784
|
-
params['callerMethodName'] = 'watchOrderBook'
|
785
|
-
return await self.watch_order_book_for_symbols([symbol], limit, params)
|
786
|
-
|
787
|
-
def handle_delta(self, bookside, delta):
|
788
|
-
bidAsk = self.parse_bid_ask(delta, 0, 1)
|
789
|
-
bookside.storeArray(bidAsk)
|
790
|
-
|
791
|
-
def handle_deltas(self, bookside, deltas):
|
792
|
-
for i in range(0, len(deltas)):
|
793
|
-
self.handle_delta(bookside, deltas[i])
|
794
|
-
|
795
|
-
def handle_order_book(self, client: Client, message):
|
796
|
-
#
|
797
|
-
# {
|
798
|
-
# "method": "depth.update",
|
799
|
-
# "data": {
|
800
|
-
# "market": "BTCUSDT",
|
801
|
-
# "is_full": True,
|
802
|
-
# "depth": {
|
803
|
-
# "asks": [
|
804
|
-
# [
|
805
|
-
# "30740.00",
|
806
|
-
# "0.31763545"
|
807
|
-
# ],
|
808
|
-
# ],
|
809
|
-
# "bids": [
|
810
|
-
# [
|
811
|
-
# "30736.00",
|
812
|
-
# "0.04857373"
|
813
|
-
# ],
|
814
|
-
# ],
|
815
|
-
# "last": "30746.28",
|
816
|
-
# "updated_at": 1689152421692,
|
817
|
-
# "checksum": 2578768879
|
818
|
-
# }
|
819
|
-
# },
|
820
|
-
# "id": null
|
821
|
-
# }
|
822
|
-
#
|
823
|
-
defaultType = self.safe_string(self.options, 'defaultType')
|
824
|
-
data = self.safe_dict(message, 'data', {})
|
825
|
-
depth = self.safe_dict(data, 'depth', {})
|
826
|
-
marketId = self.safe_string(data, 'market')
|
827
|
-
market = self.safe_market(marketId, None, None, defaultType)
|
828
|
-
symbol = market['symbol']
|
829
|
-
name = 'orderbook'
|
830
|
-
messageHash = name + ':' + symbol
|
831
|
-
timestamp = self.safe_integer(depth, 'updated_at')
|
832
|
-
currentOrderBook = self.safe_value(self.orderbooks, symbol)
|
833
|
-
fullOrderBook = self.safe_bool(data, 'is_full', False)
|
834
|
-
if fullOrderBook:
|
835
|
-
snapshot = self.parse_order_book(depth, symbol, timestamp)
|
836
|
-
if currentOrderBook is None:
|
837
|
-
self.orderbooks[symbol] = self.order_book(snapshot)
|
838
|
-
else:
|
839
|
-
orderbook = self.orderbooks[symbol]
|
840
|
-
orderbook.reset(snapshot)
|
841
|
-
else:
|
842
|
-
asks = self.safe_list(depth, 'asks', [])
|
843
|
-
bids = self.safe_list(depth, 'bids', [])
|
844
|
-
self.handle_deltas(currentOrderBook['asks'], asks)
|
845
|
-
self.handle_deltas(currentOrderBook['bids'], bids)
|
846
|
-
currentOrderBook['nonce'] = timestamp
|
847
|
-
currentOrderBook['timestamp'] = timestamp
|
848
|
-
currentOrderBook['datetime'] = self.iso8601(timestamp)
|
849
|
-
self.orderbooks[symbol] = currentOrderBook
|
850
|
-
# self.checkOrderBookChecksum(self.orderbooks[symbol])
|
851
|
-
client.resolve(self.orderbooks[symbol], messageHash)
|
852
|
-
|
853
|
-
async def watch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
854
|
-
"""
|
855
|
-
watches information on multiple orders made by the user
|
856
|
-
|
857
|
-
https://docs.coinex.com/api/v2/spot/order/ws/user-order
|
858
|
-
https://docs.coinex.com/api/v2/futures/order/ws/user-order
|
859
|
-
|
860
|
-
:param str symbol: unified market symbol of the market orders were made in
|
861
|
-
:param int [since]: the earliest time in ms to fetch orders for
|
862
|
-
:param int [limit]: the maximum number of order structures to retrieve
|
863
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
864
|
-
:param bool [params.trigger]: if the orders to watch are trigger orders or not
|
865
|
-
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
866
|
-
"""
|
867
|
-
await self.load_markets()
|
868
|
-
trigger = self.safe_bool_2(params, 'trigger', 'stop')
|
869
|
-
params = self.omit(params, ['trigger', 'stop'])
|
870
|
-
messageHash = 'orders'
|
871
|
-
market = None
|
872
|
-
marketList = None
|
873
|
-
if symbol is not None:
|
874
|
-
market = self.market(symbol)
|
875
|
-
symbol = market['symbol']
|
876
|
-
type = None
|
877
|
-
type, params = self.handle_market_type_and_params('watchOrders', market, params, 'spot')
|
878
|
-
await self.authenticate(type)
|
879
|
-
if symbol is not None:
|
880
|
-
marketList = [market['id']]
|
881
|
-
messageHash += ':' + symbol
|
882
|
-
else:
|
883
|
-
marketList = []
|
884
|
-
if type == 'spot':
|
885
|
-
messageHash += ':spot'
|
886
|
-
else:
|
887
|
-
messageHash += ':swap'
|
888
|
-
method = None
|
889
|
-
if trigger:
|
890
|
-
method = 'stop.subscribe'
|
891
|
-
else:
|
892
|
-
method = 'order.subscribe'
|
893
|
-
message: dict = {
|
894
|
-
'method': method,
|
895
|
-
'params': {'market_list': marketList},
|
896
|
-
'id': self.request_id(),
|
897
|
-
}
|
898
|
-
url = self.urls['api']['ws'][type]
|
899
|
-
request = self.deep_extend(message, params)
|
900
|
-
orders = await self.watch(url, messageHash, request, messageHash, request)
|
901
|
-
if self.newUpdates:
|
902
|
-
limit = orders.getLimit(symbol, limit)
|
903
|
-
return self.filter_by_symbol_since_limit(orders, symbol, since, limit, True)
|
904
|
-
|
905
|
-
def handle_orders(self, client: Client, message):
|
906
|
-
#
|
907
|
-
# spot
|
908
|
-
#
|
909
|
-
# {
|
910
|
-
# "method": "order.update",
|
911
|
-
# "data": {
|
912
|
-
# "event": "put",
|
913
|
-
# "order": {
|
914
|
-
# "order_id": 12750,
|
915
|
-
# "market": "BTCUSDT",
|
916
|
-
# "margin_market": "BTCUSDT",
|
917
|
-
# "type": "limit",
|
918
|
-
# "side": "buy",
|
919
|
-
# "price": "5999.00",
|
920
|
-
# "amount": "1.50000000",
|
921
|
-
# "unfill_amount": "1.50000000",
|
922
|
-
# "fill_value": "1.50000000",
|
923
|
-
# "taker_fee_rate": "0.0001",
|
924
|
-
# "maker_fee_rate": "0.0001",
|
925
|
-
# "base_ccy_fee": "0.0001",
|
926
|
-
# "quote_ccy_fee": "0.0001",
|
927
|
-
# "discount_ccy_fee": "0.0001",
|
928
|
-
# "last_fill_amount": "0",
|
929
|
-
# "last_fill_price": "0",
|
930
|
-
# "client_id": "buy1_1234",
|
931
|
-
# "created_at": 1689152421692,
|
932
|
-
# "updated_at": 1689152421692,
|
933
|
-
# }
|
934
|
-
# },
|
935
|
-
# "id": null
|
936
|
-
# }
|
937
|
-
#
|
938
|
-
# spot stop
|
939
|
-
#
|
940
|
-
# {
|
941
|
-
# "method": "stop.update",
|
942
|
-
# "data": {
|
943
|
-
# "event": 1,
|
944
|
-
# "stop": {
|
945
|
-
# "stop_id": 102067022299,
|
946
|
-
# "market": "BTCUSDT",
|
947
|
-
# "margin_market": "BTCUSDT",
|
948
|
-
# "type": "limit",
|
949
|
-
# "side": "buy",
|
950
|
-
# "price": "20000.00",
|
951
|
-
# "amount": "0.10000000",
|
952
|
-
# "trigger_price": "20000.00",
|
953
|
-
# "trigger_direction": "lower",
|
954
|
-
# "taker_fee_rate": "0.0016",
|
955
|
-
# "maker_fee_rate": "0.0016",
|
956
|
-
# "status": "active_success",
|
957
|
-
# "client_id": "",
|
958
|
-
# "created_at": 1689152996689,
|
959
|
-
# "updated_at": 1689152996689,
|
960
|
-
# }
|
961
|
-
# },
|
962
|
-
# "id": null
|
963
|
-
# }
|
964
|
-
#
|
965
|
-
# swap
|
966
|
-
#
|
967
|
-
# {
|
968
|
-
# "method": "order.update",
|
969
|
-
# "data": {
|
970
|
-
# "event": "put",
|
971
|
-
# "order": {
|
972
|
-
# "order_id": 98388656341,
|
973
|
-
# "stop_id": 0,
|
974
|
-
# "market": "BTCUSDT",
|
975
|
-
# "side": "buy",
|
976
|
-
# "type": "limit",
|
977
|
-
# "amount": "0.0010",
|
978
|
-
# "price": "50000.00",
|
979
|
-
# "unfilled_amount": "0.0010",
|
980
|
-
# "filled_amount": "0",
|
981
|
-
# "filled_value": "0",
|
982
|
-
# "fee": "0",
|
983
|
-
# "fee_ccy": "USDT",
|
984
|
-
# "taker_fee_rate": "0.00046",
|
985
|
-
# "maker_fee_rate": "0.00000000000000000000",
|
986
|
-
# "client_id": "",
|
987
|
-
# "last_filled_amount": "0.0010",
|
988
|
-
# "last_filled_price": "30721.35",
|
989
|
-
# "created_at": 1689145715129,
|
990
|
-
# "updated_at": 1689145715129
|
991
|
-
# }
|
992
|
-
# },
|
993
|
-
# "id": null
|
994
|
-
# }
|
995
|
-
#
|
996
|
-
# swap stop
|
997
|
-
#
|
998
|
-
# {
|
999
|
-
# "method": "stop.update",
|
1000
|
-
# "data": {
|
1001
|
-
# "event": "put",
|
1002
|
-
# "stop": {
|
1003
|
-
# "stop_id": 98389557871,
|
1004
|
-
# "market": "BTCUSDT",
|
1005
|
-
# "side": "sell",
|
1006
|
-
# "type": "limit",
|
1007
|
-
# "price": "20000.00",
|
1008
|
-
# "amount": "0.0100",
|
1009
|
-
# "trigger_price": "20000.00",
|
1010
|
-
# "trigger_direction": "higer",
|
1011
|
-
# "trigger_price_type": "index_price",
|
1012
|
-
# "taker_fee_rate": "0.00046",
|
1013
|
-
# "maker_fee_rate": "0.00026",
|
1014
|
-
# "client_id": "",
|
1015
|
-
# "created_at": 1689146382674,
|
1016
|
-
# "updated_at": 1689146382674
|
1017
|
-
# }
|
1018
|
-
# },
|
1019
|
-
# "id": null
|
1020
|
-
# }
|
1021
|
-
#
|
1022
|
-
data = self.safe_dict(message, 'data', {})
|
1023
|
-
order = self.safe_dict_2(data, 'order', 'stop', {})
|
1024
|
-
parsedOrder = self.parse_ws_order(order)
|
1025
|
-
symbol = parsedOrder['symbol']
|
1026
|
-
market = self.market(symbol)
|
1027
|
-
if self.orders is None:
|
1028
|
-
limit = self.safe_integer(self.options, 'ordersLimit', 1000)
|
1029
|
-
self.orders = ArrayCacheBySymbolById(limit)
|
1030
|
-
orders = self.orders
|
1031
|
-
orders.append(parsedOrder)
|
1032
|
-
messageHash = 'orders'
|
1033
|
-
messageWithType = messageHash + ':' + market['type']
|
1034
|
-
client.resolve(self.orders, messageWithType)
|
1035
|
-
messageHash += ':' + symbol
|
1036
|
-
client.resolve(self.orders, messageHash)
|
1037
|
-
|
1038
|
-
def parse_ws_order(self, order, market=None):
|
1039
|
-
#
|
1040
|
-
# spot
|
1041
|
-
#
|
1042
|
-
# {
|
1043
|
-
# "order_id": 12750,
|
1044
|
-
# "market": "BTCUSDT",
|
1045
|
-
# "margin_market": "BTCUSDT",
|
1046
|
-
# "type": "limit",
|
1047
|
-
# "side": "buy",
|
1048
|
-
# "price": "5999.00",
|
1049
|
-
# "amount": "1.50000000",
|
1050
|
-
# "unfill_amount": "1.50000000",
|
1051
|
-
# "fill_value": "1.50000000",
|
1052
|
-
# "taker_fee_rate": "0.0001",
|
1053
|
-
# "maker_fee_rate": "0.0001",
|
1054
|
-
# "base_ccy_fee": "0.0001",
|
1055
|
-
# "quote_ccy_fee": "0.0001",
|
1056
|
-
# "discount_ccy_fee": "0.0001",
|
1057
|
-
# "last_fill_amount": "0",
|
1058
|
-
# "last_fill_price": "0",
|
1059
|
-
# "client_id": "buy1_1234",
|
1060
|
-
# "created_at": 1689152421692,
|
1061
|
-
# "updated_at": 1689152421692,
|
1062
|
-
# }
|
1063
|
-
#
|
1064
|
-
# spot stop
|
1065
|
-
#
|
1066
|
-
# {
|
1067
|
-
# "stop_id": 102067022299,
|
1068
|
-
# "market": "BTCUSDT",
|
1069
|
-
# "margin_market": "BTCUSDT",
|
1070
|
-
# "type": "limit",
|
1071
|
-
# "side": "buy",
|
1072
|
-
# "price": "20000.00",
|
1073
|
-
# "amount": "0.10000000",
|
1074
|
-
# "trigger_price": "20000.00",
|
1075
|
-
# "trigger_direction": "lower",
|
1076
|
-
# "taker_fee_rate": "0.0016",
|
1077
|
-
# "maker_fee_rate": "0.0016",
|
1078
|
-
# "status": "active_success",
|
1079
|
-
# "client_id": "",
|
1080
|
-
# "created_at": 1689152996689,
|
1081
|
-
# "updated_at": 1689152996689,
|
1082
|
-
# }
|
1083
|
-
#
|
1084
|
-
# swap
|
1085
|
-
#
|
1086
|
-
# {
|
1087
|
-
# "order_id": 98388656341,
|
1088
|
-
# "stop_id": 0,
|
1089
|
-
# "market": "BTCUSDT",
|
1090
|
-
# "side": "buy",
|
1091
|
-
# "type": "limit",
|
1092
|
-
# "amount": "0.0010",
|
1093
|
-
# "price": "50000.00",
|
1094
|
-
# "unfilled_amount": "0.0010",
|
1095
|
-
# "filled_amount": "0",
|
1096
|
-
# "filled_value": "0",
|
1097
|
-
# "fee": "0",
|
1098
|
-
# "fee_ccy": "USDT",
|
1099
|
-
# "taker_fee_rate": "0.00046",
|
1100
|
-
# "maker_fee_rate": "0.00000000000000000000",
|
1101
|
-
# "client_id": "",
|
1102
|
-
# "last_filled_amount": "0.0010",
|
1103
|
-
# "last_filled_price": "30721.35",
|
1104
|
-
# "created_at": 1689145715129,
|
1105
|
-
# "updated_at": 1689145715129
|
1106
|
-
# }
|
1107
|
-
#
|
1108
|
-
# swap stop
|
1109
|
-
#
|
1110
|
-
# {
|
1111
|
-
# "stop_id": 98389557871,
|
1112
|
-
# "market": "BTCUSDT",
|
1113
|
-
# "side": "sell",
|
1114
|
-
# "type": "limit",
|
1115
|
-
# "price": "20000.00",
|
1116
|
-
# "amount": "0.0100",
|
1117
|
-
# "trigger_price": "20000.00",
|
1118
|
-
# "trigger_direction": "higer",
|
1119
|
-
# "trigger_price_type": "index_price",
|
1120
|
-
# "taker_fee_rate": "0.00046",
|
1121
|
-
# "maker_fee_rate": "0.00026",
|
1122
|
-
# "client_id": "",
|
1123
|
-
# "created_at": 1689146382674,
|
1124
|
-
# "updated_at": 1689146382674
|
1125
|
-
# }
|
1126
|
-
#
|
1127
|
-
timestamp = self.safe_integer(order, 'created_at')
|
1128
|
-
marketId = self.safe_string(order, 'market')
|
1129
|
-
status = self.safe_string(order, 'status')
|
1130
|
-
isSpot = ('margin_market' in order)
|
1131
|
-
defaultType = 'spot' if isSpot else 'swap'
|
1132
|
-
market = self.safe_market(marketId, market, None, defaultType)
|
1133
|
-
fee = None
|
1134
|
-
feeCost = self.omit_zero(self.safe_string_2(order, 'fee', 'quote_ccy_fee'))
|
1135
|
-
if feeCost is not None:
|
1136
|
-
feeCurrencyId = self.safe_string(order, 'fee_ccy', market['quote'])
|
1137
|
-
fee = {
|
1138
|
-
'currency': self.safe_currency_code(feeCurrencyId),
|
1139
|
-
'cost': feeCost,
|
1140
|
-
}
|
1141
|
-
return self.safe_order({
|
1142
|
-
'info': order,
|
1143
|
-
'id': self.safe_string_2(order, 'order_id', 'stop_id'),
|
1144
|
-
'clientOrderId': self.safe_string(order, 'client_id'),
|
1145
|
-
'datetime': self.iso8601(timestamp),
|
1146
|
-
'timestamp': timestamp,
|
1147
|
-
'lastTradeTimestamp': self.safe_integer(order, 'updated_at'),
|
1148
|
-
'symbol': market['symbol'],
|
1149
|
-
'type': self.safe_string(order, 'type'),
|
1150
|
-
'timeInForce': None,
|
1151
|
-
'postOnly': None,
|
1152
|
-
'side': self.safe_string(order, 'side'),
|
1153
|
-
'price': self.safe_string(order, 'price'),
|
1154
|
-
'stopPrice': self.safe_string(order, 'trigger_price'),
|
1155
|
-
'triggerPrice': self.safe_string(order, 'trigger_price'),
|
1156
|
-
'amount': self.safe_string(order, 'amount'),
|
1157
|
-
'filled': self.safe_string_2(order, 'filled_amount', 'fill_value'),
|
1158
|
-
'remaining': self.safe_string_2(order, 'unfilled_amount', 'unfill_amount'),
|
1159
|
-
'cost': None,
|
1160
|
-
'average': None,
|
1161
|
-
'status': self.parse_ws_order_status(status),
|
1162
|
-
'fee': fee,
|
1163
|
-
'trades': None,
|
1164
|
-
}, market)
|
1165
|
-
|
1166
|
-
def parse_ws_order_status(self, status):
|
1167
|
-
statuses: dict = {
|
1168
|
-
'active_success': 'open',
|
1169
|
-
'active_fail': 'canceled',
|
1170
|
-
'cancel': 'canceled',
|
1171
|
-
}
|
1172
|
-
return self.safe_string(statuses, status, status)
|
1173
|
-
|
1174
|
-
async def watch_bids_asks(self, symbols: Strings = None, params={}) -> Tickers:
|
1175
|
-
"""
|
1176
|
-
watches best bid & ask for symbols
|
1177
|
-
|
1178
|
-
https://docs.coinex.com/api/v2/spot/market/ws/market-bbo
|
1179
|
-
https://docs.coinex.com/api/v2/futures/market/ws/market-bbo
|
1180
|
-
|
1181
|
-
:param str[] [symbols]: unified symbol of the market to fetch the ticker for
|
1182
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1183
|
-
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1184
|
-
"""
|
1185
|
-
await self.load_markets()
|
1186
|
-
marketIds = self.market_ids(symbols)
|
1187
|
-
messageHashes = []
|
1188
|
-
market = None
|
1189
|
-
symbolsDefined = (symbols is not None)
|
1190
|
-
if symbolsDefined:
|
1191
|
-
for i in range(0, len(symbols)):
|
1192
|
-
symbol = symbols[i]
|
1193
|
-
market = self.market(symbol)
|
1194
|
-
messageHashes.append('bidsasks:' + market['symbol'])
|
1195
|
-
else:
|
1196
|
-
messageHashes.append('bidsasks')
|
1197
|
-
type = None
|
1198
|
-
type, params = self.handle_market_type_and_params('watchBidsAsks', market, params)
|
1199
|
-
url = self.urls['api']['ws'][type]
|
1200
|
-
subscriptionHashes = ['all@bidsasks']
|
1201
|
-
subscribe: dict = {
|
1202
|
-
'method': 'bbo.subscribe',
|
1203
|
-
'params': {'market_list': marketIds},
|
1204
|
-
'id': self.request_id(),
|
1205
|
-
}
|
1206
|
-
result = await self.watch_multiple(url, messageHashes, self.deep_extend(subscribe, params), subscriptionHashes)
|
1207
|
-
if self.newUpdates:
|
1208
|
-
return result
|
1209
|
-
return self.filter_by_array(self.bidsasks, 'symbol', symbols)
|
1210
|
-
|
1211
|
-
def handle_bid_ask(self, client: Client, message):
|
1212
|
-
#
|
1213
|
-
# {
|
1214
|
-
# "method": "bbo.update",
|
1215
|
-
# "data": {
|
1216
|
-
# "market": "BTCUSDT",
|
1217
|
-
# "updated_at": 1656660154,
|
1218
|
-
# "best_bid_price": "20000",
|
1219
|
-
# "best_bid_size": "0.1",
|
1220
|
-
# "best_ask_price": "20001",
|
1221
|
-
# "best_ask_size": "0.15"
|
1222
|
-
# },
|
1223
|
-
# "id": null
|
1224
|
-
# }
|
1225
|
-
#
|
1226
|
-
data = self.safe_dict(message, 'data', {})
|
1227
|
-
parsedTicker = self.parse_ws_bid_ask(data)
|
1228
|
-
symbol = parsedTicker['symbol']
|
1229
|
-
self.bidsasks[symbol] = parsedTicker
|
1230
|
-
messageHash = 'bidsasks:' + symbol
|
1231
|
-
client.resolve(parsedTicker, messageHash)
|
1232
|
-
|
1233
|
-
def parse_ws_bid_ask(self, ticker, market=None):
|
1234
|
-
#
|
1235
|
-
# {
|
1236
|
-
# "market": "BTCUSDT",
|
1237
|
-
# "updated_at": 1656660154,
|
1238
|
-
# "best_bid_price": "20000",
|
1239
|
-
# "best_bid_size": "0.1",
|
1240
|
-
# "best_ask_price": "20001",
|
1241
|
-
# "best_ask_size": "0.15"
|
1242
|
-
# }
|
1243
|
-
#
|
1244
|
-
defaultType = self.safe_string(self.options, 'defaultType')
|
1245
|
-
marketId = self.safe_string(ticker, 'market')
|
1246
|
-
market = self.safe_market(marketId, market, None, defaultType)
|
1247
|
-
timestamp = self.safe_integer(ticker, 'updated_at')
|
1248
|
-
return self.safe_ticker({
|
1249
|
-
'symbol': self.safe_symbol(marketId, market, None, defaultType),
|
1250
|
-
'timestamp': timestamp,
|
1251
|
-
'datetime': self.iso8601(timestamp),
|
1252
|
-
'ask': self.safe_number(ticker, 'best_ask_price'),
|
1253
|
-
'askVolume': self.safe_number(ticker, 'best_ask_size'),
|
1254
|
-
'bid': self.safe_number(ticker, 'best_bid_price'),
|
1255
|
-
'bidVolume': self.safe_number(ticker, 'best_bid_size'),
|
1256
|
-
'info': ticker,
|
1257
|
-
}, market)
|
1258
|
-
|
1259
|
-
def handle_message(self, client: Client, message):
|
1260
|
-
method = self.safe_string(message, 'method')
|
1261
|
-
error = self.safe_string(message, 'message')
|
1262
|
-
if error is not None:
|
1263
|
-
self.handle_errors(None, None, client.url, method, None, self.json(error), message, None, None)
|
1264
|
-
handlers: dict = {
|
1265
|
-
'state.update': self.handle_ticker,
|
1266
|
-
'balance.update': self.handle_balance,
|
1267
|
-
'deals.update': self.handle_trades,
|
1268
|
-
'user_deals.update': self.handle_my_trades,
|
1269
|
-
'depth.update': self.handle_order_book,
|
1270
|
-
'order.update': self.handle_orders,
|
1271
|
-
'stop.update': self.handle_orders,
|
1272
|
-
'bbo.update': self.handle_bid_ask,
|
1273
|
-
}
|
1274
|
-
handler = self.safe_value(handlers, method)
|
1275
|
-
if handler is not None:
|
1276
|
-
handler(client, message)
|
1277
|
-
return
|
1278
|
-
self.handle_subscription_status(client, message)
|
1279
|
-
|
1280
|
-
def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
|
1281
|
-
if response is None:
|
1282
|
-
return None
|
1283
|
-
#
|
1284
|
-
# {"id": 1, "code": 20001, "message": "invalid argument"}
|
1285
|
-
# {"id": 2, "code": 21001, "message": "require auth"}
|
1286
|
-
# {"id": 1, "code": 21002, "message": "Signature Incorrect"}
|
1287
|
-
#
|
1288
|
-
message = self.safe_string_lower(response, 'message')
|
1289
|
-
isErrorMessage = (message is not None) and (message != 'ok')
|
1290
|
-
errorCode = self.safe_string(response, 'code')
|
1291
|
-
isErrorCode = (errorCode is not None) and (errorCode != '0')
|
1292
|
-
if isErrorCode or isErrorMessage:
|
1293
|
-
feedback = self.id + ' ' + body
|
1294
|
-
self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
|
1295
|
-
self.throw_broadly_matched_exception(self.exceptions['broad'], message, feedback)
|
1296
|
-
raise ExchangeError(feedback)
|
1297
|
-
return None
|
1298
|
-
|
1299
|
-
def handle_authentication_message(self, client: Client, message):
|
1300
|
-
#
|
1301
|
-
# success
|
1302
|
-
#
|
1303
|
-
# {
|
1304
|
-
# "id": 1,
|
1305
|
-
# "code": 0,
|
1306
|
-
# "message": "OK"
|
1307
|
-
# }
|
1308
|
-
#
|
1309
|
-
# fail
|
1310
|
-
#
|
1311
|
-
# {
|
1312
|
-
# "id": 1,
|
1313
|
-
# "code": 21002,
|
1314
|
-
# "message": ""
|
1315
|
-
# }
|
1316
|
-
#
|
1317
|
-
status = self.safe_string_lower(message, 'message')
|
1318
|
-
errorCode = self.safe_string(message, 'code')
|
1319
|
-
messageHash = 'authenticated'
|
1320
|
-
if (status == 'ok') or (errorCode == '0'):
|
1321
|
-
future = self.safe_value(client.futures, messageHash)
|
1322
|
-
future.resolve(True)
|
1323
|
-
else:
|
1324
|
-
error = AuthenticationError(self.json(message))
|
1325
|
-
client.reject(error, messageHash)
|
1326
|
-
if messageHash in client.subscriptions:
|
1327
|
-
del client.subscriptions[messageHash]
|
1328
|
-
|
1329
|
-
def handle_subscription_status(self, client: Client, message):
|
1330
|
-
id = self.safe_integer(message, 'id')
|
1331
|
-
subscription = self.safe_value(client.subscriptions, id)
|
1332
|
-
if subscription is not None:
|
1333
|
-
futureIndex = self.safe_string(subscription, 'future')
|
1334
|
-
future = self.safe_value(client.futures, futureIndex)
|
1335
|
-
if future is not None:
|
1336
|
-
future.resolve(True)
|
1337
|
-
del client.subscriptions[id]
|
1338
|
-
|
1339
|
-
async def authenticate(self, type: str):
|
1340
|
-
url = self.urls['api']['ws'][type]
|
1341
|
-
client = self.client(url)
|
1342
|
-
time = self.milliseconds()
|
1343
|
-
timestamp = str(time)
|
1344
|
-
messageHash = 'authenticated'
|
1345
|
-
future = client.future(messageHash)
|
1346
|
-
authenticated = self.safe_value(client.subscriptions, messageHash)
|
1347
|
-
if authenticated is not None:
|
1348
|
-
return await future
|
1349
|
-
requestId = self.request_id()
|
1350
|
-
subscribe: dict = {
|
1351
|
-
'id': requestId,
|
1352
|
-
'future': messageHash,
|
1353
|
-
}
|
1354
|
-
hmac = self.hmac(self.encode(timestamp), self.encode(self.secret), hashlib.sha256, 'hex')
|
1355
|
-
request: dict = {
|
1356
|
-
'id': requestId,
|
1357
|
-
'method': 'server.sign',
|
1358
|
-
'params': {
|
1359
|
-
'access_id': self.apiKey,
|
1360
|
-
'signed_str': hmac.lower(),
|
1361
|
-
'timestamp': time,
|
1362
|
-
},
|
1363
|
-
}
|
1364
|
-
self.watch(url, messageHash, request, requestId, subscribe)
|
1365
|
-
client.subscriptions[messageHash] = True
|
1366
|
-
return await future
|