
    !:h                       d dl mZ d dlm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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'm0Z0 d dl'm1Z1 d dl'm2Z2 d dl'm3Z3 d dl'm4Z4 d dl'm5Z5 d dl'm6Z6 d dl'm7Z7 d dl'm8Z8 d dl9m:Z: d dl;m<Z<  G d dee      Z=y)    )Exchange)ImplicitAPIN)AnyBalancesBorrowInterestCrossBorrowRateCrossBorrowRates
CurrenciesCurrencyDepositAddressIntLedgerEntryLeverageTierLeverageTiersMarginModificationMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateTradeTradingFeeInterfaceTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)NotSupported)NetworkError)DDoSProtection)RateLimitExceeded)InvalidNonce)BadResponse)	TICK_SIZE)Precisec                       e Zd Zdef 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dvdededefdZdvdededefdZi fdefdZi fdZd	d	i fd
edededee   fdZdvd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( Z-d	i fd
e+fd)Z.d*e+fd+Z/dvd,edede0fd-Z1d	d	d	i fd
e+dededee0   fd.Z2d	d	d	i fd
e+dededee0   fd/Z3d	i fd&ed
e+fd0Z4d	d	d	i fd
e+dedefd1Z5d2 Z6dvd3ed4e7de8fd5Z9d	d	d	i fd6e+dededee8   fd7Z:dvd4e7de;fd8Z<i fd6ede;fd9Z=d	d	d	i fd6e+dedefd:Z>d	d	d	i fd6e+dededee?   fd;Z@d	d	d	i fd6e+dededee?   fd<ZAd*e+fd=ZBdvd>ed4e7de?fd?ZCd*e+de+fd@ZDdvdAed4e7deEfdBZFi fd6ede$dCedDedeEf
dEZGd	i fd6ede$dFede?fdGZHd	d	d	d	i fd6e+d
e+dededeeI   f
dHZJdvdIededeIfdJZKi fd6edeLfdKZMi fdeNfdLZOdvd4e7fdMZPdN ZQi fd
edeRfdOZSi fd
edeRfdPZTdvdedeRfdQZUdR ZVd	d	d	i fd
e+dedefdSZWi fd
edeXfdTZYdvdUededeXfdVZZd	i fdedee[   fdWZ\i fd
efdXZ]dvdYedefdZZ^d	i fd[ed
e+fd\Z_d	d	d	i fd6e+dededeeE   fd]Z`d	i fdedeafd^Zbi fd
edeec   fd_Zddvdedeec   fd`Zei d	f fda	Zfd	i fdbefdcZgdwddZhi fd
ede$deifdeZji fd
ede$deifdfZki fd
edeifdgZldvdhededeifdiZmd	d	d	i fd
e+dedefdjZndvdefdkZod	i fdled
e+fdmZpg dni d	d	fdoZqdperdqedredsedtef
duZs xZtS )x	digifinexreturnc                    | j                  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d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dddd dddd dddddjddddddddkdldmiddndodpddqddddddrdd ddddsddtdodpddddud dvdnidw	dxdyidydzdd{ddtdodod|d}diddtd~ddoddvdtiddxdidxdidd d ddddd| j	                  d      | j	                  d      dit
        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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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 (  Nr8   	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fetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervals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)r?   rA   )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/newr   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/transferz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)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedselfTradePreventiontrailingleveragemarketBuyByCostmarketBuyRequiresPriceicebergmax
     i    )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   
marketTyper   )r   r   r   r   r   d   )r   r   r   r   r   r   r   r   )	sandboxrJ   rK   ro   rr   rq   rt   fetchClosedOrdersrp   extendsdefault   )r   r   )r   r   r   r   r   )r   r   )r   r   )r   rK   ro   rr   rq   rt   rp   forDerivatives)linearinverse)r   r?   r   rA   rB   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)r?   r@   otc23)r?   r@   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   featuresr   precisionMode
exceptionsoptionscommonCurrencies)deep_extendsuperr8   describeparse_numberr5   r)   r%   r1   r&   r3   r0   r'   r-   r+   r*   r$   r,   r2   )self	__class__s    H/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/digifinex.pyr`  zdigifinex.describe#   s1   i ? ALLL $L 	L
 %L %L TL tL L /L ,UL 0L tL L &tL  (!L" '#L$ (%L& "5'L( )L* &t+L, +E-L. )%/L0 '1L2 (3L4 "45L6 &t7L8 (9L: 1%;L<  =L> *:?L@ +DALB &tCLD 'ELF (GLH #DILJ *4KLL $UMLN "5OLP *5QLR +ESLT tULV  WLX %dYLZ "5[L\ +D]L^ _L` !%aLb  cLd deLf "4gLh diLj !$kLl tmLn  oLp $UqLr !$sLt %euLv )%wLx tyLz t{L| }L~ TL@ tALB "4CLD #EELF !$GLH #DILJ !%#"!%#(  WL\ 
 ; 30 r\   $   %"J 2!5'R !"SLIqh  %&*(-,0,1).+06:#(#("&#(	( #(/4$)$)+027#()$. r% '+!$$*%'*/& '+#($)&**.# '+!%#($)*/( '+!$$*%'#($)*/$ *.#u=~ y  )!&+%
 ',!$$*%+	& %e# ',!$(
 ',$*$
  #/#: "#3 "#3 	 ##KiV !%"&!..w7!..w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$ /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F /0YZ(*UV.0DE(*?@.0cd.0BC+-MN,  /L  M,._`+-RS/1yz.0ST')\])+>?a1dg5n  &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",\ *%&!eyD
 y y	    c                    | j                  |      }| j                  |dg       }i }t        dt        |            D ]  }||   }| j	                  |d      }| j                  |      }| j                  |dd      }	| j                  |dd      }
|	dkD  }|
dkD  }|xr |}| j	                  |d      }| j	                  |d      }| j	                  |d	      }| j                  |      }| j                  |      }| j                  |      }t        j                  |t        j                  ||            }| j                  |      }| j	                  |d
      }d}|| j                  |      }||||||||ddd|dd|dddd	}||v r||   d   }t        |t              r|j                  |       n||g}|r,d||   d<   t        ||   d   d   d   |      ||   d   d   d<   |r,d||   d<   t        ||   d   d   d   |      ||   d   d   d<   |r7d||   d<   n.|||dd|||| j                  |      dddd|dd|dddi d||<   ||||   d   |<   nD|||   d<   | j                  |      ||   d<   |||   d<   |||   d<   ddd|dd|ddd||   d<   ||   d   |nt        ||   d   |      ||   d<    |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
        datar   currencydeposit_status   withdraw_statusmin_withdraw_feemin_withdraw_amountmin_deposit_amountchainNminr   )amountr   deposit)	inforQ  networkactivefee	precisionrs  r   limitsrt  Tr   ry  rq  rs  rv  )rQ  codert  typerR  rv  rs  r   rw  rx  ry  rH  rH  rw  rx  )publicSpotGetCurrencies
safe_valuerangelensafe_stringsafe_currency_codesafe_integerra  r6   
string_minnetwork_id_to_code
isinstancelistappendrq  r   )rb  paramsresponserg  resultirh  rQ  rz  depositStatuswithdrawStatusrs  r   rv  	feeStringminWithdrawStringminDepositString
minDepositminWithdrawrw  minFoundPrecisionrx  	networkIdnetworkCoderu  resultCodeInfos                             rd  fetch_currencieszdigifinex.fetch_currencies  s    //7L x4q#d)$ m	HAAwH!!(J7B**2.D --h8H!LM!..x9JANN#a'G%)H)F((3EFI $ 0 0;P Q#//:NO**+;<J++,=>K##I.C ' 2 29g>P>PQact>u v))*;<I((7;IK$"55i@ & &"$  $#
  +#!
  *# G0 v~!'f!5nd3"))(3&4h%?N/3F4L,@CF4LQYDZ[eDfglDmoz@{F4L*:6u=.2F4L+?B6$<PXCYZcCdejCkmw?xF4L*95e<-1F4L*  $  $& (,,Y7!% $(#'#
 $/#'%
 $.#'$ !#3 t6 $6=tZ(3)/tX&&*&7&7	&BtU#*1tY'+3tZ(  $#
  +#!
  *# *tX& 7=Tl;6O6W	^abhimbnozb{  ~G  _HF4L%[m	H\ re  c                     | j                  | j                  di       }| j                  |dd      }|dk(  r| j                  |      S | j	                  |      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
        rm   methodfetch_markets_v2)r}  r\  r  r  fetch_markets_v1)rb  r  r\  r  s       rd  fetch_marketszdigifinex.fetch_markets}  sZ     //$,,C!!'85GH''((00$$V,,re  c                    | j                  | j                  d      }| j                  d|      \  }}g }|!|j                  | j	                  |             n |j                  | j                  |             |j                  | j                  |             |}|d   }|d   }| j                  |dg       }	| j                  |dg       }
| j                  |	|
      }g }t        dt        |            D ]  }||   }| j                  |dd      }| j                  |d	d
      }| j                  |dd      }| j                  |d      }| j                  |      }| j                  |      }| j                  |      }| j                  |dd      }|dk(  rdnd}|d u }| }|dnd }|dz   |z   }d }d }|r>d}|dz   |z   dz   |z   }| j                  |d      }|sdnd}| j                  |d      }|rd}|j                  i d|d|d|d|d|d|d|d|d|d|d|d|d dd!dd"|rdndd#|d$||| j                  |d%      d d d d | j                  | j!                  | j                  |d&                  | j                  | j!                  | j                  |d'                  d(d d d)| j#                  |d*d+      d d)| j                  |d,      d d)| j                  |d-      d d)d.d |d/
        |S )0NrD  fetchMarketsV2r   rj  symbol_listrg  symbolinstrument_id
