
    eij                         d dl mZ d dlm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 d dlmZ d dlmZ d dlmZ d dlmZ  G d	 d
ee          ZdS )    )Exchange)ImplicitAPIN)AnyBalancesCurrencyDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrTickerTradeTradingFeesTransaction)List)
BadRequest)	TICK_SIZE)Precisec                   X    e Zd Zdef fdZi fdee         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d1d
ededefdZi fdedefdZd1dededefdZdefdZdefdZdi fdedefdZdddi fdedededee         fdZdddi fdedededee         fdZdddi fdededefdZd1dededefdZddi fdedededee         fdZi fdefdZ di fdede!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(d1d'e)de'fd(Z*di fd%ed!e#d)ed*ede+f
d+Z,d1d,ed'e)de+fd-Z-d.d/i ddfd0Z. xZ/S )2independentreservereturnc                    |                      t          t          |                                           d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
d/d
d0d
d1d
d2d
d3d
d4d
d5d
d6d
d7d
d8d
d9d
d:d
i d;d
d<d
d=d
d>dd?d
d@d
dAd
dBd
dCd
dDddEd
dFd
dGd
dHddId
dJd
dKdi dLddMd
dNd
dOd
dPd
dQd
dRd
dSd
dTd
dUd
dVd
dWd
dXddYddZd
d[dd\d
d
d
d
d
d
d
d
d
dd]	d^d_d`dadbdcdddeg dfidgg dhidadi|                     dj          |                     dj          dd
dkid
d
d
d d
d
d
d ddddd
dld
d
d
d
d
d
d
dmd d
dnd d d
dod
d
d
d
dpd
dnd
d
d
dqd d
dnd d d d
d
d
drd ds	d d dtd d dtdudvdwit
          i dxdydzdyd{d|d}d~ddyddddddyddddddyddddyddyddyddyddyi ddyddyddyddddyddddyddddddyddyddyddddddddyddyd|dyd~dddddddddddddd          S )Nr   zIndependent ReserveAUNZi  TCORSspotmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercloseAllPositionsclosePositioncreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAllGreeksfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTradesfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchPositionfetchPositionForSymbolWsfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsForSymbolWsfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTradesfetchTradingFeefetchTradingFeesfetchUnderlyingAssets)	fetchVolatilityHistoryreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModewithdrawzdhttps://user-images.githubusercontent.com/51840849/87182090-1e9e9080-c2ec-11ea-8e49-563db9a38f37.jpgz)https://api.independentreserve.com/Publicz*https://api.independentreserve.com/Private)publicprivatez"https://www.independentreserve.comz&https://www.independentreserve.com/API)logoapiwwwdocget)GetValidPrimaryCurrencyCodesGetValidSecondaryCurrencyCodesGetValidLimitOrderTypesGetValidMarketOrderTypesGetValidOrderTypesGetValidTransactionTypesGetMarketSummaryGetOrderBookGetAllOrdersGetTradeHistorySummaryGetRecentTrades
GetFxRatesGetOrderMinimumVolumesGetCryptoWithdrawalFeesGetCryptoWithdrawalFees2GetNetworksGetPrimaryCurrencyConfig2post)GetOpenOrdersGetClosedOrdersGetClosedFilledOrdersGetOrderDetailsGetAccountsGetTransactionsGetFiatBankAccounts GetDigitalCurrencyDepositAddress!GetDigitalCurrencyDepositAddress2"GetDigitalCurrencyDepositAddresses#GetDigitalCurrencyDepositAddresses2	GetTradesGetBrokerageFeesGetDigitalCurrencyWithdrawalPlaceLimitOrderPlaceMarketOrderCancelOrder0SynchDigitalCurrencyDepositAddressWithBlockchainRequestFiatWithdrawalWithdrawFiatCurrencyWithdrawDigitalCurrencyWithdrawCryptotradingz0.005)takermaker
percentage	tierBased)GTCIOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedselfTradePreventiontrailingleveragemarketBuyByCostmarketBuyRequiresPriceicebergd   )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )r   r   r   daysBackCanceledr   r   r   r   )	sandboxr,   createOrdersr[   rb   r_   fetchOrdersr9   
fetchOHLCV)linearinverse)r    r"   r#   PLAPlayChipUSDTEthereumUSDCBTCBitcoinBCHBitcoinCashETHLTCLitecoinXRP	XrpLedgerZRXEOSEosIoXLMStellarBATETCEthereumClassicLINKMKRDAICOMPSNXYFIAAVEGRTDOTPolkadotUNIADACardanoMATICDOGEDogecoinSOLSolanaMANASANDSHIBTRXTronRENDERWIFRLUSDPEPE	BitcoinSV)r   r   r   r   r   r   r   r   BSVr   r   r   r   r   )defaultNetworksnetworks)idname	countries	rateLimitprohasurlsr   feesfeaturescommonCurrenciesprecisionModeoptions)deep_extendsuperr   describeparse_numberr   )self	__class__s    U/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/independentreserve.pyr  zindependentreserve.describe   s'	   &8$ ? ? H H J J&)___ %_ 	_
 %_ %_ U_ $U_ '_ _ t_ $U_  _ t_ (_  '!_" (#_ _$ "5%_& !%'_( )_* &u+_, "5-_. +E/_0 )%1_2 #E3_4 ,U5_6 $T7_8 '9_: (;_< "5=_> &t?_@ (A_B 1%C_D &uE_ _ _F 'G_H (I_J #EK_L *5M_N $UO_P uQ_R "5S_T *5U_V +EW_X )%Y_Z  [_\ !%]_^ %e__` $Ua_b &uc_d -ee_f /g_ _ _h "5i_j #Ek_l +Em_n o_p !%q_r !%s_t "5u_v &uw_x +Ey_z  {_| $U}_~ +E_@ %eA_B "4C_D uE_F #EG_H dI_ _ _J !$K_L  M_N +EO_P 'Q_R $US_T !%U_V *5W_X ,UY_Z ([_\ %e]_^ )%__` )%a_b tc_d te_f "5g_h #Di_j (k_ _l +0 %$)',$"!&#( }_ _ _B IK  <?     ,    -0 0d !..w77!..w77"&!&	   %&+(-,0,1).+06:#'#'#'"&#(( ( #(/4$)$)+027#(+$ $. %)&+!$$(%)*/& & ',#($)*/	# # ',!$#($)*/( ( $(&+!$$(,0%)#($)*/	* 	* #'s: :x ## 
 ## AD DL z! '#$J#$J#$ 9#$ =	#$
 :#$ :#$ ;#$ :#$ 7#$ 9#$ :#$ ,#$ J#$ :#$ :#$  J!#$" :##$ #$$ :%#$& J'#$( :)#$* :+#$, :-#$. 9/#$0 Z1#$2 J3#$4 85#$6 J7#$8 J9#$: J;#$< 6=#$> h?#$@ 8A#$B ZC#$D JE#$ #$J %%(%&"$,&&%$#! K5 5cgM
 gM
 g g g	    c                    |                      |          }|                     |          }|                     |          }|||g\  }}}g }t          dt	          |                    D ]}	||	         }
