
    i                       d dl mZ d dlmZ d dlZd dlZd dlZd dlmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlm Z  d dlm!Z! d d	lm"Z" d d
lm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dlm)Z) d dlm*Z* d dlm+Z+ d dlm,Z, d dlm-Z- d dlm.Z. d dlm/Z/ d dl0m1Z1 d dl2m3Z3  G d dee          Z4dS )    )Exchange)ImplicitAPIN)Balances
CurrenciesCurrencyIntMarginModificationMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeeInterfaceTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)BadResponse)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)NotSupported)NetworkError)DDoSProtection)RateLimitExceeded)InvalidNonce)	TICK_SIZE)Precisec                       e Zd Z fdZi fdefdZi fdee         fdZi fdZ	i fdZ
defdZi fdefdZd	i fd
ededefdZd	i fdedefdZi fd
edefdZdbdedefdZdbdedefdZi fdZi fdZd	d	i fd
edededee         fdZdbdedefdZdd	d	i fd
edededee         fdZd	i fd
ede de!de"de#f
dZ$i fdee%         fd Z&d	i fd
ede de!de"de#f
d!Z'i fd
ed"e"fd#Z(d	i fd$ed
e)fd%Z*d	i fd
e)fd&Z+d' Z,dbdede-fd(Z.d	d	d	i fd
e)dededee-         fd)Z/d	d	d	i fd
e)dededee-         fd*Z0d	i fd$ed
e)fd+Z1d	d	d	i fd
e)dedefd,Z2d- Z3dbd.e4fd/Z5d	d	d	i fd0e)dedefd1Z6dbd.e4fd2Z7i fd0efd3Z8d	d	d	i fd0e)dedefd4Z9d	d	d	i fd0e)dededee:         fd5Z;d	d	d	i fd0e)dededee:         fd6Z<d7 Z=dbd.e4de:fd8Z>d9 Z?dbd.e4fd:Z@i fd0ede"d;ed<edeAf
d=ZBd	i fd0ede"fd>ZCd	d	d	d	i fd0e)d
e)dedefd?ZDdbdefd@ZEi fd0efdAZFi fdBZGdbd.e4fdCZHdD ZIi fd
efdEZJdbdefdFZKd	d	d	i fd
e)dedefdGZLi fd
edeMfdHZNdbdedeMfdIZOd	i fdefdJZPi fd
efdKZQdbdefdLZRd	i fdMed
e)fdNZSd	d	d	i fd0e)dedefdOZTd	i fdefdPZUi fd
efdQZVdbdefdRZWi d	f fdS	ZXd	i fdTefdUZYdcdVZZi fd
ede[fdWZ\i fd
ede[fdXZ]i fd
ede[fdYZ^dbdede[fdZZ_d	d	d	i fd
e)dedefd[Z`dbdefd\Zad	i fd]ed
e)fd^Zbg d_i d	d	fd`Zcda Zd xZeS )d	digifinexc                    |                      t          t          |                                           dddgddi dd ddd	dd
dddddddddddddddddddddddddddi ddddddddddddddd dd!dd"dd#dd$d%d&dd'dd(dd)dd*di d+dd,dd-dd.dd/dd0dd1dd2dd3dd4dd5dd6dd7dd8dd9dd:dd;di d<dd=dd>dd?dd@ddAddBddCddDddEddFddGddHddIddJddKddLdddddMdNdOdPdQdRdSdTdUdVdW	dXdYdZid[d\gd]d^d_d`g daid`g dbidcg ddg dedfg dgg dhdfdcdidjdd|                     dk          |                     dk          dlit
          i dmt          dngdot          dpgdqt          drgdst          dtgdut          dvgdwt          dxgdyt          dzgd{t          d|gd}t          d~gdt          dgdt          dgdt          dgdt          dgdt          dgdt          dgdt          dgdt          dgi dt          dgdt          dgdt          dgdt          dgdt          dgdt          dgdt          dgdt          dgdt           dgdt          dgdt          dgdt          dgdt          dgdt          dgdt          dgdt          dgdt          dgt          dgt          dgt          dgt          dgt          dgt          dgt           dgt"          dgt"          dgt           dgt$          dgt          dgt          dgt          dgdi ddg dddNdddĜi ddƓddȓddʓdd˓dd˓ddΓddГddғddӓddՓddՓddؓddٓddٓddۓddݓddߓi ddddddddddddddddddddddddddddddddddddd ddd          S (  Nr.   	DigiFinexSGv3i  CORSspotTmarginswapfutureFoption	addMargincancelOrdercancelOrderscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrderscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLedgerfetchLeveragefetchLeverageTiersfetchMarginModefetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransfersfetchWithdrawalsreduceMarginsetLeverage	setMarginsetMarginMode)setPositionModetransferwithdraw151530602407201D1W)	1m5m15m30m1h4h12h1d1wzdhttps://user-images.githubusercontent.com/51840849/87443315-01283a00-c5fe-11ea-8628-c2a0feaf07ac.jpgrestzhttps://openapi.digifinex.comzhttps://www.digifinex.comzhttps://docs.digifinex.comzWhttps://digifinex.zendesk.com/hc/en-us/articles/360000328422-Fee-Structure-on-DigiFinexz>https://www.digifinex.com/en-ww/from/DhOzBg?channelCode=ljaUPp)logoapiwwwdocfeesreferralget)z{market}/symbolsklinezmargin/currencieszmargin/symbolsmarkets
order_bookpingzspot/symbolstimetradesztrades/symbolsticker
currencies)zpublic/api_weightzpublic/candleszpublic/candles_historyzpublic/depthzpublic/funding_ratezpublic/funding_rate_historyzpublic/instrumentzpublic/instrumentszpublic/tickerzpublic/tickerszpublic/timezpublic/trades)r4   r6   )z{market}/financelogz{market}/mytradesz{market}/orderz{market}/order/detailz{market}/order/currentz{market}/order/historyzmargin/assetszmargin/financelogzmargin/mytradeszmargin/orderzmargin/order/currentzmargin/order/historyzmargin/positionszotc/financelogzspot/assetszspot/financelogzspot/mytradesz
spot/orderzspot/order/currentzspot/order/historyzdeposit/addresszdeposit/historyzwithdraw/history)z{market}/order/cancelz{market}/order/newz{market}/order/batch_newzmargin/order/cancelzmargin/order/newzmargin/position/closezspot/order/cancelzspot/order/newry   zwithdraw/newzwithdraw/cancel)r   post)
zaccount/balancezaccount/positionszaccount/finance_recordzaccount/trading_fee_ratezaccount/transfer_recordzaccount/funding_feeztrade/history_ordersztrade/history_tradesztrade/open_ordersztrade/order_info)zaccount/leveragezaccount/position_modezaccount/position_marginztrade/batch_cancel_orderztrade/batch_orderztrade/cancel_orderztrade/order_placezfollow/sponsor_orderzfollow/close_orderzfollow/cancel_orderzfollow/user_center_currentzfollow/user_center_historyz follow/expert_current_open_orderzfollow/add_algozfollow/cancel_algozfollow/account_availablezfollow/plan_taskzfollow/instrument_list)publicprivatetradingz0.002)	tierBased
percentagemakertaker10001z=Wrong request method, please check it's a GET ot POST request10002zInvalid ApiKey10003zSign doesn't match10004zIllegal request parameters10005z#Request frequency exceeds the limit10006z$Unauthorized to execute self request10007zIP address Unauthorized10008zETimestamp for self request is invalid, timestamp must within 1 minute10009z+Unexist endpoint, please check endpoint URL10011z?ApiKey expired. Please go to client side to re-create an ApiKey20001z'Trade is not open for self trading pair20002z'Trade of self trading pair is suspended20003zInvalid price or amount20007zPrice precision error20008zAmount precision error20009z+Amount is less than the minimum requirement20010z0Cash Amount is less than the minimum requirement20011zInsufficient balance20012z*Invalid trade type, valid value: buy/sell)20013zNo order info found20014z'Invalid date, Valid format: 2018-07-25)20015zDate exceeds the limit20018z2Your trading rights have been banned by the system20019zQWrong trading pair symbol. Correct format:"usdt_btc". Quote asset is in the front20020zYou have violated the API operation trading rules and temporarily forbid trading. At present, we have certain restrictions on the user's transaction rate and withdrawal rate.50000zException error20021zInvalid currency20022z?The ending timestamp must be larger than the starting timestamp20023zInvalid transfer type20024zInvalid amount20025z/This currency is not transferable at the moment20026z#Transfer amount exceed your balance20027zAbnormal account status20028zBlacklist for transferz'Transfer amount exceed your daily limitz)You have no position on self trading pairzWithdrawal limitedzWrong Withdrawal IDz1Withdrawal service of self crypto has been closedzWithdrawal limitzWithdrawal cancellation failedz[The withdrawal address, Tag or chain type is not included in the withdrawal management listz/The withdrawal address is not on the white listz#Can't be canceled in current statuszFWithdraw too frequently; limitation: 3 times a minute, 100 times a dayz!Beyond the daily withdrawal limitz1Current trading pair does not support API tradingzInvalid Parameter)20029200302003220033200342003520036200372003820039200402004120042400002)exactbroad)r4   r5   otc23)r4   r5   OTCARBITRUMArbitrum	AVALANCECzAVAX-CCHAIN	AVALANCEXzAVAX-XCHAINBEP20BSCCARDANOCardanoCELOCeloCHILIZChilizCOSMOSCRC20z
Crypto.comCRONOSDOGECOIN	DogeChainERC20ETHETHWIOTAMIOTAKLAYTNKLAYMATICPolygonMETISMetisDAOMOONBEAMGLMR	MOONRIVER	MoonriverOPTIMISMOPETHPOLYGONRIPPLEXRPSOLANASOLSTELLARStellaTERRACLASSICTerraClassicTERRATerraTONTonTRC20TRONTRXVECHAINVechain)defaultTypetypes!createMarketBuyOrderRequiresPriceaccountsByTypenetworkszBlack House TestEpanusFreeRossDAOzMobilian CoinTEL666)BHTEPSFREEMBNTEL)idname	countriesversion	rateLimithas
timeframesurlsr   r   precisionMode
exceptionsoptionscommonCurrencies)deep_extendsuperr.   describeparse_numberr+   r   r   r(   r   r*   r'   r   r$   r"   r    r   r#   r)   )self	__class__s    b/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/digifinex.pyr*  zdigifinex.describe$   s
   i 6 6 ? ? A AHHH $H 	H
 %H %H TH tH H /H ,UH 0H tH H &tH  (!H" '#H H$ (%H& "5'H( )H* &t+H, +E-H. )%/H0 '1H2 (3H4 "45H6 &t7H8  9H: *:;H< +D=H> &t?H@ #DAHB *4CHD $UEH H HF "5GHH *5IHJ +EKHL tMHN  OHP %dQHR "5SHT +DUHV WHX !%YHZ  [H\ d]H^ "4_H` daHb !$cHd teHf  gH H Hh $UiHj !$kHl %emHn )%oHp tqHr tsHt uHv TwHx tyHz "4{H| #E}H~ !$H@ #DAHB CHD tEHF UGHH  IH HJ $)  OH H HT 
 
 ; 30 r\        $       %" "J     2! ! !5' 'R     ! ! !! !SK KIp pd !%"&!..w77!..w77	  '1j*ij113CD1 13GH1 j*FG	1
 n.ST1 .0VW1 .0IJ1 l,st1 l,YZ1 .0qr1 .0YZ1 .0YZ1 l,EF1 l,CD1 l,DE1  l,YZ!1" l,^_#1 1$ /1GH%1& j*VW'1( l,AB)1* j*ST+1, j*BC-1. .0de/10 i)|}112 n  /_  `314 m->?516 j*<=718 j*kl91: j*AB;1< j*:;=1> j*[\?1@ /1VWA1B .0IJC1D .0HIE1 1F /0YZ(*UV.0DE(*?@.0cd.0BC+-MN,  /L  M,._`+-RS/1yz.0ST')\])+>?a1 1 1dg5 5n  &22259!# #
"
""  " W	"
 7" y" F" h" h" \" l" " W" 7" F"  G!"" f#" "$ Y%"& Z'"( )"*  +", -". y/"0 e1"2 e3"4 x5"6 #N7"8 W9": 5;"< W="> G?"@ 7A"B yC" ", ,\ *%&! !G
JD
 JD
 J J J	    returnc                 L  K   |                      |           d{V }|                     |dg           }i }t          dt          |                    D ]N}||         }|                     |d          }|                     |          }|                     |dd          }	|                     |dd          }
|	dk    }|
dk    }|o|}|                     |d          }|                     |d	          }|                     |d
          }|                     |          }|                     |          }|                     |          }t          j	        |t          j	        ||                    }|                     |          }|                     |d          }d}|| 
                    |          }||||||||ddd|dd|dddd	}||v rt          ||         d         t                    r"||         d                             |           n||         d         |g||         d<   |rHd||         d<   t          ||         d         d         d         |          ||         d         d         d<   |rHd||         d<   t          ||         d         d         d         |          ||         d         d         d<   |rd||         d<   n2|||dd||||                     |          dddd|dd|dddi d||<   ||||         d         |<   nW|||         d<   |                     |          ||         d<   |||         d<   |||         d<   ddd|dd|ddd||         d<   ||         d         |nt          ||         d         |          ||         d<   P|S )z
        fetches all available currencies on an exchange
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Ndatar   currencydeposit_status   withdraw_statusmin_withdraw_feemin_withdraw_amountmin_deposit_amountchainminmax)amountrz   deposit)	infor  networkactivefee	precisionr?  rz   limitsr@  Trz   rE  r<  r?  rB  )r  coder@  typer  rB  r?  rz   rC  rD  rE  r  r  rC  rD  )publicSpotGetCurrencies
safe_valuerangelensafe_stringsafe_currency_codesafe_integerr+  r,   
string_minnetwork_id_to_code
isinstancelistappendr<  r=  )r,  paramsresponser2  resultir3  r  rF  depositStatuswithdrawStatusr?  rz   rB  	feeStringminWithdrawStringminDepositString
minDepositminWithdrawrC  minFoundPrecisionrD  	networkIdnetworkCoderA  s                            r.  fetch_currencieszdigifinex.fetch_currenciesq  s      55f========L x44q#d))$$ l	H l	HAAwH!!(J77B**2..D --h8H!LLM!..x9JANNN#a'G%)H)F((3EFFI $ 0 0;P Q Q#//:NOO**+;<<J++,=>>K##I..C ' 29g>PQact>u>u v v))*;<<I((7;;IK$"55i@@ & &"$  $# 
  +#! !
  *#     G0 v~~fTl62D99 L4L(//9999,24L,@(+KF4L( |/3F4L,@CF4LQYDZ[eDfglDmoz@{@{F4L*:6u= y.2F4L+?B6$<PXCYZcCdejCkmw?x?xF4L*95e< 2-1F4L*  $  $& (,,Y77!% $(#'# #
 $/#'% %
 $.#'$ $  !#3   t6 $6=tZ(33)/tX&&*&7&7	&B&BtU#*1tY'+3tZ(  $# 
  +#! !
  *#   * *tX& 7=Tl;6O6W		^abhimbnozb{  ~G  _H  _HF4L%%r/  c                    K   |                      | j        di           }|                     |dd          }|dk    r|                     |           d{V S |                     |           d{V S )z
        retrieves data on all markets for digifinex
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r^   methodfetch_markets_v2N)rI  r&  rL  re  fetch_markets_v1)r,  rT  r&  rd  s       r.  fetch_marketszdigifinex.fetch_markets  s       //$,CC!!'85GHH'''..v666666666**6222222222r/  c                 0  K   |                      | j        d          }|                     d|          \  }}g }|)|                    |                     |                     n(|                    |                     |                     |                    |                     |                     t          j        |  d {V }|d         }|d         }| 	                    |dg           }	| 	                    |dg           }
| 
                    |	|
          }g }t          dt          |                    D ]Y}||         }|                     |dd          }|                     |d	d
          }|                     |dd          }|                      |d          }|                     |          }|                     |          }|                     |          }|                     |dd          }|dk    rdnd}|d u }| }|dnd }|dz   |z   }d }d }|rFd}|dz   |z   dz   |z   }| 	                    |d          }|sdnd}| 	                    |d          }|rd}|                    i d|d|d|d|d|d|d|d|d|d|d|d|d dd!dd"|rdndd#|d$|||                     |d%          d d d d |                     |                     |                      |d&                              |                     |                     |                      |d'                              d(d d d)|                     |d*d+          d d)|                     |d,          d d)|                     |d-          d d)d.d |d/
           [|S )0Nr  fetchMarketsV2r   r5  symbol_listr2  symbolinstrument_id
base_assetbase_currencyquote_assetquote_currencyclear_currencyis_allowr5   r4   T/r6   :
is_inverseF	isTradingr  basequotesettlebaseIdquoteIdsettleIdrG  r7   r8   rB  contractlinearcontract_valueamount_precisionprice_precision)r>  pricer;  minimum_amountmin_order_amount	tick_sizeminimum_valueleverager>  r  cost)
inversecontractSizeexpiryexpiryDatetimestrike
optionTyperD  rE  createdr@  )rL  r&  handle_margin_mode_and_paramsrS  publicSpotGetMarginSymbolspublicSpotGetTradesSymbolspublicSwapGetPublicInstrumentsasynciogatherrI  array_concatrJ  rK  safe_string_2rM  rN  safe_numberr+  parse_precisionsafe_number_2)r,  rT  r  
marginModequerypromisesRawpromisesspotMarketsswapMarketsspotDataswapDatarU  rV  rW  marketr  rz  r{  r|  rw  rx  ry  	isAllowedrG  r4   r6   r5   rk  	isInverseisLinearrv  s                                  r.  re  zdigifinex.fetch_markets_v2  s     &&t|]CC >>?OQWXX
E!t>>uEEFFFFt>>uEEFFF4>>vFFGGG 5555555qkqkj ??;rBB??;;;$$Xx88q#h--(( S	 S	Aa[F##FHoFFB''oNNF((@PQQG''0@AAH**622D++G44E,,X66F ))&*a@@I +x 7 788fDT>D8D(4TT4FCZ%'FIH "e+c1F: OOFLAA	(1=44 OOFK@@	 " !IMM 0b0&0 0 	0
 &0 &0 70 H0 0 0 &0 0 %0 %0 )6$$0  D!0" (#0$ % $ 0 09I J J"&""//0D0DTEUEUV\^pEqEq0r0rss!..t/C/CDDTDTU[]nDoDo/p/pqq   $#! !
  $11&:JL^__# 
  $//DD# 
  $//HH#  $  _0 0 0 0 0 0 0b r/  c                   K   |                      |           d {V }|                     |dg           }g }t          dt          |                    D ]m}||         }|                     |d          }|                    d          \  }}	|                     |          }
|                     |	          }|                    i d|d|
dz   |z   d|
d	|d
d d|d|	dd dddddd dddddddd dddd d d d d d d |                     | 	                    |                     |d                              |                     | 	                    |                     |d                              dd d d| 
                    |d          d dd d d| 
                    |d          d dd|d 	           o|S )!Nr2  r   r  _r  rk  rs  rw  rx  ry  rz  r{  r|  rG  r4   Tr5   r6   Fr7   r8   rB  r}  r~  r  volume_precision)r  r>  r;  
min_volume
min_amountr  )	r  r  r  r  r  r  rD  rE  r@  )publicSpotGetMarketsrI  rJ  rK  rL  splitrM  rS  r+  r  r  )r,  rT  rU  r   rV  rW  r  r  rz  r{  rw  rx  s               r.  rf  zdigifinex.fetch_markets_v1  s     226::::::::  //(FB77q#g,,'' 5	 5	AQZF!!&(33B hhsmmOFG**622D++G44EMM /b/$*u,/ / 	/
 $/ &/ 7/ D/ / / $/ / %/ %/ $/  E!/" $#/$   $"&"!..t/C/CDDTDTU[]nDoDo/p/pqq"//0D0DTEUEUV\^pEqEq0r0rss   $#! !
  $//EE# 
  $# 
  $//EE#  $ ]/ / / / / / /` r/  c                    d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |dd          }|                     |dd          }	||d<   t          j        |	|          |d<   |	|d<   |||<   |                     |          S )	Nr@  r   r3  freeavail_balancetotalequityused)	rJ  rK  rL  rM  accountr  r,   
string_subsafe_balance)
r,  rU  rV  rW  balance
currencyIdrF  r  r  r  s
             r.  parse_balancezdigifinex.parse_balance  s    2 (#q#h--(( 
	# 
	#AqkG))':>>J**:66DllnnG%%gvGGD&&wBBE"GFO%0==GFO$GG"F4LL  (((r/  c                   K   |                                   d{V  d}|                     dd|          \  }}|                     d|          \  }}d}||dk    rd}|                     |           d{V }n[|dk    r|                     |           d{V }n9|dk    r|                     |           d{V }nt          | j        dz             |dk    rdnd}|                     ||g           }| 	                    |          S )	a  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-account-assets
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#accountbalance
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        NrF   r5   r4   r6   z, fetchBalance() not support self market typer2  rR  )
load_marketshandle_market_type_and_paramsr  privateSpotGetMarginAssetsprivateSpotGetSpotAssetsprivateSwapGetAccountBalancer&   r  rI  r  )r,  rT  
marketTyper  r  rU  balanceRequestbalancess           r.  fetch_balancezdigifinex.fetch_balance&  sc      !!!!!!!!!
!??PTV\]]
F >>~vVV
E!Z8%;%;!J!<<UCCCCCCCCHH6!!!::5AAAAAAAAHH6!!!>>uEEEEEEEEHHtw)WWXXXJ %/&$8$8v??8^R@@!!(+++r/  Nrk  limitc                 ~  K   |                                   d{V  |                     |          }|                     d||          \  }}i }|||d<   d}|dk    r;|d         |d<   |                     |                     ||                     d{V }n:|d         |d<   |                     |                     ||                     d{V }d}	d}
|dk    r.|                     |di           }
|                     |
d	          }	n|}
|                     |d
          }	| 	                    |