base_assetbase_currencyquote_assetquote_currencyclear_currencyis_allowr@   r?   T/rA   :
is_inverseF	isTradingrQ  basequotesettlebaseIdquoteIdsettleIdr{  rB   rC   rv  contractr   contract_valueamount_precisionprice_precision)rr  pricerp  minimum_amountmin_order_amount	tick_sizeminimum_valuer   rr  r  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionTyperx  ry  createdrt  )r  r\  handle_margin_mode_and_paramsr  publicSpotGetMarginSymbolspublicSpotGetTradesSymbolspublicSwapGetPublicInstrumentsr}  array_concatr~  r  safe_string_2r  r  safe_numberra  parse_precisionsafe_number_2)rb  r  rD  r   querypromisesRawpromisesspotMarketsswapMarketsspotDataswapDatar  r  r  marketrQ  r  r  r  r  r  r  	isAllowedr{  r?   rA   r@   r  	isInverseisLinearr  s                                  rd  r  zdigifinex.fetch_markets_v2  s   &&t||]C >>?OQWX
E!t>>uEFt>>uEF4>>vFGqkqkj ??;rB??;;$$Xx8q#h-( S	Aa[F##FHoFB''oNF((@PQG''0@AH**62D++G4E,,X6F ))&*a@I +x 78fDT>D8D(4T4FCZ%'FIHe+c1F: OOFLA	(14 OOFK@	 !IMM 0b0&0 0 	0
 &0 &0 70 H0 0 0 &0 0 %0 %0 )$0  D!0" (#0$ % $ 0 09I J"&""//0D0DTEUEUV\^pEq0rs!..t/C/CDDTDTU[]nDo/pq  $#!
  $11&:JL^_#
  $//D#
  $//H#$  _0 0GS	h re  c                    | j                  |      }| j                  |dg       }g }t        dt        |            D ]6  }||   }| j	                  |d      }|j                  d      \  }}	| j                  |      }
| j                  |	      }|j                  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 | j                  | j                  | j	                  |d                  | j                  | j                  | j	                  |d                  dd d d| j                  |d      d dd d d| j                  |d      d dd|d 	       9 |S )!Nrg  r   r  _rQ  r  r  r  r  r  r  r  r  r{  r?   Tr@   rA   FrB   rC   rv  r  r   r  volume_precision)r  rr  rp  
min_volume
min_amountr  )	r   r  r  r  r  r  rx  ry  rt  )publicSpotGetMarketsr}  r~  r  r  splitr  r  ra  r  r  )rb  r  r  r   r  r  r  rQ  r  r  r  r  s               rd  r  zdigifinex.fetch_markets_v1#  sB   ,,V4  //(FB7q#g,' 5	AQZF!!&(3B hhsmOFG**62D++G4EMM /b/$*u,/ / 	/
 $/ &/ 7/ D/ / / $/ / %/ %/ $/  E!/" $#/$   $"&"!..t/C/CDDTDTU[]nDo/pq"//0D0DTEUEUV\^pEq0rs  $#!
  $//E#
  $#
  $//E#$ ]/ /5	l re  c                 l   d|i}t        dt        |            D ]  }||   }| j                  |d      }| j                  |      }| j	                         }| j                  |dd      }| j                  |dd      }	||d<   t        j                  |	|      |d<   |	|d<   |||<    | j                  |      S )	Nrt  r   rh  freeavail_balancetotalequityused)	r~  r  r  r  accountr  r6   
string_subsafe_balance)
rb  r  r  r  balance
currencyIdrz  r  r  r  s
             rd  parse_balancezdigifinex.parse_balancen  s    2 )q#h-( 
	#AqkG))':>J**:6DllnG%%gvGD&&wBE"GFO%00=GFO$GG"F4L
	#   ((re  c                    | j                          d}| j                  dd|      \  }}| j                  d|      \  }}d}||dk(  rd}| j                  |      }nF|dk(  r| j	                  |      }n/|dk(  r| j                  |      }nt        | j                  dz         |dk(  rdnd}| j                  ||g       }| j                  |      S )	a  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-account-assets
        https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
        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>`
        NrQ   r@   r?   rA   z, fetchBalance() not support self market typerg  r  )
load_marketshandle_market_type_and_paramsr  privateSpotGetMarginAssetsprivateSpotGetSpotAssetsprivateSwapGetAccountBalancer/   rQ  r}  r  )rb  r  r   r   r  r  balanceRequestbalancess           rd  fetch_balancezdigifinex.fetch_balance  s     	
!??PTV\]
F >>~vV
E!Z8%;!J66u=H6!44U;H6!88?Htww)WWXXJ %/&$8v??8^R@!!(++re  Nr  r   c                    | j                          | j                  |      }| j                  d||      \  }}i }|||d<   d}|dk(  r*|d   |d<   | j                  | j	                  ||            }n)|d   |d<   | j                  | j	                  ||            }d}	d}
|dk(  r&| j                  |di       }
| j                  |
d	      }	n|}
| j                  |d
      }	| j                  |
|d   |	      S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-orderbook
        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
        rs   Nr   rA   rQ  r  r  rg  	timestampdate)
r  r  r  publicSwapGetPublicDepthextendpublicSpotGetOrderBookr}  r  safe_timestampparse_order_book)rb  r  r   r  r  r   r  requestr  r  	orderBooks              rd  fetch_order_bookzdigifinex.fetch_order_book  s    	V$ >>?OQWY_`
E$GG'-d|GO$44T[[%5PQH &tGH224;;w3NOHN 		&"=I)))[AI I++Hf=I$$Yx0@)LLre  symbolsc                 h   | j                          | j                  |      }| j                  |d      }d}|| j                  |      }d}| j	                  d||      \  }}i }d}|dk(  r"| j                  | j                  ||            }n!| j                  | j                  ||            }i }| j                  |ddg       }	| j                  |d      }
t        dt        |	            D ]4  }| j                  d|
i|	|         }| j                  |      }|d   }|||<   6 | j                  |d|      S )	a^  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
        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>`
        r   Nr|   rA   r   rg  r  r  )r  market_symbolsr  r  r  publicSwapGetPublicTickersr  publicSpotGetTickersafe_value_2r  r~  r  parse_tickerfilter_by_array_tickers)rb  r  r  firstr  r{  r  r  r  tickersr  r  	rawTickerr   r  s                  rd  fetch_tickerszdigifinex.fetch_tickers  sU    	%%g.  !,[['F99.&RXYf6>66t{{7F7STH//GV0LMHb ##HhC  62q#g,' 	$A%qzI &&y1FH%F#F6N	$ ++FHgFFre  c                    | j                          | j                  |      }i }d}|d   r*|d   |d<   | j                  | j                  ||            }n)|d   |d<   | j	                  | j                  ||            }| j                  |d      }| j                  |dg       }| j                  |di       }| j                  |d	i       }	d}
|d   r|}
n| j                  d|i|	      }
| j                  |
|      S )
a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
        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>`
        NrA   rQ  r  r  r  r   rg  r   )r  r  publicSwapGetPublicTickerr  r  r  r}  r  )rb  r  r  r  r  r  r  r  rg  firstTickerr  s              rd  fetch_tickerzdigifinex.fetch_tickert  s    	V$&>'-d|GO$55dkk'66RSH &tGH//GV0LMH\   62//(Hb9x4oogq"5&>F[[&$=F  00re  r   r  c           	      B   | j                  |d      }|dnd}| j                  |dd      }| j                  ||d |      }| j                  ||d |      }| j	                  |d      }|d   r| j                  |d      }| j                  |d	      }| j                  i d|d|d
| j                  |      d| j                  |dd      d| j                  |dd      d| j                  |dd      d| j                  |d      d| j                  |dd      d| j                  |d      dd d| j                  |d      d|d	|dd dd d| j                  |dd       d!d | j                  |d"d#      | j                  |d$      | j                  |d%      ||d&|      S )'Nindex_pricer  r?   r  r  r  rA   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
mark_price)
baseVolumequoteVolume	markPrice
indexPricert  )
r  safe_string_upper_2safe_symbolsafe_marketr  r  r  safe_tickeriso8601r  )	rb  r   r  r/  r   marketIdr  r  r  s	            rd  r  zdigifinex.parse_ticker  s@   P %%fm<
$.$:Z
++FHoN!!(FD*E!!(FD*E''7	&>))&+>I/ !
f!
!
 Y/!
 D&&vvzB	!

 4%%feY?!
 4%%feZ@!
 ))&/B!
 4%%ffjA!
 ))&/B!
 D!
 D$$VZ8!
 T!
 D!
 T!
 d!
  $,,VX?UV!!
" t#!
$ ,,VULI++FJ?))&,?$-!
. / 	re  tradec                 "   | j                  |dd      }| j                  |d      }| j                  |d      }| j                  |g d      }| j                  |dd      }| j	                  ||      }|| j                  |      }| j                  |dd	      }	| j                  |d
d      }
d }d }|d
   dk(  r| j                  |d      }	| j                  |d      }| j                  |d      }| j                  |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}