|                     |
          }|                     ||
          }t          dt	          |                    D ]}||         }|                     |          }|
dz   |z   }|                    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
           |S )z
        retrieves data on all markets for independentreserve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r   /r  symbolbasequotesettleNbaseIdquoteIdsettleIdtyper    Tr!   Fr"   r#   r$   activecontractr   )amountprice)minmax)r   r'  r(  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)%publicGetGetValidPrimaryCurrencyCodes'publicGetGetValidSecondaryCurrencyCodespublicGetGetOrderMinimumVolumesrangelensafe_currency_codesafe_numberappend)r  paramsbaseCurrenciesPromisequoteCurrenciesPromiselimitsPromisebaseCurrenciesquoteCurrenciesr2  resultir!  r  	minAmountjr"  r  r  s                    r  fetch_marketsz independentreserve.fetch_markets<  s    !% J J6 R R!%!M!Mf!U!U<<VDD3HJ`bo2p/ q#n--.. 8	 8	A#A&F**622D((88I1c/2233 4 4)!,//88c\G+ 0"0dSj500 D0 U	0
 d0 f0 w0 0 F0 D0 e0 E0 e0 e0 d0  !0" d#0$  $$("&*""&"&!%" " $(#'% %
 $-#'# #
 $(#'" "
 $(#'! ! $  $_0 0 0 0 0 0 0	4j r  c                 p   d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )Nr4  r   CurrencyCodeAvailableBalancefreeTotalBalancetotal)r8  r9  safe_stringr:  accountsafe_balance)r  responserC  rD  balance
currencyIdcoderO  s           r  parse_balancez independentreserve.parse_balance  s    )q#h--(( 	# 	#AqkG))'>BBJ**:66DllnnG"..w8JKKGFO#//HHGG"F4LL  (((r  c                 ~    |                                   |                     |          }|                     |          S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        )load_marketsprivatePostGetAccountsrU  )r  r=  rQ  s      r  fetch_balancez independentreserve.fetch_balance  s=     	..v66!!(+++r  Nr  r   c           	      \   |                                   |                     |          }|d         |d         d}|                     |                     ||                    }|                     |                     |d                    }|                     ||d         |dddd	          S )
a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :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
        r!  r"  primaryCurrencyCodesecondaryCurrencyCodeCreatedTimestampUtcr  	BuyOrders
SellOrdersPriceVolume)rW  marketpublicGetGetOrderBookextend	parse8601rN  parse_order_book)r  r  r   r=  rc  requestrQ  	timestamps           r  fetch_order_bookz#independentreserve.fetch_order_book  s     	V$$#)(#3%+I%6
 
 --dkk'6.J.JKKNN4#3#3H>S#T#TUU	$$Xvh/?KYegnpxyyyr  tickerrc  c                    |                      |                     |d                    }|                     |d          }|                     |d          }d }|
||dz   |z   }|                     ||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|          S )Nr^  PrimaryCurrencyCodeSecondaryCurrencyCoder  r  	LastPriceri  datetimehighDayHighestPricelowDayLowestPricebidCurrentHighestBidPrice	bidVolumeaskCurrentLowestOfferPrice	askVolumevwapopencloselastpreviousClosechanger   averageDayAvgPrice DayVolumeXbtInSecondaryCurrrency)
baseVolumequoteVolumer4  )rf  rN  safe_marketsafe_tickeriso8601)	r  rk  rc  ri  r!  r"  defaultMarketIdr  r~  s	            r  parse_tickerzindependentreserve.parse_ticker  s    NN4#3#3F<Q#R#RSS	!!&*?@@""6+BCCW%8$slW4O!!/63??!44 !
f!
!
 Y//!
 D$$V->??	!

 4##F,<==!
 4##F,DEE!
 !
 4##F,EFF!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t''>>#!
$ **63UVV)!
 !
 !
* +  	r  c                     |                                   |                     |          }|d         |d         d}|                     |                     ||                    }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :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>`
        r!  r"  r[  )rW  rc  publicGetGetMarketSummaryre  r  )r  r  r=  rc  rh  rQ  s         r  fetch_tickerzindependentreserve.fetch_ticker  s~     	V$$#)(#3%+I%6
 
 11$++gv2N2NOO   6222r  orderc           
      V   d }|                      |d          }|                      |d          }d }d }|5|3|                     |          }|                     |          }|dz   |z   }n||d         }|d         }|d         }|                     |dd          }d }	|n|                    d	          d
