Skip to content

mufex

Classes

Mufex

Bases: Exchange

Functions

__init__
__init__(use_testnet, api_key=None, secret_key=None)

main docs page https://www.mufex.finance/apidocs/derivatives/contract/index.html

Make sure you have your position mode set to hedge or else a lot of functions will not work. https://www.mufex.finance/apidocs/derivatives/contract/index.html?console#t-dv_switchpositionmode

adjust_order
adjust_order(params={})

you basically have to use the same info that you would for create order https://www.mufex.finance/apidocs/derivatives/contract/index.html#t-dv_placeorder

cancel_all_open_orders_per_symbol
cancel_all_open_orders_per_symbol(symbol)

no link yet

cancel_open_order
cancel_open_order(symbol, order_id=None, custom_order_id=None)
close_hedge_positions_and_orders
close_hedge_positions_and_orders(symbol=None, settleCoin=None)

Parameters:

Name Type Description Default
symbol str
None
create_order
create_order(symbol, buy_sell, position_mode, order_type, asset_size, time_in_force='GoodTillCancel', price=None, triggerDirection=None, triggerPrice=None, triggerBy=None, tpTriggerBy=None, slTriggerBy=None, custom_order_id=None, takeProfit=None, stopLoss=None, reduce_only=None, closeOnTrigger=None)

time_in_force: GoodTillCancel ImmediateOrCancel FillOrKill PostOnly

position_mode: used to identify positions in different position modes. Required if you are under Hedge Mode: 0-One-Way Mode 1-Buy side of both side mode 2-Sell side of both side mode

get_all_symbols_info
get_all_symbols_info(category='linear', limit=1000, symbol=None)

Mufex API link to Get Instrument Info

Parameters:

Name Type Description Default
category str

If category is not passed, then return ""For now, default:linear

'linear'
limit int

Limit for data size per page, max size is 1000. Default as showing 500 pieces of data per page.It's not sorted by time

1000
symbol str

Symbol

None

Returns:

Type Description
_type_

description

get_candles
get_candles(symbol, timeframe, since_datetime=None, until_datetime=None, candles_to_dl=1500, category='linear')

mufex candle docs

Parameters:

Name Type Description Default
symbol str required
timeframe str

"1m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "d", "w"

required
since_datetime datetime

The start date, in datetime format, of candles you want to download. EX: datetime(year, month, day, hour, minute)

None
until_datetime datetime

The until date, in datetime format, of candles you want to download minus one candle so if you are on the 5 min if you say your until date is 1200 your last candle will be 1155. EX: datetime(year, month, day, hour, minute)

None
candles_to_dl int

The amount of candles you want to download

1500
category str 'linear'

Returns:

Type Description
array

a 2 dim array with the following columns "timestamp", "open", "high", "low", "close", "volume"

get_closed_pnl
get_closed_pnl(symbol, limit=200, since_datetime=None, until_datetime=None)
get_filled_orders
get_filled_orders(symbol, limit=200, since_datetime=None, until_datetime=None, execType=None, order_id=None)

Get user's trading records. The results are ordered in descending order (the first item is the latest). Returns records up to 2 years old.

use link to see all Request Parameters

get_open_orders
get_open_orders(symbol, limit=50, order_id=None, custom_order_id=None, orderFilter=None)

Query real-time order information. If only orderId or orderLinkId are passed, a single order will be returned; otherwise, returns up to 500 unfilled orders

orderId limit

get_order_history
get_order_history(symbol, limit=50, order_id=None, custom_order_id=None, orderStatus=None, orderFilter=None)

use link to see all Request Parameters

get_position_info
get_position_info(symbol=None, settleCoin=None, limit=50)
get_risk_limit_info
get_risk_limit_info(symbol, category='linear')

Mufex API link to Get Risk Limit

Parameters:

Name Type Description Default
symbol str

Symbol

required
category str

If category is not passed, then return ""For now, default:linear

'linear'

Returns:

Type Description
_type_

description

get_symbol_trading_fee_rates
get_symbol_trading_fee_rates(symbol=None)
get_symbols_list
get_symbols_list()

Returns a list of the symbols in alphabetical order

Parameters:

Name Type Description Default
None
required

Returns:

Type Description
list

symbols

get_trading_fee_rates
get_trading_fee_rates(symbol=None)
get_wallet_info
get_wallet_info(trading_with=None)
set_leverage
set_leverage(symbol, leverage)

No link yet

set_leverage_mode
set_leverage_mode(symbol, leverage_mode, leverage=5)

Cross/isolated mode. 0: cross margin mode; 1: isolated margin mode

set_position_mode
set_position_mode(position_mode, trading_with=None, symbol=None)