
    eiǪ                       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=dS )    )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dydededefdZdyd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dydedefdZ dd	d	i fd
e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e         d
e+fd+Z.d,e+fd-Z/dyd.edede0fd/Z1d	d	d	i fd
e+dededee0         fd0Z2d	d	d	i fd
e+dededee0         fd1Z3d	i fd'ed
e+fd2Z4d	d	d	i fd
e+dedefd3Z5d4 Z6dyd5ed6e7de8fd7Z9d	d	d	i fd8e+dededee8         fd9Z:dyd6e7de;fd:Z<i fd8ede;fd;Z=d	d	d	i fd8e+dedefd<Z>d	d	d	i fd8e+dededee?         fd=Z@d	d	d	i fd8e+dededee?         fd>ZAd,e+fd?ZBdyd@ed6e7de?fdAZCd,e+de+fdBZDdydCed6e7deEfdDZFi fd8ede$dEedFedeEf
dGZGd	i fd8ede$dHedIe+de?f
dJZHd	d	d	d	i fd8e+d
e+dededeeI         f
dKZJdydLededeIfdMZKi fd8edeLfdNZMi fdeNfdOZOdyd6e7fdPZPdQ ZQi fd
edeRfdRZSi fd
edeRfdSZTdydedeRfdTZUdU ZVd	d	d	i fd
e+dedefdVZWi fd
edeXfdWZYdydXededeXfdYZZd	i fdedee[         fdZZ\i fd
efd[Z]dyd\edefd]Z^d	i fd^e_d
e+fd_Z`d	d	d	i fd8e+dededeeE         fd`Zad	i fdedebfdaZci fd
edeed         fdbZedydedeed         fdcZfi d	f fdd	Zgd	i fdeefdfZhdzdgZii fd
ede$dejfdhZki fd
ede$dejfdiZli fd
edejfdjZmdydkededejfdlZnd	d	d	i fd
e+dedefdmZodydefdnZpd	i fdoed
e+fdpZqg dqi d	d	fdrZrdse_dteduedvedwef
dxZs xZtS ){	digifinexreturnc                    |                      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|                     d          |                     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dddd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CRC20
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)r@  rB  r  r  r"  r#  r*  r  )defaultTypetypes!createMarketBuyOrderRequiresPriceaccountsByTypenetworksnetworksByIdz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    L/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/digifinex.pyrb  zdigifinex.describe#   s   i 6 6 ? ? A 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$ (%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 L 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 L 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 LJ !%#"!%#(  WL L L\ 
 
 ; 30 r\        $       %" "J     2! ! !5' 'R     ! ! !" "SL LIq qh  %&*(-,0,1).+06:#(#("&#(	( ( #(/4$)$)+027#()$ $. r% '+!$$*%'*/& & '+#($)&**.# # '+!%#($)*/( ( '+!$$*%'#($)*/$ $ *.#u= =~ y  )!&+% %
 ',!$$*%+	& & %e# ',!$( (
 ',$*$ $
  #/# #: "#3 "#3 	  ## Ki iV !%"&!..w77!..w77	  '1j*ij113CD1 13GH1 j*FG	1
 n.ST1 .0VW1 .0IJ1 l,st1 l,YZ1 .0qr1 .0YZ1 .0YZ1 l,EF1 l,CD1 l,DE1  l,YZ!1" l,^_#1 1$ /1GH%1& j*VW'1( l,AB)1* j*ST+1, j*BC-1. .0de/10 i)|}112 n  /_  `314 m->?516 j*<=718 j*kl91: j*AB;1< j*:;=1> j*[\?1@ /1VWA1B .0IJC1D .0HIE1 1F /0YZ(*UV.0DE(*?@.0cd.0BC+-MN,  /L  M,._`+-RS/1yz.0ST')\])+>?a1 1 1dg5 5n  &22259!# #
"
""  " W	"
 7" y" F" h" h" \" l" " W" 7" F"  G!"" f#" "$ Y%"& Z'"( )"*  +", -". y/"0 e1"2 e3"4 x5"6 #N7"8 W9": 5;"< W="> G?"@ 7A"B yC" "H %"$"$"("*	! 	!Y6 6p *%&! !yCD
 CD
 C C C	    c                 L   |                      |          }|                     |dg           }|                     |d          }t          |                                          }i }t          dt          |                    D ]}||         }||         }	|                     |          }
i }t          dt          |	                    D ]}|	|         }|                     |dd          }| 	                    |          }||d| 
                    |d          dk    | 
                    |d          dk    |                     |d	          d|                     |d
          dd|                     |d          ddd|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
        datacurrencyr   chainNdeposit_status   withdraw_statusmin_withdraw_feemin_withdraw_amountminr   min_deposit_amountr   deposit)	rS  networkactiveru  r   fee	precisionlimitsinfo)rS  coder{  rI  )publicSpotGetCurrencies	safe_listgroup_bylistkeysrangelensafe_currency_codesafe_string_2network_id_to_codesafe_integersafe_numbersafe_currency_structure)rd  paramsresponseri  groupedByIdr  resultirS  networkEntriesr|  rI  jnetworkEntry	networkIdnetworkCodes                   rf  fetch_currencieszdigifinex.fetch_currencies  s    //77R ~~h33mmD*55K$$&&''q#d))$$ "	 "	AaB(_N**2..DH1c.1122  -a0 ..|WjQQ	"55i@@#*"#00?OPPTUU $ 1 1,@Q R RVW W++L:LMM!% $(#3#3LBW#X#X#'% %
 $(#3#3LBV#W#W#'$ $	 	 )%) )%%(  77&$	9 9  F4LL rg  c                     |                      | j        di           }|                     |dd          }|dk    r|                     |          S |                     |          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)
safe_valuer^  safe_stringr  fetch_markets_v1)rd  r  r^  r  s       rf  fetch_marketszdigifinex.fetch_marketsA  sg     //$,CC!!'85GHH'''((000$$V,,,rg  c                    |                      | j        d          }|                     d|          \  }}g }|)|                    |                     |                     n(|                    |                     |                     |                    |                     |                     |}|d         }|d         }|                     |dg           }	|                     |dg           }
|                     |	|
          }g }t          dt          |                    D ]Y}||         }|                     |dd          }|                     |d	d
          }|                     |dd          }|                      |d          }|                     |          }|                     |          }|                     |          }|                     |dd          }|dk    rdnd}|d u }| }|dnd }|dz   |z   }d }d }|rFd}|dz   |z   dz   |z   }|                     |d          }|sdnd}|                     |d          }|rd}|                    i d|d|d|d|d|d|d|d|d|d|d|d|d dd!dd"|rdndd#|d$|||                     |d%          d d d d |                     |                     |                      |d&                              |                     |                     |                      |d'                              d(d d d)|                     |d*d+          d d)|                     |d,          d d)|                     |d-          d d)d.d |d/
           [|S )0NrE  fetchMarketsV2r   rm  symbol_listri  symbolinstrument_id
base_assetbase_currencyquote_assetquote_currencyclear_currencyis_allowr@   r?   T/rA   :
is_inverseF	isTradingrS  basequotesettlebaseIdquoteIdsettleIdtyperB   rC   rw  contractr   contract_valueamount_precisionprice_precision)amountpricerq  minimum_amountmin_order_amount	tick_sizeminimum_valuer   r  r  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionTypery  rz  createdr{  )r  r^  handle_margin_mode_and_paramsappendpublicSpotGetMarginSymbolspublicSpotGetTradesSymbolspublicSwapGetPublicInstrumentsr  array_concatr  r  r  r  r  r  rc  parse_precisionsafe_number_2)rd  r  rE  r   querypromisesRawpromisesspotMarketsswapMarketsspotDataswapDatar  r  r  marketrS  r  r  r  r  r  r  	isAllowedr  r?   rA   r@   r  	isInverseisLinearr  s                                  rf  r  zdigifinex.fetch_markets_v2M  s   &&t|]CC >>?OQWXX
E!t>>uEEFFFFt>>uEEFFF4>>vFFGGGqkqkj ??;rBB??;;;$$Xx88q#h--(( S	 S	Aa[F##FHoFFB''oNNF((@PQQG''0@AAH**622D++G44E,,X66F ))&*a@@I +x 7 788fDT>D8D(4TT4FCZ%'FIH "e+c1F: OOFLAA	(1=44 OOFK@@	 " !IMM 0b0&0 0 	0
 &0 &0 70 H0 0 0 &0 0 %0 %0 )6$$0  D!0" (#0$ % $ 0 09I J J"&""//0D0DTEUEUV\^pEqEq0r0rss!..t/C/CDDTDTU[]nDoDo/p/pqq   $#! !
  $11&:JL^__# 
  $//DD# 
  $//HH#  $  _0 0 0 0 0 0 0b rg  c                 z   |                      |          }|                     |dg           }g }t          dt          |                    D ]m}||         }|                     |d          }|                    d          \  }}	|                     |          }