nx|
dk(  s|dk(  rd}
nk|
dk(  s|dk(  rd}
n^|
dk(  s|dk(  rTd}
nQ|
j                  d      }| j                  |d      }
| j                  |d      }|d}| j                  |d      }|rdnd}d }| j                  |d      }|,| j                  |d       }d }|| j                  |      }||d!}| j                  |||	| j                  |	      ||||
||d ||d"|      S )#NrQ  trade_idorder_idr  )rr  volumesizer  r  r  r  r{  siderA   
trade_time
order_type
match_role	direction0r   r   r   r  r   r  r  r  4r  r   rj  is_makerrw  fee_currency)r  rh  )rQ  rt  r  r  r  r{  orderr<  r  rr  r  takerOrMakerrw  )r  r  safe_string_nr0  r1  r2  safe_timestamp_2r  r  r}  r  
safe_trader4  )rb  r6  r  rQ  orderIdpriceStringamountStringr5  r  r  r<  r{  rF  	orderType	tradeRoler@  partsisMakerrw  feeCostStringfeeCurrencyIdfeeCurrencyCodes                         rd  parse_tradezdigifinex.parse_trade  s   p tZ8""5*5&&ug6))%1MN++E8_M!!(F3>%%h/F))%E	!!%8&>V#))%>I((=I((=I((<I$#,#3w$C&c!&#c!1#+9#3#+9#3#+9#3JJsOE##E1-D##E1-D|ooeZ8G&-77L((6$ ,,UNCM"O("&"9"9-"H%+C "Y/ "( 
  	re  c                 H    | j                  |      }| j                  |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
        server_time)publicSpotGetTimer  )rb  r  r  s      rd  
fetch_timezdigifinex.fetch_time  s)     ))&1 ""8];;re  c                 j    | j                  |      }| j                  |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>`
        rz  r   okmaintenanceN)statusupdatedetaurlrt  )publicSpotGetPingr  )rb  r  r  rz  r\  s        rd  fetch_statuszdigifinex.fetch_status  sN     ))&1   62!)-
 	
re  sincec                 z   | j                          | j                  |      }i }||d   rt        |d      n||d<   d}|d   r*|d   |d<   | j                  | j	                  ||            }n)|d   |d<   | j                  | j	                  ||            }| j                  |dg       }| j                  ||||      S )	at  
        get the list of most recent trades for a particular symbol

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-recent-trades
        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>`
        NrA   r   r   rQ  r  r  rg  )r  r  rq  publicSwapGetPublicTradesr  publicSpotGetTrades	safe_listparse_trades)	rb  r  rb  r   r  r  r  r  rg  s	            rd  fetch_tradeszdigifinex.fetch_trades  s     	V$28.s5#eGG&>'-d|GO$55dkk'66RSH &tGH//GV0LMHT ~~h3  vue<<re  c           	         |d   rh| j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )NrA   r   rj              )r  r  r  )rb  ohlcvr  s      rd  parse_ohlcvzdigifinex.parse_ohlcv  s     &>!!%+  *  *  *  *  *  ##E1-  *  *  *  *  * re  r   c                    | j                          | j                  |      }i }d}|d   rA|d   |d<   ||d<   |t        |d      |d<   | j                  | j	                  ||            }n%| j                  |d      }	|d   |d	<   | j                  | j                  ||      |d
<   |}
| j                  |      }|
)||	%|	|	n| j                         }||nd}|||z  dz  z
  }
|
x| j                  |
dz        }
|
|d<   ||	[|	A| j                  |	dz        }|%| j                  |
||z        }t        ||      |d<   n||d<   n| j                  |
||z        |d<   | j                  |d      }| j                  | j	                  ||            }d}|d   r'| j                  |di       }| j                  |dg       }n| j                  |dg       }| j                  |||||      S )a8  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-candles-data
        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
        :param int [params.until]: timestamp in ms of the latest candle to fetch
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        NrA   rQ  r  granularityr   r   untilr  period     
start_timeend_timerg  candles)r  r  rq  publicSwapGetPublicCandlesr  r  r  rW  parse_timeframemillisecondsparse_to_intsumomitpublicSpotGetKliner}  parse_ohlcvs)rb  r  	timeframerb  r   r  r  r  r  rr  	startTimedurationendTime
startLimit
endByUntil
endByLimitrx  rg  s                     rd  fetch_ohlcvzdigifinex.fetch_ohlcv  s2    	V$&>'-d|GO$%.GM" #&uc? 66t{{7F7STH%%fg6E &tGH $ 0 0)Y WGHI++I6H %5+<(-(9e@Q@Q@SG+0+<3J ':+@4+G HI$ --i$.>?	(1%%5+<(%)%6%6ut|%D
 ,)-)UX=M)NJ25j*2MGJ/2<GJ/.2hhy%(BR.S
+YYvw/F..t{{7F/KLH8 &>??8VR8DoodIr:Gooh;G  &)UEJJre  r{  r<  rr  r  c                 z   | j                          | j                  |      }| j                  d|      }|d   }	| j                  ||||||      }
d}|d   r| j	                  |
      }n%|	| j                  |
      }n| j                  |
      }| j                  ||      }|d   |d<   ||d<   ||d<   ||d<   ||d	<   |S )
a  
        create a trade order

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
        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 fulfilled, 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>`
        rJ   r   NrA   r  r{  r<  rr  r  )r  r  r  create_order_requestprivateSwapPostTradeOrderPlaceprivateSpotPostMarginOrderNewprivateSpotPostSpotOrderNewparse_order)rb  r  r{  r<  rr  r  r  r  marginResultr   r  r  rE  s                rd  create_orderzdigifinex.create_orderj  s    ( 	V$99-P!!_
++FD$vV&>::7CH%==gF;;GD    62 *hff hgre  ordersc           	      n   | j                          g }d}d}t        dt        |            D ]  }||   }| j                  |d      }||}n||k7  rt	        | j
                  dz         | j                  |d      }	| j                  |d      }
| j                  |d      }| j                  |d      }| j                  |d	i       }| j                  d
|      }|d   }|"||}n||k7  rt	        | j
                  dz         | j                  ||	|
|||      }|j                  |        | j                  |      }i }d}|d   r| j                  |      }n6|dnd|d<   |d   |d<   | j                  |      |d<   | j                  |      }g }|d   r| j                  |dg       }n| j                  |dg       }g }t        dt        |            D ]T  }||   }i }||   |d<   |d   |d<   | j                  |d      |d<   | j                  |d      |d<   |j                  |       V | j                  ||      S )aN  
        create a list of trade orders(all orders should be of the same symbol)

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-multiple-order
        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   r  z; createOrders() requires all orders to have the same symbolr{  r<  rr  r  r  rK   zS createOrders() requires all orders to have the same margin mode(isolated or cross)rA   r@   r?   r  rQ  r  rg  	order_idsr9  r  )r  r~  r  r  r)   rQ  r}  r  r  r  r  privateSwapPostTradeBatchOrderjson"privateSpotPostMarketOrderBatchNewr  parse_orders)rb  r  r  ordersRequestsr  r   r  rawOrderr5  r{  r<  rr  r  orderParamsr  currentMarginModeorderRequestr  r  r  rg  r  individualOrders                          rd  create_orderszdigifinex.create_orders  s    	
q#f+& 	0AayH''(;H~!X%$TWW/l%lmm##Hf5D##Hf5D__Xx8FOOHg6E//(HbAK==nkZL ,Q ,%!2J!%66(  4I  *I  J  J44XtT6SXZefL!!,/-	0. V$&>::>JH-7-C&GH &tGH"ii7GFO>>wGH, &>??8VR8D??8["=Dq#f+& 	+AayH$&O*.q'OJ'/5d|OO,(,(8(88(LOH%'+'7'7''JOG$MM/*	+   00re  c                 
   | j                  |      }d}d}	| j                  d||      \  }}| j                  d|      \  }	}|	d}i }
|dk(  }|dk(  }|dk(  }|rdnd}|d	   |
|<   | j                  |d
|      }d}|r| j	                  |dd
      }| j                  |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}|| j                  ||      |
d<   ||
d<   ||
d<   | j                  |ddg      }n/|du rdnd}||
d<   d }|dk(  rd!}n| j                  ||      |
d<   ||z   |
d<   d}d}| j                  |dd"d      \  }}|r|dk(  r| j                  |d#      }| j                  |d#      }|| j                  ||      }n|rt|t        | j                  d$z         | j                  |      }| j                  |      }| j                  t        j                   ||            }| j                  ||      }n%| j                  ||      }n| j#                  ||      }||
d%<   |r|r||
d&<   n||
d&<   | j                  |d'g      }| j%                  |
|      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 fulfilled, 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createOrderRequestr@   rA   r  r   r  r  rQ  F
reduceOnlyr   r  rl  rj  r{  rk  rj  r   r      	   r      GTC   r   Tr  r>  r;   _marketrF  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 argumentrr  	post_onlypostOnly)r  r  r  is_post_only	safe_boolr  price_to_precisionr~  handle_option_and_paramsr  cost_to_precisionr-   rQ  number_to_stringra  r6   
string_mulamount_to_precisionr  )rb  r  r{  r<  rr  r  r  r  r   r   r  rA   isMarketOrderisLimitOrdermarketIdRequestr  postOnlyParsedr  r   rM  requestTypesuffixquantityrF  r  rL  rK  costRequests                               rd  r  zdigifinex.create_order_request  s;    V$

!??@TV\^de
F!??@TV\]
F!!Jf$)-1/x#)$< $$]E6BeDJ**6=AKIu}$.aQ"-$.aQ"-	e#"/BQ	%"/BQ	&M	$ #'#:#:65#I $-GL!$GFOYYvm'DEF#+t#3Q!N *GHFx"#'#:#:65#I "VmGFOH04-8<8U8UV\^r  uX  Z^  9_5-v$%-''7662##55fdCH6}*477  6A  ,A  B  B'+'<'<V'D&*&;&;E&B&*&7&78J8J<Yd8e&f#'#9#9&+#N#55ffEH33FFC (GH'5$'/$6J<0{{7F++re  r  c                     | j                          | j                  |      }|d   st        | j                  dz         d|d<   | j	                  |dd|d|      S )a  
        create a market buy order by providing the symbol and cost

        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>`
        r?   z9 createMarketBuyOrderWithCost() supports spot orders onlyFrF  r  r  N)r  r  r/   rQ  r  )rb  r  r  r  r  s        rd  !create_market_buy_order_with_costz+digifinex.create_market_buy_order_with_costR  s`     	V$f~tww)ddee6;23  5$fMMre  rQ  c                 h   | j                          d}|| j                  |      }t        |      }d}| j                  d||      \  }}d|i}|dk(  r#|t	        | j
                  dz         |d   |d<   n||d<   | j                  d|      \  }}d}	||d	k(  r$d	}| j                  | j                  ||            }	nf|d
k(  r"| j                  | j                  ||            }	n?|dk(  r"| j                  | j                  ||            }	nt        | j
                  dz         |d
k(  s|d	k(  rd| j                  |	dg       }
t        |
      }|dk7  rt        | j
                  dz   |z   dz         | j                  |	      }| j!                  |d      S | j#                  |	| j%                  |	d      d      S )a  
        cancels an open order

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#cancel-order
        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>`
        NrE   r9  rA   z) cancelOrder() requires a symbol argumentrQ  r  r  r@   r?   z+ cancelOrder() not support self market typesuccessrj  z cancelOrder() 
 not foundr   rg  )rt  rJ  )r  r  strr  r(   rQ  r   privateSpotPostMarginOrderCancelr  privateSpotPostSpotOrderCancelprivateSwapPostTradeCancelOrderr/   r}  r  r.   parse_cancel_orders	safe_dict