k    rd}	n|                    d          d
k    rd}	|                    d          d
k    rd}n|                    d          d
k    r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,          | 
                    |                      |d-                    |||d.d d/|          S )0Nrm  rn  r  r  r  r  Typer   Bidr   buyOffersellr
   rc  Limitr   r^  VolumeFilled
FeePercentr4  r  	OrderGuidclientOrderIdri  rp  lastTradeTimestampr$  r   TimeInForcepostOnlysider(  ra  r   r+  Valuer  AvgPricer'  VolumeOrderedrb  filledOutstandingStatus)rater+  currency)	remainingstatusfeetrades)rN  r:  safe_string_2findrf  r   
string_mul
safe_orderr  parse_time_in_forceparse_order_status)r  r  rc  r  r!  r"  r  r  	orderTyper  ri  r  feeRatefeeCosts                 r  parse_orderzindependentreserve.parse_order  sh   d !!%)>??""5*ABBW%8**622D++G44ECZ%'FFH%F&>D7OE&&ufkBB	 ~~e$$))((A--~~h''1,,$		((A--#	NN4#3#3E;P#Q#QRR	!!%88""5,776#5(&99G  
E 
$""5+66 
 T 
 	 

 Y// 
 !$ 
 f 
 I 
 433D4D4DUM4Z4Z[[ 
  
 D 
 T%%eW55 
 D 
 D$$UG44 
 t''z:: 
  d((JJ! 
" f# 
$ ))%??--d.>.>uh.O.OPP  
 3 
  
  
4 5  	r  r  c           	      F    ddddddddd}|                      |||          S )Nr|  closedcanceled)OpenPartiallyFilledFilledPartiallyFilledAndCancelled	CancelledPartiallyFilledAndExpiredExpiredFailedrN  )r  r  statusess      r  r  z%independentreserve.parse_order_statusk  s@    %+5#)3! 	
 	
 &&999r  r   c                 >    ddddd}|                      |||          S )Nr   r   r   r   )GtcMocFokIocr  )r  r   timeInForcess      r  r  z&independentreserve.parse_time_in_forcex  s4    	
 
 k;GGGr  r  c                     |                                   |                     |                     d|i|                    }d}||                     |          }|                     ||          S )a]  
        fetches information on an order made by the user
        :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>`
        	orderGuidN)rW  privatePostGetOrderDetailsre  rc  r  )r  r  r  r=  rQ  rc  s         r  fetch_orderzindependentreserve.fetch_order  s}     	224;;@
4 4   [[((F&111r  sincec                 X   |                                   i }d}|+|                     |          }|d         |d<   |d         |d<   |d}d|d<   ||d	<   |                     |                     ||                    }|                     |d
g           }|                     ||||          S )a  
        fetch all unfilled currently open orders
        :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>`
        Nr!  r\  r"  r]  2      	pageIndexpageSizeData)rW  rc  privatePostGetOpenOrdersre  	safe_listparse_orders	r  r  r  r   r=  rh  rc  rQ  datas	            r  fetch_open_ordersz$independentreserve.fetch_open_orders  s     	[[((F-3H-=G)*/5i/@G+,=E #