|                     |	          }|                    i d|d|
dz   |z   d|
d	|d
d d|d|	dd dddddd dddddddd dddd d d d d d d |                     | 	                    |                     |d                              |                     | 	                    |                     |d                              dd d d| 
                    |d          d dd d d| 
                    |d          d dd|d 	           o|S )!Nri  r   r  _rS  r  r  r  r  r  r  r  r  r  r?   Tr@   rA   FrB   rC   rw  r  r   r  volume_precision)r  r  rq  
min_volume
min_amountr  )	r   r  r  r  r  r  ry  rz  r{  )publicSpotGetMarketsr  r  r  r  splitr  r  rc  r  r  )rd  r  r  r   r  r  r  rS  r  r  r  r  s               rf  r  zdigifinex.fetch_markets_v1  s   ,,V44  //(FB77q#g,,'' 5	 5	AQZF!!&(33B hhsmmOFG**622D++G44EMM /b/$*u,/ / 	/
 $/ &/ 7/ D/ / / $/ / %/ %/ $/  E!/" $#/$   $"&"!..t/C/CDDTDTU[]nDoDo/p/pqq"//0D0DTEUEUV\^pEqEq0r0rss   $#! !
  $//EE# 
  $# 
  $//EE#  $ ]/ / / / / / /` rg  c                    d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |dd          }|                     |dd          }	||d<   t          j        |	|          |d<   |	|d<   |||<   |                     |          S )	Nr{  r   rj  freeavail_balancetotalequityused)	r  r  r  r  accountr  r6   
string_subsafe_balance)
rd  r  r  r  balance
currencyIdr|  r  r  r  s
             rf  parse_balancezdigifinex.parse_balance2  s    2 )q#h--(( 
	# 
	#AqkG))':>>J**:66DllnnG%%gvGGD&&wBBE"GFO%0==GFO$GG"F4LL  (((rg  c                    |                                   d}|                     dd|          \  }}|                     d|          \  }}d}||dk    rd}|                     |          }nO|dk    r|                     |          }n3|dk    r|                     |          }nt          | j        dz             |dk    rdnd}|                     ||g           }| 	                    |          S )	a  
        query for balance and get the amount of funds available for trading or funds locked in orders

        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 typeri  r  )
load_marketshandle_market_type_and_paramsr  privateSpotGetMarginAssetsprivateSpotGetSpotAssetsprivateSwapGetAccountBalancer/   rS  r  r  )rd  r  r   r   r  r  balanceRequestbalancess           rf  fetch_balancezdigifinex.fetch_balanceY  s    	
!??PTV\]]
F >>~vVV
E!Z8%;%;!J66u==HH6!!44U;;HH6!!88??HHtw)WWXXXJ %/&$8$8v??8^R@@!!(+++rg  Nr  r   c                 V   |                                   |                     |          }|                     d||          \  }}i }|||d<   d}|dk    r5|d         |d<   |                     |                     ||                    }n4|d         |d<   |                     |                     ||                    }d}	d}
|dk    r.|                     |di           }
|                     |
d	          }	n|}
|                     |d
          }	| 	                    |
|d         |	          S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        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   rS  r  r  ri  	timestampdate)
r  r  r  publicSwapGetPublicDepthextendpublicSpotGetOrderBookr  r  safe_timestampparse_order_book)rd  r  r   r  r  r   r  requestr  r  	orderBooks              rf  fetch_order_bookzdigifinex.fetch_order_book  sF    	V$$ >>?OQWY_``
E$GG'-d|GO$44T[[%5P5PQQHH &tGH224;;w3N3NOOHN 		&"==I)))[AAII I++Hf==I$$Yx0@)LLLrg  symbolsc                    |                                   |                     |          }|                     |d          }d}||                     |          }d}|                     d||          \  }}i }d}|dk    r*|                     |                     ||                    }n)|                     |                     ||                    }i }|                     |ddg           }	| 	                    |d          }
t          dt          |	                    D ]B}|                     d|
i|	|                   }|                     |          }|d         }|||<   C|                     |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   ri  r  r  )r  market_symbolsr  r  r  publicSwapGetPublicTickersr  publicSpotGetTickersafe_value_2r  r  r  parse_tickerfilter_by_array_tickers)rd  r  r  firstr  r  r  r  r  tickersr  r  	rawTickerr   r  s                  rf  fetch_tickerszdigifinex.fetch_tickers  s    	%%g..  !,,[[''F99.&RXYYf6>>66t{{7F7S7STTHH//GV0L0LMMHb ##HhCC  622q#g,,'' 	$ 	$A%qz I &&y11FH%F#F6NN++FHgFFFrg  c                 j   |                                   |                     |          }i }d}|d         r5|d         |d<   |                     |                     ||                    }n4|d         |d<   |                     |                     ||                    }|                     |d          }|                     |dg           }|                     |di           }|                     |d	i           }	d}
|d         r|}
n|                     d|i|	          }
|                     |
|          S )
a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        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   rS  r  r  r  r   ri  r   )r  r  publicSwapGetPublicTickerr  r  r  r  r  )rd  r  r  r  r  r  r  r  ri  firstTickerr  s              rf  fetch_tickerzdigifinex.fetch_ticker8  s:    	V$$&> 	N'-d|GO$55dkk'66R6RSSHH &tGH//GV0L0LMMH\   622//(Hb99x44oogq"55&> 	>FF[[&$==F  000rg  r   r  c           	         |                      |d          }|dnd}|                     |dd          }|                     ||d |          }|                     ||d |          }|                     |d          }|d         r|                     |d          }|                     |d	          }|                     i d|d|d
|                     |          d| 	                    |dd          d| 	                    |dd          d| 	                    |dd          d|                     |d          d| 	                    |dd          d|                     |d          dd d|                     |d          d|d	|dd dd d| 	                    |dd           d!d | 	                    |d"d#          |                     |d$          |                     |d%          ||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
indexPricer{  )
r  safe_string_upper_2safe_symbolsafe_marketr  r  r  safe_tickeriso8601r  )	rd  r   r  r/  r   marketIdr  r  r  s	            rf  r  zdigifinex.parse_ticker  s   P %%fm<<
$.$:ZZ
++FHoNN!!(FD*EE!!(FD*EE''77	&> 	?))&+>>I// !
f!
!
 Y//!
 D&&vvzBB	!

 4%%feY??!
 4%%feZ@@!
 ))&/BB!
 4%%ffjAA!
 ))&/BB!
 D!
 D$$VZ88!
 T!
 D!
 T!
 d!
  $,,VX?UVV!!
" t#!
$ ,,VULII++FJ??))&,??$-!
 !
 !
. /  	rg  tradec                    |                      |dd          }|                     |d          }|                     |d          }|                     |g d          }|                     |dd          }|                     ||          }||                     |          }|                     |dd	          }	|                      |d
d          }
d }d }|d
         dk    r|                     |d          }	|                     |d          }|                     |d          }|                     |d          }|
|dk    rdnd }|dk    rd}n|dk    rd}nd }|
dk    s|dk    rd}
n|
dk    s|dk    rd}
n|
dk    s|dk    rd}
np|
dk    s|dk    rd}
na|
                    d          }|                     |d          }
|                     |d          }|d}| 	                    |d          }|rdnd}d }|                     |d          }|4|                     |d           }d }|| 
                    |          }||d!}|                     |||	|                     |	          ||||
||d ||d"|          S )#NrS  trade_idorder_idr  )r  volumesizer  r  r  r  r  siderA   
trade_time
order_type
match_role	direction0r   r   r   r  r   r  r  r  4r  r   rm  is_makerrx  fee_currency)r  rj  )rS  r{  r  r  r  r  orderr<  r  r  r  takerOrMakerrx  )r  r  safe_string_nr0  r1  r2  safe_timestamp_2r  r  r  r  
safe_trader4  )rd  r6  r  rS  orderIdpriceStringamountStringr5  r  r  r<  r  rF  	orderType	tradeRoler@  partsisMakerrx  feeCostStringfeeCurrencyIdfeeCurrencyCodes                         rf  parse_tradezdigifinex.parse_trade  s   p tZ88""5*55&&ug66))%1M1M1MNN++E8_MM!!(F33>%%h//F))%EE	!!%88&>V##))%>>I((==I((==I((<<I$#,#3#3ww$C&c!!&#c!1!1#++9#3#3#++9#3#3#++9#3#3JJsOOE##E1--D##E1--D|ooeZ88G&-:777L((66$ ,,UNCCM"O("&"9"9-"H"H%+ C "Y// "( 
  
   	rg  c                 X    |                      |          }|                     |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  )rd  r  r  s      rf  