safe_orderr  )rb  rQ  r  r  r  r   r  r   r  r  canceledOrdersnumCanceledOrdersr  s                rd  cancel_orderzdigifinex.cancel_orderd  s    	[[(FW
!??vW]^
F
 ~'2](]^^'-d|GO$ *GH >>}fU
E!Z8%;!J<<T[[RW=XYH6!::4;;wPU;VWH6!;;DKKQV<WXHtww)VVWW, & jH&<!__Xy"EN #N 3 A%#DGG.?$?"$D|$STT--h7F>>&!,,?? ++Hf=$  re  c                    | j                  |d      }| j                  |d      }g }t        dt        |            D ]+  }||   }|j                  | j	                  ||dd             - t        dt        |            D ]M  }||   }|j                  | j	                  || j                  |dd      d| j                  |d	      d
             O |S )Nr  errorr   canceled)rt  rQ  r\  zorder-idr9  failedzclient-order-id)rt  rQ  r\  clientOrderId)rf  r~  r  r  r  r  r  )rb  r  r  r  r  r  rE  s          rd  r  zdigifinex.parse_cancel_orders  s    ..95x1q#g,' 	AAJEMM$//$+  	 q#e*% 	A!HEMM$//((
JG"!%!1!1%9J!K	+  	 re  c                 2   | j                          | j                  | j                  dd      }| j                  |d|      }| j                  |d      }|dj	                  |      d}| j                  | j                  ||            }| j                  |      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>`
        rD  r?   r{  ,)r  r9  )r  r  r\  r~  joinr  r  r  )rb  idsr  r  rD  rM  r  r  s           rd  cancel_orderszdigifinex.cancel_orders  s     	&&t||]FK$$VV[A	66*
 66t{{7F7ST ''11re  r\  c                 8    dddddd}| j                  |||      S )Nr!  closedr  )rA  r   r  r  rB  r  rb  r\  statusess      rd  parse_order_statuszdigifinex.parse_order_status  s/    
 &&99re  rE  c                    d }d }d }d }| j                  |d      }| j                  |dd      }| j                  ||      }	| j                  |	      }|d   dk(  r| j	                  |d      }
|
q|
dk(  s|
dk(  s|
dk(  s
|
d	k(  s|
d
k(  rd}n2|
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"}| j	                  |d#      }| j	                  |d$      }nT| j                  |d%      }| j                  |d&      }|.|j                  d'      }t        |      }|dkD  r|d   }|d   }nd}| j                  i d(|d)| j                  |d*d+      d,d d-|d.| j                  |      d/|d|	d|d0|d1d d2|d3| j                  |d3      d4d d5| j                  |d5d6      d7| j                  |d8d9      d:d d;d | j                  |d<d=      | j                  | j                  |d>d?            d;| j                  |d@      id dA|      S )BNr{  r  r  rA   r>  r  r         r  r   rj  rj  rk  rl  r  r            r  r  r   rm  r   r  r   z	open longr  z
open shortr  z
close longrB  zclose shortinsert_time
time_stampcreated_datefinished_dater  rt  rQ  r9  rg  r  r  r  lastTradeTimestampr   r  r<  r  r   rr  r;  filledexecuted_amount
filled_qty	remainingr  	avg_price	price_avgr\  staterw  )r'  r\  rw  r   )r  r  r1  r  r  r  r  r  r  r4  r  r  r  )rb  rE  r  r  r  r   r{  r<  r5  r  rM  rO  numPartss                rd  r  zdigifinex.parse_order  sl   @ 	!v.%%eXG!!(F3V$&>V#))%>I$N	RY"_R[_aRagptvgv"'K1n)q.i1nR[_`R`fosufu"'K1n)q.i1nR[_aRa"'KN	QINPY]^P^dmqrdr  yB  FH  yH"D#Ds{"##$))%?I!%!2!25,!G++E>BI!%!4!4UO!L

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

 Y/ 
 !"4 
 f 
 D 
 ; 
  
 D 
 T%%eW5 
 D 
 d((&A 
 d((0A<P 
  ! 
" D# 
$ ))%kJ--d.@.@RY.Z[((6 / 
0 1 	re  c                 t   | j                          d}|| j                  |      }d}| j                  d||      \  }}| j                  d|      \  }}i }	|dk(  }
|
r|||	d<   |||	d<   n||	d<   ||
rdnd}|d	   |	|<   d}||d
k(  r$d
}| j	                  | j                  |	|            }nf|dk(  r"| j                  | j                  |	|            }n?|dk(  r"| j                  | j                  |	|            }nt        | j                  dz         | j                  |dg       }| j                  ||||      S )a`  
        fetch all unfilled currently open orders

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#current-active-orders
        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>`
        Nrq   rA   start_timestampr   r  r  r  rQ  r@   r?   z/ fetchOpenOrders() not support self market typerg  )r  r  r  r   privateSpotGetMarginOrderCurrentr  privateSpotGetSpotOrderCurrentprivateSwapGetTradeOpenOrdersr/   rQ  rf  r  )rb  r  rb  r   r  r  r   r   r  r  rA   r  r  rg  s                 rd  fetch_open_orderszdigifinex.fetch_open_orderso  sx    	[[(F
!??@QSY[ab
F >>?PRXY
Ef$ -2)* #(  *GH15o8O'-d|GO$!Z8%;!J<<T[[RW=XYH6!::4;;wPU;VWH6!99$++gu:UVHtww)ZZ[[h ~~h3  vue<<re  c                    | j                          d}|| j                  |      }d}| j                  d||      \  }}| j                  d|      \  }}i }	|dk(  r|$||	d<   n||	d<   || j	                  |dz        |	d<   ||dk(  rdnd	}
|d
   |	|
<   |||	d<   d}||dk(  r$d}| j                  | j                  |	|            }nf|dk(  r"| j                  | j                  |	|            }n?|dk(  r"| j                  | j                  |	|            }nt        | j                  dz         | j                  |dg       }| j                  ||||      S )a  
        fetches information on multiple orders made by the user

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-all-orders-including-history-orders
        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>`
        Nrt   rA   r  r  ru  rv  r  r  rQ  r   r@   r?   z+ fetchOrders() not support self market typerg  )r  r  r  r  r|   privateSpotGetMarginOrderHistoryr  privateSpotGetSpotOrderHistory privateSwapGetTradeHistoryOrdersr/   rQ  rf  r  )rb  r  rb  r   r  r  r   r   r  r  r  r  rg  s                rd  fetch_orderszdigifinex.fetch_orders  s    	[[(F
!??vW]^
F >>}fU
E -2)* *GH (,(9(9%$,(G%2<2FoXO'-d|GO$$GG!Z8%;!J<<T[[RW=XYH6!::4;;wPU;VWH6!<<T[[RW=XYHtww)VVWWh ~~h3  vue<<re  c                    | j                          d}|| j                  |      }d}| j                  d||      \  }}| j                  d|      \  }}d|i}|dk(  r||d   |d<   n||d<   d}	||dk(  r$d}| j	                  | j                  ||            }	nf|d	k(  r"| j                  | j                  ||            }	n?|dk(  r"| j                  | j                  ||            }	nt        | j                  d
z         | j                  |	d      }
|dk(  r|
n| j                  |
d      }|'t        | j                  dz   t        |      z   dz         | j                  ||      S )a  
        fetches information on an order made by the user

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-order-status
        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>`
        Nrr   r9  rA   rQ  r  r  r@   r?   z* fetchOrder() not support self market typerg  r   z fetchOrder() order r  )r  r  r  r  privateSpotGetMarginOrderr  privateSpotGetSpotOrderprivateSwapGetTradeOrderInfor/   rQ  r}  r.   r  r  )rb  rQ  r  r  r  r   r   r  r  r  rg  rE  s               rd  fetch_orderzdigifinex.fetch_order0	  s    	[[(F
!??fV\]
F >>|VT
E
 !+1$<( *GH"
h(>!J55dkk'56QRH6!33DKK4OPH6!88We9TUHtww)UUVVb x0#v-DOOD!4L=*@ @3r7 J\ YZZv..re  c                    | j                          d}i }|| j                  |      }d}| j                  d||      \  }}| j                  d|      \  }}	|dk(  r|$||d<   n||d<   || j	                  |dz        |d<   |dk(  rdnd	}
||d
   ||
<   |||d<   d}||dk(  r$d}| j                  | j                  ||	            }nf|dk(  r"| j                  | j                  ||	            }n?|dk(  r"| j                  | j                  ||	            }nt        | j                  dz         |dk(  rdnd}| j                  ||g       }| j                  ||||      S )aP  
        fetch all trades made by the user

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#customer-39-s-trades
        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>`
        Nro   rA   r  r  ru  rv  r  r  rQ  r   r@   r?   z- fetchMyTrades() not support self market typerg  r  )r  r  r  r  r|  privateSpotGetMarginMytradesr  privateSpotGetSpotMytrades privateSwapGetTradeHistoryTradesr/   rQ  rf  rg  )rb  r  rb  r   r  r  r  r   r   r  r  r  responseRequestrg  s                 rd  fetch_my_tradeszdigifinex.fetch_my_trades	  s    	[[(F
!??QWY_`
F >>PVW
E -2)* *GH (,(9(9%$,(G%.8F.B/'-d|GO$$GG!Z8%;!J88We9TUH6!66t{{7E7RSH6!<<T[[RW=XYHtww)XXYY\ &06%9&~~h<  vue<<re  c                 ,    i }| j                  |||      S Nr  )rb  r{  rE  s      rd  parse_ledger_entry_typez!digifinex.parse_ledger_entry_type	  s    tT22re  itemrh  c                    | j                  | j                  |dd            }| j                  |dd      }| j                  ||      }| j                  ||      }| j	                  |dd      }| j                  |d      }| j                  |d      }|| j                  |d	      }| j                  |d d d d d |||d |d || j                  |      d d
|      S )Nr{  finance_typecurrency_markrh  numr%  r  r   r  )rt  rQ  r@  r  referenceIdreferenceAccountr{  rh  rr  beforeafterr\  r  r  rw  )
r  r  r  safe_currencyr  r  r  r  safe_ledger_entryr4  )	rb  r  rh  r{  r  rz  rr  r  r  s	            rd  parse_ledger_entryzdigifinex.parse_ledger_entry	  s    * ++D,>,>tV^,\]''ozJ
&&z8<%%j(;##D%:  y1''f5	))$<I%% $"Y/'
  ! 	re  rz  c                     | j                          i }d}| j                  dd|      \  }}| j                  d|      \  }}|dk(  r|$||d<   n||d<   || j                  |dz        |d<   |dk(  rdnd	}	d}