00Wf1M1MNN~~h33  vue<<<r  c                 X   |                                   i }d}|+|                     |          }|d         |d<   |d         |d<   |d}d|d<   ||d	<   |                     |                     ||                    }|                     |d
g           }|                     ||||          S )a  
        fetches information on multiple closed orders made by the user
        :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>`
        Nr!  r\  r"  r]  r  r  r  r  r  )rW  rc  privatePostGetClosedOrdersre  r  r  r  s	            r  fetch_closed_ordersz&independentreserve.fetch_closed_orders  s     	[[((F-3H-=G)*/5i/@G+,=E #
224;;w3O3OPP~~h33  vue<<<r  r  c                 *   |                                   |                     |dd          }|d}||d}|                     |                     ||                    }d}||                     |          }|                     |d         |||          S )a  
        fetch all trades made by the user
        :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>`
        r  r  Nr  )r  r  r  )rW  safe_integerprivatePostGetTradesre  rc  parse_trades)	r  r  r  r   r=  r  rh  rQ  rc  s	            r  fetch_my_tradesz"independentreserve.fetch_my_trades  s     	%%fk1==	=E"
 
 ,,T[[&-I-IJJ[[((F  &!165%HHHr  tradec                 >   |                      |d                   }|                     |d          }|                     |d          }|                     |dd          }|                     |dd          }|                     |          }|                     |          }	|                     t	          j        ||                    }
|                     |d          }|                     |d	          }d }|
||d
z   |z   }|                     ||d
          }|                     |d          }|7|                    d          dk    rd}n|                    d          dk    rd}|                     |||| 	                    |          ||d |d ||	|