fetch_timezdigifinex.fetch_timeO  s/     ))&11 ""8];;;rg  c                 |    |                      |          }|                     |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>`
        r|  r   okmaintenanceN)statusupdatedetaurlr{  )publicSpotGetPingr  )rd  r  r  r|  r\  s        rf  fetch_statuszdigifinex.fetch_status^  s]     ))&11   622!))-
 
 	
rg  sincec                    |                                   |                     |          }i }||d         rt          |d          n||d<   d}|d         r5|d         |d<   |                     |                     ||                    }n4|d         |d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )	ar  
        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   rS  r  r  ri  )r  r  rr  publicSwapGetPublicTradesr  publicSpotGetTradesr~  parse_trades)	rd  r  rb  r   r  r  r  r  ri  s	            rf  fetch_tradeszdigifinex.fetch_tradesu  s     	V$$28.Ks5#eGG&> 	N'-d|GO$55dkk'66R6RSSHH &tGH//GV0L0LMMHT ~~h33  vue<<<rg  c           	         |d         r|                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )NrA   r   rm              )r  r  r  )rd  ohlcvr  s      rf  parse_ohlcvzdigifinex.parse_ohlcv  s
    &> 	!!%++  **  **  **  **  **  ##E1--  **  **  **  **  ** rg  r   	timeframec                    |                                   |                     |          }i }d}|d         rP|d         |d<   ||d<   |t          |d          |d<   |                     |                     ||                    }nS|                     |d          }	|d         |d	<   |                     | j        ||          |d
<   |}
|                     |          }|
-||	)|	|	n| 	                                }||nd}|||z  dz  z
  }
|
| 
                    |
dz            }
|
|d<   ||	k|	M| 
                    |	dz            }|-|                     |
||z            }t          ||          |d<   n"||d<   n|                     |
||z            |d<   |                     |d          }|                     |                     ||                    }d}|d         r/|                     |di           }|                     |dg           }n|                     |dg           }|                     |||||          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   rS  r  granularityr   r   untilr  period     
start_timeend_timeri  candles)r  r  rr  publicSwapGetPublicCandlesr  r  r  rY  parse_timeframemillisecondsparse_to_intsumomitpublicSpotGetKliner  parse_ohlcvs)rd  r  ro  rb  r   r  r  r  r  rr  	startTimedurationendTime
startLimit
endByUntil
endByLimitrx  ri  s                     rf  fetch_ohlcvzdigifinex.fetch_ohlcv  s    	V$$&> 	M'-d|GO$%.GM" #&uc?? 66t{{7F7S7STTHH%%fg66E &tGH $ 0 0)Y W WGHI++I66H %5+<(-(9ee@Q@Q@S@SG+0+<3J ':+@4+G HI$ --i$.>??	(1%%5+<(%)%6%6ut|%D%D
 ,)-)UX=M)N)NJ25j*2M2MGJ//2<GJ//.2hhy%(BR.S.S
+YYvw//F..t{{7F/K/KLLH8 &> 	<??8VR88DoodIr::GGooh;;G  &)UEJJJrg  r  r<  r  r  c                    |                                   |                     |          }|                     d|          }|d         }	|                     ||||||          }
d}|d         r|                     |
          }n-|	|                     |
          }n|                     |
          }|                     ||          }|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<  r  r  )r  r  r  create_order_requestprivateSwapPostTradeOrderPlaceprivateSpotPostMarginOrderNewprivateSpotPostSpotOrderNewparse_order)rd  r  r  r<  r  r  r  r  marginResultr   r  r  rE  s                rf  create_orderzdigifinex.create_order.  s   ( 	V$$99-PP!!_
++FD$vVV&> 	E::7CCHH%==gFF;;GDD    622 *hff hgrg  ordersc           	      Z   |                                   g }d}d}t          dt          |                    D ]#}||         }|                     |d          }||}n||k    rt	          | j        dz             |                     |d          }	|                     |d          }
|                     |d          }|                     |d          }|                     |d	i           }|                     d
|          }|d         }|"||}n||k    rt	          | j        dz             |                     ||	|
|||          }|	                    |           %| 
                    |          }i }d}|d         r|                     |          }nA|dnd|d<   |d         |d<   |                     |          |d<   |                     |          }g }|d         r|                     |dg           }n|                     |dg           }g }t          dt          |                    D ]i}||         }i }||         |d<   |d         |d<   |                     |d          |d<   |                     |d          |d<   |	                    |           j|                     ||          S )aL  
        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<  r  r  r  rK   zS createOrders() requires all orders to have the same margin mode(isolated or cross)rA   r@   r?   r  rS  r  ri  	order_idsr9  r  )r  r  r  r  r)   rS  r  r  r  r  r  privateSwapPostTradeBatchOrderjson"privateSpotPostMarketOrderBatchNewr  parse_orders)rd  r  r  ordersRequestsr  r   r  rawOrderr5  r  r<  r  r  orderParamsr  currentMarginModeorderRequestr  r  r  ri  r  individualOrders                          rf  create_orderszdigifinex.create_ordersf  s    	
q#f++&& 	0 	0AayH''(;;H~!X%%$TW/l%lmmm##Hf55D##Hf55D__Xx88FOOHg66E//(HbAAK==nkZZL ,Q ,%!2JJ!%666(  4I  *I  J  J  J44XtT6SXZeffL!!,////V$$&> 	H::>JJHH-7-C&GH &tGH"ii77GFO>>wGGH, &> 	>??8VR88DD??8["==Dq#f++&& 	+ 	+AayH$&O*.q'OJ'/5d|OO,(,(8(88(L(LOH%'+'7'7''J'JOG$MM/****  000rg  c                    |                      |          }d}d}	|                     d||          \  }}|                     d|          \  }	}|	d}i }
|dk    }|dk    }|dk    }|rdnd}|d	         |
|<   |                     |d
|          }d}|r|                     |dd
          }|                     |d          }d}|dk    r|rdnd}||
d<   n|rdnd}||
d<   |rd}|dk    r|rdnd}n |dk    r|rdnd}n|dk    s|rd}n|dk    rd}||                     ||          |
d<   ||
d<   ||
d<   |                     |ddg          }n[|du rdnd}||
d<   d }|dk    rd!}n|                     ||          |
d<   ||z   |
d<   d}d}|                     |dd"d          \  }}|r|dk    r| 	                    |d#          }|                     |d#          }|| 
                    ||          }n|r|t          | j        d$z             |                     |          }|                     |          }|                     t          j        ||                    }| 
                    ||          }n-| 
                    ||          }n|                     ||          }||
d%<   |r|r||
d&<   n||
d&<   |                     |d'g          }|                     |
|          S )(a  
 @ignore
        helper function to build request
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency, spot market orders use the quote currency, swap requires the number of contracts
        :param float [price]: the price at which the order is to be 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  rS  F
reduceOnlyr   r  rk  rm  r  rj  ri  r   r      	   r      GTC   r   Tr  r>  r;   _marketrG  r  a	   createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argumentr  	post_onlypostOnly)r  r  r  is_post_only	safe_boolr  price_to_precisionr~  handle_option_and_paramsr  cost_to_precisionr-   rS  number_to_stringrc  r6   
string_mulamount_to_precisionr  )rd  r  r  r<  r  r  r  r  r   r   r  rA   isMarketOrderisLimitOrdermarketIdRequestr  postOnlyParsedr  r   rM  requestTypesuffixquantityrG  r  rL  rK  costRequests                               rf  r  zdigifinex.create_order_request  s    V$$

!??@TV\^dee
F!??@TV\]]
F!!Jf$)-1?//x#)$< $$]E6BB 7	)eDDJ**6=AAKIu}}$.6aaQ"-$.6aaQ"- 	e##"/6BBQ		%%"/6BBQ		&&M&		$$ #'#:#:65#I#I $-GL!$GFOYYvm'DEEFF#+t#3#3QQ!N *GHFx"#'#:#:65#I#I "VmGFOH04-8<8U8UV\^r  uX  Z^  9_  9_5-v D$%--''776622##55fdCCHH6 	F}*47  6A  ,A  B  B  B'+'<'<V'D'D&*&;&;E&B&B&*&7&78J<Yd8e8e&f&f#'#9#9&+#N#N#55ffEEHH33FFCC (GH 	0 0'5$$'/$6J<00{{7F+++rg  r  c                     |                                   |                     |          }|d         st          | j        dz             d|d<   |                     |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 onlyFrG  r  r  N)r  r  r/   rS  r  )rd  r  r  r  r  s        rf  !create_market_buy_order_with_costz+digifinex.create_market_buy_order_with_cost  ss     	V$$f~ 	ftw)ddeee6;23  5$fMMMrg  rS  c                    |                                   d}||                     |          }t          |          }d}|                     d||          \  }}d|i}|dk    r%|t	          | j        dz             |d         |d<   n||d<   |                     d|          \  }}d}	||d	k    r,d	}|                     |                     ||                    }	nw|d
k    r*| 	                    |                     ||                    }	nG|dk    r*| 
                    |                     ||                    }	nt          | j        dz             |d
k    s|d	k    rt|                     |	dg           }
t          |
          }|dk    rt          | j        dz   |z   dz             |                     |	          }|                     |d          S |                     |	|                     |	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 argumentrS  r  r  r@   r?   z+ cancelOrder() not support self market typesuccessrm  z cancelOrder() 
 not foundr   ri  )r{  rJ  )r  r  strr  r(   rS  r   privateSpotPostMarginOrderCancelr  privateSpotPostSpotOrderCancelprivateSwapPostTradeCancelOrderr/   r  r  r.   parse_cancel_orders	safe_dict
safe_orderr  )rd  rS  r  r  r  r   r  r   r  r  canceledOrdersnumCanceledOrdersr  s                rf  cancel_orderzdigifinex.cancel_order(  s<    	[[((FWW
!??vW]^^
F
 ~'2](]^^^'-d|GO$$ *GH >>}fUU
E!Z8%;%;!J<<T[[RW=X=XYYHH6!!::4;;wPU;V;VWWHH6!!;;DKKQV<W<WXXHHtw)VVWWW, &  jH&<&<!__Xy"EEN #N 3 3 A%%#DG.?$?"$D|$STTT--h77F>>&!,,,?? ++Hf==$ $   rg  c                    |                      |d          }|                      |d          }g }t          dt          |                    D ]6}||         }|                    |                     ||dd                     7t          dt          |                    D ]`}||         }|                    |                     ||                     |dd          d|                     |d	          d
                     a|S )Nr  errorr   canceled)r{  rS  r\  zorder-idr9  failedzclient-order-id)r{  rS  r\  clientOrderId)r~  r  r  r  r  r  r  )rd  r  r  r  r  r  rE  s          rf  r  zdigifinex.parse_cancel_ordersq  s(   ..955x11q#g,,'' 	 	AAJEMM$//$+ +      
 q#e**%% 	 	A!HEMM$//((
JGG"!%!1!1%9J!K!K	+ +       rg  idsc                 h   |                                   |                     | j        dd          }|                     |d|          }|                     |d          }|d                    |          d}|                     |                     ||                    }|                     |          S )aB  
        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>`
        rE  r?   r  ,)r  r9  )r  r  r^  r~  joinr  r  r  )rd  r  r  r  rE  rM  r  r  s           rf  cancel_orderszdigifinex.cancel_orders  s     	&&t|]FKK$$VV[AA	66**
 
 66t{{7F7S7STT ''111rg  r\  c                 @    dddddd}|                      |||          S )Nr!  closedr  )rA  r   r  r  rB  r  rd  r\  statusess      rf  parse_order_statuszdigifinex.parse_order_status  s7    
 
 &&999rg  rE  c                    d }d }d }d }|                      |d          }|                     |dd          }|                     ||          }	|                     |	          }|d         dk    r|                     |d          }
|
|
dk    s|
dk    s|
dk    s|
d	k    s|
d
k    rd}n;|
dk    s|
dk    s|
dk    s|
dk    s|
dk    rd}n|
dk    s|
dk    s|
dk    s|
dk    rd}|
dk    s|
dk    s|
dk    s|
dk    s|
dk    s|
dk    rd}nd}|dk    rd}n|dk    rd}n|dk    rd }n|d!k    rd"}|                     |d#          }|                     |d$          }nk|                     |d%          }|                     |d&          }|=|                    d'          }t          |          }|dk    r|d         }|d         }nd}|                     i d(|d)|                     |d*d+          d,d d-|d.| 	                    |          d/|d|	d|d0|d1d d2|d3| 
                    |d3          d4d d5|                     |d5d6          d7|                     |d8d9          d:d d;d |                     |d<d=          |                     |                     |d>d?                    d;| 
                    |d@          id dA|          S )BNr  r  r  rA   r>  r  r         r  r   rm  ri  rj  rk  r  r            r  r  r   rl  r   r  r   z	open longr  z
open shortr  z
close longrB  zclose shortinsert_time
time_stampcreated_datefinished_dater  r{  rS  r9  ri  r  r  r  lastTradeTimestampr   r  r<  r  r   r  r;  filledexecuted_amount
filled_qty	remainingr  	avg_price	price_avgr\  staterx  )r'  r\  rx  r   )r  r  r1  r  r  r  r  r  r  r4  r  r  r  )rd  rE  r  r  r  r   r  r<  r5  r  rM  rO  numPartss                rf  r  zdigifinex.parse_order  s   @ 	!v..%%eXGG!!(F33V$$&>V##))%>>I$NN	RY"__R[_aRaRagptvgvgv"'KK1nn)q..i1nnR[_`R`R`fosufufu"'KK1nn)q..i1nnR[_aRaRa"'KNN	QINNPY]^P^P^dmqrdrdr  yB  FH  yH  yH"DD#Ds{{"##$))%??I!%!2!25,!G!G++E>BBI!%!4!4UO!L!L

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

 Y// 
 !"4 
 f 
 D 
 ; 
  
 D 
 T%%eW55 
 D 
 d((&AA 
 d((0A<PP 
  ! 
" D# 
$ ))%kJJ--d.@.@RY.Z.Z[[((66 / 
  
  
0 1  	rg  c                    |                                   d}||                     |          }d}|                     d||          \  }}|                     d|          \  }}i }	|dk    }
|
r|||	d<   |||	d<   n||	d<   ||
rdnd}|d	         |	|<   d}||d
k    r,d
}|                     |                     |	|                    }nw|dk    r*|                     |                     |	|                    }nG|dk    r*|                     |                     |	|                    }nt          | j	        dz             | 
                    |dg           }|                     ||||          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  rS  r@   r?   z/ fetchOpenOrders() not support self market typeri  )r  r  r  r   privateSpotGetMarginOrderCurrentr  privateSpotGetSpotOrderCurrentprivateSwapGetTradeOpenOrdersr/   rS  r~  r  )rd  r  rb  r   r  r  r   r   r  r  rA   r  r  ri  s                 rf  fetch_open_orderszdigifinex.fetch_open_orders3  s    	[[((F
!??@QSY[abb
F >>?PRXYY
Ef$ 	+ -2)* #(  *GH15Coo8O'-d|GO$!Z8%;%;!J<<T[[RW=X=XYYHH6!!::4;;wPU;V;VWWHH6!!99$++gu:U:UVVHHtw)ZZ[[[h ~~h33  vue<<<rg  c                    |                                   d}||                     |          }d}|                     d||          \  }}|                     d|          \  }}i }	|dk    r|||	d<   n"||	d<   ||                     |dz            |	d<   ||dk    rdnd	}
|d
         |	|
<   |||	d<   d}||dk    r,d}|                     |                     |	|                    }nw|dk    r*|                     |                     |	|                    }nG|dk    r*|                     |                     |	|                    }nt          | j
        dz             |                     |dg           }|                     ||||          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  rS  r   r@   r?   z+ fetchOrders() not support self market typeri  )r  r  r  r  r|   privateSpotGetMarginOrderHistoryr  privateSpotGetSpotOrderHistory privateSwapGetTradeHistoryOrdersr/   rS  r~  r  )rd  r  rb  r   r  r  r   r   r  r  r  r  ri  s                rf  fetch_orderszdigifinex.fetch_orders  s    	[[((F
!??vW]^^
F >>}fUU
E -2)* *GH (,(9(9%$,(G(G%2<2F2FooXO'-d|GO$$GG!Z8%;%;!J<<T[[RW=X=XYYHH6!!::4;;wPU;V;VWWHH6!!<<T[[RW=X=XYYHHtw)VVWWWh ~~h33  vue<<<rg  c                 F   |                                   d}||                     |          }d}|                     d||          \  }}|                     d|          \  }}d|i}|dk    r||d         |d<   n||d<   d}	||dk    r,d}|                     |                     ||                    }	nw|d	k    r*|                     |                     ||                    }	nG|dk    r*|                     |                     ||                    }	nt          | j	        d
z             | 
                    |	d          }
|dk    r|
n| 
                    |
d          }|*t          | j	        dz   t          |          z   dz             |                     ||          S )a  
        fetches information on an order made by the user

        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   rS  r  r  r@   r?   z* fetchOrder() not support self market typeri  r   z fetchOrder() order r  )r  r  r  r  privateSpotGetMarginOrderr  privateSpotGetSpotOrderprivateSwapGetTradeOrderInfor/   rS  r  r.   r  r  )rd  rS  r  r  r  r   r   r  r  r  ri  rE  s               rf  fetch_orderzdigifinex.fetch_order  s    	[[((F
!??fV\]]
F >>|VTT
E
 !+1$<( *GH"
h(>(>!J55dkk'56Q6QRRHH6!!33DKK4O4OPPHH6!!88We9T9TUUHHtw)UUVVVb x00#v--DOOD!4L4L=*@ @3r77 J\ YZZZv...rg  c                 2   |                                   d}i }||                     |          }d}|                     d||          \  }}|                     d|          \  }}	|dk    r|||d<   n"||d<   ||                     |dz            |d<   |dk    rdnd	}
||d
         ||
<   |||d<   d}||dk    r,d}|                     |                     ||	                    }nw|dk    r*|                     |                     ||	                    }nG|dk    r*|                     |                     ||	                    }nt          | j
        dz             |dk    rdnd}|                     ||g           }|                     ||||          S )aN  
        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  rS  r   r@   r?   z- fetchMyTrades() not support self market typeri  r  )r  r  r  r  r|  privateSpotGetMarginMytradesr  privateSpotGetSpotMytrades privateSwapGetTradeHistoryTradesr/   rS  r~  rf  )rd  r  rb  r   r  r  r  r   r   r  r  r  responseRequestri  s                 rf  fetch_my_tradeszdigifinex.fetch_my_tradesO	  s    	[[((F
!??QWY_``
F >>PVWW
E -2)* *GH (,(9(9%$,(G(G%.8F.B.B//'-d|GO$$GG!Z8%;%;!J88We9T9TUUHH6!!66t{{7E7R7RSSHH6!!<<T[[RW=X=XYYHHtw)XXYYY\ &06%9%9&&~~h<<  vue<<<rg  c                 4    i }|                      |||          S Nr  )rd  r  rF  s      rf  parse_ledger_entry_typez!digifinex.parse_ledger_entry_type	  s    tT222rg  itemrj  c                    |                      |                     |dd                    }|                     |dd          }|                     ||          }|                     ||          }|                     |dd          }|                     |d          }|                     |d          }||                     |d	          }|                     |d d d d d |||d |d || 	                    |          d d
|          S )Nr  finance_typecurrency_markrj  numr%  r  r   r  )r{  rS  r@  r  referenceIdreferenceAccountr  rj  r  beforeafterr\  r  r  rx  )
r  r  r  safe_currencyr  r  r  r  safe_ledger_entryr4  )	rd  r  rj  r  r  r|  r  r  r  s	            rf  parse_ledger_entryzdigifinex.parse_ledger_entry	  s&   * ++D,>,>tV^,\,\]]''ozJJ
&&z8<<%%j(;;##D%::  y11''f55	))$<<I%% $"Y//'
 '
  !  	rg  r|  c                    |                                   i }d}|                     dd|          \  }}|                     d|          \  }}|dk    r|||d<   n"||d<   ||                     |dz            |d<   |dk    rdnd	}	d}