|| j	                  |      }
|
d
   ||	<   |||d<   d}||dk(  r$d}| j                  | j                  ||            }nf|dk(  r"| j                  | j                  ||            }n?|dk(  r"| j                  | j                  ||            }nt        | j                  dz         d}|dk(  r| j                  |dg       }n&| j                  |di       }| j                  |dg       }| j                  ||
||      S )a  
        fetch the history of changes, actions done by the user or operations that altered the balance of the user

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-margin-otc-financial-logs
        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 entries 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>`
        Nrh   rA   r  r  ru  rv  rh  r	  rQ  r   r@   r?   z+ fetchLedger() not support self market typerg  finance)r  r  r  r|  rh  privateSpotGetMarginFinancelogr  privateSpotGetSpotFinancelog"privateSwapGetAccountFinanceRecordr/   rQ  r}  parse_ledger)rb  rz  rb  r   r  r  r   r   r  currencyIdRequestrh  r  ledgerrg  s                 rd  fetch_ledgerzdigifinex.fetch_ledger
  s    	
!??tU[\
F >>}fU
E -2)* *GH (,(9(9%$,(G%+5+?Jo}}T*H)1$G%&$GG!Z8%;!J::4;;wPU;VWH6!88We9TUH6!>>t{{7TY?Z[Htww)VVWWD __Xvr:F??8VR8D__T9b9F  5%@@re  c                     | j                  |d      }| j                  |d      }| j                  |d      }| j                  |      }||d ||dS )Naddress
addressTagrh  )rt  rh  ru  r  tag)r  safe_string_upperr  )rb  depositAddressrh  r  r  r  rz  s          rd  parse_deposit_addresszdigifinex.parse_deposit_addressn
  sc     "">9=~|<++NJG
&&z2"
 	
re  c                 N   | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |dg       }| j                  ||d   g      }| j	                  ||      }|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>`
        rh  rQ  rg  rz  z5 fetchDepositAddress() did not return an address for zQ - create the deposit address in the user settings on the exchange website first.)r  rh  privateSpotGetDepositAddressr  r}  parse_deposit_addressesr,   rQ  )	rb  rz  r  rh  r  r  rg  	addressesr  s	            rd  fetch_deposit_addresszdigifinex.fetch_deposit_address
  s     	==&
 44T[[&5QR x4008H7IJ	//)T2? +b!bei!i  m@  "@  A  Are  c                 j   | j                          d }i }|| j                  |      }|d   |d<   |t        d|      |d<   d }|dk(  r"| j                  | j	                  ||            }n!| j                  | j	                  ||            }| j                  |dg       }	| j                  |	|||d|i      S )NrQ  rh  r   r;  rs  rg  r{  )r  rh  rq  privateSpotGetDepositHistoryr  privateSpotGetWithdrawHistoryrf  parse_transactions)
rb  r{  rz  rb  r   r  rh  r  r  rg  s
             rd  fetch_transactions_by_typez$digifinex.fetch_transactions_by_type
  s    
 }}T*H"*4.GJ!#uoGFO988Wf9UVH99$++gv:VWH* ~~h3&&tXuefd^TTre  c                 ,    | j                  d||||      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>`
        rs  r+  rb  rz  rb  r   r  s        rd  fetch_depositszdigifinex.fetch_deposits
  s     ..y$ufUUre  c                 ,    | j                  d||||      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>`
        
withdrawalr-  r.  s        rd  fetch_withdrawalszdigifinex.fetch_withdrawals
  s     ..|T5%QWXXre  c                 6    ddddd}| j                  |||      S )NpendingrZ  r  )r   r  r  rB  r  r  s      rd  parse_transaction_statusz"digifinex.parse_transaction_status
  s.     	
 &&99re  transactionc                    | j                  |dd      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  ||      }| j	                  | j                  |d            }	| j	                  | j                  |d            }
| j                  | j                  |d	            }| j                  |d
      }| j                  |d      }d }|||d}| j                  |d      }i d|d|d|d|	d| j                  |	      d|d|d|dd d|d|dd dd d
|d|d|d|
d d |dS )NrQ  withdraw_idr  memohashrh  r  r  r  rr  rw  )rh  r  ro  rt  txidr  r  ru  	addressToaddressFromr  tagTotagFromr{  r\  r]  )internalcommentrw  )r  r  r  r  	parse8601r5  r  r4  )rb  r6  rh  rQ  r  r  r;  r  rz  r  r]  r\  rr  feeCostrw  ru  s                   rd  parse_transactionzdigifinex.parse_transaction
  s   2 T=A"";	:{F3V4++KD
&&z8<NN4#3#3K#PQ	..!1!1+!OP..t/?/?W/UV!!+x8"";6#W5C"";8
K
"
 D
 	

 Y/
 w
 w
 
 4
 3
 S
 t
 D
 f
 
  f!
" w#
$ )
 	
re  c                 0    ddi}| j                  |||      S )NrA  rZ  r  r  s      rd  parse_transfer_statuszdigifinex.parse_transfer_status.  s%    
 &&99re  r   c                    d }d }| j                  |d|      }| j                  |d      }|dk(  rd}d}n	|dk(  rd}d}| j                  |d      }|| j                  |d      || j                  |      | j	                  | j                  |d	      |      | j                  |d
d      ||| j                  | j                  |d            d	S )Nrg  r{  rj  r?   rA   rj  r  transfer_idrh  rr  transfer_amountrz  )	rt  rQ  r  r  rh  rr  fromAccount	toAccountr\  )r  r  r  r4  r  r  rF  )rb  r   rh  rJ  rK  rg  r{  r  s           rd  parse_transferzdigifinex.parse_transfer4  s    : 	~~h9  v.19 KIQY KI%%h<	""8];"Y///0@0@z0RT\]((x9JK&"001A1A(F1ST

 
	
re  rJ  rK  c                 X   | j                          | j                  |      }|d   }| j                  | j                  di       }| j	                  |||      }	| j	                  |||      }
i }|dk(  }|dk(  }d}| j                  ||      }|s|rW|	dk7  r|
dk7  rt        | j                  dz         |rdnd|d	<   ||d
<   ||d<   | j                  | j                  ||            }n5||d<   ||d<   |	|d<   |
|d<   | j                  | j                  ||            }| j                  ||      S )a  
        transfer currency internally between wallets on the same account

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#transfer-assets-among-accounts
        https://docs.digifinex.com/en-ww/swap/v2/rest.html#accounttransfer

        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: 'spot', 'swap', 'margin', 'OTC' - account to transfer from
        :param str toAccount: 'spot', 'swap', 'margin', 'OTC' - 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>`
        rQ  rG  rA   Nr   z[ transfer() supports transferring between spot and swap, spot and margin, spot and OTC onlyrj  rj  r{  rh  rI  r	  r
  fromto)r  rh  r}  r\  r  currency_to_precisionr$   rQ  privateSwapPostAccountTransferr  privateSpotPostTransferrL  )rb  rz  rr  rJ  rK  r  rh  r  rG  fromIdtoIdr  fromSwaptoSwapr  rL  s                   rd  r   zdigifinex.transferh  s^    	==&d^