d d|          S )NTradeTimestampUtc	TradeGuidr  ra  SecondaryCurrencyTradePriceVolumeTradedPrimaryCurrencyAmountrm  rn  r  r   r  r   r  r  r  )r  r4  ri  rp  r  r  r$  r  takerOrMakerr(  r'  r+  r  )
rf  rN  r  r  r   r  safe_symbolr  
safe_trader  )r  r  rc  ri  r  orderIdpriceStringamountStringr(  r'  r+  r!  r"  marketIdr  r  s                   r  parse_tradezindependentreserve.parse_trade  s   NN5)<#=>>	e[11""5+66((9VWW))%AXYY!!+..""<00  !3K!N!NOO!!%)>??""5*ABBW%8|g-H!!(FC88{33yy1$$7##q(("Y//  
  
   	r  c                    |                                   |                     |          }|d         |d         dd}|                     |                     ||                    }|                     |d         |||          S )a  
        get the list of most recent trades for a particular symbol
        :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>`
        r!  r"  r  )r\  r]  numberOfRecentTradesToRetrieveTrades)rW  rc  publicGetGetRecentTradesre  r  )r  r  r  r   r=  rc  rh  rQ  s           r  fetch_tradeszindependentreserve.fetch_trades  s     	V$$#)(#3%+I%6.0
 

 00Wf1M1MNN  (!3VUEJJJr  c                    |                                   |                     |          }i }t          dt          |                    D ]S}||         }|                     |d          }|                     |          }|                     |d          }||d||<   Ti }	t          dt          | j                            D ]}| j        |         }
|                     |
          }| 	                    ||d         i           }| 	                    |d          |
|                     |d          |                     |d          ddd	|	|
<   |	S )
a  
        fetch the trading fees for multiple markets
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/?id=fee-structure>` indexed by market symbols
        r   rI  Fee)r4  r  r  r4  r  T)r4  r  r   r   r   r   )
rW  privatePostGetBrokerageFeesr8  r9  rN  r:  r;  symbolsrc  
safe_value)r  r=  rQ  r  rD  r  rS  rT  
tradingFeerC  r  rc  s               r  fetch_trading_feesz%independentreserve.fetch_trading_fees  se    	33F;; q#h--(( 	 	A1+C))#~>>J**:66D))#u55J! DJJ q#dl++,, 	 	A\!_F[[((F//$v;;CV44 ))#u55))#u55"! F6NN r  r$  r  r'  r(  c                    |                                   |                     |          }|                     |          }||dk    rdndz  }|d         |d         |d}	d}
||	d<   |d	k    r/||	d
<   |                     |                     |	|                    }
n)|                     |                     |	|                    }
|                     |
|
d         d|          S )a]  
        create a trade order
        :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 of currency you want to trade in units of base currency
        :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: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        r  r  r  r!  r"  )r\  r]  r  Nvolumer   r(  r  )r4  r  )rW  rc  
capitalizeprivatePostPlaceLimitOrderre  privatePostPlaceMarketOrderr  )r  r  r$  r  r'  r(  r=  rc  r  rh  rQ  s              r  create_orderzindependentreserve.create_order;  s    	V$$OOD))	WWe;	#)(#3%+I%6"
 

 "7??$GG66t{{7F7S7STTHH77GV8T8TUUH;' 
  
   	r  c                     |                                   d|i}|                     |                     ||                    }|                     |          S )a  
        cancels an open order

        https://www.independentreserve.com/features/api#CancelOrder

        :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>`
        r  )rW  privatePostCancelOrderre  r  )r  r  r  r=  rh  rQ  s         r  cancel_orderzindependentreserve.cancel_order[  s[     	
 ..t{{7F/K/KLL  )))r  rT  c                     |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |          S )a  
        fetch the deposit address for a currency associated with self account

        https://www.independentreserve.com/features/api#GetDigitalCurrencyDepositAddress

        :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>`
        r\  r  )rW  r  +privatePostGetDigitalCurrencyDepositAddressre  parse_deposit_address)r  rT  r=  r  rh  rQ  s         r  fetch_deposit_addressz(independentreserve.fetch_deposit_address|  sr     	==&&!8D>
 CCDKKPWY_D`D`aa ))(333r  r  c                     |                      |d          }|                     |           ||                      |d          d ||                      |d          dS )Nr   rT  Tag)r4  r  networkaddresstag)rN  check_address)r  depositAddressr  r  s       r  r  z(independentreserve.parse_deposit_address  sl     "">3CDD7###"((6::##NE::
 
 	
r  r  r  c                    |                      ||          \  }}|                                  |                     |          }|d         ||                     ||          d}|||d<   d}|                     |          \  }}|t          | j        dz             |                     |                     ||                    }	| 	                    |	|          S )aY  
        make a withdrawal

        https://www.independentreserve.com/features/api#WithdrawDigitalCurrency

        :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

 EXCHANGE SPECIFIC PARAMETERS
        :param dict [params.comment]: withdrawal comment, should not exceed 500 characters
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        r  )r\  withdrawalAddressr'  NdestinationTagz1 withdraw() does not accept params["networkCode"])
handle_withdraw_tag_and_paramsrW  r  currency_to_precisionhandle_network_code_and_paramsr   r  "privatePostWithdrawDigitalCurrencyre  parse_transaction)
r  rT  r'  r  r  r=  r  rh  networkCoderQ  s
             r  r|   zindependentreserve.withdraw  s      99#vFFV==&&#+D>!(00v>>
 

 ?(+G$%"AA&IIV"TW'ZZ[[[::4;;wPV;W;WXX$ %%h999r  transactionc                 z   |                      |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S ) NAmountDestinationrm  r^  Addressr	  r4  r  TransactionGuidtxidr$  r|   r  r
  r'  Totalr  r  ri  rp  r  addressFrom	addressTor  tagFromtagToupdatedr  )r  r+  r  F)commentr  internal)	safe_dictrN  r:  r;  rf  )
r  r  r  r'  destinationrS  rp  r  r  rT  s
             r  r  z$independentreserve.parse_transaction  s   $ X66nn[-@@%%k3HII
##K1FGG"";	::{E22&&z8<<
K
$"";0ABB
 D
 J	

 
 t
 d&&vw77
 d&&{H==
 11
 
 w
 4
 
 3
 t
  S!
" t#
$  ((77 
 1
 
 
 	
r  r}   GETc                    | j         d         |         dz   |z   }|dk    r|r|d|                     |          z   z  }n|                                  |                                 }|d| j        z   dt          |          z   g}	t          |                                          }
t          dt          |
                    D ]:}|