|d         |	          S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-orderbook
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderbook
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        Nrd   r  r6   r  rl  rk  r2  	timestampdate)
r  r  r  publicSwapGetPublicDepthextendpublicSpotGetOrderBookrI  rN  safe_timestampparse_order_book)r,  rk  r  rT  r  r  r  requestrU  r  	orderBooks              r.  fetch_order_bookzdigifinex.fetch_order_booke  s      !!!!!!!!!V$$ >>?OQWY_``
E$GG'-d|GO$!::4;;wPU;V;VWWWWWWWWHH &tGH!88We9T9TUUUUUUUUHN 		&"==I)))[AAII I++Hf==I$$Yx0@)LLLr/  symbolsc                   K   |                                   d{V  |                     |          }|                     |d          }d}||                     |          }d}|                     d||          \  }}i }d}|dk    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }i }|                     |ddg           }	| 	                    |d          }
t          dt          |	                    D ]B}|                     d|
i|	|                   }|                     |          }|d         }|||<   C|                     |d|          S )	ah  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#tickers
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   rm   r6   r   r2  r  rk  )r  market_symbolsrL  r  r  publicSwapGetPublicTickersr  publicSpotGetTickersafe_value_2rN  rJ  rK  parse_tickerfilter_by_array_tickers)r,  r  rT  firstr  rG  r  rU  rV  tickersr  rW  	rawTickerr   rk  s                  r.  fetch_tickerszdigifinex.fetch_tickers  s      !!!!!!!!!%%g..  !,,[[''F99.&RXYYf6>>!<<T[[RX=Y=YZZZZZZZZHH!55dkk'66R6RSSSSSSSSHb ##HhCC  622q#g,,'' 	$ 	$A%qz I &&y11FH%F#F6NN++FHgFFFr/  c                   K   |                                   d{V  |                     |          }i }d}|d         r;|d         |d<   |                     |                     ||                     d{V }n:|d         |d<   |                     |                     ||                     d{V }|                     |d          }|                     |dg           }|                     |di           }|                     |d	i           }	d}
|d         r|}
n|                     d|i|	          }
|                     |
|          S )
a&  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#ticker
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr6   r  rl  rk  r  r   r2  r   )r  r  publicSwapGetPublicTickerr  r  rN  rI  r  )r,  rk  rT  r  r  rU  r  r  r2  firstTickerrV  s              r.  fetch_tickerzdigifinex.fetch_ticker  su      !!!!!!!!!V$$&> 	T'-d|GO$!;;DKKQW<X<XYYYYYYYYHH &tGH!55dkk'66R6RSSSSSSSSH\   622//(Hb99x44oogq"55&> 	>FF[[&$==F  000r/  r  c           	         |                      |d          }|dnd}|                     |dd          }|                     ||d |          }|                     ||d |          }|                     |d          }|d         r|                     |d          }|                     |d	          }|                     i d|d|d
|                     |          d| 	                    |dd          d| 	                    |dd          d| 	                    |dd          d|                     |d          d| 	                    |dd          d|                     |d          dd d|                     |d          d|d	|dd dd d| 	                    |dd           d!d | 	                    |d"d#          |                     |d$          |d%|          S )&Nindex_pricer}  r4   rk  rl  r  r6   r  lastdatetimehighhigh_24hlowlow_24hbidbuybest_bid	bidVolumebest_bid_sizeasksellbest_ask	askVolumebest_ask_sizevwapopenopen_24hclosepreviousClosechanger   price_change_percentaveragevol
volume_24hbase_vol)
baseVolumequoteVolumer@  )
r  safe_string_upper_2safe_symbolsafe_marketr  rN  rL  safe_tickeriso8601r  )	r,  r   r  
indexPricer  marketIdrk  r  r  s	            r.  r  zdigifinex.parse_tickerJ  sy   P %%fm<<
$.$:ZZ
++FHoNN!!(FD*EE!!(FD*EE''77	&> 	?))&+>>I// !
f!
!
 Y//!
 D&&vvzBB	!

 4%%feY??!
 4%%feZ@@!
 ))&/BB!
 4%%ffjAA!
 ))&/BB!
 D!
 D$$VZ88!
 T!
 D!
 T!
 d!
  $,,VX?UVV!!