7GL!!.+{K	9E6)v%11$?v#DCK#DGG  /L  %L  M  M#)aqGFO",GJ)5G%& ::4;;wPV;WXH'1GO$)GEN$GFO GDM 33DKK4PQH""8X66re  r  c                 6   | j                  ||      \  }}| j                  |       | j                          | j                  |      }|| j	                  ||      |d   d}|||d<   | j                  | j                  ||            }| j                  ||      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>`
        rQ  )r  rr  rh  r9  )handle_withdraw_tag_and_paramscheck_addressr  rh  rP  privateSpotPostWithdrawNewr  rD  )	rb  rz  rr  r  r  r  rh  r  r  s	            rd  r   zdigifinex.withdraw  s     99#vFV7#==& 00v> 	
 ?!GFO224;;w3OP %%h99re  c                    | j                          i }d }|| j                  |      }|d   |d<   | j                  | j                  ||            }| j	                  |d      }	| j                  |	|      }
| j                  |
|||      S )NrQ  r  	positions)r  r  privateSpotGetMarginPositionsr  r}  parse_borrow_interestsfilter_by_currency_since_limit)rb  rz  r  rb  r   r  r  r  r  rowsinterests              rd  fetch_borrow_interestzdigifinex.fetch_borrow_interest  s    [[(F &tGH55dkk'66RS, x5..tV<228T5%PPre  rt  c           
      2   | j                  |d      }| j                  |d      }| j                  |d      }t        j                  ||      }t        j                  ||      }|d n|d   }| j	                  ||      }	||	|d d| j                  |      d d d d	S )Nr  rr  leverage_ratior  MbP?)	rt  r  rh  ra  interestRateamountBorrowedr   r  r  )r  r6   
string_divr  r1  ra  )
rb  rt  r  r5  rL  leverageStringamountInvestedrg  rh  r  s
             rd  parse_borrow_interestzdigifinex.parse_borrow_interest  s     ##D(3''h7))$0@A ++L.I ++L.I"N4!!(F3 !"//?

 
	
re  c                 F   | j                          i }| j                  | j                  ||            }| j                  |dg       }g }t	        dt        |            D ]  }||   }| j                  |d      |k(  s|}! | j                  |      }	| j                  ||	      S )a  
        fetch the rate of interest to borrow a currency for margin trading

        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>`
        r  r   rh  )	r  r  r  r}  r~  r  r  rh  parse_borrow_rate)
rb  rz  r  r  r  rg  r  r  entryrh  s
             rd  fetch_cross_borrow_ratez!digifinex.fetch_cross_borrow_rate   s     	224;;w3OP$ x4q#d)$ 	AGEz2d:	 ==&%%fh77re  c                     | j                          | j                  |      }| j                  |dg       }| j                  |d      S )aQ  
        fetch the borrow interest rates of all currencies

        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>`
        r  rh  )r  r  r}  parse_borrow_rates)rb  r  r  r  s       rd  fetch_cross_borrow_ratesz"digifinex.fetch_cross_borrow_rates'  sG     	226:$ 626&&vz::re  c                     | j                         }| j                  |d      }| j                  ||      dd|| j                  |      |dS )Nrh  re  i \&)rh  raters  r  r  rt  )r{  r  r  r4  )rb  rt  rh  r  r  s        rd  rm  zdigifinex.parse_borrow_rateF  sV     %%'	%%dJ7
//
HE"Y/
 	
re  c                     i }t        dt        |            D ]@  }||   }| j                  ||      }| j                  |      }| j	                  |      }|||<   B |S )Nr   )r~  r  r  r  rm  )	rb  rt  codeKeyr  r  r  rh  rz  
borrowRates	            rd  rq  zdigifinex.parse_borrow_ratesZ  sn     q#d)$ 	&A7D''g6H**84D//5J%F4L	& re  c                    | j                          | j                  |      }|d   st        | j                  dz         d|d   i}| j	                  | j                  ||            }| j                  |di       }| j                  ||      S )am  
        fetch the current funding rate

        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>`
        rA   z0 fetchFundingRate() supports swap contracts onlyr  rQ  rg  )r  r  r*   rQ  publicSwapGetPublicFundingRater  r  parse_funding_raterb  r  r  r  r  r  rg  s          rd  fetch_funding_ratezdigifinex.fetch_funding_ratel  s     	V$f~DGG&XXYYVD\
 66t{{7F7ST ~~h3&&tV44re  c                 &    | j                  ||      S )av  
        fetch the current funding rate interval

        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>`
        )r|  )rb  r  r  s      rd  fetch_funding_intervalz digifinex.fetch_funding_interval  s     &&vv66re  c                    | j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }t        j                  ||      }i d|d| j	                  ||      dd dd dd d	d d
d dd d| j                  |d      d|d| j                  |      d| j                  |d      d|d| j                  |      dd dd dd d| j                  |      iS )Nr  funding_timenext_funding_timert  r  r.  r/  rf  estimatedSettlePricer  r  fundingRatefunding_ratefundingTimestampfundingDatetimenextFundingRatenext_funding_ratenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimeinterval)r  r  r6   r  r1  r  r4  parse_funding_interval)	rb  r  r  r5  r  nextTimestampfundingTimeStringnextFundingTimeStringmillisecondsIntervals	            rd  rz  zdigifinex.parse_funding_rate  s    ##Ho>%%h?	))(4GH ,,X~F $ 0 0;N O&112GIZ[
H
d&&x8
 
 $	

 D
 #D
 
 
 4++HnE
 	
 t||I6
 t//:MN
 #M
 "4<<#>
 "4
  '!
" &t#
$ 334HI%
 	
re  c                 8    dddddd}| j                  |||      S )Nr   r   8h16h24h)360000014400000288000005760000086400000r  )rb  r  	intervalss      rd  r  z digifinex.parse_funding_interval  s/    
	 	8X>>re  c           
         |t        | j                  dz         | j                          | j                  |      }|d   st	        | j                  dz         d|d   i}|||d<   |||d<   | j                  | j                  ||            }| j                  |di       }| j                  |d	g       }	g }
t        d
t        |	            D ]r  }|	|   }| j                  |d      }| j                  |      }| j                  |d      }|
j                  ||| j                  |d      || j                  |      d       t | j!                  |
d      }| j#                  ||||      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>`
        z5 fetchFundingRateHistory() requires a symbol argumentrA   z7 fetchFundingRateHistory() supports swap contracts onlyr  rQ  r  r   rg  funding_ratesr   r   rt  )rt  r  r  r  r  r  )r(   rQ  r  r  r*   %publicSwapGetPublicFundingRateHistoryr  r}  r~  r  r  r1  r  r  r  r4  sort_byfilter_by_symbol_since_limit)rb  r  rb  r   r  r  r  r  rg  r  ratesr  rn  r5  symbolInnerr  sorteds                    rd  fetch_funding_rate_historyz$digifinex.fetch_funding_rate_history  s    >#DGG.e$effV$f~DGG&__``VD\
 ).G%&$GG==dkk'SY>Z[  x4;q#f+& 	A1IE''o>H**84K))%8ILL%#//v>& LL3 	 e[100NNre  c                    | j                          | j                  |      }|d   st        | j                  dz         d|d   i}| j	                  | j                  ||            }| j                  |di       }| j                  ||      S )aX  
        fetch the trading fees for a market

        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>`
        rA   z- fetchTradingFee() supports swap markets onlyr  rQ  rg  )r  r  r)   rQ  #privateSwapGetAccountTradingFeeRater  r}  parse_trading_feer{  s          rd  fetch_trading_feezdigifinex.fetch_trading_fee   s     	V$f~TWW'VVWWVD\
 ;;DKKQW<XY x4%%dF33re  rw  c                     | j                  |d      }| j                  ||      }||| j                  |d      | j                  |d      d d dS )Nr  maker_fee_ratetaker_fee_rate)rt  r  r   r   r   r   )r  r1  r  )rb  rw  r  r5  r  s        rd  r  zdigifinex.parse_trading_fee  s`     ##C9!!(F3%%c+;<%%c+;<
 	
re  c                 8   | j                          | j                  |      }i }d}d}|Sd}t        |t              r.t	        |      }|dkD  rt        | j                  dz         |d   }n|}| j                  |      }| j                  d||      \  }}| j                  d|      \  }}	|d}||dk(  rdnd	}
|d
   ||