|         }t          ||                   }|	
                    |dz   |z              ;d	                    |	          }|                     |                     |          |                     | j                  t          j                  }i }| j        |d
<   ||d<   |                                |d<   t          dt          |
                    D ]}|
|         }||         ||<   |                     |          }ddi}||||dS )Nr   r  r}   ?zapiKey=znonce=r   =,apiKeynonce	signaturezContent-Typezapplication/json)urlmethodbodyheaders)r  	urlencodecheck_required_credentialsr/  r.  strlistkeysr8  r9  r<  joinhmacencodesecrethashlibsha256upperjson)r  pathr   r2  r=  r4  r3  r1  r/  authr9  rD  keyvaluemessager0  querys                    r  signzindependentreserve.sign  s   is#c)D0(?? 4sT^^F3333++---JJLLEDK'3u::%D
 &&D1c$ii(( / /1gF3K((C#I-....hhtnnG		$++g"6"6DK8P8PRYR`aaIE"kE(O"E'N!*!2!2E+1c$ii(( ) )1g#C[c

99U##D%'9:GfdwOOOr  )N)0__name__
__module____qualname__r   r  r   r
   rG  r   rU  rY  r7  r	   r   rj  dictr   r  r  r   r  r   r  r  r  r  r  r  r   r  r  r   r  r   r   floatr   r   r  r   r  r   r  r   r|   r  rH  __classcell__)r  s   @r  r   r      s       h# h h h h h hT	 $& N N$v, N N N N`
) 
) 
) 
) 
) $& , ,( , , , , :>b z zs z3 zY z z z z$, ,4 , ,6 , , , ,\ 02 3 33 3f 3 3 3 3:j j jv j j j j jX: : : : :Hs H H H H 26b 2 2c 23 2 2 2 2" /3TXac = = =3 =c =hlmrhs = = = =0 154VZce = =# =S =PS =jnotju = = = =0 -1tRT]_ I Ic I IC I I I I.# # #v # # # # #J 6:UW K K3 Ks K# K\`af\g K K K K& )+ ( ({ ( ( ( (T gksu  3 i y RW `c    @ 37r * *s *C * * * *B 79 4 4# 4^ 4 4 4 44
 
h 
R` 
 
 
 
& KOWY 0: 0:S 0:% 0:# 0:C 0:^i 0: 0: 0: 0:d2
 2
T 2
X 2
Q\ 2
 2
 2
 2
h &eBSW P P P P P P P Pr  r   )ccxt.base.exchanger    ccxt.abstract.independentreserver   r>  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r    r  r  <module>rW     s   ( ' ' ' ' ' 8 8 8 8 8 8  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l  l       ' ' ' ' ' ' 4 4 4 4 4 4 % % % % % %\P \P \P \P \P; \P \P \P \P \Pr  