| |                     |          }
|
d
         ||	<   |||d<   d}||dk    r,d}|                     |                     ||                    }nw|dk    r*|                     |                     ||                    }nG|dk    r*|                     |                     ||                    }nt          | j
        dz             d}|dk    r|                     |dg           }n.|                     |di           }|                     |dg           }|                     ||
||          S )a  
        fetch the history of changes, actions done by the user or operations that altered 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-entry-structure>`
        Nrh   rA   r  r  ru  rv  rj  r  rS  r   r@   r?   z+ fetchLedger() not support self market typeri  finance)r  r  r  r|  rj  privateSpotGetMarginFinancelogr  privateSpotGetSpotFinancelog"privateSwapGetAccountFinanceRecordr/   rS  r  parse_ledger)rd  r|  rb  r   r  r  r   r   r  currencyIdRequestrj  r  ledgerri  s                 rf  fetch_ledgerzdigifinex.fetch_ledger	  s    	
!??tU[\\
F >>}fUU
E -2)* *GH (,(9(9%$,(G(G%+5+?+?JJo}}T**H)1$G%&$GG!Z8%;%;!J::4;;wPU;V;VWWHH6!!88We9T9TUUHH6!!>>t{{7TY?Z?Z[[HHtw)VVWWWD __Xvr::FF??8VR88D__T9b99F  5%@@@rg  c                     |                      |d          }|                      |d          }|                     |d          }|                     |          }||d ||dS )Naddress
addressTagrj  )r{  rj  rv  r  tag)r  safe_string_upperr  )rd  depositAddressrj  r  r  r  r|  s          rf  parse_deposit_addresszdigifinex.parse_deposit_address2
  st     "">9==~|<<++NJGG
&&z22"
 
 	
rg  c                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |dg           }|                     ||d         g          }|                     ||          }|t          | j        dz   |z   dz             |S )a7  
        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>`
        rj  rS  ri  r|  Nz5 fetchDepositAddress() did not return an address for zQ - create the deposit address in the user settings on the exchange website first.)r  rj  privateSpotGetDepositAddressr  r  parse_deposit_addressesr,   rS  )	rd  r|  r  rj  r  r  ri  	addressesr  s	            rf  fetch_deposit_addresszdigifinex.fetch_deposit_addressG
  s     	==&&
 44T[[&5Q5QRR x44008H7IJJ	//)T22? +b!bei!i  m@  "@  A  A  Arg  c                    |                                   d }i }| |                     |          }|d         |d<   |t          d|          |d<   d }|dk    r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |dg           }	|                     |	|||d|i          S )NrS  rj  r   r;  ru  ri  r  )r  rj  rr  privateSpotGetDepositHistoryr  privateSpotGetWithdrawHistoryr~  parse_transactions)
rd  r  r|  rb  r   r  rj  r  r  ri  s
             rf  fetch_transactions_by_typez$digifinex.fetch_transactions_by_typeh
  s    
 }}T**H"*4.GJ!#uooGFO988Wf9U9UVVHH99$++gv:V:VWWH* ~~h33&&tXuefd^TTTrg  c                 4    |                      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>`
        ru  r*  rd  r|  rb  r   r  s        rf  fetch_depositszdigifinex.fetch_deposits
  s      ..y$ufUUUrg  c                 4    |                      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        rf  fetch_withdrawalszdigifinex.fetch_withdrawals
  s!     ..|T5%QWXXXrg  c                 >    ddddd}|                      |||          S )NpendingrZ  r  )r   r  r  rB  r  r  s      rf  parse_transaction_statusz"digifinex.parse_transaction_status
  s6     	
 
 &&999rg  transactionc                 4   |                      |dd          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     ||          }|                     |                     |d                    }	|                     |                     |d                    }