<   d}|dk(  s|dk(  r"| j                  | j                  ||	            }n?|dk(  r"| j                  | j                  ||	            }nt        | j                  dz         |dk(  rdnd}| j                  ||g       }g }t        dt	        |            D ]&  }|j!                  | j#                  ||   |             ( | j%                  |d	|d      S )a  
        fetch all open positions

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
        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>`
        Nrj  zD fetchPositions() symbols argument cannot contain more than 1 symbolr   rw   r@   rA   r  r  rQ  r?   z. fetchPositions() not support self market typerg  r\  F)r  r   r  r  r  r)   rQ  r  r  r  r]  r  privateSwapGetAccountPositionsr/   r}  r~  r  parse_positionfilter_by_array_positions)rb  r  r  r  r  r   r  symbolsLengthr   r  r  r  positionRequestr\  r  r  s                   rd  fetch_positionszdigifinex.fetch_positions2  s    	%%g.
F'4( #G 1$$TWW/u%uvv  [[(F!??@PRXZ`a
F >>?OQWX
E!!J2<2FoXO'-d|GO$:#999$++gu:UVH6!::4;;wPU;VWHtww)YYZZl &06%9&OOHorB	q#i.) 	EAMM$--ilFCD	E--fhOOre  c                 n   | j                          | j                  |      }i }d}| j                  d||      \  }}| j                  d|      \  }}|d}|dk(  rdnd}|d   ||<   d}	|dk(  s|dk(  r"| j	                  | j                  ||            }	n?|dk(  r"| j                  | j                  ||            }	nt        | j                  d	z         |dk(  rd
nd}
| j                  |	|
g       }| j                  |d   |      }|dk(  r|S | j                  |	d      |d<   | j                  |	d      |d<   |S )a  

        https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
        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>`
        Nru   r@   rA   r  r  rQ  r?   z- fetchPosition() not support self market typerg  r\  r   
collateralmargin_ratemarginRatio)r  r  r  r  r]  r  r  r/   rQ  r}  r  r  )rb  r  r  r  r  r   r   r  r  r  dataRequestrg  positions                rd  fetch_positionzdigifinex.fetch_position  sc    	V$
!??QWY_`
F >>PVW
E!!J.8F.B/#)$< :#999$++gu:UVH6!::4;;wPU;VWHtww)XXYYh ",v!5fKxb9&&tAw7O%)%5%5h%IH\"&*&6&6x&OH]#Ore  r  c                    | j                  |dd      }| j                  ||      }|d   }| j                  |d      }|
|dk(  rdnd}nd}| j                  |d      }| j                  |d      }|d	k(  rd
}n|dk(  rd}| j	                  i d|dd d|d| j                  |d      d|d| j                  |d      d| j                  |dd      d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      d|dd d|d| j                  |      d | j                  |d!      d"| j                  |d#      d d d | j                  |d$d%      | j                  |d&      d d d d'      S )(Nr  r  margin_modecrossedcrossisolatedr  r<  go_longlonggo_shortshortrt  rQ  notionalrr  r   liquidationPriceliquidation_price
entryPriceavg_costentry_priceunrealizedPnlunrealized_pnl	contractsavail_positionr  r.  r  r   r  maintenanceMarginr@   maintenanceMarginPercentagemaint_margin_ratior   rd  margin_ratio)r  initialMargininitialMarginPercentager   r  r   r   r   )r  r2  r  r  safe_positionr  r  r4  )rb  r  r  r5  r  r   r  r<  s           rd  r  zdigifinex.parse_position  s>   N %%hJ!!(F3!%%h>
!%/9%<:J"J%%h<	&19DZD!! #
H#
$#
 f#
 ((8<	#

 *#
  0 0;N O#
 $,,Xz=Q#
 T--h8HI#
 ))(4DE#
 D,,V^D#
 ))(F;#
 D#
 d#
 #
 Y/#
   !1!1(H!E!#
" *4+;+;HFZ+[##
$ !'+**8ZAQR++HnE!#3#
  	re  r   c                    |t        | j                  dz         | j                          | j                  |      }|d   dk7  rt	        | j                  dz         |dk  s|dkD  rt        | j                  dz         |d   |d	}| j                  | j                  d
d      }| j                  |d
d|      }|"|dk(  rdnd}||d<   | j                  |d
dg      }|dk(  rB| j                  |d      }|||d<   | j                  |d      }n| j                  d|dddg       | j                  | j                  ||            S )a#  
        set the level of leverage for a market

        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
        z) setLeverage() requires a symbol argumentr{  rA   z+ setLeverage() supports swap contracts onlyrj  r   z% leverage should be between 1 and 100rQ  )r  r   r   defaultMarginModer  r  r  r  r<  r   r  r  )r(   rQ  r  r  r*   r)   r  r\  safe_string_lower_2r~  r  check_required_argumentprivateSwapPostAccountLeverager  )	rb  r   r  r  r  r  r  r   r<  s	            rd  set_leveragezdigifinex.set_leverage@  sc    >#DGG.Y$YZZV$&>V#DGG&SSTTqLhnTWW'NNOO#D\ 
 !..t||\K^_--flDWYjk
!'1W'<:J%/GM"YYv6I'JKF###FF3D"&662,,]D&6SZJ[\224;;w3OPPre  c                    | j                          d}i }|| j                  |      }|d   |d<   |||d<   |||d<   | j                  | j                  ||            }| j	                  |dg       }| j                  ||||      S )aS  
        fetch the transfer history, only transfers between spot and swap accounts are supported

        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>`
        NrQ  rh  r  r   rg  )r  r  #privateSwapGetAccountTransferRecordr  rf  parse_transfers)	rb  rz  rb  r   r  rh  r  r  	transferss	            rd  fetch_transferszdigifinex.fetch_transferss  s     	..t4H"*4.GJ).G%&$GG;;DKKQW<XY  NN8VR8	##IxFFre  c                     | j                          | j                  |      }| j                  |dg       }| j                  |      }| j	                  ||d      S )a  

        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
        rg  r  )r  r  r}  r   parse_leverage_tiers)rb  r  r  r  rg  s        rd  fetch_leverage_tierszdigifinex.fetch_leverage_tiers  sY     	66v>< x4%%g.((wHHre  c                    | j                          | j                  |      }|d   st        | j                  dz         d|d   i}| j	                  | j                  ||            }| j                  |di       }| j                  ||      S )a  
        retrieve information on the maximum leverage, for different trade sizes for a single market

        https://docs.digifinex.com/en-ww/swap/v2/rest.html#instrument

        :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>`
        rA   z6 fetchMarketLeverageTiers() supports swap markets onlyr  rQ  rg  )r  r  r)   rQ  publicSwapGetPublicInstrumentr  r}  parse_market_leverage_tiersr{  s          rd  fetch_market_leverage_tiersz%digifinex.fetch_market_leverage_tiers  s     	V$f~TWW'__``VD\
 55dkk'66RS8 x4//f==re  c                 t   g }| j                  |di       }t        dt        |            D ]  }||   }| j                  |d      }| j	                  ||      }|j                  | j                  |d      | j                  ||d d      |d   d | j                  |d      d | j                  |d      |d	        |S )
Nopen_max_limitsr   r  rj  rA   r  	max_limitr   )tierr  rh  minNotionalmaxNotionalmaintenanceMarginRatemaxLeveragert  )	r}  r~  r  r  r2  r  r}  r1  r  )rb  rt  r  tiersbracketsr  r  r5  s           rd  r  z%digifinex.parse_market_leverage_tiers  s    2 ??4):B?q#h-( 	AA;D''o>H%%h7FLLA**8VT6J"8,##//kB)-#//jA	 			 re  c                     | j                  | j                  d      }| j                  |dd      }d}t        t        |   |||      \  }}|!|dk7  rt        | j                  dz         ||gS |dk(  s|du rd}||gS )aR  
 @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
        rD  r@   FNr  z only cross margin is supportedT)r  r\  r  r_  r8   r  r/   rQ  )rb  