" t#!
$ ,,VULII++FJ??)!
 !
 !
* +  	r/  c                    |                      |dd          }|                     |d          }|                     |d          }|                     |g d          }|                     |dd          }|                     ||          }||                     |          }|                     |dd	          }	|                      |d
d          }
d }d }|d
         dk    r|                     |d          }	|                     |d          }|                     |d          }|                     |d          }|
|dk    rdnd }|dk    rd}n|dk    rd}nd }|
dk    s|dk    rd}
n|
dk    s|dk    rd}
n|
dk    s|dk    rd}
np|
dk    s|dk    rd}
na|
                    d          }|                     |d          }
|                     |d          }|d}| 	                    |d          }|rdnd}d }|                     |d          }|4|                     |d           }d }|| 
                    |          }||d!}|                     |||	|                     |	          ||||
||d ||d"|          S )#Nr  trade_idorder_idr  )r>  volumesizerk  rl  r  r  rG  sider6   
trade_time
order_type
match_role	direction0r  r{   r   r   r   r  r  r   4r  r   r5  is_makerrC  fee_currency)r  r3  )r  r@  r  r  rk  rG  orderr  r  r>  r  takerOrMakerrC  )r  rL  safe_string_nr   r  r  safe_timestamp_2rN  r  rI  rM  
safe_trader  )r,  trader  r  orderIdpriceStringamountStringr  rk  r  r  rG  r  	orderType	tradeRoler  partsisMakerrC  feeCostStringfeeCurrencyIdfeeCurrencyCodes                         r.  parse_tradezdigifinex.parse_trade  s   p tZ88""5*55&&ug66))%1M1M1MNN++E8_MM!!(F33>%%h//F))%EE	!!%88&>V##))%>>I((==I((==I((<<I$#,#3#3ww$C&c!!&#c!1!1#++9#3#3#++9#3#3#++9#3#3JJsOOE##E1--D##E1--D|ooeZ88G&-:777L((66$ ,,UNCCM"O("&"9"9-"H"H%+ C "Y// "( 
  
   	r/  c                 h   K   |                      |           d{V }|                     |d          S )a  
        fetches the current integer timestamp in milliseconds from the exchange server
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        Nserver_time)publicSpotGetTimer  )r,  rT  rU  s      r.  
fetch_timezdigifinex.fetch_time  sE       //77777777 ""8];;;r/  c                    K   |                      |           d{V }|                     |d          }|dk    rdnd}|ddd|dS )a  
        the latest known information on the availability of the exchange API
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
        NrF  r   okmaintenance)statusupdatedetaurlr@  )publicSpotGetPingrN  )r,  rT  rU  rF  r-  s        r.  fetch_statuszdigifinex.fetch_status!  ss       //77777777   622!))-
 
 	
r/  sincec                   K   |                                   d{V  |                     |          }i }||d         rt          |d          n||d<   d}|d         r;|d         |d<   |                     |                     ||                     d{V }n:|d         |d<   |                     |                     ||                     d{V }|                     |dg           }|                     ||||          S )	a~  
        get the list of most recent trades for a particular symbol
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-recent-trades
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#recenttrades
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        Nr6   d   r  r  rl  rk  r2  )r  r  r<  publicSwapGetPublicTradesr  publicSpotGetTrades	safe_listparse_trades)	r,  rk  r3  r  rT  r  r  rU  r2  s	            r.  fetch_tradeszdigifinex.fetch_trades8  s0      !!!!!!!!!V$$28.Ks5#eGG&> 	T'-d|GO$!;;DKKQW<X<XYYYYYYYYHH &tGH!55dkk'66R6RSSSSSSSSHT ~~h33  vue<<<r/  c           	         |d         r|                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr6   r   r5              )rN  r  r  )r,  ohlcvr  s      r.  parse_ohlcvzdigifinex.parse_ohlcv{  s
    &> 	!!%++  **  **  **  **  **  ##E1--  **  **  **  **  ** r/  r   c                   K   |                                   d{V  |                     |          }i }d}|d         rU|d         |d<   ||d<   |t          |d          |d<   |                     |                     ||                     d{V }n|d         |d<   |                     | j        ||          |d	<   |Q|                     |d
z            }	|	|d<   |1|                     |          }
| 	                    |	||
z            |d<   nJ|H| 
                                }|                     |          }
|}| 	                    || |
z            |d<   |                     |                     ||                     d{V }d}|d         r/|                     |di           }|                     |dg           }n|                     |dg           }|                     |||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-candles-data
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#recentcandle
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        Nr6   r  rl  granularityr5  r  rk  period  
start_timeend_timer2  candles)r  r  r<  publicSwapGetPublicCandlesr  rL  r"  parse_to_intparse_timeframesumsecondspublicSpotGetKlinerI  parse_ohlcvs)r,  rk  	timeframer3  r  rT  r  r  rU  	startTimedurationendTimeauxLimitrH  r2  s                  r.  fetch_ohlcvzdigifinex.fetch_ohlcv  s1      !!!!!!!!!V$$&> 	S'-d|GO$%.GM" #&uc?? !<<T[[RX=Y=YZZZZZZZZHH &tGH $ 0 0)Y W WGH  --edl;;	(1%$#33I>>H*.((9eh>N*O*OGJ'",,..//	:: (,8)h:N(O(O%!44T[[&5Q5QRRRRRRRRH8 &> 	<??8VR88DoodIr::GGooh;;G  &)UEJJJr/  rG  r  r>  r  c                    K   |                                   d{V  |                     |          }|                     d|          }|d         }	|                     ||||||          }
d}|d         r|                     |
           d{V }n9|	|                     |
           d{V }n|                     |
           d{V }|                     ||          }|d         |d<   ||d<   ||d<   ||d<   ||d	<   |S )
a  
        create a trade order
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderplace
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency, spot market orders use the quote currency, swap requires the number of contracts
        :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
        :param bool [params.postOnly]: True or False
        :param bool [params.reduceOnly]: True or False
        :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
        :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr?   r   r6   rk  rG  r  r>  r  )r  r  r  create_order_requestprivateSwapPostTradeOrderPlaceprivateSpotPostMarginOrderNewprivateSpotPostSpotOrderNewparse_order)r,  rk  rG  r  r>  r  rT  r  marginResultr  r  rU  r  s                r.  create_orderzdigifinex.create_order  sQ     $ !!!!!!!!!V$$99-PP!!_