|                     |                     |d	                    }|                     |d
          }|                     |d          }d }|||d}|                     |d          }i d|d|d|d|	d|                     |	          d|d|d|dd d|d|dd dd d
|d|d|d|
d d |dS )NrS  withdraw_idr  memohashrj  r  r  r  r  rx  )rj  r  rk  r{  txidr  r  rv  	addressToaddressFromr  tagTotagFromr  r\  r]  )internalcommentrx  )r  r  r  r  	parse8601r4  r  r4  )rd  r5  rj  rS  r  r  r:  r  r|  r  r]  r\  r  feeCostrx  rv  s                   rf  parse_transactionzdigifinex.parse_transaction
  s8   2 T=AA"";	::{F33V44++KDD
&&z8<<NN4#3#3K#P#PQQ	..!1!1+!O!OPP..t/?/?W/U/UVV!!+x88"";66#W55C"";88
K
"
 D
 	

 Y//
 w
 w
 
 4
 3
 S
 t
 D
 f
 
  f!
" w#
$ )
 
 
 	
rg  c                 8    ddi}|                      |||          S )NrA  rZ  r  r  s      rf  parse_transfer_statuszdigifinex.parse_transfer_status
  s(    
 &&999rg  r   c                    d }d }|                      |d|          }|                     |d          }|dk    rd}d}n
|dk    rd}d}|                     |d          }||                     |d          ||                     |          |                     |                     |d	          |          |                     |d
d          |||                     |                     |d                    d	S )Nri  r  rm  r?   rA   ri  r  transfer_idrj  r  transfer_amountr|  )	r{  rS  r  r  rj  r  fromAccount	toAccountr\  )r  r  r  r4  r  r  rE  )rd  r   rj  rI  rJ  ri  r  r  s           rf  parse_transferzdigifinex.parse_transfer
  s   : 	~~h99  v..199 KIIQYY KI%%h<<	""8];;"Y////0@0@z0R0RT\]]((x9JKK&"001A1A(F1S1STT

 

 
	
rg  rI  rJ  c                    |                                   |                     |          }|d         }|                     | j        di           }|                     |||          }	|                     |||          }
i }|dk    }|dk    }d}|                     ||          }|s|r`|	dk    r|
dk    rt          | j        dz             |rdnd|d	<   ||d
<   ||d<   |                     | 	                    ||                    }n=||d<   ||d<   |	|d<   |
|d<   | 
                    | 	                    ||                    }|                     ||          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>`
        rS  rH  rA   Nr   z[ transfer() supports transferring between spot and swap, spot and margin, spot and OTC onlyrm  ri  r  rj  rH  r  r	  fromto)r  rj  r  r^  r  currency_to_precisionr$   rS  privateSwapPostAccountTransferr  privateSpotPostTransferrK  )rd  r|  r  rI  rJ  r  rj  r  rH  fromIdtoIdr  fromSwaptoSwapr  rL  s                   rf  r   zdigifinex.transfer,  s    	==&&d^
