Demex Class - demex_client

Table of Contents

Description:

Demex Client for the Switcheo Tradehub decentralized exchange. This is the client that you should use to start trading with Demex. You will find the necessary trading functions to trade on the exchange that you would find in the UI. To get started you will need to use your mnemonic to access your wallet and define the network you want to use.

Usage:

from tradehub.demex_client import DemexClient

Classes:

DemexClient(mnemonic, network, trusted_ips, …)

This class allows the user to interact with the Demex API to manage and trade the users Tradehub account. Execution of this function is as follows::.

class tradehub.demex_client.DemexClient(mnemonic: str, network: str = 'testnet', trusted_ips: Optional[list] = None, trusted_uris: Optional[list] = None)[source]

Bases: object

This class allows the user to interact with the Demex API to manage and trade the users Tradehub account. Execution of this function is as follows:

DemexClient(mnemonic='lorem ipsum dolor consectetur adipiscing eiusmod tempor incididunt labore magna',
            network='mainnet',
            trusted_ips=None,
            trusted_uris=['http://175.41.151.35:5001', 'http://54.255.5.46:5001'])

Methods:

cancel_all_open_orders_for_pair(pair)

Function to place a cancel all open orders for a trading pair on Demex.

cancel_order(order_id)

Function to place a cancel order on Demex.

cancel_orders(order_ids)

Function to place a cancel orders on Demex.

edit_limit_order(order_id[, quantity, price])

Function to edit an open limit order on Demex.

edit_orders(orders)

edit_stop_order(order_id[, quantity, price, …])

Function to edit an open stop order on Demex.

get_open_limit_orders()

Function to get all open limit orders for the wallet attached to the Demex Client.

get_open_orders()

Function to get all open orders for the wallet attached to the Demex Client.

get_open_orders_by_pair(pair)

Function to get all open orders for a specific pair for the wallet attached to the Demex Client.

get_open_stop_orders()

Function to get all open stop orders for the wallet attached to the Demex Client.

limit_buy(pair, quantity, price)

Function to place a limit buy order on Demex.

limit_sell(pair, quantity, price)

Function to place a limit sell order on Demex.

market_buy(pair, quantity)

Function to place a market buy order on Demex.

market_sell(pair, quantity)

Function to place a market sell order on Demex.

stop_limit_buy(pair, price, quantity, stop_price)

Function to place a stop limit buy order on Demex.

stop_limit_sell(pair, price, quantity, …)

Function to place a stop limit sell order on Demex.

stop_market_buy(pair, quantity, stop_price)

Function to place a stop market buy order on Demex.

stop_market_sell(pair, quantity, stop_price)

Function to place a stop market sell order on Demex.

cancel_all_open_orders_for_pair(pair: str)[source]

Function to place a cancel all open orders for a trading pair on Demex.

Execution of this function is as follows:

cancel_all_open_orders_for_pair(pair='swth_eth1')

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the cancel all orders for pair details.

cancel_order(order_id: str)[source]

Function to place a cancel order on Demex.

Execution of this function is as follows:

cancel_order(order_id='86BE018C4691E1495DA439647A2246ADFB6101D6292A0C9D365AD88E4A6285B6')

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the cancel order details.

cancel_orders(order_ids: list)[source]

Function to place a cancel orders on Demex.

Execution of this function is as follows:

cancel_order(order_ids=['86BE018C4691E1495DA439647A2246ADFB6101D6292A0C9D365AD88E4A6285B6'])

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the cancel orders details.

edit_limit_order(order_id: str, quantity: Optional[str] = None, price: Optional[str] = None)[source]

Function to edit an open limit order on Demex.

Execution of this function is as follows:

edit_limit_order(order_id='86BE018C4691E1495DA439647A2246ADFB6101D6292A0C9D365AD88E4A6285B6',
                 quantity='10000',
                 price='0.00011')

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the edit limit order details.

edit_orders(orders: [<class 'tradehub.types.EditOrderMessage'>])[source]
edit_stop_order(order_id: str, quantity: Optional[str] = None, price: Optional[str] = None, stop_price: Optional[str] = None)[source]

Function to edit an open stop order on Demex.

