# MOV-MMDK API
# 获得磁力交易对信息
# Request
print(api.get_exchange_info())
# Response
名称 | 类型 | 描述 |
---|---|---|
price_decimal | Int | 报价的精度(小数点后的位数) |
amount_decimal | Int | 数量的精度(小数点后的位数) |
base_asset | Object | 基础货币的对象 |
├── asset_id | String | 基础货币的ID |
├── decimals | Int | 精度(小数点后的位数) |
└── symbol | String | 基础货币的名称 |
quote_asset | Object | 基础货币的对象 |
├── asset_id | String | 基础货币的ID |
├── decimals | Int | 精度(小数点后的位数) |
└── symbol | String | 基础货币的名称 |
示例如下,部分结果省略
>>> print(api.get_exchange_info())
{
'code': 200,
'msg': '',
'data': [{
'price_decimal': 4,
'amount_decimal': 2,
'base_asset': {
'asset_id': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
'decimals': 8,
'symbol': 'BTM'
},
'quote_asset': {
'asset_id': '184e1cc4ee4845023888810a79eed7a42c02c544cf2c61ceac05e176d575bd46',
'decimals': 6,
'symbol': 'USDT'
}
},
…………
{
'price_decimal': 4,
'amount_decimal': 8,
'base_asset': {
'asset_id': '47fcd4d7c22d1d38931a6cd7767156babbd5f05bbbb3f7d3900635b56eb1b67e',
'decimals': 8,
'symbol': 'SUP'
},
'quote_asset': {
'asset_id': '184e1cc4ee4845023888810a79eed7a42c02c544cf2c61ceac05e176d575bd46',
'decimals': 6,
'symbol': 'USDT'
}
}]
}
# 获得磁力兑换深度
获取市场指定交易对的深度
# Request
print(api.get_depth(symbol, depth))
# Params
名称 | 必选 | 类型 | 描述 |
---|---|---|---|
symbol | 是 | String | 查询深度的交易对,比如BTM/USDT |
depth | 否 | Int | 查询的市场深度,默认是20 |
# Response
名称 | 类型 | 描述 |
---|---|---|
symbol | String | 交易对 |
fee_rate | String | 交易手续费费率 |
bids | Array | 指定深度的买单的价格和数量 |
asks | Array | 指定深度的卖单的价格和数量 |
timestamp | Int64 | 服务器时间戳 |
示例
>>> print(api.get_depth("BTC/USDT", 5))
{
'code': 200,
'msg': '',
'data': {
'symbol': 'BTC/USDT',
'fee_rate': '',
'asks': [
['17951.94', '0.0022'],
['17954.80', '0.2183'],
['17956.60', '0.0124'],
['17958.40', '0.0742'],
['17961.11', '0.1758']
],
'bids': [
['17908.50', '0.0317'],
['17903.69', '0.0428'],
['17901.90', '0.0184'],
['17900.11', '0.0166'],
['17898.32', '0.0011']
],
'timestamp': 1605754831534
}
}
# 发送磁力交易订单
调用SDK发送订单,send order封装了build和submit过程。
# Request
print(api.send_order(symbol, side, price, volume))
# Params
名称 | 必选 | 类型 | 描述 |
---|---|---|---|
symbol | 是 | String | 交易对,比如BTM/USDT |
side | 是 | String | 买或者卖,不填表示所有订单 |
price | 是 | String | 订单价格 |
volume | 是 | String | 交易数量 |
# Response
名称 | 类型 | 描述 |
---|---|---|
symbol | String | 交易对,比如BTC/USDT |
side | String | buy为买单,sell为卖单 |
order_id | Int | 订单ID |
open_price | String | 下单价格 |
deal_price | String | 下单价格 |
amount | String | 下单数量 |
filled_amount | String | 成交数量 |
fee_amount | String | 手续费数量 |
status | String | 表示订单状态 open:未成交 partial:部分成交 filled:完全成交 cancelled:已经取消 submitted:挂单但为上链 cancelling:取消但未上链 |
type | String | 订单类型 |
order_txs | Array | 订单包含的交易 |
├── hash | 订单哈希 | |
├── type | String | 订单类型 chain_tx:链式合并UTXO 交易 mov_matched_tx:磁力合约成交交易 mov_place_order:磁力合约挂单交易 mov_cancel_order:磁力合约取消挂单交易 mov_cancel_order:闪兑交易 |
└── timestamp | Int64 | 订单下到数据库的时间戳 |
order_timestamp | Int64 | 订单下单时间 |
update_timestamp | Int64 | 订单更新时间 |
示例
>>> print(api.send_order(symbol="BTM/USDT", side="sell", price=888, volume=1))
{
'code': 200,
'msg': '',
'data': {
'tx_hash': '1335845f53c7e0f72b709b659c1db69f60a42adcdb3dd2b0c7bbedc2be1d73f7',
'order': {
'symbol': 'BTM/USDT',
'side': 'sell',
'order_id': 6688061,
'open_price': '888.00000000000000000000',
'deal_price': '0',
'amount': '1.00',
'filled_amount': '0.00',
'fee_amount': '0.000000',
'status': 'submitted',
'type': 'mov',
'client_id': '',
'order_txs': [{
'hash': '1335845f53c7e0f72b709b659c1db69f60a42adcdb3dd2b0c7bbedc2be1d73f7',
'type': 'mov_place_order',
'timestamp': 1605755145
}],
'order_timestamp': 1605755145,
'update_timestamp': 1605755145
}
}
}
# 查询所有未成交的磁力订单
调用SDK查询所有未成交的磁力订单
# Request
print(api.query_open_orders(symbol))
# Params
名称 | 必选 | 类型 | 描述 |
---|---|---|---|
symbol | 是 | String | 查询的交易对,比如BTM/USDT |
# Response
名称 | 类型 | 描述 |
---|---|---|
symbol | String | 交易对,比如BTC/USDT |
side | String | buy为买单,sell为卖单 |
order_id | Int | 订单ID |
open_price | String | 下单价格 |
deal_price | String | 下单价格 |
amount | String | 下单数量 |
filled_amount | String | 成交数量 |
fee_amount | String | 手续费数量 |
status | String | 表示订单状态 open:未成交 partial:部分成交 filled:完全成交 cancelled:已经取消 submitted:挂单但为上链 cancelling:取消但未上链 |
type | String | 订单类型 |
order_txs | Array | 订单包含的交易 |
├── hash | 订单哈希 | |
├── type | String | 订单类型 chain_tx:链式合并UTXO 交易 mov_matched_tx:磁力合约成交交易 mov_place_order:磁力合约挂单交易 mov_cancel_order:磁力合约取消挂单交易 mov_cancel_order:闪兑交易 |
└── timestamp | Int64 | 订单下到数据库的时间戳 |
order_timestamp | Int64 | 订单下单时间 |
update_timestamp | Int64 | 订单更新时间 |
示例
>>> print(api.query_open_orders("BTM/USDT"))
{
'code': 200,
'msg': '',
'data': [{
'symbol': 'BTM/USDT',
'side': 'sell',
'order_id': 6688061,
'open_price': '888.0000000000',
'deal_price': '0.0000000000',
'amount': '1.00',
'filled_amount': '0.00',
'fee_amount': '0.000000',
'status': 'open',
'type': 'mov',
'client_id': '',
'order_txs': [{
'hash': '1335845f53c7e0f72b709b659c1db69f60a42adcdb3dd2b0c7bbedc2be1d73f7',
'type': 'mov_place_order',
'timestamp': 1605755145
}],
'order_timestamp': 1605755145,
'update_timestamp': 1605755146
}],
'pagination': {
'start': 0,
'limit': 1000,
'_links': {}
}
}
# 通过订单号查询磁力订单
调用SDK查询指定订单号的磁力订单
# Request
print(api.query_list_orders([order_id]))
Params
名称 | 必选 | 类型 | 描述 |
---|---|---|---|
order_id | 是 | Int | 订单号 |
# Response
名称 | 类型 | 描述 |
---|---|---|
symbol | String | 交易对,比如BTC/USDT |
side | String | buy为买单,sell为卖单 |
order_id | Int | 订单ID |
open_price | String | 下单价格 |
deal_price | String | 下单价格 |
amount | String | 下单数量 |
filled_amount | String | 成交数量 |
fee_amount | String | 手续费数量 |
status | String | 表示订单状态 open:未成交 partial:部分成交 filled:完全成交 cancelled:已经取消 submitted:挂单但为上链 cancelling:取消但未上链 |
type | String | 订单类型 |
order_txs | Array | 订单包含的交易 |
├── hash | 订单哈希 | |
├── type | String | 订单类型 chain_tx:链式合并UTXO 交易 mov_matched_tx:磁力合约成交交易 mov_place_order:磁力合约挂单交易 mov_cancel_order:磁力合约取消挂单交易 mov_cancel_order:闪兑交易 |
└── timestamp | Int64 | 订单下到数据库的时间戳 |
order_timestamp | Int64 | 订单下单时间 |
update_timestamp | Int64 | 订单更新时间 |
示例
>>> print(api.query_list_orders([6688061]))
{
'code': 200,
'msg': '',
'data': [{
'symbol': 'BTM/USDT',
'side': 'sell',
'order_id': 6688061,
'open_price': '888.0000000000',
'deal_price': '0.0000000000',
'amount': '1.00',
'filled_amount': '0.00',
'fee_amount': '0.000000',
'status': 'open',
'type': 'mov',
'client_id': '',
'order_txs': [{
'hash': '1335845f53c7e0f72b709b659c1db69f60a42adcdb3dd2b0c7bbedc2be1d73f7',
'type': 'mov_place_order',
'timestamp': 1605755145
}],
'order_timestamp': 1605755145,
'update_timestamp': 1605755146
}],
'pagination': {
'start': 0,
'limit': 1000,
'_links': {}
}
}
# 磁力撤单
通过sdk撤销指定订单号的订单
# Request
print(api.cancel_order(order_id))
Params
名称 | 必选 | 类型 | 描述 |
---|---|---|---|
order_id | 是 | Int | 订单号 |
# Response
名称 | 类型 | 描述 |
---|---|---|
tx_hash | String | 交易哈希 |
示例
>>> print(api.cancel_order(710924))
{
'code': 200,
'msg': '',
'data': {
'tx_hash': '2387e1ab0c462b212fb2252708a8792ad57c5b1ad5857cadf1cce200ce6ab5d3'
}
}
# 查询账户余额数据
# Request
print(api.get_balance())
# Response
名称 | 类型 | 描述 |
---|---|---|
address | String | 侧链地址 |
label | String | 请求的发送方 |
balances | Array | 余额数组 |
asset | Object | 资产对象 |
├── asset_id | String | 资产ID |
├── decimals | Int | 精度 |
├── symbol | String | 资产简称 |
├── name | String | 资产全称 |
└── type | String | 资产归属类型 |
balance | String | 总资产数量 |
available_balance | String | 可用资产数量 |
unconfirmed_balance | String | 未确认资产数量 |
total_received | String | 接收总计 |
total_sent | String | 发送总计 |
in_usd | String | 总量以usd计价 |
in_cny | String | 总量以cny计价 |
in_btc | String | 总量以btc计价 |
示例, 部分结果省略
>>> print(api.get_balance())
{
'code': 200,
'msg': '',
'data': {
'address': 'vp1quxu2u2m04stfc82v3ucgpr00vr0w8xuc2zqgu5',
'label': 'byone',
'balances': [{
'asset': {
'asset_id': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
'decimals': 0,
'symbol': 'BTM',
'name': 'Bytom',
'type': 'BTM'
},
'balance': '0.97555',
'available_balance': '0.97555',
'unconfirmed_balance': '0',
'total_received': '3.98355',
'total_sent': '3.008',
'in_usd': '0.06',
'in_cny': '0.37',
'in_btc': '0.000003'
},
……………………
{
'asset': {
'asset_id': '011a24f9da7551d4cd9ae0f194aa1d1691e22a173edf7d81aabd9a97ca386252',
'decimals': 0,
'symbol': 'LTC',
'name': 'Litecoin',
'type': 'LTC'
},
'balance': '0',
'available_balance': '0',
'unconfirmed_balance': '0',
'total_received': '0',
'total_sent': '0',
'in_usd': '0.00',
'in_cny': '0.00',
'in_btc': '0.000000'
}],
'votes': []
}
}
以上就是在磁力兑换中常使用的方法,包括了订单的发送、查询、撤销和对账户资产的查阅。本教程中的过程全部通过MOV-MMDK进行磁力交易,除了这种方式以外,用户也可用直接通过磁力兑换的RESTful API进行交易。