++FD$vVV&> 	K!@@IIIIIIIIHH%!%!C!CG!L!LLLLLLL!%!A!A'!J!JJJJJJJ    622 *hff hgr/  ordersc           	        K   |                                   d{V  g }d}d}t          dt          |                    D ]#}||         }|                     |d          }||}n||k    rt	          | j        dz             |                     |d          }	|                     |d          }
|                     |d          }|                     |d          }|                     |d	i           }|                     d
|          }|d         }|"||}n||k    rt	          | j        dz             |                     ||	|
|||          }|	                    |           %| 
                    |          }i }d}|d         r|                     |           d{V }nG|dnd|d<   |d         |d<   |                     |          |d<   |                     |           d{V }g }|d         r|                     |dg           }n|                     |dg           }g }t          dt          |                    D ]i}||         }i }||         |d<   |d         |d<   |                     |d          |d<   |                     |d          |d<   |	                    |           j|                     ||          S )aX  
        create a list of trade orders(all orders should be of the same symbol)
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-multiple-order
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#batchorder
        :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   rk  z; createOrders() requires all orders to have the same symbolrG  r  r>  r  rT  r@   zS createOrders() requires all orders to have the same margin mode(isolated or cross)r6   r5   r4   r  r  rR  r2  	order_idsr	  rl  )r  rJ  rK  rL  r   r  rI  r  rW  rS  r  privateSwapPostTradeBatchOrderjson"privateSpotPostMarketOrderBatchNewr  parse_orders)r,  r^  rT  ordersRequestsrk  r  rW  rawOrderr  rG  r  r>  r  orderParamsr\  currentMarginModeorderRequestr  r  rU  r2  rV  individualOrders                          r.  create_orderszdigifinex.create_orders  s9      !!!!!!!!!
q#f++&& 	0 	0AayH''(;;H~!X%%$TW/l%lmmm##Hf55D##Hf55D__Xx88FOOHg66E//(HbAAK==nkZZL ,Q ,%!2JJ!%666(  4I  *I  J  J  J44XtT6SXZeffL!!,////V$$&> 	N!@@PPPPPPPPHH-7-C&GH &tGH"ii77GFO!DDWMMMMMMMMH, &> 	>??8VR88DD??8["==Dq#f++&& 	+ 	+AayH O*.q'OJ'/5d|OO,(,(8(88(L(LOH%'+'7'7''J'JOG$MM/****  000r/  c                    |                      |          }d}d}	|                     d||          \  }}|                     d|          \  }	}|	d}i }
|dk    }|dk    }|dk    }|rdnd}|d	         |
|<   |                     |d
|          }d}|r|                     |dd
          }|                     |d          }d}|dk    r|rdnd}||
d<   n|rdnd}||
d<   |rd}|dk    r|rdnd}n |dk    r|rdnd}n|dk    s|rd}n|dk    rd}||                     ||          |
d<   ||
d<   ||
d<   |                     |ddg          }n[|du rdnd}||
d<   d }|dk    rd!}n|                     ||          |
d<   ||z   |
d<   d}d}|                     |dd"d          \  }}|r|dk    r| 	                    |d#          }|                     |d#          }|| 
                    ||          }n|r|t          | j        d$z             |                     |          }|                     |          }|                     t          j        ||                    }| 
                    ||          }n-| 
                    ||          }n|                     ||          }||
d%<   |r|r||
d&<   n||
d&<   |                     |d'g          }|                     |
|          S )(a  
         * @ignore
        helper function to build request
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency, spot market orders use the quote currency, swap requires the number of contracts
        :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: request to be sent to the exchange
        NcreateOrderRequestr5   r6   r  r  rl  rk  r  F
reduceOnlytimeInForcer  r>  r5  rG  r=  r<  r   FOK   	   IOC   GTC   POTr  r  r   _marketr  r  a	   createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argumentr>  	post_onlypostOnly)r  r  r  is_post_only	safe_boolrL  price_to_precisionomithandle_option_and_paramsr  cost_to_precisionr$   r  number_to_stringr+  r,   
string_mulamount_to_precisionr  )r,  rk  rG  r  r>  r  rT  r  r  r  r  r6   isMarketOrderisLimitOrdermarketIdRequestr{  postOnlyParsedrn  ro  r  requestTypesuffixquantityr  r  r  r  costRequests                               r.  rW  zdigifinex.create_order_requestj  s    V$$

!??@TV\^dee
F!??@TV\]]
F!!Jf$)-1?//x#)$< $$]E6BB 7	)eDDJ**6=AAKIu}}$.6aaQ"-$.6aaQ"- 	e##"/6BBQ		%%"/6BBQ		&&M&		$$ #'#:#:65#I#I $-GL!$GFOYYvm'DEEFF#+t#3#3QQ!N *GHFx"#'#:#:65#I#I "VmGFOH04-8<8U8UV\^r  uX  Z^  9_  9_5-v D$%--''776622##55fdCCHH6 	F}*47  6A  ,A  B  B  B'+'<'<V'D'D&*&;&;E&B&B&*&7&78J<Yd8e8e&f&f#'#9#9&+#N#N#55ffEEHH33FFCC (GH 	0 0'5$$'/$6J<00{{7F+++r/  r  c                    K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d<   |                     |dd|d|           d{V S )a  
        create a market buy order by providing the symbol and cost
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr4   z9 createMarketBuyOrderWithCost() supports spot orders onlyFr  r  r  )r  r  r&   r  r]  )r,  rk  r  rT  r  s        r.  !create_market_buy_order_with_costz+digifinex.create_market_buy_order_with_cost  s       !!!!!!!!!V$$f~ 	ftw)ddeee6;23&&vxdFSSSSSSSSSr/  r  c                   K   |                                   d{V  d}||                     |          }t          |          }d}|                     d||          \  }}d|i}|dk    r%|t	          | j        dz             |d         |d<   n||d<   |                     d|          \  }}d}	||d	k    r2d	}|                     |                     ||                     d{V }	n|d
k    r0| 	                    |                     ||                     d{V }	nM|dk    r0| 
                    |                     ||                     d{V }	nt          | j        dz             |d
k    s|d	k    rI|                     |	dg           }
t          |
          }|dk    rt          | j        dz   |z   dz             |	S )a  
        cancels an open order
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#cancel-order
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#cancelorder
        :param str id: order id
        :param str symbol: not used by digifinex cancelOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr:   r	  r6   z) cancelOrder() requires a symbol argumentr  rl  r  r5   r4   z+ cancelOrder() not support self market typesuccessr5  z cancelOrder() 
 not found)r  r  strr  r   r  r   privateSpotPostMarginOrderCancelr  privateSpotPostSpotOrderCancelprivateSwapPostTradeCancelOrderr&   rI  rK  r%   )r,  r  rk  rT  r  r  r  r  r  rU  canceledOrdersnumCanceledOrderss               r.  cancel_orderzdigifinex.cancel_order  s0      !!!!!!!!![[((FWW
!??vW]^^
F
 ~'2](]^^^'-d|GO$$ *GH >>}fUU
E!Z8%;%;!J!BB4;;wX]C^C^________HH6!!!@@WV[A\A\]]]]]]]]HH6!!!AA$++gW\B]B]^^^^^^^^HHtw)VVWWW, &  jH&<&<!__Xy"EEN #N 3 3 A%%#DG.?$?"$D|$STTTr/  c                   K   |                                   d{V  |                     | j        dd          }|                     |d|          }|                     |d          }|d                    |          d}|                     |                     ||                     d{V }|                     |dg           }t          |          }	|	dk     rt          | j
        d	z             |S )
aD  
        cancel multiple orders
        :param str[] ids: order ids
        :param str symbol: not used by digifinex cancelOrders()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr  r4   rG  ,)r  r	  r  r5  z cancelOrders() error)r  rL  r&  r  joinr  r  rI  rK  r%   r  )
r,  idsrk  rT  r  r  r  rU  r  r  s
             r.  cancel_orderszdigifinex.cancel_orders  s      !!!!!!!!!&&t|]FKK$$VV[AA	66**
 
 <<T[[RX=Y=YZZZZZZZZ 9bAA//q  *A ABBBr/  c                 @    dddddd}|                      |||          S )Nr  closedcanceled)r  r{   r   r   r  rL  r,  r-  statusess      r.  parse_order_statuszdigifinex.parse_order_status9  s7    
 
 &&999r/  c                    d }d }d }d }|                      |d          }|                     |dd          }|                     ||          }	|                     |	          }|d         dk    r|                     |d          }