7GLL!!.+{KK	9EE6)v%11$?? 	Rv 	R#DCKK#DG  /L  %L  M  M  M#)0aaqGFO",GJ)5G%& ::4;;wPV;W;WXXHH'1GO$)GEN$GFO GDM 33DKK4P4PQQH""8X666rg  r  r  c                 |   |                      ||          \  }}|                     |           |                                  |                     |          }||                     ||          |d         d}|||d<   |                     |                     ||                    }|                     ||          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>`
        rS  )r  r  rj  Nr8  )handle_withdraw_tag_and_paramscheck_addressr  rj  rO  privateSpotPostWithdrawNewr  rC  )	rd  r|  r  r  r  r  rj  r  r  s	            rf  r   zdigifinex.withdrawc  s     99#vFFV7###==&& 00v>> 	
 
 ?!GFO224;;w3O3OPP %%h999rg  c                 P   |                                   i }d }| |                     |          }|d         |d<   |                     |                     ||                    }|                     |d          }	|                     |	|          }
|                     |
|||          S )NrS  r  	positions)r  r  privateSpotGetMarginPositionsr  r  parse_borrow_interestsfilter_by_currency_since_limit)rd  r|  r  rb  r   r  r  r  r  rowsinterests              rf  fetch_borrow_interestzdigifinex.fetch_borrow_interest  s    [[((F &tGH55dkk'66R6RSS, x55..tV<<228T5%PPPrg  r{  c           
      \   |                      |d          }|                      |d          }|                      |d          }t          j        ||          }t          j        ||          }|d n|d         }|                     ||          }	||	|d d|                     |          d d d d	S )Nr  r  leverage_ratior  MbP?)	r{  r  rj  r`  interestRateamountBorrowedr   r  r  )r  r6   
string_divr  r1  rc  )
rd  r{  r  r5  rL  leverageStringamountInvestedrf  rj  r  s
             rf  parse_borrow_interestzdigifinex.parse_borrow_interest  s     ##D(33''h77))$0@AA +L.II +L.II"N44!!(F33 !"//??

 

 
	
rg  c                    |                                   i }|                     |                     ||                    }|                     |dg           }g }t	          dt          |                    D ]&}||         }|                     |d          |k    r|}'|                     |          }	|                     ||	          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   rj  )	r  r  r  r  r  r  r  rj  parse_borrow_rate)
rd  r|  r  r  r  ri  r  r  entryrj  s
             rf  fetch_cross_borrow_ratez!digifinex.fetch_cross_borrow_rate  s     	224;;w3O3OPP$ x44q#d))$$ 	 	AGEz22d::==&&%%fh777rg  c                     |                                   |                     |          }|                     |dg           }|                     |d          S )aO  
        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  rj  )r  r  r  parse_borrow_rates)rd  r  r  r  s       rf  fetch_cross_borrow_ratesz"digifinex.fetch_cross_borrow_rates  sV     	226::$ 6266&&vz:::rg  c                     |                                  }|                     |d          }|                     ||          dd||                     |          |dS )Nrj  rd  i \&)rj  raters  r  r  r{  )r{  r  r  r4  )rd  r{  rj  r  r  s        rf  rl  zdigifinex.parse_borrow_rate
  sg     %%''	%%dJ77
//
HEE"Y//
 
 	
rg  c                     i }t          dt          |                    D ]O}||         }|                     ||          }|                     |          }|                     |          }|||<   P|S )Nr   )r  r  r  r  rl  )	rd  r{  codeKeyr  r  r  rj  r|  
borrowRates	            rf  rp  zdigifinex.parse_borrow_rates  s|     q#d))$$ 	& 	&A7D''g66H**844D//55J%F4LLrg  c                 R   |                                   |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                    }|                     |di           }|                     ||          S )ak  
        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  rS  ri  )r  r  r*   rS  publicSwapGetPublicFundingRater  r  parse_funding_raterd  r  r  r  r  r  ri  s          rf  fetch_funding_ratezdigifinex.fetch_funding_rate0  s     	V$$f~ 	ZDG&XXYYYVD\
 66t{{7F7S7STT ~~h33&&tV444rg  c                 .    |                      ||          S )at  
        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{  )rd  r  r  s      rf  fetch_funding_intervalz digifinex.fetch_funding_intervalQ  s     &&vv666rg  c                 d   |                      |d          }|                     |d          }|                     |d          }|                      |d          }|                      |d          }t          j        ||          }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|                     |          iS )Nr  funding_timenext_funding_timer{  r  r.  r/  re  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)	rd  r  r  r5  r  nextTimestampfundingTimeStringnextFundingTimeStringmillisecondsIntervals	            rf  ry  zdigifinex.parse_funding_rate]  s    ##Ho>>%%h??	))(4GHH ,,X~FF $ 0 0;N O O&12GIZ[[
H
d&&x88
 
 $	

 D
 #D
 
 
 4++HnEE
 	
 t||I66
 t//:MNN
 #M
 "4<<#>#>
 "4
  '!
" &t#
$ 334HII%
 
 	
rg  c                 @    dddddd}|                      |||          S )Nr   r   8h16h24h)360000014400000288000005760000086400000r  )rd  r  	intervalss      rf  r  z digifinex.parse_funding_interval  s7    
 
	 	8X>>>rg  c           
      X   |t          | j        dz             |                                  |                     |          }|d         st	          | j        dz             d|d         i}|||d<   |||d<   |                     |                     ||                    }|                     |d	i           }|                     |d
g           }	g }
t          dt          |	                    D ]}|	|         }| 
                    |d          }|                     |          }|                     |d          }|
                    |||                     |d          ||                     |          d           |                     |
d          }|                     ||||          S )aE  
        fetches historical funding rate prices
        :param str symbol: unified symbol of the market to fetch the funding rate history for
        :param int [since]: timestamp in ms of the earliest funding rate to fetch
        :param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/?id=funding-rate-history-structure>` to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/?id=funding-rate-history-structure>`
        Nz5 fetchFundingRateHistory() requires a symbol argumentrA   z7 fetchFundingRateHistory() supports swap contracts onlyr  rS  r  r   ri  funding_ratesr   r   rs  )r{  r  r  r  r  r  )r(   rS  r  r  r*   %publicSwapGetPublicFundingRateHistoryr  r  r  r  r  r1  r  r  r  r4  sort_byfilter_by_symbol_since_limit)rd  r  rb  r   r  r  r  r  ri  r  ratesr  rm  r5  symbolInnerr  sorteds                    rf  fetch_funding_rate_historyz$digifinex.fetch_funding_rate_history  s    >#DG.e$efffV$$f~ 	aDG&__```VD\
 ).G%&$GG==dkk'SY>Z>Z[[  x44;;q#f++&& 	 	A1IE''o>>H**844K))%88ILL%#//v>>& LL33      e[1100NNNrg  c                 R   |                                   |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                    }|                     |di           }|                     ||          S )aV  
        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  rS  ri  )r  r  r)   rS  #privateSwapGetAccountTradingFeeRater  r  parse_trading_feerz  s          rf  fetch_trading_feezdigifinex.fetch_trading_fee  s     	V$$f~ 	XTW'VVWWWVD\
 ;;DKKQW<X<XYY x44%%dF333rg  rx  c                     |                      |d          }|                     ||          }|||                     |d          |                     |d          d d dS )Nr  maker_fee_ratetaker_fee_rate)r{  r  r   r   r   r   )r  r1  r  )rd  rx  r  r5  r  s        rf  r  zdigifinex.parse_trading_fee  sq     ##C99!!(F33%%c+;<<%%c+;<<
 
 	
rg  c                    |                                   |                     |          }i }d}d}|cd}t          |t                    r5t	          |          }|dk    rt          | j        dz             |d         }n|}|                     |          }|                     d||          \  }}| 	                    d|          \  }}	|d}||dk    rdnd	}
|d
         ||