Execution of this function is as follows:

edit_stop_order(order_id='86BE018C4691E1495DA439647A2246ADFB6101D6292A0C9D365AD88E4A6285B6',
                quantity='10000',
                price='0.00011')

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the edit stop order details.

get_open_limit_orders()[source]

Function to get all open limit orders for the wallet attached to the Demex Client.

Execution of this function is as follows:

get_open_limit_orders()

The expected return result for this function is as follows:

[
    '86BE018C4691E1495DA439647A2246ADFB6101D6292A0C9D365AD88E4A6285B6',
    ...
]
Returns

List of order IDs.

get_open_orders()[source]

Function to get all open orders for the wallet attached to the Demex Client.

Execution of this function is as follows:

get_open_orders()

The expected return result for this function is as follows:

[
    '86BE018C4691E1495DA439647A2246ADFB6101D6292A0C9D365AD88E4A6285B6',
    ...
]
Returns

List of order IDs.

get_open_orders_by_pair(pair: str)[source]

Function to get all open orders for a specific pair for the wallet attached to the Demex Client.

Execution of this function is as follows:

get_open_orders(pair='swth_eth1')

The expected return result for this function is as follows:

[
    '86BE018C4691E1495DA439647A2246ADFB6101D6292A0C9D365AD88E4A6285B6',
    ...
]
Returns

List of order IDs.

get_open_stop_orders()[source]

Function to get all open stop orders for the wallet attached to the Demex Client.

Execution of this function is as follows:

get_open_stop_orders()

The expected return result for this function is as follows:

[
    '86BE018C4691E1495DA439647A2246ADFB6101D6292A0C9D365AD88E4A6285B6',
    ...
]
Returns

List of order IDs.

limit_buy(pair: str, quantity: str, price: str)[source]

Function to place a limit buy order on Demex.

Execution of this function is as follows:

limit_buy(pair='swth_eth1', quantity=1000, price='0.0001')

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the limit order details.

limit_sell(pair: str, quantity: str, price: str)[source]

Function to place a limit sell order on Demex.

Execution of this function is as follows:

limit_sell(pair='swth_eth1', quantity=1000, price='0.0002')

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the limit order details.

market_buy(pair: str, quantity: str)[source]

Function to place a market buy order on Demex.

Execution of this function is as follows:

market_buy(pair='swth_eth1', quantity=1000)

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the market order details.

market_sell(pair: str, quantity: str)[source]

Function to place a market sell order on Demex.

Execution of this function is as follows:

market_sell(pair='swth_eth1', quantity=1000)

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the market order details.

stop_limit_buy(pair: str, price: str, quantity: str, stop_price: str)[source]

Function to place a stop limit buy order on Demex.

Execution of this function is as follows:

stop_limit_buy(pair='swth_eth1', quantity=1000, price='0.0001', stop_price='0.00015')

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the stop limit order details.

stop_limit_sell(pair: str, price: str, quantity: str, stop_price: str)[source]

Function to place a stop limit sell order on Demex.

Execution of this function is as follows:

stop_limit_sell(pair='swth_eth1', quantity=1000, price='0.0002', stop_price='0.00015')

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the stop limit order details.

stop_market_buy(pair: str, quantity: str, stop_price: str)[source]

Function to place a stop market buy order on Demex.

Execution of this function is as follows:

stop_market_buy(pair='swth_eth1', quantity=1000, stop_price='0.00015')

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the stop market order details.

stop_market_sell(pair: str, quantity: str, stop_price: str)[source]

Function to place a stop market sell order on Demex.

Execution of this function is as follows:

stop_market_sell(pair='swth_eth1', quantity=1000, stop_price='0.00015')

The expected return result for this function is as follows:

{
    'height': str,
    'txhash': str,
    `'raw_log': str,
    'logs': [{
        'msg_index': int,
        'log': str,
        'events': [{
            'type': str,
            'attributes': [{
                'key': str,
                'value': str
            }, {
                'key': str,
                'value': str
            }]
        }]
    }],
    'gas_wanted': str,
    'gas_used': str
}
Returns

Dictionary in the form of a JSON message with the stop market order details.