|
|
dk    s|
dk    s|
dk    s|
d	k    s|
d
k    rd}n;|
dk    s|
dk    s|
dk    s|
dk    s|
dk    rd}n|
dk    s|
dk    s|
dk    s|
dk    rd}|
dk    s|
dk    s|
dk    s|
dk    s|
dk    s|
dk    rd}nd}|dk    rd}n|dk    rd}n|dk    rd }n|d!k    rd"}|                     |d#          }|                     |d$          }nk|                     |d%          }|                     |d&          }|=|                    d'          }t          |          }|dk    r|d         }|d         }nd}|                     i d(|d)|                     |d*d+          d,d d-|d.| 	                    |          d/|d|	d|d0|d1d d2|d3| 
                    |d3          d4d d5d d6|                     |d6d7          d8|                     |d9d:          d;d d |                     |d<d=          |                     |                     |d>d?                    d@| 
                    |dA          id dB|          S )CNrG  rk  rl  r6   r  rr  
         rq  rp  r5  r<  r=  r>  rt  rs           rv  ru  r   r?  r  r  r{   z	open longr   z
open shortr   z
close longr  zclose shortinsert_time
time_stampcreated_datefinished_dater  r@  r  r	  r2  clientOrderIdr  r  lastTradeTimestampro  r{  r  r  	stopPricetriggerPricer>  r  filledexecuted_amount
filled_qty	remaining	avg_price	price_avgr-  stater  rC  )r  r  r-  rC  r   )rL  r  r  r  rN  r  r  rK  
safe_orderr  r  r  r  )r,  r  r  r  r  ro  rG  r  r  rk  r  r   numPartss                r.  r[  zdigifinex.parse_orderC  s
   @ 	!v..%%eXGG!!(F33V$$&>V##))%>>I$NN	RY"__R[_aRaRagptvgvgv"'KK1nn)q..i1nnR[_`R`R`fosufufu"'KK1nn)q..i1nnR[_aRaRa"'KNN	QINNPY]^P^P^dmqrdrdr  yB  FH  yH  yH"DD#Ds{{"##$))%??I!%!2!25,!G!G++E>BBI!%!4!4UO!L!L

3u::a<< 8D 8DD"D  
E 
$$$UJ?? 
 T 
 	 

 Y// 
 !"4 
 f 
 D 
 ; 
  
 D 
 T%%eW55 
  
 D 
 d((&AA 
  d((0A<PP! 
" # 
$ ))%kJJ--d.@.@RY.Z.Z[[((66 1 
  
  
2 3  	r/  c                   K   |                                   d{V  d}||                     |          }d}|                     d||          \  }}|                     d|          \  }}i }	|dk    }
|
r|||	d<   |||	d<   n||	d<   ||
rdnd}|d	         |	|<   d}||d
k    r2d
}|                     |                     |	|                     d{V }n|dk    r0|                     |                     |	|                     d{V }nM|dk    r0|                     |                     |	|                     d{V }nt          | j	        dz             | 
                    |dg           }|                     ||||          S )aj  
        fetch all unfilled currently open orders
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#current-active-orders
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#openorder
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nrb   r6   start_timestampr  r  rl  rk  r  r5   r4   z/ fetchOpenOrders() not support self market typer2  )r  r  r  r   privateSpotGetMarginOrderCurrentr  privateSpotGetSpotOrderCurrentprivateSwapGetTradeOpenOrdersr&   r  r8  rd  )r,  rk  r3  r  rT  r  r  r  r  r  r6   r  rU  r2  s                 r.  fetch_open_orderszdigifinex.fetch_open_orders  s      !!!!!!!!![[((F
!??@QSY[abb
F >>?PRXYY
Ef$ 	+ -2)* #(  *GH15Coo8O'-d|GO$!Z8%;%;!J!BB4;;wX]C^C^________HH6!!!@@WV[A\A\]]]]]]]]HH6!!!??GUZ@[@[\\\\\\\\HHtw)ZZ[[[h ~~h33  vue<<<r/  c                 R  K   |                                   d{V  d}||                     |          }d}|                     d||          \  }}|                     d|          \  }}i }	|dk    r|||	d<   n"||	d<   ||                     |dz            |	d<   ||dk    rdnd	}
|d
         |	|
<   |||	d<   d}||dk    r2d}|                     |                     |	|                     d{V }n|dk    r0|                     |                     |	|                     d{V }nM|dk    r0|                     |                     |	|                     d{V }nt          | j
        dz             |                     |dg           }|                     ||||          S )a  
        fetches information on multiple orders made by the user
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-all-orders-including-history-orders
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#historyorder
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nre   r6   r  r  rE  rF  rl  rk  r  r  r5   r4   z+ fetchOrders() not support self market typer2  )r  r  r  r  rJ   privateSpotGetMarginOrderHistoryr  privateSpotGetSpotOrderHistory privateSwapGetTradeHistoryOrdersr&   r  r8  rd  )r,  rk  r3  r  rT  r  r  r  r  r  r  rU  r2  s                r.  fetch_orderszdigifinex.fetch_orders&  s#      !!!!!!!!![[((F
!??vW]^^
F >>}fUU
E -2)* *GH (,(9(9%$,(G(G%2<2F2FooXO'-d|GO$$GG!Z8%;%;!J!BB4;;wX]C^C^________HH6!!!@@WV[A\A\]]]]]]]]HH6!!!BB4;;wX]C^C^________HHtw)VVWWWh ~~h33  vue<<<r/  c                 z  K   |                                   d{V  d}||                     |          }d}|                     d||          \  }}|                     d|          \  }}d|i}|dk    r||d         |d<   n||d<   d}	||dk    r2d}|                     |                     ||                     d{V }	n|d	k    r0|                     |                     ||                     d{V }	nM|dk    r0|                     |                     ||                     d{V }	nt          | j	        d
z             | 
                    |	d          }
|dk    r|
n| 
                    |
d          }|*t          | j	        dz   t          |          z   dz             |                     ||          S )a  
        fetches information on an order made by the user
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-order-status
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderinfo
        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nrc   r	  r6   r  rl  r  r5   r4   z* fetchOrder() not support self market typer2  r   z fetchOrder() order r  )r  r  r  r  privateSpotGetMarginOrderr  privateSpotGetSpotOrderprivateSwapGetTradeOrderInfor&   r  rI  r%   r  r[  )r,  r  rk  rT  r  r  r  r  r  rU  r2  r  s               r.  fetch_orderzdigifinex.fetch_order  s      !!!!!!!!![[((F
!??fV\]]
F >>|VTT
E
 !+1$<( *GH"
h(>(>!J!;;DKKQV<W<WXXXXXXXXHH6!!!99$++gu:U:UVVVVVVVVHH6!!!>>t{{7TY?Z?Z[[[[[[[[HHtw)UUVVVb x00#v--DOOD!4L4L=*@ @3r77 J\ YZZZv...r/  c                 f  K   |                                   d{V  d}i }||                     |          }d}|                     d||          \  }}|                     d|          \  }}	|dk    r|||d<   n"||d<   ||                     |dz            |d<   |dk    rdnd	}
||d
         ||
<   |||d<   d}||dk    r2d}|                     |                     ||	                     d{V }n|dk    r0|                     |                     ||	                     d{V }nM|dk    r0|                     |                     ||	                     d{V }nt          | j
        dz             |dk    rdnd}|                     ||g           }|                     ||||          S )aZ  
        fetch all trades made by the user
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#customer-39-s-trades
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#historytrade
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nr`   r6   r  r  rE  rF  rl  rk  r  r  r5   r4   z- fetchMyTrades() not support self market typer2  rR  )r  r  r  r  rJ  privateSpotGetMarginMytradesr  privateSpotGetSpotMytrades privateSwapGetTradeHistoryTradesr&   r  r8  r9  )r,  rk  r3  r  rT  r  r  r  r  r  r  rU  responseRequestr2  s                 r.  fetch_my_tradeszdigifinex.fetch_my_trades  s8      !!!!!!!!![[((F
!??QWY_``
F >>PVWW
E -2)* *GH (,(9(9%$,(G(G%.8F.B.B//'-d|GO$$GG!Z8%;%;!J!>>t{{7TY?Z?Z[[[[[[[[HH6!!!<<T[[RW=X=XYYYYYYYYHH6!!!BB4;;wX]C^C^________HHtw)XXYYY\ &06%9%9&&~~h<<  vue<<<r/  c                 4    i }|                      |||          S Nr  )r,  rG  r  s      r.  parse_ledger_entry_typez!digifinex.parse_ledger_entry_type8	  s    tT222r/  r3  c                    |                      |                     |dd                    }|                     |                     |dd          |          }|                     |dd          }|                     |d          }|                     |d          }||                     |d	          }|d d d d d |||d |d ||                     |          d d
S )NrG  finance_typecurrency_markr3  numr  r  r   r  )r@  r  r  r  referenceIdreferenceAccountrG  r3  r>  beforeafterr-  r  r  rC  )r  r  rM  r  r  r  rN  r  )r,  itemr3  rG  rF  r>  r  r  s           r.  parse_ledger_entryzdigifinex.parse_ledger_entry<	  s    * ++D,>,>tV^,\,\]]&&t'9'9$Q['\'\^fgg##D%::  y11''f55	))$<<I $"Y//
 
 	
r/  rF  c                   K   |                                   d{V  i }d}|                     dd|          \  }}|                     d|          \  }}|dk    r|||d<   n"||d<   ||                     |dz            |d<   |dk    rdnd	}	d}
| |                     |          }
|
d
         ||	<   |||d<   d}||dk    r2d}|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }nM|dk    r0|                     |                     ||                     d{V }nt          | j
        dz             d}|dk    r|                     |dg           }n.|                     |di           }|                     |dg           }|                     ||
||          S )a  
        fetch the history of changes, actions done by the user or operations that altered balance of the user
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-margin-otc-financial-logs
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#bills
        :param str code: unified currency code, default is None
        :param int [since]: timestamp in ms of the earliest ledger entry, default is None
        :param int [limit]: max number of ledger entrys to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
        NrY   r6   r  r  rE  rF  r3  r  r  r  r5   r4   z+ fetchLedger() not support self market typer2  finance)r  r  r  rJ  r3  privateSpotGetMarginFinancelogr  privateSpotGetSpotFinancelog"privateSwapGetAccountFinanceRecordr&   r  rI  parse_ledger)r,  rF  r3  r  rT  r  r  r  r  currencyIdRequestr3  rU  ledgerr2  s                 r.  fetch_ledgerzdigifinex.fetch_ledgerj	  s\      !!!!!!!!!
!??tU[\\
F >>}fUU
E -2)* *GH (,(9(9%$,(G(G%+5+?+?JJo}}T**H)1$G%&$GG!Z8%;%;!J!@@WV[A\A\]]]]]]]]HH6!!!>>t{{7TY?Z?Z[[[[[[[[HH6!!!DDT[[QXZ_E`E`aaaaaaaaHHtw)VVWWWD __Xvr::FF??8VR88D__T9b99F  5%@@@r/  c                     |                      |d          }|                      |d          }|                     |d          }|                     |          }||||d dS )Naddress
addressTagr3  )r@  r3  r  tagrA  )rL  safe_string_upperrM  )r,  depositAddressr3  r  r  r  rF  s          r.  parse_deposit_addresszdigifinex.parse_deposit_address	  st     "">9==~|<<++NJGG
&&z22"
 
 	
r/  c                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     ||d         g          }|                     ||          }|t          | j        dz   |z   dz             |S )a9  
        fetch the deposit address for a currency associated with self account
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        Nr3  r  r2  rF  z5 fetchDepositAddress() did not return an address for zQ - create the deposit address in the user settings on the exchange website first.)r  r3  privateSpotGetDepositAddressr  rI  parse_deposit_addressesr#   r  )	r,  rF  rT  r3  r  rU  r2  	addressesr  s	            r.  fetch_deposit_addresszdigifinex.fetch_deposit_address	  s      !!!!!!!!!==&&
 ::4;;wPV;W;WXXXXXXXX x44008H7IJJ	//)T22? +b!bei!i  m@  "@  A  A  Ar/  c                   K   |                                   d {V  d }i }| |                     |          }|d         |d<   |t          d|          |d<   d }|dk    r0|                     |                     ||                     d {V }n/|                     |                     ||                     d {V }|                     |dg           }	|                     |	|||d|i          S )Nr  r3  i  r  r?  r2  rG  )r  r3  r<  privateSpotGetDepositHistoryr  privateSpotGetWithdrawHistoryr8  parse_transactions)
r,  rG  rF  r3  r  rT  r3  r  rU  r2  s
             r.  fetch_transactions_by_typez$digifinex.fetch_transactions_by_type	  s%     !!!!!!!!!
 }}T**H"*4.GJ!#uooGFO9!>>t{{7TZ?[?[\\\\\\\\HH!??GU[@\@\]]]]]]]]H* ~~h33&&tXuefd^TTTr/  c                 D   K   |                      d||||           d{V S )a  
        fetch all deposits made to an account
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch deposits for
        :param int [limit]: the maximum number of deposits structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        r?  Nr  r,  rF  r3  r  rT  s        r.  fetch_depositszdigifinex.fetch_deposits
  s7       44YeUTZ[[[[[[[[[r/  c                 D   K   |                      d||||           d{V S )a  
        fetch all withdrawals made from an account
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch withdrawals for
        :param int [limit]: the maximum number of withdrawals structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        
withdrawalNr  r  s        r.  fetch_withdrawalszdigifinex.fetch_withdrawals&
  s8       44\4PUW]^^^^^^^^^r/  c                 >    ddddd}|                      |||          S )Npendingr+  failed)r{   r   r   r  r  r  s      r.  parse_transaction_statusz"digifinex.parse_transaction_status1
  s6     	
 
 &&999r/  c                 4   |                      |dd          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     ||          }|                     |                     |d                    }	|                     |                     |d                    }
|                     |                     |d	                    }|                     |d
          }|                     |d          }d }|||d}|                     |d          }i d|d|d|d|	d|                     |	          d|d|d|dd d|d|dd dd d
|d|d|d|
d d |dS )Nr  withdraw_idr  memohashr3  r  r  r  r>  rC  )r3  r  r:  r@  txidr  r  rA  	addressToaddressFromr  tagTotagFromrG  r-  r.  )internalcommentrC  )r  rL  r  rM  	parse8601r  r  r  )r,  transactionr3  r  r  r  r	  r  rF  r  r.  r-  r>  feeCostrC  rA  s                   r.  parse_transactionzdigifinex.parse_transaction<
  s8   2 T=AA"";	::{F33V44++KDD
&&z8<<NN4#3#3K#P#PQQ	..!1!1+!O!OPP..t/?/?W/U/UVV!!+x88"";66#W55C"";88
K
"
 D
 	

 Y//
 w
 w
 
 4
 3
 S
 t
 D
 f
 
  f!
" w#
$ )
 
 
 	
r/  c                 8    ddi}|                      |||          S )Nr  r+  r  r  s      r.  parse_transfer_statuszdigifinex.parse_transfer_status{
  s(    
 &&999r/  c                    d }d }|                      |d          }|dk    rd}d}n
|dk    rd}d}|                      |d          }||                     |d          ||                     |          |                     |                     |d          |          |                     |d	          |||                     |                     |d
                    d	S )NrG  r5  r4   r6   r<  r  transfer_idr3  r>  rF  )	r@  r  r  r  r3  r>  fromAccount	toAccountr-  )rN  rL  r  rM  r  r  )r,  ry   r3  r  r  rG  r  s          r.  parse_transferzdigifinex.parse_transfer
  s    $ 	  622199 KIIQYY KI%%h<<	""8];;"Y////0@0@:0V0VX`aa&&x::&"001A1A(F1S1STT

 

 
	
r/  r  r  c                   K   |                                   d{V  |                     |          }|                     | j        di           }|                     |||          }|                     |||          }	|d         |                     ||          ||	d}
|                     |                     |
|                     d{V }|                     ||          S )a  
        transfer currency internally between wallets on the same account
        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from
        :param str toAccount: account to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        Nr  r  )r  r  fromto)	r  r3  rI  r&  rL  currency_to_precisionprivateSpotPostTransferr  r  )r,  rF  r>  r  r  rT  r3  r  fromIdtoIdr  rU  s               r.  ry   zdigifinex.transfer
  s       !!!!!!!!!==&&7GLL!!.+{KK	9EE%d^--dF;;	
 
 55dkk'66R6RSSSSSSSS ""8X666r/  c                   K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }||                     ||          |d         d}|||d<   |                     |                     ||                     d{V }|                     ||          S )a  
        make a withdrawal
        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr  )r  r>  r3  r  )handle_withdraw_tag_and_paramscheck_addressr  r3  r  privateSpotPostWithdrawNewr  r  )	r,  rF  r>  r  r  rT  r3  r  rU  s	            r.  rz   zdigifinex.withdraw
  s       99#vFFV7###!!!!!!!!!==&& 00v>> 	
 
 ?!GFO88Wf9U9UVVVVVVVV %%h999r/  c                 l  K   |                                   d {V  i }d }| |                     |          }|d         |d<   |                     |                     ||                     d {V }|                     |d          }	|                     |	|          }