methodNamer  defaultValuerD  isMarginr   rc  s          rd  r  z'digifinex.handle_margin_mode_and_params$  s     &&t||]C>>&(E:
"9dQR\^dfrs
F!W$"477-N#NOO F## x'X-=$
F##re  codesc                     | j                          | j                  |      }| j                  |d      }| j                  ||      S )a  
        fetch deposit and withdraw fees

        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>`
        rg  )r  r|  rf  parse_deposit_withdraw_fees)rb  r  r  r  rg  s        rd  fetch_deposit_withdraw_feesz%digifinex.fetch_deposit_withdraw_fees7  sE     	//7< ~~h///e<<re  c                    i }| j                  |      }t        dt        |            D ]  }||   }| j                  |d      }| j	                  |      }|| j                  ||      s@| j                  ||      }	|	| j                  i       ||<   g ||   d<   ||   d   }
|
j                  |       | j                  |d      }| j                  |d      }||dnd d}d d d}| | j                  |      }||d||   d	   |<   |||   d
<   |||   d<    t        |j                               }t        dt        |            D ]0  }||   }| j                  |      }| j                  ||   |      ||<   2 |S )Nr   rh  rt  ro  rl  F)rw  r   )r   rs  rH  r   rs  )market_codesr~  r  r  r  in_arrayr}  deposit_withdraw_feer  r  r  keysrh  $assign_default_deposit_withdraw_fees)rb  r  r  currencyIdKeydepositWithdrawFeesr  rn  r  rz  depositWithdrawFeedepositWithdrawInfor  withdrawFeewithdrawResultdepositResultr  depositWithdrawCodesrh  s                     rd  r  z%digifinex.parse_deposit_withdraw_feesc  s   6 %'!!%(q#h-( 	IAQKE))%<J**:6D4==u#=%)__5H$%O"%-040I0I"0M'-8:'-f5&9$&?&G##**51 ,,UG<	"ooe5GH&,7,C%$(
  "&' ("&"9"9)"DK$2#0J'-j9+F
 =K'-j9;H'-i8;	I<  $$7$<$<$>?q#234 	wA'*D}}T*H(,(Q(QRefjRkmu(v%	w #"re  c                 z    | j                  |d      }| j                  d|dddg       | j                  ||d|      S )a  
        add margin to a position

        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<  rD   r  r  rj  r  r  modify_margin_helperrb  r  rr  r  r<  s        rd  
add_marginzdigifinex.add_margin  sF     /$$[$@QR((FCCre  c                 z    | j                  |d      }| j                  d|dddg       | j                  ||d|      S )a  
        remove margin from a position

        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<  r   r  r  rj  r	  r  s        rd  reduce_marginzdigifinex.reduce_margin  sF     /$$^T6FGCTU((FCCre  c                    | j                          | j                  |d      }| j                  |      }|d   | j                  |      ||d}| j	                  | j                  ||            }| j                  |d      }	|	dk(  rdnd}
| j                  |di       }| j                  | j                  ||      d	|
i      S )
Nr<  rQ  )r  rr  r{  r<  rz  r   rZ  r  rg  r\  )	r  r  r  r  $privateSwapPostAccountPositionMarginr  r  r}  parse_margin_modification)rb  r  rr  r{  r  r<  r  r  r  rz  r\  rg  s               rd  r
  zdigifinex.modify_margin_helper  s    /V$#D\++F3	
 <<T[[RX=YZ   62!)(x4{{499$GfJ
  	re  rg  c                     | j                  |d      }| j                  |d      }|| j                  ||d d      |dk(  rdndd| j                  |d      d |d	   d d d d

S )Nr  r{  rA   rj  addreducer  rr  r  )
rt  r  r{  r   rr  r  rz  r\  r  r  )r  r  r1  r  )rb  rg  r  r5  rawTypes        rd  r  z#digifinex.parse_margin_modification  s{     ##D/:##D&1&&xvF%lE$&&tX68$
 	
re  c                 8   | j                          i }| j                  d||      \  }}d}|| j                  |      }|d   |d<   |||d<   |||d<   | j                  | j	                  ||            }| j                  |dg       }| j                  ||||      S )a  
        fetch the history of funding payments paid and received on self account

        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>`
        end_timestampNrQ  r  r   r  rg  )r  handle_until_optionr  privateSwapGetAccountFundingFeer  rf  parse_incomes)	rb  r  rb  r   r  r  r  r  rg  s	            rd  fetch_funding_historyzdigifinex.fetch_funding_history  s     	22?GVT[[(F'-d|GO$$GG).G%&77GV8TU ~~h3!!$u==re  c           
         | j                  |d      }| j                  |d      }| j                  |d      }|| j                  ||d d      | j                  |      || j	                  |      d | j                  |d      dS )Nr  rh  r  rA   rr  )rt  r  rz  r  r  rQ  rr  )r  r  r1  r  r4  r  )rb  incomer  r5  r  r  s         rd  parse_incomezdigifinex.parse_income#  s     ##FO<%%fj9
%%fk:	&&xvF++J7"Y/&&vx8
 	
re  r   c                     |t        | j                  dz         | j                          | j                  |      }|j	                         }|dk(  rd}|d   |d}| j                  | j                  ||            S )aq  
        set margin mode to 'cross' or 'isolated'

        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
        z+ setMarginMode() requires a symbol argumentr  r  rQ  )r  r  )r(   rQ  r  r  lower"privateSwapPostAccountPositionModer  )rb  r   r  r  r  r  s         rd  set_margin_modezdigifinex.set_margin_mode9  s     >#DGG.[$[\\V$%%'
 "J#D\%
 66t{{7F7STTre  GETc                 *   |d   dk(  }|d   }|dk(  rdnd}	d| j                  ||      z   }
|	|
z   }| j                  d   d	   |z   }| j                  || j                  |            }d }|r |	dk(  r|d
k(  rt	        j
                  |      }n | j                  | j                  |            }|rd }d }|	dk(  r<t        | j                               }||z   |z   }|dk(  r|r/|d|z   z  }n&|d
k(  r!||z  }nt        | j                               }|}| j                  | j                  |      | j                  | 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   rj  r?   z/v3z/swap/v2r  r   r   POSTr#  ?zContent-Typez!application/x-www-form-urlencoded)z
ACCESS-KEYzACCESS-SIGNzACCESS-TIMESTAMP)r_  r  bodyheaders)implode_paramsrX  r~  extract_paramsr  dumps	urlencodekeysortr  r{  noncehmacencodesecrethashlibsha256apiKey)rb  pathr   r  r  r(  r'  signedendpointpathPartr  payloadr_  r  
urlencodedauthr.  	signatures                     rd  signzdigifinex.signQ  s   Q9$q6%/5j++D&99W$iiv&0		&$"5"5d";<
x:-Ff4DF+JU(;<JDE:%D--/0v~/U?!j 00v%J&DDJJL)!		$++d"3T[[5Mw~~^I3++C6!"$G %D"kk($)G sZ''fdwOOre  
statusCode
statusTextr_  r  responseHeadersc
                     |sy | j                  |d      }
|
dk(  s|
dk(  ry | j                  dz   |z   }|
t        |      t        |g}| j	                  | j
                  d   |
|      \  }} ||      )Nrz  rA  200 r
  )r  rQ  r4   r$   r}  r[  )rb  r>  r?  r_  r  r@  responseBodyr  requestHeadersrequestBodyrz  feedbackunknownErrorExceptionClassmessages                  rd  handle_errorszdigifinex.handle_errors  s    &1CKTU]77S=</<h''%x0"&//$//'2JDR^"_W%%re  r  )NN)u__name__
__module____qualname__r   r`  r
   r  r#   r   r  r  r  r   r  r  r  r   r   r  r   r   r	  r   r  dictr  r   rT  rX  ra  rh  r  ro  r  r   r   floatr   r  r   r  r  r  r   r  r  r  r  r   r  r  r  r  r  r  r   r   r  r  r   r!  r&  r+  r!   r/  r2  r5  rD  rF  r"   rL  r   r   r   rb  rk  r   ro  r	   rr  rm  rq  r   r|  r~  rz  r  r  r    r  r  r   r  r  r  r  r  r   r  r   r  r  r  r  r  r   r  r  r
  r  r  r  r"  r=  intrK  __classcell__)rc  s   @rd  r8   r8   !   s   z# zx ') \Z \| $& 
-$v, 
- ') Xt ') IV%) %)N $& ?,( ?,B :>b GMs GM3 GMY GMR 04B SGW SG7 SGj 02 K13 K1f K1ZH4 H H6 HT~ ~v ~ ~@ !# <s < #% 
. 6:UW C=3 C=s C=# C=\`af\g C=J 4 < 26DW[df TK# TKc TKQT TKkoptku TKl gksu 63 6i 6y 6RW 6`c 6p @B S1D$6 S1j os{} Y,3 Y,i Y,y Y,Z_ Y,hk Y,v RT N N5 N$ 37r Gs GC GR* 04B 2 2>: :B Bv B BH /3TXac ^= ^=3 ^=c ^=hlmrhs ^=@ *.Dt\^ _=3 _=c _= _=cghmcn _=B 26b Y/c Y/3 Y/v -1tRV_a Z=c Z= Z=C Z=x3.t .x .; .` (,$TZ\ QA QAC QAs QAaefqar QAf
h 
R` 
* 79 # ^ B <@daenp (US (U (U[^ (UT *.Dt\^ 	V3 	Vc 	V 	Vcghsct 	V -1tRV_a 	Yc 	Y 	YC 	Yfjkvfw 	Y	:s 	:=
T =
X =
Q\ =
~:C :C :2
t 2
x 2
= 2
h [] 57S 57% 57c 57c 57an 57n DHPR :S :% :# :Wb :> 15DW[jnwy Q# Qc QQT Qdg Q  C  DR  S QB
$ 
 
. 
B 9; %8C %8 %8N /1 ;5E ;>
 
($ 68 5 5K 5B :< 
7S 
7 
7#
6 #
[ #
J? 8<$]ajl 6O 6OC 6OWZ 6Op 57 4 4;N 4>
T 
6 
EX 
& 26b bPw bPT(^ bPH 24 WS WrOt OV Ob 9=R &QS &Q# &Qf +/TPT]_ 'GC 'Gs 'G# 'Gdhivdw 'GR 7;2 +IG +I- +IZ ?A .># .>T,EW .>`) )$|J\ )V @BPT $& <@ *= *=X@#D =? D De DCU D  @B DC D DFX D  FH 3 L^ :
d 
F 
N` 
0 37TX\eg '>C '>s '>RU '>R
6 
, >B" U# Us U0  b$T -P^& & &3 &PS &fj &re  r8   )>ccxt.base.exchanger   ccxt.abstract.digifinexr   r2  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   typingr#   ccxt.base.errorsr$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   ccxt.base.decimal_to_precisionr5   ccxt.base.preciser6   r8    re  rd  <module>r[     s    ( /   w  w  w  w  w  w  w  w  * 0 - - . ' & . + ) * ) ) + . ) ( 4 %jA&+ jA&re  