<   d}|dk    s|dk    r*| 
                    |                     ||	                    }nG|dk    r*|                     |                     ||	                    }nt          | j        dz             |dk    rdnd}|                     ||g           }g }t          dt	          |                    D ]1}|                    |                     ||         |                     2|                     |d	|d          S )a  
        fetch all open positions

        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>`
        Nrm  zD fetchPositions() symbols argument cannot contain more than 1 symbolr   rw   r@   rA   r  r  rS  r?   z. fetchPositions() not support self market typeri  r[  F)r  r   
isinstancer  r  r)   rS  r  r  r  r\  r  privateSwapGetAccountPositionsr/   r  r  r  parse_positionfilter_by_array_positions)rd  r  r  r  r  r   r  symbolsLengthr   r  r  r  positionRequestr[  r  r  s                   rf  fetch_positionszdigifinex.fetch_positions  s%    	%%g..
F'4(( ! #G 1$$$TW/u%uvvv  [[((F!??@PRXZ`aa
F >>?OQWXX
E!!J2<2F2FooXO'-d|GO$:#9#999$++gu:U:UVVHH6!!::4;;wPU;V;VWWHHtw)YYZZZl &06%9%9&&OOHorBB	q#i..)) 	E 	EAMM$--ilFCCDDDD--fhOOOrg  c                    |                                   |                     |          }i }d}|                     d||          \  }}|                     d|          \  }}|d}|dk    rdnd}|d         ||<   d}	|dk    s|dk    r*|                     |                     ||                    }	nG|dk    r*|                     |                     ||                    }	nt          | j        d	z             |dk    rd
nd}
| 	                    |	|
g           }| 
                    |d         |          }|dk    r|S |                     |	d          |d<   |                     |	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  rS  r?   z- fetchPosition() not support self market typeri  r[  r   
collateralmargin_ratemarginRatio)r  r  r  r  r\  r  r  r/   rS  r  r  r  )rd  r  r  r  r  r   r   r  r  r  dataRequestri  positions                rf  fetch_positionzdigifinex.fetch_positionZ  s    	V$$
!??QWY_``
F >>PVWW
E!!J.8F.B.B//#)$< :#9#999$++gu:U:UVVHH6!!::4;;wPU;V;VWWHHtw)XXYYYh ",v!5!5ffKxb99&&tAw77O%)%5%5h%I%IH\"&*&6&6x&O&OH]#Org  r  c                    |                      |dd          }|                     ||          }|d         }|                     |d          }||dk    rdnd}nd}|                     |d          }|                     |d          }|d	k    rd
}n|dk    rd}|                     i d|dd d|d|                     |d          d|d|                     |d          d|                     |dd          d|                     |d          d|                     |d          d|                     |d          d|                     |d          d|dd d|d|                     |          d |                     |d!          d"|                     |d#          d d d |                     |d$d%          |                     |d&          d d d d'          S )(Nr  r  margin_modecrossedcrossisolatedr  r<  go_longlonggo_shortshortr{  rS  notionalr  r   liquidationPriceliquidation_price
entryPriceavg_costentry_priceunrealizedPnlunrealized_pnl	contractsavail_positionr  r.  r  r   r  maintenanceMarginr@   maintenanceMarginPercentagemaint_margin_ratior   rc  margin_ratio)r  initialMargininitialMarginPercentager   r  r   r   r   )r  r2  r  r  safe_positionr  r  r4  )rd  r  r  r5  r  r   r  r<  s           rf  r  zdigifinex.parse_position  s   N %%hJJ!!(F33!%%h>>
!%/9%<%<:JJ"J%%h<<	&119DDZD!! #
H#
$#
 f#
 ((8<<	#

 *#
  0 0;N O O#
 $,,Xz=QQ#
 T--h8HII#
 ))(4DEE#
 D,,V^DD#
 ))(F;;#
 D#
 d#
 #
 Y//#
   !1!1(H!E!E!#
" *4+;+;HFZ+[+[##
$ !'+**8ZAQRR++HnEE!#3#
 #
 #
   	rg  r   c                    |t          | j        dz             |                                  |                     |          }|d         dk    rt	          | j        dz             |dk     s|dk    rt          | j        dz             |d	         |d
}|                     | j        dd          }|                     |dd|          }|'|dk    rdnd}||d<   | 	                    |ddg          }|dk    rN| 
                    |d          }|||d<   | 	                    |d          }n|                     d|dddg           |                     |                     ||                    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
        Nz) setLeverage() requires a symbol argumentr  rA   z+ setLeverage() supports swap contracts onlyrm  r   z% leverage should be between 1 and 100rS  )r  r   r   defaultMarginModer  r  r  r  r<  r   r  r  )r(   rS  r  r  r*   r)   r  r^  safe_string_lower_2r~  r  check_required_argumentprivateSwapPostAccountLeverager  )	rd  r   r  r  r  r  r  r   r<  s	            rf  set_leveragezdigifinex.set_leverage  s    >#DG.Y$YZZZV$$&>V##DG&SSTTTqLLhnnTW'NNOOO#D\ 
 
 !..t|\K^__--flDWYjkk
!'1W'<'<:J%/GM"YYv6I'JKKF####FF33D"&6622,,]D&6SZJ[\\\224;;w3O3OPPPrg  c                 B   |                                   d}i }| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )aQ  
        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>`
        NrS  rj  r  r   ri  )r  r  #privateSwapGetAccountTransferRecordr  r~  parse_transfers)	rd  r|  rb  r   r  rj  r  r  	transferss	            rf  fetch_transferszdigifinex.fetch_transfers7  s     	..t44H"*4.GJ).G%&$GG;;DKKQW<X<XYY  NN8VR88	##IxFFFrg  c                     |                                   |                     |          }|                     |dg           }|                     |          }|                     ||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
        ri  r  )r  r  r  r   parse_leverage_tiers)rd  r  r  r  ri  s        rf  fetch_leverage_tierszdigifinex.fetch_leverage_tiers`  sk     	66v>>< x44%%g..((wHHHrg  c                 R   |                                   |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                    }|                     |di           }|                     ||          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  rS  ri  )r  r  r)   rS  publicSwapGetPublicInstrumentr  r  parse_market_leverage_tiersrz  s          rf  fetch_market_leverage_tiersz%digifinex.fetch_market_leverage_tiers  s     	V$$f~ 	aTW'__```VD\
 55dkk'66R6RSS8 x44//f===rg  c                    g }|                      |di           }t          dt          |                    D ]}||         }|                     |d          }|                     ||          }|                    |                     |d          |                     ||d d          |d         d |                     |d          d |                     |d          |d	           |S )
Nopen_max_limitsr   r  rm  rA   r  	max_limitr   )tierr  rj  minNotionalmaxNotionalmaintenanceMarginRatemaxLeverager{  )	r  r  r  r  r2  r  r}  r1  r  )rd  r{  r  tiersbracketsr  r  r5  s           rf  r  z%digifinex.parse_market_leverage_tiers  s    2 ??4):B??q#h--(( 	 	AA;D''o>>H%%h77FLLA**8VT6JJ"8,##//kBB)-#//jAA	 	 	 	 	 	 rg  c                 &   |                      | j        d          }|                     |dd          }d}t          t          |                               |||          \  }}||dk    rt          | j        dz             n|dk    s|du rd}||gS )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
        rE  r@   FNr  z only cross margin is supportedT)r  r^  r  ra  r8   r  r/   rS  )rd  
methodNamer  defaultValuerE  isMarginr   re  s          rf  r  z'digifinex.handle_margin_mode_and_params  s     &&t|]CC>>&(E::
"9d33QQR\^dfrss
F!W$$"47-N#NOOO % x''X-=-=$
F##rg  codesc                     |                                   |                     |          }|                     |d          }|                     ||          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>`
        ri  )r  r}  r~  parse_deposit_withdraw_fees)rd  r  r  r  ri  s        rf  fetch_deposit_withdraw_feesz%digifinex.fetch_deposit_withdraw_fees  sT     	//77< ~~h////e<<<rg  c                    i }|                      |          }t          dt          |                    D ])}||         }|                     |d          }|                     |          }||                     ||          r|                     ||          }	|	#|                     i           ||<   g ||         d<   ||         d         }
|
                    |           |                     |d          }|                     |d          }||dnd d}d d d}|+| 	                    |          }||d||         d	         |<   |||         d
<   |||         d<   +t          |                                          }t          dt          |                    D ]>}||         }|                     |          }|                     ||         |          ||<   ?|S )Nr   rj  r{  rk  ro  F)rx  r   rt  rI  r   ru  )market_codesr  r  r  r  in_arrayr  deposit_withdraw_feer  r  r  r  rj  $assign_default_deposit_withdraw_fees)rd  r  r  currencyIdKeydepositWithdrawFeesr  rm  r  r|  depositWithdrawFeedepositWithdrawInfor  withdrawFeewithdrawResultdepositResultr  depositWithdrawCodesrj  s                     rf  r  z%digifinex.parse_deposit_withdraw_fees'  s2   6 %'!!%((q#h--(( 	I 	IAQKE))%<<J**:66D4==u#=#=%)__5H$%O%O"%-040I0I"0M0M'-8:'-f5&9$&?&G##**5111 ,,UG<<	"ooe5GHH&,7,C%%$( (
  "&' ' ("&"9"9)"D"DK$2#0J J'-j9+FF
 =K'-j9;H'-i8#$7$<$<$>$>??q#23344 	w 	wA'*D}}T**H(,(Q(QRefjRkmu(v(v%%""rg  c                     |                      |d          }|                     d|dddg           |                     ||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  rm  r  r  modify_margin_helperrd  r  r  r  r<  s        rf  
add_marginzdigifinex.add_margini  sR     //$$[$@QRRR((FCCCrg  c                     |                      |d          }|                     d|dddg           |                     ||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  ri  r  r
  s        rf  reduce_marginzdigifinex.reduce_marginy  sR     //$$^T6FGCTUUU((FCCCrg  c                    |                                   |                     |d          }|                     |          }|d         |                     |          ||d}|                     |                     ||                    }|                     |d          }	|	dk    rdnd}
|                     |di           }|                     |                     ||          d	|
i          S )
Nr<  rS  )r  r  r  r<  r|  r   rZ  r  ri  r\  )	r  r  r  r  $privateSwapPostAccountPositionMarginr  r  r  parse_margin_modification)rd  r  r  r  r  r<  r  r  r  r|  r\  ri  s               rf  r	  zdigifinex.modify_margin_helper  s    //V$$#D\++F33	
 
 <<T[[RX=Y=YZZ   622!))(x44{{499$GGfJ
   	rg  ri  c                     |                      |d          }|                     |d          }||                     ||d d          |dk    rdndd|                     |d          d |d	         d d d d

S )Nr  r  rA   rm  addreducer  r  r  )
r{  r  r  r   r  r  r|  r\  r  r  )r  r  r1  r  )rd  ri  r  r5  rawTypes        rf  r  z#digifinex.parse_margin_modification  s     ##D/::##D&11&&xvFF%llEE$&&tX668$
 
 	
rg  c                 v   |                                   i }|                     d||          \  }}d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                    }|                     |dg           }|                     ||||          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_timestampNrS  r  r   r  ri  )r  handle_until_optionr  privateSwapGetAccountFundingFeer  r~  parse_incomes)	rd  r  rb  r   r  r  r  r  ri  s	            rf  fetch_funding_historyzdigifinex.fetch_funding_history  s     	22?GVTT[[((F'-d|GO$$GG).G%&77GV8T8TUU ~~h33!!$u===rg  c           
      :   |                      |d          }|                      |d          }|                     |d          }||                     ||d d          |                     |          ||                     |          d |                     |d          dS )Nr  rj  r  rA   r  )r{  r  r|  r  r  rS  r  )r  r  r1  r  r4  r  )rd  incomer  r5  r  r  s         rf  parse_incomezdigifinex.parse_income  s     ##FO<<%%fj99