|                     |
|||          S )Nr  rk  	positions)r  r  privateSpotGetMarginPositionsr  rI  parse_borrow_interestsfilter_by_currency_since_limit)r,  rF  rk  r3  r  rT  r  r  rU  rowsinterests              r.  fetch_borrow_interestzdigifinex.fetch_borrow_interest
  s      !!!!!!!!![[((F &tGH;;DKKQW<X<XYYYYYYYY, x55..tV<<228T5%PPPr/  c           
      \   |                      |d          }|                      |d          }|                      |d          }t          j        ||          }t          j        ||          }|d n|d         }|                     ||          }	|	|	|d d|                     |          d d |d	S )Nrk  r>  leverage_ratiorw  MbP?)	r  rk  r3  r,  interestRateamountBorrowedr  r  r@  )rL  r,   
string_divr  r  r+  )
r,  r@  r  r  r  leverageStringamountInvestedr2  r3  rk  s
             r.  parse_borrow_interestzdigifinex.parse_borrow_interest  s     ##D(33''h77))$0@AA +L.II +L.II"N44!!(F33 !"//??

 

 
	
r/  c                   K   |                                   d{V  i }|                     |                     ||                     d{V }|                     |dg           }g }t	          dt          |                    D ]&}||         }|                     |d          |k    r|}'|                     |          }	|                     ||	          S )a  
        fetch the rate of interest to borrow a currency for margin trading
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `borrow rate structure <https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure>`
        NrR  r   r3  )	r  r  r  rI  rJ  rK  rL  r3  parse_borrow_rate)
r,  rF  rT  r  rU  r2  rV  rW  entryr3  s
             r.  fetch_cross_borrow_ratez!digifinex.fetch_cross_borrow_rate'  s       !!!!!!!!!88Wf9U9UVVVVVVVV$ x44q#d))$$ 	 	AGEz22d::==&&%%fh777r/  c                    K   |                                   d{V  |                     |           d{V }|                     |dg           }|                     |d          S )aU  
        fetch the borrow interest rates of all currencies
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `borrow rate structures <https://docs.ccxt.com/#/?id=borrow-rate-structure>`
        NrR  r3  )r  r  rI  parse_borrow_rates)r,  rT  rU  rV  s       r.  fetch_cross_borrow_ratesz"digifinex.fetch_cross_borrow_ratesL  s~       !!!!!!!!!88@@@@@@@@$ 6266&&vz:::r/  c                     |                                  }|                     |d          }|                     ||          dd||                     |          |dS )Nr3  r0  i \&)r3  raterD  r  r  r@  )millisecondsrL  rM  r  )r,  r@  r3  r  r  s        r.  r8  zdigifinex.parse_borrow_ratei  sg     %%''	%%dJ77
//
HEE"Y//
 
 	
r/  c                     i }t          dt          |                    D ]O}||         }|                     ||          }|                     |          }|                     |          }|||<   P|S )Nr   )rJ  rK  rL  rM  r8  )	r,  r@  codeKeyrV  rW  r  r3  rF  
borrowRates	            r.  r<  zdigifinex.parse_borrow_rates}  s|     q#d))$$ 	& 	&A7D''g66H**844D//55J%F4LLr/  c                 n  K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )aq  
        fetch the current funding rate
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
        Nr6   z0 fetchFundingRate() supports swap contracts onlyrl  r  r2  )r  r  r    r  publicSwapGetPublicFundingRater  rI  parse_funding_rater,  rk  rT  r  r  rU  r2  s          r.  fetch_funding_ratezdigifinex.fetch_funding_rate  s       !!!!!!!!!V$$f~ 	ZDG&XXYYYVD\
 <<T[[RX=Y=YZZZZZZZZ x44&&tV444r/  c                    |                      |d          }|                     |d          }|                     |d          }i d|d|                     ||          dd dd dd d	d d
d dd d|                     |d          d|d|                     |          d|                      |d          d|d|                     |          dd dd dd S )Nrl  funding_timenext_funding_timer@  rk  	markPricer  r1  estimatedSettlePricer  r  fundingRatefunding_ratefundingTimestampfundingDatetimenextFundingRatenext_funding_ratenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetime)rL  rN  r  r  r  )r,  r}  r  r  r  nextTimestamps         r.  rF  zdigifinex.parse_funding_rate  s_    ##Ho>>%%h??	))(4GHH
H
d&&x88
 
 $	

 D
 #D
 
 
 4++HnEE
 	
 t||I66
 t//:MNN
 #M
 "4<<#>#>
 "4
  '!
" &t#
 	
r/  c           
      t  K   |t          | j        dz             |                                  d{V  |                     |          }|d         st	          | j        dz             d|d         i}|||d<   |||d<   |                     |                     ||                     d{V }|                     |d	i           }|                     |d
g           }	g }
t          dt          |	                    D ]}|	|         }| 
                    |d          }|                     |          }|                     |d          }|
                    |||                     |d          ||                     |          d           |                     |
d          }|                     ||||          S )aI  
        fetches historical funding rate prices
        :param str symbol: unified symbol of the market to fetch the funding rate history for
        :param int [since]: timestamp in ms of the earliest funding rate to fetch
        :param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
        Nz5 fetchFundingRateHistory() requires a symbol argumentr6   z7 fetchFundingRateHistory() supports swap contracts onlyrl  r  r  r  r2  funding_ratesr   r   r?  )r@  rk  rN  r  r  r  )r   r  r  r  r    %publicSwapGetPublicFundingRateHistoryr  rI  rJ  rK  rL  r  rN  rS  r  r  sort_byfilter_by_symbol_since_limit)r,  rk  r3  r  rT  r  r  rU  r2  rV  ratesrW  r9  r  symbolInnerr  sorteds                    r.  fetch_funding_rate_historyz$digifinex.fetch_funding_rate_history  s      >#DG.e$efff!!!!!!!!!V$$f~ 	aDG&__```VD\
 ).G%&$GGCCDKKPWY_D`D`aaaaaaaa  x44;;q#f++&& 	 	A1IE''o>>H**844K))%88ILL%#//v>>& LL33      e[1100NNNr/  c                 n  K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a\  
        fetch the trading fees for a market
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#tradingfee
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
        Nr6   z- fetchTradingFee() supports swap markets onlyrl  r  r2  )r  r  r   r  #privateSwapGetAccountTradingFeeRater  rI  parse_trading_feerG  s          r.  fetch_trading_feezdigifinex.fetch_trading_fee  s       !!!!!!!!!V$$f~ 	XTW'VVWWWVD\
 AA$++gW]B^B^________ x44%%dF333r/  c                     |                      |d          }|                     ||          }|||                     |d          |                     |d          d d dS )Nrl  maker_fee_ratetaker_fee_rate)r@  rk  r   r   r   r   )rL  r  r  )r,  rC  r  r  rk  s        r.  re  zdigifinex.parse_trading_fee$  sq     ##C99!!(F33%%c+;<<%%c+;<<
 
 	
r/  c                    K   |                                   d{V  |                     |          }i }d}d}|cd}t          |t                    r5t	          |          }|dk    rt          | j        dz             |d         }n|}|                     |          }|                     d||          \  }}| 	                    d|          \  }}	|d}||dk    rdnd	}
|d
         ||
