Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
BitgetLimited
GitHub Repository: BitgetLimited/V3-bitget-api-sdk
Path: blob/master/bitget-python-sdk-api/bitget/__pycache__/swap_api.cpython-38.pyc
732 views
U

�J_�+�@s(ddlmZddlTGdd�de�ZdS)�)�Client)�*c@sVeZdZdQdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�ZdRdd�Z	dSdd�Z
dd�ZdTdd�ZdUdd�Z
dVdd�ZdWdd�ZdXdd�Zd d!�Zd"d#�Zd$d%�ZdYd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�ZdZd8d9�Zd:d;�Zd[d<d=�Zd>d?�Z d\d@dA�Z!dBdC�Z"dDdE�Z#dFdG�Z$dHdI�Z%d]dJdK�Z&dLdM�Z'dNdO�Z(dPS)^�SwapAPIFcCst�||||||�dS�N)r�__init__)�self�api_key�api_secret_key�
passphrase�use_server_time�first�r
�Q/Users/larry/PycharmProjects/V3-Open-API-SDK/okex-python-sdk-api/okex/swap_api.pyrszSwapAPI.__init__cCs|�tt�Sr)�_request_without_params�GET�SWAP_POSITIONS�rr
r
r�get_position
szSwapAPI.get_positioncCs|�ttt|�d�S)Nz	/position)rr�
SWAP_POSITION�str�r�
instrument_idr
r
r�get_specific_position
szSwapAPI.get_specific_positioncCs|�ttt|�d�S�Nz	/accounts)rr�SWAP_ACCOUNTrrr
r
r�get_coin_accountszSwapAPI.get_coin_accountcCs|�ttdj|d��S)Nz/settings?symbol={symbol}��symbol�rr�API_SWAP_V3_ACCOUNT�format�rrr
r
r�get_settingsszSwapAPI.get_settingscCs:|r6t|t�r6t|t�r6|||d�}|�ttd|�SdS)N)r�leverage�sidez	/leverage)�
isinstance�int�_request_with_params�POSTr)rrr#r$�paramsr
r
r�set_leverageszSwapAPI.set_leverage�cCsVi}|r||d<|r||d<|r(||d<|r4||d<|jttdt|�d|dd�S)	N�after�before�limit�type�/z/ledgerT��cursor)r'r�
SWAP_ACCOUNTSr)rrr,r-r.r/r)r
r
r�
get_ledger szSwapAPI.get_ledger�0c	Cs@||||d�}|r||d<|r&||d<|r2||d<|�tt|�S)N)rr/�size�price�
client_oid�
order_type�match_price)r'r(�
SWAP_ORDER)	rrr/r7r6r8r9r:r)r
r
r�
take_order,szSwapAPI.take_ordercCs||d�}|�tt|�S)N)r�
order_data)r'r(�SWAP_ORDERS)rrr=r)r
r
r�take_orders6s
zSwapAPI.take_orderscCsL|r$|�ttt|�dt|��S|rH|�ttt|�dt|��SdS�Nr0)rr(�SWAP_CANCEL_ORDERr�rr�order_idr8r
r
r�revoke_order:s zSwapAPI.revoke_ordercCs4i}|rd|i}n|rd|i}|�ttt|�|�S)N�ids�client_oids)r'r(�SWAP_CANCEL_ORDERSr)rrrErFr)r
r
r�
revoke_orders@s
zSwapAPI.revoke_orderscCsJd|i}|r||d<|r ||d<|r,||d<|jttdt|�|dd�S)N�stater,r-r.r0Tr1)r'rr>r)rrrIr,r-r.r)r
r
r�get_order_listHszSwapAPI.get_order_listcCsT|r(|�ttdt|�dt|��S|rP|�ttdt|�dt|��SdSr@)rrr>rrBr
r
r�get_order_infoRs$zSwapAPI.get_order_infocCsJd|i}|r||d<|r ||d<|r,||d<|r8||d<|jtt|dd�S)NrrCr,r-r.Tr1)r'r�
SWAP_FILLS)rrrCr,r-r.r)r
r
r�	get_fillsXszSwapAPI.get_fillscCs||d�}|�tt|�S�N)r�	direction)r'r(�SWAP_CLOSE_POSITION�rrrOr)r
r
r�close_positionds
zSwapAPI.close_positioncCs||d�}|�tt|�SrN)r'r(�SWAP_CANCEL_ALLrQr
r
r�
cancel_allhs
zSwapAPI.cancel_allcCs|�tt�Sr)rr�SWAP_INSTRUMENTSrr
r
r�get_instrumentslszSwapAPI.get_instrumentscCs6i}|r.|r.||d<||d<|�ttd|�SdSdS)Nrr.z/depthz
args error�r'r�API_SWAP_V3_ROOT)rrr.�depthr)r
r
r�	get_depthpszSwapAPI.get_depthcCs|�tt�Sr)rr�SWAP_TICKETSrr
r
r�
get_tickeryszSwapAPI.get_tickercCs&i}|r||d<|�tt|�SdSdS)Nr�pls check args)r'r�SWAP_SOMEONE_TICKER)rrr)r
r
r�get_specific_ticker}s
zSwapAPI.get_specific_tickercCs:i}|r2|r2||d<||d<|jttd|dd�SdSdS)Nrr.z/tradesTr1r]rW)rrr.r)r
r
r�
get_trades�szSwapAPI.get_tradescCsNi}|rF|rF|rF|rF||d<||d<||d<||d<|�ttd|�SdSdS)Nr�start�end�granularityz/candlesr]rW)rrrarbrcr)r
r
r�	get_kline�szSwapAPI.get_klinecCs |r|�ttdj|d��SdS)Nz/index?symbol={symbol}r�rrrXr r!r
r
r�	get_index�szSwapAPI.get_indexcCs|�tt�Sr)rr�	SWAP_RATErr
r
r�get_rate�szSwapAPI.get_ratecCs|�ttdj|d��S)Nz/open_interest?symbol={symbol}rrer!r
r
r�	get_holds�szSwapAPI.get_holdscCs|�ttdj|d��S)Nz/price_limit?symbol={symbol}rrer!r
r
r�	get_limit�szSwapAPI.get_limitcCsJd|i}|r||d<|r ||d<|r,||d<|�ttdt|�d|�S)N�status�from�tor.r0z/liquidation)r'rrUr)rrrk�fromsrmr.r)r
r
r�get_liquidation�szSwapAPI.get_liquidationcCs|�ttdt|�d�S)Nr0z/holds)rrr3rrr
r
r�get_holds_amount�szSwapAPI.get_holds_amountcCs�||||d�}|dkr4||d<||d<|r�||d<nl|dkrN||d<||d<nR|dkrp|	|d	<|
|d
<||d<n0|dkr�||d
<|
|d<||d<||d<||d<|�tt|�S)N)rr/r9r6�1�
trigger_price�
algo_price�	algo_type�2�
callback_rate�3�
algo_variance�
avg_amount�price_limit�4�sweep_range�sweep_ratio�single_limit�
time_interval)r'r(�SWAP_ORDER_ALGO)rrr/r9r6rrrsrtrvrxryrzr|r}r~rr)r
r
r�take_order_algo�s(


zSwapAPI.take_order_algocCs|||d�}|�tt|�S)N)r�algo_idsr9)r'r(�SWAP_CANCEL_ALGOS)rrr�r9r)r
r
r�cancel_algos�szSwapAPI.cancel_algosc	Cs\d|i}|r||d<n|r"||d<|r.||d<|r:||d<|rF||d<|�ttt|�|�S)Nr9rk�algo_idr-r,r.)r'r�SWAP_GET_ORDER_ALGOSr)	rrr9rkr�r-r,r.r)r
r
r�get_order_algos�s
zSwapAPI.get_order_algoscCs|�tt�Sr)rr�SWAP_GET_TRADE_FEErr
r
r�
get_trade_fee�szSwapAPI.get_trade_feecCs|�ttdj|d��S)Nz/funding_time?symbol={symbol}rrer!r
r
r�get_funding_time�szSwapAPI.get_funding_timecCs|�ttdj|d��S)Nz/mark_price?symbol={symbol}rrer!r
r
r�get_mark_price�szSwapAPI.get_mark_pricecCsNi}|rF|rF|rF|rF||d<||d<||d<||d<|�ttd|�SdSdS)Nrrlrmr.z/historical_funding_rater]rW)rrZ	from_pageZto_pager.r)r
r
r�get_historical_funding_rate�sz#SwapAPI.get_historical_funding_ratecCsRi}|rJ|rJ|rJ|rJ||d<||d<||d<|r8||d<|�ttd|�SdSdS)Nr�amount�	openPricer#z/open_countr]rW)rrr�r�r#r)r
r
r�get_open_countszSwapAPI.get_open_countcCs|�ttd�Sr)rrrrr
r
r�get_accountsszSwapAPI.get_accountscCs|�ttdj|d��S)Nz/account?symbol={symbol}rrr!r
r
r�get_accountszSwapAPI.get_accountN)FF)r+r+r+r+)r+r5r+)r+r+)r+r+)r+r+r+)r+r+)r+r+r+r+)r+)r+r+r+)r+r+r+r+r+r+r+r+r+r+r+)r+r+r+r+r+)r+))�__name__�
__module__�__qualname__rrrrr"r*r4r<r?rDrHrJrKrMrRrTrVrZr\r_r`rdrfrhrirjrorpr�r�r�r�r�r�r�r�r�r�r
r
r
rrs^










		



�


rN)�clientr�constsrr
r
r
r�<module>s