%%fk::	&&xvFF++J77"Y//&&vx88
 
 	
rg  r   c                 &   |t          | j        dz             |                                  |                     |          }|                                }|dk    rd}|d         |d}|                     |                     ||                    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
        Nz+ setMarginMode() requires a symbol argumentr  r  rS  )r  r  )r(   rS  r  r  lower"privateSwapPostAccountPositionModer  )rd  r   r  r  r  r  s         rf  set_margin_modezdigifinex.set_margin_mode  s     >#DG.[$[\\\V$$%%''
  "J#D\%
 
 66t{{7F7S7STTTrg  GETc                    |d         dk    }|d         }|dk    rdnd}	d|                      ||          z   }
|	|
z   }| j        d         d	         |z   }|                     ||                     |                    }d }|r!|	dk    r|d
k    rt	          j        |          }n(|                     |                     |                    }|rd }d }|	dk    rFt          | 	                                          }||z   |z   }|dk    r|r|d|z   z  }n/|d
k    r||z  }n#t          | 
                                          }|}|                     |                     |          |                     | j                  t          j                  }|dk    r|r|d|z   z  }n|d
k    rddi}|r|}| j        ||d}n
|r|d|z   z  }||||dS )Nr   r   rm  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_paramsrZ  r~  extract_paramsr  dumps	urlencodekeysortr  r{  noncehmacencodesecrethashlibsha256apiKey)rd  pathr   r  r  r'  r&  signedendpointpathPartr  payloadr_  r  
urlencodedauthr-  	signatures                     rf  signzdigifinex.sign  s(   Q9$q6%//55j++D&999W$iv&0		&$"5"5d";";<<
 	=x:--Ff4D4DF++JJU(;(;<<J 	(DE:%%D--//00v~/U??! 1j 00v%%J&DDJJLL))!		$++d"3"3T[[5M5Mw~^^I ,3++C6!!"$G  &%D"k($) GG  (sZ''fdwOOOrg  
statusCode
statusTextr_  r  responseHeadersc
                     |sd S |                      |d          }
|
dk    s|
dk    rd S | j        dz   |z   }|
t          |          t          |g}|                     | j        d         |
|          \  }} ||          )Nr|  rA  200 r
  )r  rS  r4   r$   r  r]  )rd  r=  r>  r_  r  r?  responseBodyr  requestHeadersrequestBodyr|  feedbackunknownErrorExceptionClassmessages                  rf  handle_errorszdigifinex.handle_errorsD  s     	4&11CKKTU]]47S=</<h'''%x0"&//$/'2JDR^"_"_nW%%%rg  r  )NN)u__name__
__module____qualname__r   rb  r
   r  r#   r   r  r  r  r   r  r  r  r   r   r  r   r   r	  r   r  dictr  r   rT  rX  ra  rg  r  rn  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.  r1  r4  rC  rE  r"   rK  r   r   r   ra  rj  r   rn  r	   rq  rl  rp  r   r{  r}  ry  r  r  r    r  r  r   r  r  r  intr  r  r   r  r   r  r  r  r  r  r   r  r  r	  r  r  r  r!  r<  rJ  __classcell__)re  s   @rf  r8   r8   !   s       D# D D D D D DL ') V VZ V V V Vp $& 
- 
-$v, 
- 
- 
- 
- ') X X X Xt ') I I I IV%) %) %) %) %)N $& ?, ?,( ?, ?, ?, ?,B :>b GM GMs GM3 GMY GM GM GM GMR 04B SG SGW SG7 SG SG SG SGj 02 K1 K13 K1f K1 K1 K1 K1ZH H4 H H6 H H H HT~ ~ ~v ~ ~ ~ ~ ~@ !# < <s < < < < #% 
 
 
 
. 6:UW C= C=3 C=s C=# C=\`af\g C= C= C= C=J  4    < 9=4^bkm TK TK# TK# TKS TKX[ TKrvw{r| TK TK TK TKl gksu 6 63 6i 6y 6RW 6`c 6 6 6 6p @B S1 S1D$6 S1 S1 S1 S1j os{} Y, Y,3 Y,i Y,y Y,Z_ Y,hk Y, Y, Y, Y,v RT N N N5 N N N N$ 37r G Gs GC G G G GR  * ;?r 2 2c 2C 2 2 2 2>: : : : :B B Bv B B B B BH /3TXac ^= ^= ^=3 ^=c ^=hlmrhs ^= ^= ^= ^=@ *.Dt\^ _= _=3 _=c _= _=cghmcn _= _= _= _=B 26b Y/ Y/c Y/3 Y/ Y/ Y/ Y/v -1tRV_a Z= Z=c Z= Z=C Z= Z= Z= Z=x3 3 3. .t .x .; . . . .` (,$TZ\ QA QA QAC QAs QAaefqar QA QA QA QAf
 
h 
R` 
 
 
 
* 79  # ^    B <@daenp (U (US (U (U[^ (U (U (U (UT *.Dt\^ 	V 	V3 	Vc 	V 	Vcghsct 	V 	V 	V 	V -1tRV_a 	Y 	Yc 	Y 	YC 	Yfjkvfw 	Y 	Y 	Y 	Y	:s 	: 	: 	: 	:=
 =
T =
X =
Q\ =
 =
 =
 =
~:C :C : : : :2
 2
t 2
x 2
= 2
 2
 2
 2
h [] 57 57S 57% 57c 57c 57an 57 57 57 57n KOWY : :S :% :# :C :^i : : : :> 15DW[jnwy Q Q# Qc QQT Qdg Q  C  DR  S Q Q Q QB
 
$ 
 
. 
 
 
 
B 9; %8 %8C %8 %8 %8 %8 %8N /1 ; ;5E ; ; ; ;>
 
 
 
 
 
(  $ 68 5 5 5K 5 5 5 5B :< 
7 
7S 
7 
7 
7 
7 
7#
 #
6 #
[ #
 #
 #
 #
J? ? ? 8<$]ajl 6O 6O 6OC 6OWZ 6O 6O 6O 6Op 57 4 4 4;N 4 4 4 4>
 
T 
6 
EX 
 
 
 
& 26b bP bPw bPT(^ bP bP bP bPH 24 W WS W W W WrO Ot OV O O O Ob 9=R &Q &QS &Q# &Q &Q &Q &Qf +/TPT]_ 'G 'GC 'Gs 'G# 'Gdhivdw 'G 'G 'G 'GR 7;2 +I +IG +I- +I +I +I +IZ ?A .> .># .>T,EW .> .> .> .>`) ) )$|J\ ) ) ) )V @BPT $ $ $ $ $ $& <@ *= *= *= *= *= *=X@# @# @# @#D =? D D De DCU D D D D  @B D DC D DFX D D D D  FH  3 L^    :
 
d 
F 
N` 
 
 
 
0 37TX\eg '> '>C '>s '>RU '> '> '> '>R
 
6 
 
 
 
, >B" U U# Us U U U U0  b$T -P -P -P -P^& & &3 &PS &fj & & & & & & & &rg  r8   )>ccxt.base.exchanger   ccxt.abstract.digifinexr   r1  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    rg  rf  <module>rZ     so   ( ' ' ' ' ' / / / / / /   w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . + + + + + + ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) ) ) ) ) ) ) + + + + + + . . . . . . ) ) ) ) ) ) ( ( ( ( ( ( 4 4 4 4 4 4 % % % % % %n@& n@& n@& n@& n@&+ n@& n@& n@& n@& n@&rg  