<   d}|dk    s|dk    r0| 
                    |                     ||	                     d{V }nM|dk    r0|                     |                     ||	                     d{V }nt          | j        dz             |dk    rdnd}|                     ||g           }g }t          dt	          |                    D ]1}|                    |                     ||         |                     2|                     |d	|d          S )a  
        fetch all open positions
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
        Nr5  zD fetchPositions() symbols argument cannot contain more than 1 symbolr   rh   r5   r6   rl  rk  r  r4   z. fetchPositions() not support self market typer2  r'  F)r  r  rQ  rR  rK  r   r  r  r  r  r(  r  privateSwapGetAccountPositionsr&   rI  rJ  rS  parse_positionfilter_by_array_positions)r,  r  rT  r  r  r  rk  symbolsLengthr  r  r  rU  positionRequestr'  rV  rW  s                   r.  fetch_positionszdigifinex.fetch_positions7  s`      !!!!!!!!!%%g..
F'4(( ! #G 1$$$TW/u%uvvv  [[((F!??@PRXZ`aa
F >>?OQWXX
E!!J2<2F2FooXO'-d|GO$:#9#9!??GUZ@[@[\\\\\\\\HH6!!!@@WV[A\A\]]]]]]]]HHtw)YYZZZl &06%9%9&&OOHorBB	q#i..)) 	E 	EAMM$--ilFCCDDDD--fhOOOr/  c                   K   |                                   d{V  |                     |          }i }d}|                     d||          \  }}|                     d|          \  }}|d}|dk    rdnd}|d         ||<   d}	|dk    s|dk    r0|                     |                     ||                     d{V }	nM|dk    r0|                     |                     ||                     d{V }	nt          | j        d	z             |dk    rd
nd}
| 	                    |	|
g           }| 
                    |d         |          }|dk    r|S |                     |	d          |d<   |                     |	d          |d<   |S )a  
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
        fetch data on a single open contract trade position
        :param str symbol: unified market symbol of the market the position is held in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        Nrf   r5   r6   rl  rk  r  r4   z- fetchPosition() not support self market typer2  r'  r   
collateralmargin_ratemarginRatio)r  r  r  r  r(  r  rk  r&   r  rI  rl  r  )r,  rk  rT  r  r  r  r  r  r  rU  dataRequestr2  positions                r.  fetch_positionzdigifinex.fetch_position  s      !!!!!!!!!V$$
!??QWY_``
F >>PVWW
E!!J.8F.B.B//#)$< :#9#9!??GUZ@[@[\\\\\\\\HH6!!!@@WV[A\A\]]]]]]]]HHtw)XXYYYh ",v!5!5ffKxb99&&tAw77O%)%5%5h%I%IH\"&*&6&6x&O&OH]#Or/  c                    |                      |dd          }|                     ||          }|d         }|                     |d          }||dk    rdnd}nd}|                     |d          }|                     |d          }|d	k    rd
}n|dk    rd}|                     i d|dd d|d|                     |d          d|d|                     |d          d|                     |dd          d|                     |d          d|                     |d          d|                     |d          d|                     |d          d|dd d|d|                     |          d |                     |d!          d"|                     |d#          d d d |                     |d$d%          |                     |d&          d d d d'          S )(Nrl  rk  margin_modecrossedcrossisolatedr  r  go_longlonggo_shortshortr@  r  notionalr>  r  liquidationPriceliquidation_price
entryPriceavg_costentry_priceunrealizedPnlunrealized_pnl	contractsavail_positionr  rL  r  hedgedr  maintenanceMarginr5   maintenanceMarginPercentagemaint_margin_ratior  r/  margin_ratio)rr  initialMargininitialMarginPercentager  rt  r   stopLossPricetakeProfitPrice)r  r  rL  rN  safe_positionr  r  r  )r,  rv  r  r  rk  r  r  r  s           r.  rl  zdigifinex.parse_position  s   N %%hJJ!!(F33!%%h>>
!%/9%<%<:JJ"J%%h<<	&119DDZD!! #
H#
$#
 f#
 ((8<<	#

 *#
  0 0;N O O#
 $,,Xz=QQ#
 T--h8HII#
 ))(4DEE#
 D,,V^DD#
 ))(F;;#
 D#
 d#
 #
 Y//#
   !1!1(H!E!E!#
" *4+;+;HFZ+[+[##
$ !'+**8ZAQRR++HnEE!#3#
 #
 #
   	r/  r  c                   K   |t          | j        dz             |                                  d{V  |                     |          }|d         dk    rt	          | j        dz             |dk     s|dk    rt          | j        dz             |d	         |d
}|                     | j        dd          }|                     |dd|          }|'|dk    rdnd}||d<   | 	                    |ddg          }|dk    rN| 
                    |d          }|||d<   | 	                    |d          }n|                     d|dddg           |                     |                     ||                     d{V S )a'  
        set the level of leverage for a market
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#setleverage
        :param float leverage: the rate of leverage
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: either 'cross' or 'isolated', default is cross
        :param str [params.side]: either 'long' or 'short', required for isolated markets only
        :returns dict: response from the exchange
        Nz) setLeverage() requires a symbol argumentrG  r6   z+ setLeverage() supports swap contracts onlyr5  r5  z% leverage should be between 1 and 100r  )rl  r  r  defaultMarginModer{  rz  r|  ry  r  ru   r~  r  )r   r  r  r  r    r   r  r&  safe_string_lower_2r  rL  check_required_argumentprivateSwapPostAccountLeverager  )	r,  r  rk  rT  r  r  r  r  r  s	            r.  set_leveragezdigifinex.set_leverageA  s      >#DG.Y$YZZZ!!!!!!!!!V$$&>V##DG&SSTTTqLLhnnTW'NNOOO#D\ 
 
 !..t|\K^__--flDWYjkk
!'1W'<'<:J%/GM"YYv6I'JKKF####FF33D"&6622,,]D&6SZJ[\\\88Wf9U9UVVVVVVVVVr/  c                 ^  K   |                                   d{V  d}i }| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                     d{V }|                     |dg           }|                     ||||          S )aW  
        fetch the transfer history, only transfers between spot and swap accounts are supported
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#transferrecord
        :param str code: unified currency code of the currency transferred
        :param int [since]: the earliest time in ms to fetch transfers for
        :param int [limit]: the maximum number of  transfers to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
        Nr  r3  r  r  r2  )r  rM  #privateSwapGetAccountTransferRecordr  r8  parse_transfers)	r,  rF  r3  r  rT  r3  r  rU  	transferss	            r.  fetch_transferszdigifinex.fetch_transfersr  s       !!!!!!!!!..t44H"*4.GJ).G%&$GGAA$++gW]B^B^________  NN8VR88	##IxFFFr/  c                    K   |                                   d{V  |                     |           d{V }|                     |dg           }|                     |          }|                     ||d          S )a  
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#instruments
        retrieve information on the maximum leverage, for different trade sizes
        :param str[]|None symbols: a list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
        Nr2  rl  )r  r  rI  r  parse_leverage_tiers)r,  r  rT  rU  r2  s        r.  fetch_leverage_tierszdigifinex.fetch_leverage_tiers  s       !!!!!!!!!<<VDDDDDDDD< x44%%g..((wHHHr/  c                 n  K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#instrument
        retrieve information on the maximum leverage, for different trade sizes for a single market
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
        Nr6   z6 fetchMarketLeverageTiers() supports swap markets onlyrl  r  r2  )r  r  r   r  publicSwapGetPublicInstrumentr  rI  parse_market_leverage_tiersrG  s          r.  fetch_market_leverage_tiersz%digifinex.fetch_market_leverage_tiers  s       !!!!!!!!!V$$f~ 	aTW'__```VD\
 ;;DKKQW<X<XYYYYYYYY8 x44//f===r/  c                    g }|                      |di           }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                    |                     |d          |d         d |                     |d          d |                     |d          |d           |S )	Nopen_max_limitsr   rl  r5  ry  	max_limitr  )tierr3  minNotionalmaxNotionalmaintenanceMarginRatemaxLeverager@  )rI  rJ  rK  rL  r  rS  rL  r  )r,  r@  r  tiersbracketsrW  r  r  s           r.  r  z%digifinex.parse_market_leverage_tiers  s    2 ??4):B??q#h--(( 	 	AA;D''o>>H%%h//FLLA"8,##//kBB)-#//jAA      r/  c                 &   |                      | j        d          }|                     |dd          }d}t          t          |                               |||          \  }}||dk    rt          | j        dz             n|dk    s|du rd}||gS )a\  
         * @ignore
        marginMode specified by params["marginMode"], self.options["marginMode"], self.options["defaultMarginMode"], params["margin"] = True or self.options["defaultType"] = 'margin'
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Array: the marginMode in lowercase
        r  r5   FNr{  z only cross margin is supportedT)rL  r&  r}  r)  r.   r  r&   r  )r,  
methodNamerT  defaultValuer  isMarginr  r-  s          r.  r  z'digifinex.handle_margin_mode_and_params  s     &&t|]CC>>&(E::
"9d33QQR\^dfrss
F!W$$"47-N#NOOO % x''X-=-=$
F##r/  codesc                    K   |                                   d{V  |                     |           d{V }|                     |d          }|                     ||          S )a  
        fetch deposit and withdraw fees
        :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-currency-deposit-and-withdrawal-information
        :param str[]|None codes: not used by fetchDepositWithdrawFees()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
        Nr2  )r  rH  r8  parse_deposit_withdraw_fees)r,  r  rT  rU  r2  s        r.  fetch_deposit_withdraw_feesz%digifinex.fetch_deposit_withdraw_fees/  s|       !!!!!!!!!55f========< ~~h////e<<<r/  c                    i }|                      |          }t          dt          |                    D ]'}||         }|                     |d          }|                     |          }||                     ||          r|                     ||          }	|	#|                     i           ||<   g ||         d<   ||         d                             |           |                     |d          }
|                     |d          }||dnd d}d d d}|
+| 	                    |
          }||d||         d	         |<   |||         d
<   |||         d<   )t          |                                          }t          dt          |                    D ]>}||         }|                     |          }|                     ||         |          ||<   ?|S )Nr   r3  r@  r:  r7  F)rC  r   )rz   r?  r  rz   r?  )market_codesrJ  rK  rL  rM  in_arrayrI  deposit_withdraw_feerS  rP  rR  keysr3  $assign_default_deposit_withdraw_fees)r,  rU  r  currencyIdKeydepositWithdrawFeesrW  r9  r  rF  depositWithdrawFeer`  withdrawFeewithdrawResultdepositResultra  depositWithdrawCodesr3  s                    r.  r  z%digifinex.parse_deposit_withdraw_feesY  s,   6 !!!%((q#h--(( 	I 	IAQKE))%<<J**:66D4==u#=#=%)__5H$%O%O"%-040I0I"0M0M'-8:'-f5#D)&188??? ,,UG<<	"ooe5GHH&,7,C%%$" "
  "&! ! ("&"9"9)"D"DK$2#0J J'-j9+FF
 =K'-j9;H'-i8#$7$<$<$>$>??q#23344 	w 	wA'*D}}T**H(,(Q(QRefjRkmu(v(v%%""r/  c                    K   |                      |d          }|                     d|dddg           |                     ||d|           d{V S )a  
        add margin to a position
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
        :param str symbol: unified market symbol
        :param float amount: amount of margin to add
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str params['side']: the position side: 'long' or 'short'
        :returns dict: a `margin structure <https://docs.ccxt.com/#/?id=margin-structure>`
        r  r9   r~  r  r5  NrL  r  modify_margin_helperr,  rk  r>  rT  r  s        r.  
add_marginzdigifinex.add_margin  sh       //$$[$@QRRR..vvq&IIIIIIIIIr/  c                    K   |                      |d          }|                     d|dddg           |                     ||d|           d{V S )a  
        remove margin from a position
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
        :param str symbol: unified market symbol
        :param float amount: the amount of margin to remove
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str params['side']: the position side: 'long' or 'short'
        :returns dict: a `margin structure <https://docs.ccxt.com/#/?id=margin-structure>`
        r  rt   r~  r  r<  Nr  r  s        r.  reduce_marginzdigifinex.reduce_margin  sh       //$$^T6FGCTUUU..vvq&IIIIIIIIIr/  c                   K   |                                   d {V  |                     |d          }|                     |          }|d         |                     |          ||d}|                     |                     ||                     d {V }|                     |d          }	|	dk    rdnd}
|                     |di           }|                     |                     ||          d	|
i          S )
Nr  r  )rl  r>  rG  r  rF  r   r+  r  r2  r-  )	r  rL  r  r  $privateSwapPostAccountPositionMarginr  rN  rI  parse_margin_modification)r,  rk  r>  rG  rT  r  r  r  rU  rF  r-  r2  s               r.  r  zdigifinex.modify_margin_helper  s      !!!!!!!!!//V$$#D\++F33	
 
 BB4;;wX^C_C_````````   622!))(x44{{499$GGfJ
   	r/  c                     |                      |d          }|                     |d          }||                     ||d d          |dk    rdndd|                     |d          d |d	         d d d d

S )Nrl  rG  r6   r5  addreducer|  r>  ry  )
r@  rk  rG  r  r>  r  rF  r-  r  r  )rL  rN  r  r  )r,  r2  r  r  rawTypes        r.  r  z#digifinex.parse_margin_modification  s     ##D/::##D&11&&xvFF%llEE$&&tX668$
 
 	
r/  c                   K   |                                   d{V  i }|                     d||          \  }}d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                     d{V }|                     |dg           }|                     ||||          S )a  
        fetch the history of funding payments paid and received on self account
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#funding-fee
        :param str [symbol]: unified market symbol
        :param int [since]: the earliest time in ms to fetch funding history for
        :param int [limit]: the maximum number of funding history structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest funding payment
        :returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
        Nend_timestampr  rl  r  r  r2  )r  handle_until_optionr  privateSwapGetAccountFundingFeer  r8  parse_incomes)	r,  rk  r3  r  rT  r  r  rU  r2  s	            r.  fetch_funding_historyzdigifinex.fetch_funding_history  s       !!!!!!!!!22?GVTT[[((F'-d|GO$$GG).G%&==dkk'SY>Z>Z[[[[[[[[ ~~h33!!$u===r/  c           
      :   |                      |d          }|                      |d          }|                     |d          }||                     ||d d          |                     |          ||                     |          d |                     |d          dS )Nrl  r3  r  r6   r>  )r@  rk  rF  r  r  r  r>  )rL  rN  r  rM  r  r  )r,  incomer  r  r  r  s         r.  parse_incomezdigifinex.parse_income  s     ##FO<<%%fj99
%%fk::	&&xvFF++J77"Y//&&vx88
 
 	
r/  r  c                 B  K   |t          | j        dz             |                                  d{V  |                     |          }|                                }|dk    rd}|d         |d}|                     |                     ||                     d{V S )au  
        set margin mode to 'cross' or 'isolated'
        :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmode
        :param str marginMode: 'cross' or 'isolated'
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        Nz+ setMarginMode() requires a symbol argumentr{  rz  r  )rl  ry  )r   r  r  r  lower"privateSwapPostAccountPositionModer  )r,  r  rk  rT  r  r  s         r.  set_margin_modezdigifinex.set_margin_mode(  s       >#DG.[$[\\\!!!!!!!!!V$$%%''
  "J#D\%
 
 <<T[[RX=Y=YZZZZZZZZZr/  GETc                    |d         dk    }|d         }|dk    rdnd}	d|                      ||          z   }
|	|
z   }| j        d         d	         |z   }|                     ||                     |                    }d }|r!|	dk    r|d
k    rt	          j        |          }n(|                     |                     |                    }|rd }d }|	dk    rFt          | 	                                          }||z   |z   }|dk    r|r|d|z   z  }n/|d
k    r||z  }n#t          | 
                                          }|}|                     |                     |          |                     | j                  t          j                  }|dk    r|r|d|z   z  }n|d
k    rddi}|r|}| j        ||d}n
|r|d|z   z  }||||dS )Nr   r   r5  r4   z/v3z/swap/v2rs  r   r   POSTr  ?zContent-Typez!application/x-www-form-urlencoded)z
ACCESS-KEYzACCESS-SIGNzACCESS-TIMESTAMP)r0  rd  bodyheaders)implode_paramsr#  r  extract_paramsrb  dumps	urlencodekeysortr  r@  noncehmacencodesecrethashlibsha256apiKey)r,  pathr   rd  rT  r  r  signedendpointpathPartr  payloadr0  r  
urlencodedauthr  	signatures                     r.  signzdigifinex.sign>  s(   Q9$q6%//55j++D&999W$iv&0		&$"5"5d";";<<
 	=x:--Ff4D4DF++JJU(;(;<<J 	(DE:%%D--//00v~/U??! 1j 00v%%J&DDJJLL))!		$++d"3"3T[[5M5Mw~^^I ,3++C6!!"$G  &%D"k($) GG  (sZ''fdwOOOr/  c
                     |sd S |                      |d          }
|
dk    s|
dk    rd S | j        dz   |z   }|
t          |          t          |g}|                     | j        d         |
|          \  }} ||          )NrF  r  200 r   )rL  r  r!   r   rI  r%  )r,  
statusCode
statusTextr0  rd  responseHeadersresponseBodyrU  requestHeadersrequestBodyrF  feedbackunknownErrorExceptionClassmessages                  r.  handle_errorszdigifinex.handle_errorsm  s     	4&11CKKTU]]47S=</<h'''%x0"&//$/'2JDR^"_"_nW%%%r/  r  )NN)f__name__
__module____qualname__r*  r   rb  r   r
   rg  re  rf  r   r  r  r  r   r   r  r   r   r  r   r  r  r   r%  r)  r2  r:  rR  rA  rU  r   r   floatr   r]  r   rk  rW  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   ry   rz   r-  r6  r:  r=  r8  r<  rH  rF  rb  r   rf  re  rp  rw  rl  r  r  r  r  r  r  r  r  r	   r  r  r  r  r  r  r  r  r	  __classcell__)r-  s   @r.  r.   r.   "   s       K K K K KZ
 -/ [ [: [ [ [ [z *, 
3 
3V 
3 
3 
3 
3 -/ X X X Xt -/ I I I IV%) %) %) %) %)N *, =, =, =, =, =, =,~ @DB EM EMS EM EMS\ EM EM EM EMN 6:" QG QG7 QG QG QG QG QGf 68 I1 I1 I1F I1 I1 I1 I1VF F6 FV F F F FP~ ~ ~5 ~ ~ ~ ~@ ') < < < < )+ 
 
 
 
. <@d[] A= A= A=S A= A=bfglbm A= A= A= A=F  4    < 8<$]ajl FK FK FKC FKWZ FKquvzq{ FK FK FK FKP mqy{ 4 4 4I 4Y 4X] 4fi 4 4 4 4l FH Q1 Q1$|*< Q1 Q1 Q1 Q1f os{} Y, Y,3 Y,i Y,y Y,Z_ Y,hk Y, Y, Y, Y,v XZ T Tc T T T T T  9=R ? ?S ?# ? ? ? ?B 6:" ! !s ! ! ! !F: : :C C C5 C C C CJ 59tZ^gi \= \=c \= \=TW \=nrsxny \= \= \= \=| 04$UYbd ]= ]= ]=C ]=s ]=imnsit ]= ]= ]= ]=~ 8<B W/ W/C W/ W/ W/ W/ W/r 37TX\eg X= X=C X=s X=RU X= X= X= X=t3 3 3,
 ,
 ,
 ,
 ,
 ,
\ .2SW`b OA OAs OA# OAS OA OA OA OAb
 
h 
 
 
 
* =?      B BFTXgktv (U (U3 (Uc (Uad (U (U (U (UT 04$UYbd 	\ 	\ 	\C 	\s 	\imnyiz 	\ 	\ 	\ 	\ 37TX\eg 	_ 	_C 	_s 	_RU 	_lpq|l} 	_ 	_ 	_ 	_	: 	: 	:=
 =
x =
; =
 =
 =
 =
~: : :&
 &
 &
 &
 &
 &
P ac 7 73 7 7C 7TW 7gt 7 7 7 7: EIQS : :3 : : : : :> 7;$]apt} Q Q QC QWZ Qjm Q Q Q QB
 
& 
 
 
 
B ?A #8 #8# #8 #8 #8 #8J 57 ; ; ; ;:
 
 
 
 
 
(  $ <> 5 5s 5 5 5 5>
 
6 
 
 
 
B >BPTcgpr 6O 6Os 6O# 6O]` 6O 6O 6O 6Op ;= 4 4c 4AT 4 4 4 4:
 
V 
?R 
 
 
 
& 8<B `P `PW `P `P `P `PD 8: U U3 U U U UnO Ov O O O Ob ?C2 $W $W3 $W $W $W $W $Wb 154VZce %G %G# %GS %GPS %G %G %G %GN =A )I )I' )I )I )I )IV EG ,> ,> ,> ,> ,> ,>\( ( ( ( ( (T @BPT $ $ $ $ $ $& BFb (= (=w (= (= (= (=T?# ?# ?# ?#B <> J Js JBT J J J J ?A J J# JEW J J J J LN   Rd    :
 
f 
HZ 
 
 
 
0 9=4^bkm %> %># %>S %>X[ %> %> %> %>N
 
6 
 
 
 
, DHPR [ [ [S [ [ [ [,  b$T -P -P -P -P^& & & & & & &r/  r.   )5 ccxt.async_support.base.exchanger   ccxt.abstract.digifinexr   r  r  rb  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   ccxt.base.decimal_to_precisionr+   ccxt.base.preciser,   r.    r/  r.  <module>r     s   6 5 5 5 5 5 / / / / / /    n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n  n       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & ( ( ( ( ( ( . . . . . . + + + + + + ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) ) ) ) ) ) ) + + + + + + . . . . . . ) ) ) ) ) ) 4 4 4 4 4 4 % % % % % %V=& V=& V=& V=& V=&+ V=& V=& V=& V=& V=&r/  