
    i                       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mZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lm Z  d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dlm)Z) d dlm*Z* d dlm+Z+ d dlm,Z, d dlm-Z- d dl.m/Z/ d dl.m0Z0 d dl1m2Z2  G d dee          Z3dS )    )Exchange)ImplicitAPIN)Balances
CurrenciesCurrency	IndexTypeIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeeInterfaceTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)CancelPending)NotSupported)DDoSProtection)RateLimitExceeded)ExchangeNotAvailable)OnMaintenance)InvalidNonce)TRUNCATE)	TICK_SIZE)Precisec                       e Zd Z fdZd Zi fdee         fdZdYdef fdZ	d Z
i fdefd	Zi fd
edefdZd ZdZdededefdZdi fd
ededefdZdYd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fdZdddi fd
edededee         fdZd ZdYdefd Z dddi fd!e!dedefd"Z"di fd!e!fd#Z#di fd$ed!e!fd%Z$dYdede%fd&Z&ddi fd
edede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,d,e-d-e.f
d.Z/d/ Z0d0 Z1d1 Z2d2 Z3dYdede4fd3Z5di fd4Z6ddi fd$ed
ed*e+d+e,d,e.d-e.fd5Z7di fd$ed
e!fd6Z8dddi fd$ed
e!dedefd7Z9di fd
e!fd8Z:dddi fd
e!dedefd9Z;di fd$ed
e!fd:Z<di fd
e!fd;Z=di fd
e!fd<Z>dddi fd
e!dededee4         fd=Z?dddi fd
e!dededee4         fd>Z@d? ZAd@ ZBdYdedeCfdAZDd[d!e!dedefdBZEdddi fd!e!dededeeC         fdCZFi fdDZGdddi fd!e!dededeeC         fdEZHdF ZIi fd!efdGZJi fd!efdHZKi fd!efdIZLdYdefdJZMdi fd!ed,e-fdKZNdi fdefdLZOdYdefdMZPdN ZQi fd!efdOZRi fd!ed,e-dPedQedeSf
dRZTdYdefdSZUdTdUi ddfdVZVdW ZWdX ZX xZYS )\krakenc                    |                      t          t          |                                           i ddddddg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d'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1di d2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=d>d?dd@ddAddBddCddddddddddDdEdFdGdHdIdJdKdLdMdNdO	dPdQdRdRdSdTdUdVdWdXdYdZdd|                     d[          |                     d\          |                     d          |                     d[          g|                     d]          |                     d^          g|                     d_          |                     d`          g|                     da          |                     db          g|                     dc          |                     dd          g|                     de          |                     d\          g|                     df          |                     dg          g|                     dh          |                     di          g|                     dj          |                     dk          gg	|                     d          |                     d\          g|                     d]          |                     dg          g|                     d_          |                     di          g|                     da          |                     dl          g|                     dc          |                     dm          g|                     de          |                     dn          g|                     df          |                     do          g|                     dh          |                     dp          g|                     dj          |                     dq          gg	drdsidtddudvdwdxgidvdFdFdFdFdFdFdFdFdFdy	idzi d{d|d}d|d~ddddddddd|dd|dddddddddd|ddddddddi dddddddddddddddddddddddddddddddddddddddddddiddddddddddddi i g ddddi ddddddddddddddddddddÓddœddƓddȓddʓdd̓dd͓ddϓi ddѓddӓddՓddדddٓddۓddܓddޓddddddddddddddddddi dddddddddddddddddd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.ddd/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdCdDdDdEdFdGdHdIdJdKdLdMdNdOdPdQdR	i dSdSdddTdUdd
dddVdWdXddYdZd[dd\dZd]d]d^d_d`ddadbdLdcdBdd6d5i ddddǓdddded'dfdNdddgdd2d1d	ddIdhdiddddjddkdZddݓddddi dd dddldmdddndodpddqddrd3dsd%dtdɓdudvdwddxdxdydz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ddddddddddddddddddt
          di dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          t          t          t          t           t          t"          dǜ          S (  Nidr/   nameKraken	countriesUSversion0	rateLimit  	certifiedFproThasCORSspotmarginswapfutureoption	addMargincancelAllOrderscancelOrdercancelOrderscreateDepositAddresscreateOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrdercreateTrailingAmountOrder	editOrderfetchBalancefetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLedgerfetchLedgerEntryfetchLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderTradesemulatedfetchPositionsfetchPremiumIndexOHLCVfetchTickerfetchTickers	fetchTime)fetchTradesfetchTradingFeefetchTradingFeesfetchWithdrawalssetLeveragesetMarginModetransferwithdraw
timeframes            <      i  i`'  i`T  )	1m5m15m30m1h4h1d1w2wurlszdhttps://user-images.githubusercontent.com/51840849/76173629-fc67fb00-61b1-11ea-84fe-f2de582f58a3.jpgzhttps://api.kraken.comz<https://kraken.zendesk.com/api/v2/help_center/en-us/articles)publicprivatezendeskzhttps://www.kraken.comzhttps://docs.kraken.com/rest/z2https://www.kraken.com/en-us/features/fee-schedule)logoapiwwwdocfeesr   tradingz0.0026z0.001650000z0.0024100000z0.0022250000z0.0020500000z0.001810000002500000z0.00145000000z0.001210000000z0.0001z0.0010z0.0008z0.0006z0.0004z0.0002z0.0)takermaker)	tierBased
percentager   r   tiershandleContentTypeApplicationZipr   get360000292886	201893608)	Assets
AssetPairsDepthOHLCSpreadSystemStatusr   TimeTradespostAddOrderr   AddOrderBatch	AddExport   Balance	CancelAllCancelAllOrdersAfterCancelOrderCancelOrderBatchClosedOrdersDepositAddressesDepositMethodsDepositStatus	EditOrderExportStatusGetWebSocketsTokenLedgers   
OpenOrdersOpenPositionsQueryLedgersQueryOrdersQueryTradesRetrieveExportRemoveExport	BalanceExTradeBalanceTradesHistoryTradeVolumeWithdrawWithdrawCancelWithdrawInfoWithdrawMethodsWithdrawAddressesWithdrawStatusWalletTransfer)CreateSubaccountAccountTransferzEarn/AllocatezEarn/DeallocatezEarn/AllocateStatuszEarn/DeallocateStatuszEarn/StrategieszEarn/Allocations)r   r   r   commonCurrenciesLUNCLUNAREPREPV1USTCBTCzBTC.MDOGE)r   LUNA2REPV2r   USTXBTzXBT.MXDGoptions)CADUSDJPYGBPERC20TRC20)ETHTRX1INCHz1inch(1INCH)AAVEAaveADAALGOAlgorandANKRz
ANKR(ANKR)ANTzAragon(ANT)ATOMCosmosAXSzAxie Infinity Shards(AXS)BADGERzBager DAO(BADGER)BALzBalancer(BAL)BANDzBand Protocol(BAND)BATBCHzBitcoin CashBNCzBifrost(BNC)BNTzBancor(BNT)BitcoinCHZzChiliz(CHZ)COMPzCompound(COMP)CQTz	Covalent Query Token(CQT)CRVzCurve DAO Token(CRV)CTSIzCartesi(CTSI)DAIDaiDASHDashDogecoinDOTPolkadotDYDXz
dYdX(DYDX)ENJzEnjin Coin(ENJ)EOSETCzEther Classic(Hex)r   z
Ether(Hex)EWTzEnergy Web TokenFEEzKraken Fee CreditFILFilecoinFLOWFlowGHSTzAavegotchi(GHST)GNOGRTICXIconINJzInjective Protocol(INJ)KARzKarura(KAR)KAVAKavaKEEPzKeep Token(KEEP)KNCzKyber Network(KNC)KSMKusamaLINKLinkLPTzLivepeer Token(LPT)LRCzLoopring(LRC)LSKLiskLTCLitecoinMANAMATICzPolygon(MATIC)MINAMinaMIRzMirror Protocol(MIR)MKRz
Maker(MKR)MLNMOVRzMoonriver(MOVR)NANOOCEANOGNzOrigin Protocol(OGN)OMGOXTzOrchid(OXT)OXYzOxygen(OXY)PAXGz	PAX(Gold)PERPzPerpetual Protocol(PERP)PHAz
Phala(PHA)QTUMRARIzRarible(RARI)RAYzRaydium(RAY)RENzRen Protocol(REN)REPv2SANDzThe Sandbox(SAND)SCSiacoinSDNzShiden(SDN)SOLSolanaSNXzSynthetix  Network(SNX)SRMSerumSTORJzStorj(STORJ)SUSHIzSushiswap(SUSHI)TBTCtBTCr   TronUNIUSDCUSDTzTether USD(ERC20)z
USDT-TRC20zTether USD(TRC20)WaveszWrapped Bitcoin(WBTC)zStellar XLMMoneroz
Ripple XRPXTZYFIzZcash(Transparent)z0x(ZRX))	WAVESWBTCXLMXMRXRPrP  rQ  ZECZRX	LightningRipplerV  StellarrT  EthereumzArbitrum OneArbitrumPolygonzArbitrum NovaOptimismz
zkSync ErazkSynczEthereum ClassicZcashrW  rU  CardanoQtumTezosNanorR  ICONzPolygon - USDC.ezArbitrum One - USDC.ez
Energy WebEW
CentrifugeCFGKarura	MoonriverShidenKhalazBifrost KusamaSongbirdSGBzTerra classicKILTBasiliskBSXFlareFLRzAvalanche C-ChainAVAXKintsugiKINTAltairAIRMoonbeamGLMRAcalaACAAstarASTRAkashAKT
RobonomicsXRTFantomFTMElrondEGLD	THORchainRUNESecretSCRTNearNEARzInternet Computer ProtocolICPPicassoPICAzCrust ShadowCSM
IntegriteeTEERzParallel FinancePARAHydraDXHDXINTRFETNYMr   JUNONODLSTXETHWAPTSUIGENSAVTSEIOTPTIA)InterlayzFetch.air  z	Terra 2.0JunoNodleStackszEthereum PoWAptosSuiGenshiroAventusSeiOriginTrailCelestia)marketsByAltnamedelistedMarketsByIdinactiveCurrenciesnetworksdepositMethodswithdrawMethodsprecisionMode
exceptionszEQuery:Invalid asset pairzEAPI:Invalid keyzEFunding:Unknown withdraw keyzEFunding:Invalid amountzEService:UnavailablezEDatabase:Internal errorzEService:BusyzEQuery:Unknown assetzEAPI:Rate limit exceededzEOrder:Rate limit exceededzEGeneral:Internal errorzEGeneral:Temporary lockoutzEGeneral:Permission deniedEOrder:Unknown orderzEOrder:Order minimum not metzEGeneral:Invalid argumentszESession:Invalid session)zEAPI:Invalid noncezEFunding:No funding methodzEFunding:Unknown assetz!EService:Market in post_only modezEGeneral:Too many requestszETrade:User Locked)deep_extendsuperr/   describeparse_numberr,   r   r   r!   r    r(   r&   r   r"   r   r*   r)   r   )self	__class__s    _/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/kraken.pyr  zkraken.describe$   s   fd 3 3 < < > > jA
(jA
HjA
 $jA
 s	jA
 jA
 jA
 4jA
  <<< $< 	<
 %< %< U< "4< t< < '< t< '< (< "4<  ,T!<" T#< <$ %<& &u'<( +E)<* )%+<, $T-<. '/<0 (1<2 "43<4 &t5<6  7<8 &u9<: #E;<< *5=<> $U?<@ "5A<B *5C<D +EE< < <F tG<H #DI<J %eK<L M<N !%O<P  Q<R dS<T +EU<V "4W<X dY<Z !$[<\ #J]<^ !$_<` )%a<b tc<d e<f Tg< <h  $#'$)$($!&  w< < <jA
P 
 
QjA
f ~67] 
 06L
 
gjA
| !%"&!..x88!..x88 "..s33T5F5Fx5P5PQ!..w779J9J89T9TU!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..y994;L;LX;V;VW!..y994;L;LX;V;VW!..y994;L;LX;V;VW!..z::D<M<Mh<W<WX
" "..s33T5F5Fx5P5PQ!..w779J9J89T9TU!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..y994;L;LX;V;VW!..y994;L;LX;V;VW!..y994;L;LX;V;VW!..z::D<M<Me<T<TU
"  }jA
| .t}jA
~  '#	 "#&'!" !"#()"# !"#   -"A-'- $Q- "1	-
 $Q- /- &q- +A- '- +A- )!- (- $Q- '- -a-  "1!-" %a#- -$ (%-& ''-( &q)-* &q+-, )!--. '/-0 $Q1-2 '3-4 (5-6 &q7-8 #A9-: )!;-< '=-> *1?-@ ,QA-B )!C-D )!E- -H -.+,)*+,/012+,,-Y- - -//G GjA
N  	! 	!OjA
b $&')&B&B&B"" _#^_#F_# 5_# J	_#
 L_# =_# H_# 6_# 1_# ?_# 1_# 5_# >_# >_# =_#  9!_#" =#_# _#$ ,%_#& 8'_#( 1)_#* O+_#, 5-_#. F/_#0 J1_#2 :3_#4 L5_#6 ,7_#8 59_#: /;_#< <=_#> -?_#@ .A_#B :C_#D FE_# _# _#F .G_#H 5I_#J 5K_#L 6M_#N 4O_#P =Q_#R FS_#T .U_#V /W_#X 8Y_#Z F[_#\ 0]_#^ ?__#` 6a_#b :c_#d Fe_#f -g_# _# _#h Fi_#j 1k_#l <m_#n 5o_#p -q_#r Fs_#t Wu_#v 1w_#x 5y_#z ={_#| =}_#~ K_#@ 6A_#B <C_#D FE_#F OG_#H >I_# _# _#J .K_#L 7M_#N UO_#P /Q_#R )S_#T =U_#V 8W_#X 4Y_#Z 7[_#\ ^]_#^ /__#` Fa_#b 6c_#d 5e_#f Fg_#h /i_#j !"5k_# _#l %3(#'  /$}_# _# _#@T$T$uT$ eT$ 	T$
 T$ uT$ T$ #JT$ wT$ $ZT$ 
T$ !(T$ 'T$ UT$ eT$  G!T$" e#T$ T$$ 5%T$& #E'T$( u)T$* F+T$, U-T$. f/T$0 F1T$2 t3T$4 E5T$6 W7T$8 E9T$: ;T$< '=T$> ,Z?T$@ AT$B FCT$D ET$ T$ T$F eGT$H FIT$J !$KT$L FMT$N !%OT$P eQT$R  ST$T eUT$V UWT$X %eYT$Z [T$\ $V]T$^ F_T$` aT$b UcT$d (eT$f gT$ T$ T$h eiT$j kT$l UmT$n VoT$p UqT$r !%sT$t euT$v fwT$x  yT$z f{T$| F}T$~ 1%T$@ vAT$B #ECT$D !&ET$F 'GT$H uIT$ T$J !' % !("##$*"  &$ #( %gT$ T$ T$S~ ~cjA
` YajA
b  +Y"$7 0 *+<	
 '(< +,@  !5 '	 +N -n *+? -n -.> ' /  -j!" +,?#$ '3.8*35B.<&6/  cjA
 j j j	    c                 t    |                      |t          | j        |         d         d         | j                  S )N	precisionamount)decimal_to_precisionr+   marketsr  )r  symbolfees      r  fee_to_precisionzkraken.fee_to_precision  s2    ((hV8L[8YZb8ceiewxxxr  returnc                 R  K   |                      |           d{V }|                     |di           }t          |                                          }g }t	          dt          |                    D ]}||         }||         }|                     |d          }	|                     |d          }
|                     |	          }|                     |
          }|                    d          dk    }|                     |d          }|                     |dg           }|                     |dg           }|                     |d	          }d}|(| 	                    t          j        |d
                    }|                     |dg           }|                     |dg           }|                     |d	          }d}|(| 	                    t          j        |d
                    }|                     |dg           }t          |          }| 	                    |                     |                     |d                              }|                    i d|d|                     |d          d|r|n|dz   |z   d|d|ddd|	d|
ddd|d|d         ddddd|dk    dddddddddd||ddddd| 	                    |                     |                     |d                               |d!| 	                    d"          |                     ||d	z
  d	          d#|                     |d$          dd#|dd#|                     |d%          dd#d&d|d'           |                     |          }|                     |d          | j        d(<   |S ))a6  
        retrieves data on all markets for kraken
        :see: https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTradableAssetPairs
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        Nresultr   basequote.daltname
fees_makerrz   100r   leverage_buypair_decimalsr1   wsIdwsnamer  /settlebaseIdquoteIdsettleIddarkpooltyper>   Tr?   r@   FrA   rB   lot_decimalsr  price1minmaxordermincostmin)leverager  r  cost)activecontractlinearinverser   r   contractSizeexpiryexpiryDatetimestrike
optionTyper  limitscreatedinfor  )publicGetAssetPairs
safe_valuelistkeysrangelensafe_stringsafe_currency_codefindr  r-   
string_divparse_precisionappendsafe_numberappend_inactive_marketsindex_byr   )r  paramsresponser  r  r  ir1   marketr  r  r  r  r  r  	makerFeesfirstMakerFeefirstMakerFeeRater   	takerFeesfirstTakerFeefirstTakerFeeRater   leverageBuyleverageBuyLengthprecisionPrices                             r  fetch_marketszkraken.fetch_markets  s      11&99999999` //(Hb99GLLNN##q#d))$$ M	 M	AaBR[F%%ff55F&&vw77G**622D++G44Ewwt}})H&&vy99GbAAI OOIq"==M $ 0 0 B BE ,))'*<=NPU*V*VWW;;I OOIq"==M $ 0 0 B BE ,))'*<=NPU*V*VWW//&."EEK #K 0 0!..t/C/CDDTDTU[]lDmDm/n/nooNMM 5b5((::5 XG''D3J4F5 	5
 5 $5 &5 75 D5 H5 6),5 5 5 ,q05 5  %!5" %#5$ ! $"&""//0D0DTEUEUV\^lEmEm0n0noo+   $0055#//=NQR=RTUVV! !
  $//
CC# 
  .# 
  $//	BB#  $  i5 5 5 5 5 5 5l --f55+/==+K+K'(r  Ncurrencyc                 *   |ht          |          dk    rU|                    d          dk    s|                    d          dk    r#|                    d          dk    s
|dd          }t          t          |                               ||          S )Nr   Xr   Z.rz   )r  r  r  r/   safe_currency)r  
currencyIdr  r  s      r  r  zkraken.safe_currency`  s    !:""OOC((A--:??33G3G13L3L&OOC00144%/^
VT""00XFFFr  c                 T   |                      d          |                      d          d}d d d}|d         d d}|d         d d}|||d}dd d d d||d}g }t          d	t          |                    D ]1}	|                    |                     |||	                              2|S )
Nz1e-8r  r  r  r  )r  r  r  F)r  r  r   r   r  r  r  r   )r  r  r  r  extend)
r  r  r  
costLimitspriceLimitsamountLimitsr  defaultsr  r  s
             r  r  zkraken.append_inactive_marketsh  s     ''//&&v..
 
	 "$//
'0>>(24@@(;
SS"
 

 q#g,,'' 	= 	=AMM$++h
;;<<<<r  c                 F  K   |                      |           d{V }|                     |di           }t          |                                          }i }t	          dt          |                    D ]}||         }||         }|                     |          }	|                     |                     | 	                    |d                              }
| 	                    |d          dk    }||	|| 	                    |d          |ddd|
|
dddddd	i d
||	<   |S )a-  
        fetches all available currencies on an exchange
        :see: https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getAssetInfo
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Nr  r   decimalsstatusenabledr  r  )r  rx   )r1   coder  r2   r  depositrx   r  r  r  r  )
publicGetAssetsr  r  r  r  r  r  r  r  r  )r  r  r  
currenciesidsr  r  r1   r  r"  r  r  s               r  fetch_currencieszkraken.fetch_currencies  sj      --f55555555  __Xx<<
:??$$%%q#c((##  	  	AQB!"~H
 **2..D))$*>*>t?O?OPXZd?e?e*f*fggI%%h99YFF ((9==  &  )# 
  $#! !	 	 ) F4LL, r  r  c                 2  K   |                                   d{V  |                     |          }|d         dd}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )af  
        fetch the trading fees for a market
        :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getTradeVolume
        :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>`
        Nr1   T)pairzfee-infor  )load_marketsr  privatePostTradeVolumer  r  parse_trading_fee)r  r  r  r  requestr  r  s          r  fetch_trading_feezkraken.fetch_trading_fee  s       !!!!!!!!!V$$4L
 
 44T[[&5Q5QRRRRRRRR< 8R88%%ff555r  c                 @   |                      |di           }|                      |di           }|                      ||d         i           }|                      ||d         i           }||d         |                     |d          |                     |d          dddS )Nr  r   r1   r  r  T)r  r  r   r   r   r   )r  r   )r  r  r  r  r
  symbolMakerFeesymbolTakerFees          r  r,  zkraken.parse_trading_fee  s    OOHlB??	OOHfb99	F4L"EEF4L"EEX&%%ne<<%%ne<<
 
 	
r  r   rz      priceKey	amountKeycountOrIdKeyc                     |                      ||          }|                      ||          }|                     |d          }|||gS )Nr2  )r   safe_integer)r  bidaskr3  r4  r5  r  r  	timestamps           r  parse_bid_askzkraken.parse_bid_ask  sN      22!!&)44%%fa00	vy))r  limitc                 F  K   |                                   d{V  |                     |          }|d         rt          | j        dz   |z             d|d         i}|||d<   |                     |                     ||                     d{V }|                     |di           }|                     ||d                   }|                     |di           }	|                     |	d	          }
|
|                     ||
|          }|                     ||          S )
aK  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getOrderBook
        :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
        Nr  zE fetchOrderBook() does not provide an order book for darkpool symbol r)  r1   countr  r  r  )r*  r  r   r1   publicGetDepthr  r  parse_order_book)r  r  r;  r  r  r-  r  r  	orderbook
marketInfowsNames              r  fetch_order_bookzkraken.fetch_order_book  sE      !!!!!!!!!V$$* 	|*q qtz z{{{F4L
 $GG,,T[[&-I-IJJJJJJJJ( 8R88OOFF4L99	 __VVR88
X66	BBI$$Y777r  r  c                    |                      d |          }|                     |dg           }|                     |d          }|                     |dg           }|                     |d          }t          j        ||          }|                     |dg           }	|                     |	d          }
|                     |dg           }|                     |dg           }|                     |dg           }|                     |d	g           }|                     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|          S )Nvrz   pcr   hlbar  r9  datetimehighlowbid	bidVolumeask	askVolumevwapopenocloselastpreviousClosechanger   average)
baseVolumequoteVolumer  )safe_symbolr  r  r-   
string_mulsafe_ticker)r  tickerr  r  rE  r[  rF  rS  r\  rG  rW  rM  rN  rO  rQ  s                  r  parse_tickerzkraken.parse_ticker2  sQ    !!$//OOFC,,%%a++
OOFC,,1%%(T::OOFC,,1%%vsB//oofc2..oofc2..oofc2.. !
f!
!
 !
 D$$T1--	!

 4##C++!
 4##C++!
 !
 4##C++!
 !
 D!
 D$$VS11!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
 !
 !
* +  	r  symbolsc                   K   |                                   d{V  i }||                     |          }g }t          dt          |                    D ]B}||         }| j        |         }|d         r#|d         s|                    |d                    Cd                    |          |d<   |                     |                     ||                     d{V }|d         }	t          |	
                                          }
i }t          dt          |
                    D ]H}|
|         }|                     |          }|d	         }|	|         }|                     ||          ||<   I|                     |d	|          S )
a1  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTickerInformation
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   r  r  r1   ,r)  r  r  )r*  market_symbolsr  r  r  r  joinpublicGetTickerr  r  r  safe_marketra  filter_by_array_tickers)r  rb  r  r-  	marketIdsr  r  r  r  tickersr&  r  r1   r`  s                 r  fetch_tickerszkraken.fetch_tickersc  s      !!!!!!!!!))'22GI1c'll++ 3 3 f-(# 3F:,> 3$$VD\222!hhy11GFO--dkk'6.J.JKKKKKKKK8$7<<>>""q#c((## 	? 	?AQB%%b))FH%FR[F!..vv>>F6NN++FHgFFFr  c                   K   |                                   d{V  |                    d          dk    }|rt          | j        dz   |z             |                     |          }d|d         i}|                     |                     ||                     d{V }|d         |d                  }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTickerInformation
        :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>`
        Nr  r   z= fetchTicker() does not provide a ticker for darkpool symbol r)  r1   r  )r*  r  r   r1   r  rg  r  ra  )r  r  r  r  r  r-  r  r`  s           r  fetch_tickerzkraken.fetch_ticker  s       !!!!!!!!!;;t$$) 	t*i ilr rsssV$$F4L
 --dkk'6.J.JKKKKKKKK(#F4L1  000r  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   rz   r2  r      r   )safe_timestampr   )r  ohlcvr  s      r  parse_ohlcvzkraken.parse_ohlcv  s     q))UA&&UA&&UA&&UA&&UA&&
 	
r  r   sincec           	      x  K   |                                   d{V  d}|                     |dd          \  }}|r!|                     d|||||d           d{V S |                     |          }|                     | j        |          }d|d         i}	|||	d<   n||	d<   ||                     |          d	z   |	d
<   |                     |                     |	|                     d{V }
| 	                    |
di           }| 
                    ||d         g           }|                     |||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getOHLCData
        :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 boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        NFre   paginatei  r)  r1   interval000000rt  r  )r*  handle_option_and_params"fetch_paginated_call_deterministicr  r7  ry   number_to_stringpublicGetOHLCr  r  	safe_listparse_ohlcvs)r  r  	timeframert  r;  r  rv  r  parsedTimeframer-  r  r  ohlcvss                r  fetch_ohlcvzkraken.fetch_ohlcv  s      !!!!!!!!!88zZZ& 	}@@vW\^cenpvx{|||||||||V$$++DOYGGF4L
 &"1GJ"+GJ  $44U;;hFGG++DKK,H,HIIIIIIII 8R88tb99  E5IIIr  c                 @    dddddd}|                      |||          S )Ntradetransactionrw   r?   )r  
withdrawalr#  rw   r?   r  )r  r  typess      r  parse_ledger_entry_typezkraken.parse_ledger_entry_type  s7    '$"
 
 tT222r  c                    |                      |d          }d }d }|                      |d          }d }|                     |                      |d                    }|                     |                      |d          |          }	|                      |d          }
t          j        |
d          rd}t          j        |
          }
nd}|                     |d	          }||||||||	|                     |
          d |                     |d
          d|| 	                    |          |                     |d          |	ddS )Nr1   refidr  assetr  r7   outintimebalanceokr  r  r  )r  r1   	directionaccountreferenceIdreferenceAccountr  r  r  beforeafterr   r9  rL  r  )
r  r  r  r-   	string_lt
string_absrq  r  r   iso8601)r  itemr  r1   r  r  r  r  r  r"  r  r9  s               r  parse_ledger_entryzkraken.parse_ledger_entry  sd     dD))	&&tW55++D,<,<T6,J,JKK&&t'7'7g'F'FQQ!!$11VS)) 	I'//FFI''f55	"& 0''//%%dI66"Y//((u55  
 
 	
r  r"  c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   ||                     |dz            |d<   |                     d||          \  }}|                     |                     ||                     d{V }|                     |di           }|                     |di           }	t          |	                                          }
g }t          d	t          |
                    D ],}|
|         }|	|         }||d<   |                    |           -|                     ||||          S )
a  
        fetch the history of changes, actions done by the user or operations that altered balance of the user
        :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getLedgers
        :param str code: unified currency code, default is None
        :param int [since]: timestamp in ms of the earliest ledger entry, default is None
        :param int [limit]: max number of ledger entrys to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest ledger entry
        :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
        Nr1   r  r9   startendr  ledgerr   )r*  r  parse_to_inthandle_until_optionprivatePostLedgersr  r  r  r  r  r  r  parse_ledger)r  r"  rt  r;  r  r-  r  r  r  r  r  itemsr  keyvalues                  r  fetch_ledgerzkraken.fetch_ledger  sz      !!!!!!!!!}}T**H'~GG#00>>GG225'6JJ00Wf1M1MNNNNNNNN 8R88266FKKMM""q#d))$$ 	  	 Aq'C3KEE$KLL  %???r  c                   K   |                                   d {V  d                    |          }|                     d|i|          }|                     |           d {V }|d         }t	          |                                          }g }t          dt          |                    D ],}	||	         }
||
         }|
|d<   |                    |           -| 	                    |          S )Nrd  r1   r  r   )
r*  rf  r  privatePostQueryLedgersr  r  r  r  r  r  )r  r&  r"  r  r-  r  r  r  r  r  r  r  s               r  fetch_ledger_entries_by_idsz"kraken.fetch_ledger_entries_by_idsC  s	     !!!!!!!!!hhsmm++#
  55g>>>>>>>> (#FKKMM""q#d))$$ 	  	 Aq'C3KEE$KLL  '''r  r1   c                 R   K   |                      |g||           d {V }|d         S )Nr   )r  )r  r1   r"  r  r  s        r  fetch_ledger_entryzkraken.fetch_ledger_entry^  s:      66tT6JJJJJJJJQxr  c                 n   d }d }d }d }d }d }d }	d }
d }t          |t                    r|                     |d          }|d         dk    rdnd}|d         dk    rdnd	}|                     |d
          }|                     |d          }t	          |          }|dk    r|                     |d          }n)t          |t
                    r|}nd|v r|                     |d          }|                     |          }||}n||                     |          }|                     |d          }	|                     |dd          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }d|v r%d }||d         }|                     |d          |d}
||d         }|                     |d          }| 	                    ||	||| 
                    |          |||d ||||
d|          S )Nr2  r   ssellbuyrp  rI  r;  r  r   rz   r   	ordertxidr)  r1   postxidr  r  	ordertyper  volr  r  r  r  r  )r1   orderr  r9  rL  r  r  sidetakerOrMakerr  r  r  r  )
isinstancer  rq  r  r  strfind_market_by_altname_or_idget_delisted_market_by_idsafe_string_2
safe_trader  )r  r  r  r9  r  r  r  r  r1   orderIdr  r  tradeLengthmarketIdfoundMarketr  r  s                    r  parse_tradezkraken.parse_tradeb  s   > 	eT"" !	++E155I#Ah#oo66ED$Qx377XD$$UA..E%%eQ//Fe**KQ%%eQ//s## 	BBE!!''v66H;;HEEK&$%77AA&&uk::G##E4;;B++E6::I##E622D##E;77D$$UG44E%%eU33F~~%%gH ,,UE:: (  H%Fv.."Y//  
  
   	r  c                    K   |                                   d{V  |                     |          }|d         }d|i}||dz  |d<   t          |          dz   |d<   |||d<   |                     |                     ||                     d{V }|d         }	|	|         }
t          |
          }|d	k    rg S |
|d
z
           }|                     |	d          }|                    |           ||
|d
z
  <   |                     |
|||          S )a8  
        get the list of most recent trades for a particular symbol
        :see: https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getRecentTrades
        :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>`
        Nr1   r)  g    .Art  rx  r=  r  r   rz   rW  )	r*  r  r  publicGetTradesr  r  r  r  parse_trades)r  r  rt  r;  r  r  r1   r-  r  r  tradeslength	lastTradelastTradeIds                 r  fetch_tradeszkraken.fetch_trades  sO      !!!!!!!!!V$$D\B

   %s{GG"5zzH4GG$GG--dkk'6.J.JKKKKKKKK (#VQ;;I6A:&	&&vv66%%%&vz  >>>r  c                    |                      |di           }|d d d}t          |                                          }t          dt	          |                    D ]}||         }|                     |          }|                      ||i           }|                                 }	|                     |d          |	d<   |                     |d          |	d<   |	||<   |                     |          S )Nr  )r  r9  rL  r   
hold_tradeusedr  total)	r  r  r  r  r  r  r  r  safe_balance)
r  r  balancesr  currencyIdsr  r  r"  r  r  s
             r  parse_balancezkraken.parse_balance  s    ??8Xr::
 

 8==??++q#k**++ 	# 	#A$QJ**:66Dooh
B??GllnnG"..wEEGFO#//CCGG"F4LL  (((r  c                    K   |                                   d{V  |                     |           d{V }|                     |          S )a{  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getExtendedBalance
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        N)r*  privatePostBalanceExr  )r  r  r  s      r  fetch_balancezkraken.fetch_balance  sg       !!!!!!!!!226::::::::  !!(+++r  r  r  r  r  c                   K   |                                   d{V  |                     |          }|d         |||                     ||          d}|                     d|||||          }	|                     |                     |	d         |	d                              d{V }
|                     |
d          }|                     |          S )an  
        :see: https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
        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 fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately
        :param bool [params.reduceOnly]: *margin only* indicates if self order is to reduce the size of a position
        :param float [params.stopLossPrice]: *margin only* the price that a stop loss order is triggered at
        :param float [params.takeProfitPrice]: *margin only* the price that a take profit order is triggered at
        :param str [params.trailingAmount]: *margin only* the quote amount to trail away from the current market price
        :param str [params.trailingLimitAmount]: *margin only* the quote amount away from the trailingAmount
        :param str [params.offset]: *margin only* '+' or '-' whether you want the trailingLimitAmount value to be positive or negative, default is negative '-'
        :param str [params.trigger]: *margin only* the activation price type, 'last' or 'index', default is 'last'
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr1   )r)  r  r  volumezcreateOrder()r   rz   r  )r*  r  amount_to_precisionorder_requestprivatePostAddOrderr  	safe_dictparse_order)r  r  r  r  r  r  r  r  r-  orderRequestr  r  s               r  create_orderzkraken.create_order  s      ( !!!!!!!!!V$$4L..vv>>	
 
 ))/64RWY_``11$++l1o|\]2_2_```````` (33'''r  c                 |    |                      | j        di           }||v r||         S |                     |          S )Nr  )r  r   rh  )r  r1   r  s      r  r  z#kraken.find_market_by_altname_or_idF  sF    ??4<9KRPP!!!#B''##B'''r  c                    ||S |                      | j        d         |          }||S d}d}d}d}t          |          dk    rd}d}d}nt          |          dk    rd}d}d}|||         }|||         }|                     |          }	|                     |          }
|	dz   |
z   }||	|
||d	}|| j        d         |<   |S )
Nr  r   r   r      rp     r  )r  r  r  r  r  )r  r   r  r  )r  r1   r  baseIdStart	baseIdEndquoteIdStart
quoteIdEndr  r  r  r  r  s               r  r  z kraken.get_delisted_market_by_idM  s
   :I.C!DbIIM	
r77a<<ILJJWW\\ILJK	)*\*,-&&v..''00e#
 
 39*+B/r  c                 @    dddddd}|                      |||          S )NrT  closedcanceledexpired)pendingrT  r  r  r  r  r  r   statusess      r  parse_order_statuszkraken.parse_order_statusn  s7    " 
 
 &&999r  c                 @    dddddd}|                      |||          S )Nr  r;  )take-profitstop-loss-limit	stop-losstake-profit-limittrailing-stop-limitr  r  s      r  parse_order_typezkraken.parse_order_typex  s7    #&!!(#*
 
 &&999r  c                 V   |                      |di           }|                      |d          }d }||                     |d          }n|                     |d          }d }d }d }d }	d }
d }||                    d          }|                     |d          }|                     |d          }
|                     |d          }|                     |d          }|dk    r-|                     |d	          }|                     |d
          }	n|dk    r|                     |d          }	|                     |d|          }|                     |d|          }|                     |d|          }|                     |          }d }||}n||                     |          }|                     |d          }|                     |d|
          }
|                     |d          }d }|                     |d|	          }	|	|	                    d          rd }	|	t          j        |	d          r|                     |d          }	|	t          j        |	d          r|                     |d|	          }	|                     |dd          }|	                    d          dk    }| 
                    |d          }|p|d         }d|v rd|                     |d          }|d d}|	                    d          dk    r|d         |d <   n$|	                    d!          dk    r|d"         |d <   |                     |                     |d#                    }|                     |d$d%          }||                    d&          r,|                     |d%          }|                     |d          }|                     |d'          }|                     |d(g           }g }t!          dt#          |                    D ]b}||         }t%          |t&                    r.|                    |                     |||i d)                     M|                    |           c|                     |                     |d*|                    }d }d }|                    d+          r@|                     |d          }|                     |                     |d                    }	nT|                    d,          r?|                     |d          }|                     |                     |d                    }	|                     i d$|d-|d.|d/|d0|                     |          d1d d#|d|d|                     |          d2d d3|d4|d|	d5|d6|d7|d8|d |
||d ||d9|          S ):Ndescrr   r   rz   r2  rp  stopr   	   r;  r{   r  r  r)  opentmr  vol_execr  %r7   price2oflags r   r  r  )r  ratefciqr  r  fcibr  r   r1   txid[userrefr  )r1   r  r  r  	stoppricer  r  clientOrderIdr  r9  rL  lastTradeTimestamptimeInForcepostOnlyr  	stopPricetriggerPricetakeProfitPricestopLossPrice)r  r  filledrZ  	remainingr  r  )r  r  splitr  r  rq  endswithr-   string_equalsr  r   r  r  
startswithr}  r  r  r  r  r  r  r  	omit_zero
safe_orderr  r  ) r  r  r  descriptionorderDescriptionObjorderDescriptionr  r  r  r  r  r  partsr  r  r9  r  r  flags
isPostOnlyrZ  feeCostr   r1   r  r  	rawTradesr  r  rawTrader  r  s                                    r  r  zkraken.parse_order  s}   z nnUGR88"nnUG<<*#//0CWMM#//w??	'$**3//E##E1--D%%eQ//F''q11H##E1--Dv~~ ,,UA66	((22((22VT::[$??##KBB77AA" FF!33H==F''x88	!!%77!!%44   gu==5>>##6#6EMg3E3??M$$[(;;EMg3E3??M$$UGU;;E  "55ZZ''",
""5'22H%F~~**5%88#   ::f%%**&,WoC
OOZZ''1,,&,VnC
O(()9)9%)J)JKKtV44JBMM#..J>>%00D!!$**B((	::OOE8R88	q#i..)) 	( 	(A |H(C(( (dooX"X^hj.k.kllmmmmh''''NN4#3#3E;	#R#RSS	??=)) 	L"..{GDDONN4#3#3K#J#JKKEE__[)) 	L ,,['BBMNN4#3#3K#J#JKKE  
" 
] 
 E 
 	 

 Y// 
 !$ 
 f 
 f 
 D))$// 
 4 
 
 
 D 
 U 
  
 I 
  ! 
" ]# 
$ 1 
  
  
2 3  	r  c                    |                      |dd          }|                     |ddg          }|||d<   |                     |d          }|                     |d          }	|d u}
|	d u}|
p|}|                     |d          }|                     |d          }|d u}|                    d          }|r|s|                     ||          |d<   |                     |d	d
          }|rm|
r'|                     ||          |d<   |rd|d<   n.d|d<   n(|r&|                     ||	          |d<   |rd|d<   nd|d<   |r|                     ||          |d<   np|rn|                     |dd          }d|z   }||d<   |s|?|                     |dd          }||                     |          z   }||d<   ||d<   d|d<   n
||d<   d|d<   |rd|d
<   |                     |d          }|}|                     i |          }|                     |d          }||                     ||          |d<   |                     |d          }||                     ||          |d<   ||d<   |                      |dd          }|||d<   |dk    }d }| 	                    |d|          \  }}|rd|d<   |                     |g d           }||gS )!Nr	  r  r  r  trailingAmounttrailingLimitAmountr;  r  
reduceOnlyreduce_onlyr  r  r  r  r  r   triggerrW  +offset-r  ztrailing-stoptruerV  r  timeinforcer  Fr   r  )r  r'  r  r  r%  r&  r+  )
r  omitr  r  price_to_precisionsafe_value_2r{  r  r  handle_post_only)r  methodr  r  r-  r  r  r  stopLossTriggerPricetakeProfitTriggerPriceisStopLossTriggerOrderisTakeProfitTriggerOrderisStopLossOrTakeProfitTriggerr%  r&  isTrailingAmountOrderisLimitOrderr'  trailingActivationPriceTypetrailingAmountStringr+  trailingLimitAmountStringrV  
closePriceclosePrice2r  isMarketr  s                               r  r  zkraken.order_requestP  s   **69oNN6I#?@@$!.GI#//HH!%!1!1&:K!L!L!5T!A#9#E (>(ZBZ%))&2BCC"..v7LMM .d :}}W-- 	F 5 	F#66vuEEGG&&v|]KK
( 	7% 9#'#:#:6CW#X#X  7+<GK((+6GK(() 9#'#:#:6CY#Z#Z  9+>GK((+8GK( K$($;$;FE$J$J!" 	7*.*:*:69f*U*U'#&#7 !<GI 7 3 ?))&(C@@,2T5J5JK^5_5_,_)#7 $=!'<$$#7 '6$ 	,%+GM"00KKE**E88J%!%!8!8!L!Lg//%::K&"&"9"9&+"N"Nh$GG((NN"%0GM"H$005&II& 	' &GH6  $X  $X  $X  Y  Y  r  c                 
  K   |                                   d{V  |                     |          }|d         s#t          | j        dz   |d         z   dz             ||d         d}	||                     ||          |	d<   |                     d	|||	||          }
|                     |                     |
d
         |
d                              d{V }|                     |di           }| 	                    ||          S )a  
        edit a trade order
        :see: https://docs.kraken.com/rest/#tag/Trading/operation/editOrder
        :param str id: order id
        :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 the currency you want to trade in units of the base currency
        :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.stopLossPrice]: *margin only* the price that a stop loss order is triggered at
        :param float [params.takeProfitPrice]: *margin only* the price that a take profit order is triggered at
        :param str [params.trailingAmount]: *margin only* the quote price away from the current market price
        :param str [params.trailingLimitAmount]: *margin only* the quote amount away from the trailingAmount
        :param str [params.offset]: *margin only* '+' or '-' whether you want the trailingLimitAmount value to be positive or negative, default is negative '-'
        :param str [params.trigger]: *margin only* the activation price type, 'last' or 'index', default is 'last'
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr>   z editOrder() does not support r  z& orders, only spot orders are acceptedr1   )r  r)  r  zeditOrder()r   rz   r  )
r*  r  r%   r1   r  r  privatePostEditOrderr  r  r  )r  r1   r  r  r  r  r  r  r  r-  r  r  datas                r  
edit_orderzkraken.edit_order  sB     & !!!!!!!!!V$$f~ 	Gtw)IIFSYNZ  ^F   F  G  G  G4L
 
  $ 8 8 H HGH))-wPUW]^^224;;|AP\]^P_3`3`aaaaaaaa" ~~h"55f---r  c                   K   |                                   d{V  |                     |dd          }ddi}|}|||d<   |                     |ddg          }n||d<   |                     |                     ||                     d{V }|                     |dg           }||vrt          | j        dz   |z             |                     |                     d	|i||                             S )
a  
        fetches information on an order made by the user
        :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getOrdersInfo
        :param str symbol: not used by kraken fetchOrder
        :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  r  Tr  r  z& fetchOrder() could not find order id r1   )	r*  r1  r/  privatePostQueryOrdersr  r  r#   r1   r  )	r  r1   r  r  r  r-  queryr  r  s	            r  fetch_orderzkraken.fetch_order  s#      !!!!!!!!!))&)_MMd

 $!.GIIIfy/&BCCEE GFO44T[[%5P5PQQQQQQQQL 8R88f*R RUW WXXXT2Jr
 C CDDDr  c                   K   |                      |d          }g }|t          | j        dz             t          dt	          |                    D ]P}||         }	t          |	t                    r|                    |	           5|                    |	d                    Q|                                  d{V  || 	                    |          }|                      | j
        di           }
|                     |
dd          }t	          |          }|                     ||z            }|                     |d	          }g }t          d|          D ]6}g }t          d|          D ]<}|                     ||z  |          }||k     r|                    ||                    =d
d                    |          i}|                     |           d{V }|                      |d          }t!          |                                          }t          dt	          |                    D ]}||         |||                  d<   |                     |d||          }|                     ||          }|                     ||          }8|S )a+  
        fetch all the trades made from a single order
        :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getTradesInfo
        :param str id: order id
        :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 to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        r  Nz fetchOrderTrades() requires a unified order structure in the params argument or a 'trades' param(an array of trade id strings)r   r1   rj   	batchSize   rz   r  rd  r  )r  r   r1   r  r  r  r  r  r*  r  r   r7  r  sumrf  privatePostQueryTradesr  r  r  filter_by_symbolarray_concat)r  r1   r  rt  r;  r  orderTradestradeIdsr  
orderTrader   rJ  numTradeIds
numBatchesr  j
requestIdskindexr-  r  r"  r&  r  tradesFilteredBySymbols                            r  fetch_order_tradeszkraken.fetch_order_trades  s      oofh77#DG  /p  %p  q  q  q1c+..// 6 6(^
j#.. 6OOJ////OOJt$45555!!!!!!!!![[((F//$,0BBGG%%g{B??	(mm&&{Y'>??
XXj!,,
q*%% %	G %	GAJ1i(( 7 7Y22;&&%%huo666,,G "88AAAAAAAAH, (;;Iy~~''((C1c#hh'' 1 1*-a&	#a&!$''&&y$uEEF%)%:%:66%J%J"&&v/EFFFFr  c                   K   |                                   d{V  |                     |                     dd                    |          d|                     d{V }|                     |di           }g }t          |                                          }t          dt          |                    D ]R}||         }	||	         }
| 	                    |                     d|	i|
                    }|
                    |           S|S )as  
        fetch orders by the list of order id
        :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getClosedOrders
        :param str[]|None ids: list of order id
        :param dict [params]: extra parameters specific to the kraken api endpoint
        :returns dict[]: a list of `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        NTrd  )r  r  r  r   r1   )r*  rF  r  rf  r  r  r  r  r  r  r  )r  r&  r  r  r  r  ordersorderIdsr  r1   r  r  s               r  fetch_orders_by_idszkraken.fetch_orders_by_idsM  s1      !!!!!!!!!44T[[HHSMMB
 B
 6 6         8R88&&q#h--(( 	! 	!A!B":D$$T[[$T%B%BCCEMM%    r  c                   K   |                                   d{V  i }||                     |dz            |d<   |                     |                     ||                     d{V }|d         d         }t	          |                                          }t          dt          |                    D ]}	||	         |||	                  d<   d}
||                     |          }
| 	                    ||
||          S )a  
        fetch all trades made by the user
        :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getTradeHistory
        :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>`
        Nr9   r  r  r  r   r1   )
r*  r  privatePostTradesHistoryr  r  r  r  r  r  r  )r  r  rt  r;  r  r-  r  r  r&  r  r  s              r  fetch_my_tradeszkraken.fetch_my_tradesd  s      !!!!!!!!!
 #00>>GG66t{{7F7S7STTTTTTTT4 (#H-6;;==!!q#c((## 	* 	*A#&q6F3q6N4  [[((F  >>>r  c                   K   |                                   d{V  d}|                     |dd|          }d|i}|                     |ddg          }	 |                     |                     ||                     d{V }nX# t
          $ rK}| j        r=| j                            d          dk    rt          | j	        dz   | j        z             |d}~ww xY w|S )a  
        cancels an open order
        :see: https://docs.kraken.com/rest/#tag/Trading/operation/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>`
        Nr	  r  r  r  r   z cancelOrder() error )
r*  r1  r/  privatePostCancelOrderr  	Exceptionlast_http_responser  r#   r1   )r  r1   r  r  r  r  r-  es           r  cancel_orderzkraken.cancel_order  s      !!!!!!!!!))&)_bQQM
 6I#?@@	!88Wf9U9UVVVVVVVVHH 	 	 	& e*//0FGG1LL'2I(IDLc(cdddG		
 s   /B 
CACCc                 p   K   d|i}|                      |                     ||                     d{V }|S )a  
        cancel multiple orders
        :see: https://docs.kraken.com/rest/#tag/Trading/operation/cancelOrderBatch
        :param str[] ids: open orders transaction ID(txid) or user reference(userref)
        :param str symbol: unified market symbol
        :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>`
        r\  N)privatePostCancelOrderBatchr  )r  r&  r  r  r-  r  s         r  cancel_orderszkraken.cancel_orders  sP       c
 99$++gv:V:VWWWWWWWW r  c                 p   K   |                                   d{V  |                     |           d{V S )a  
        cancel all open orders
        :see: https://docs.kraken.com/rest/#tag/Trading/operation/cancelAllOrders
        :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        N)r*  privatePostCancelAll)r  r  r  s      r  cancel_all_orderszkraken.cancel_all_orders  sR       !!!!!!!!!..v666666666r  c                   K   |                                   d{V  i }||                     |dz            |d<   |}|                     |dd          }|||d<   |                     |ddg          }|                     |                     ||                     d{V }d}	||                     |          }	|                     |di           }
|                     |
di           }|                     ||	||          S )a  
        fetch all unfilled currently open orders
        :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenOrders
        :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>`
        Nr9   r  r	  r  r  rT  )	r*  r  r1  r/  privatePostOpenOrdersr  r  r  parse_ordersr  r  rt  r;  r  r-  rG  r  r  r  r  r\  s               r  fetch_open_orderszkraken.fetch_open_orders  s*      !!!!!!!!!#00>>GG))&)_MM$!.GIIIfy/&BCCE33DKK4O4OPPPPPPPP[[((F(B7733  >>>r  c                 8  K   |                                   d{V  i }||                     |dz            |d<   |}|                     |dd          }|||d<   |                     |ddg          }|                     d||          \  }}|                     |                     ||                     d{V }d}	||                     |          }	|                     |di           }
|                     |
di           }| 	                    ||	||          S )	a  
        fetches information on multiple closed orders made by the user
        :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getClosedOrders
        :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
        :param int [params.until]: timestamp in ms of the latest entry
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr9   r  r	  r  r  r  r  )
r*  r  r1  r/  r  privatePostClosedOrdersr  r  r  rp  rq  s               r  fetch_closed_orderszkraken.fetch_closed_orders  sH      !!!!!!!!!#00>>GG))&)_MM$!.GIIIfy/&BCCE225'6JJ55dkk'56Q6QRRRRRRRRP [[((F(B77"55  >>>r  c                 B    ddddddd}|                      |||          S )Nr  r  failed)InitialPendingSuccessSettledFailurePartialr  r  s      r  parse_transaction_statuszkraken.parse_transaction_status5  s<     !  
 
 &&999r  c                 h    |                      | j        di           }|                     |||          S )Nr  )r  r   r  )r  networkr  s      r  parse_networkzkraken.parse_networkA  s2    //$,8I2NN'BBBr  c                 D   |                      |d          }|                      |d          }|                     |d          }|                      |d          }|                     ||          }|                      |d          }|                     |d          }	|                     |                      |d                    }
|                      |d          }|d	k    }|d
k    }|dk    }|s|s|rd}
|                      |d          }|                     |d          }||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S )Nr  r  r  r  r  r  r   zstatus-propzon-holdzcancel-pendingonholdr  r  r  r#  r   r1   r  r  address	addressToaddressFromtagtagTotagFromupdatedr9  rL  )r  r  )commentinternalr  )r  rq  r  r   r~  r  r  )r  r  r  r1   r  r9  r  r"  r  r  r   
statusPropisOnHoldDepositisCancellationRequestisOnHoldWithdrawalr  r!  s                    r  parse_transactionzkraken.parse_transactionE  sp   z k733V44''V<<	%%k7;;
&&z8<<"";77!!+x88..t/?/?X/V/VWW%%k=AA
$	1 *.> >'83 	3 	7I 	FV44"";66?y  
K
"
 
 f	

 t))$*:*:;	*R*RSS
 w
 
 4
 4
 T
 t
 f
 D
 t
 D
  !
" Y//#
$   )
 
 
 	
r  c                    g }t          dt          |                    D ]H}|                     |                     d|i||                             }|                    |           I|                     ||||          S )Nr   r  )r  r  r  r  r  filter_by_currency_since_limit)	r  r  transactionsr"  rt  r;  r  r  r  s	            r  parse_transactions_by_typez!kraken.parse_transactions_by_type  s    q#l++,, 	' 	'A00>A2  2  ! !K MM+&&&&2264NNNr  c                 T  K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     d|d         |||          S )a!  
        fetch all deposits made to an account
        :see: https://docs.kraken.com/rest/#tag/Funding/operation/getStatusRecentDeposits
        :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>`
        Nz2 fetchDeposits() requires a currency code argumentr  r1   r  r#  r  )r   r1   r*  r  privatePostDepositStatusr  r  )r  r"  rt  r;  r  r  r-  r  s           r  fetch_depositszkraken.fetch_deposits  s       <#DG.b$bccc!!!!!!!!!==&&Xd^
 $GG66t{{7F7S7STTTTTTTT ..y(8:LdTY[`aaar  c                    K   |                      |           d{V }|                     |di           }|                     |d          S )ak  
        fetches the current integer timestamp in milliseconds from the exchange server
        :see: https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getServerTime
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        Nr  unixtime)publicGetTimer  rq  )r  r  r  r  s       r  
fetch_timezkraken.fetch_time  sZ       ++F33333333 8R88""6:666r  c           	      L  K   |                                   d{V  d}|                     |dd          \  }}|r&d|d<   |                     d||||dd           d{V S i }| |                     |          }|d         |d	<   |t	          |          |d
<   |                     |                     ||                     d{V }d}	|                     |d          }
t          |
t                    s| 
                    |
          }	n|
}	|                     d|	|||          S )a3  
        fetch all withdrawals made from an account
        :see: https://docs.kraken.com/rest/#tag/Funding/operation/getStatusRecentWithdrawals
        :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
        :param dict [params.end]: End timestamp, withdrawals created strictly after will be not be included in the response
        :param boolean [params.paginate]:  default False, when True will automatically paginate by calling self endpoint multiple times
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        NFrt   rv  Tcursornext_cursorr1   r  rt  r  r  )r*  ry  fetch_paginated_call_cursorr  r  privatePostWithdrawStatusr  r  r  r  add_pagination_cursor_to_resultr  )r  r"  rt  r;  r  rv  r-  r  r  rawWithdrawalsr  s              r  fetch_withdrawalszkraken.fetch_withdrawals  s      !!!!!!!!!88ASU_``& 	C#F899:LdTY[`bhjw  zB  C  C  C  C  C  C  C  C  C}}T**H'~GG"5zzGG77GV8T8TUUUUUUUUN 844&$'' 	$!AA&IINN#N..|^TSXZ_```r  c                     |                      |d          }|                     |d          }t          |          }||dk    r||dz
           }||d<   |||dz
  <   |S )Nr  withdrawalsr   rz   )r  r  r  )r  r  r  rC  
dataLengthrW  s         r  r  z&kraken.add_pagination_cursor_to_result8	  sn    !!&-88v}55YY
*q..
Q'D"(D#'Da r  c                 n   K   ddi}|                      ||                     ||                     d{V S )a  
        create a currency deposit address
        :see: https://docs.kraken.com/rest/#tag/Funding/operation/getDepositAddresses
        :param str code: unified currency code of the currency for the deposit address
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        newr-  N)fetch_deposit_addressr  )r  r"  r  r-  s       r  create_deposit_addresszkraken.create_deposit_addressB	  sL       6
 //dkk'66R6RSSSSSSSSSr  c                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |d          S )aS  
        fetch deposit methods for a currency associated with self account
        :see: https://docs.kraken.com/rest/#tag/Funding/operation/getDepositMethods
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the kraken api endpoint
        :returns dict: of deposit methods
        Nr  r1   r  )r*  r  privatePostDepositMethodsr  r  )r  r"  r  r  r-  r  s         r  fetch_deposit_methodszkraken.fetch_deposit_methodsO	  s       !!!!!!!!!==&&Xd^
 77GV8T8TUUUUUUUU0 x222r  c                 ^  K   |                                   d{V  |                     |          }|                     |d          }|                     | j        di           }|                     |||          }|                     |d          }|dk    r|dk    r|dz   |z   }|                     | j        di           }|                     ||          }|                     |d|          }||                     |           d{V }	|Yt          d	t          |	                    D ];}
|                     |	|
         d          }|
                    |          d	k    r|} n<|-|                     |	d	i           }|                     |d          }|d
         |d}|                     |                     ||                     d{V }|                     |dg           }|                     |d	i           }|t          | j        dz   |z             |                     ||          S )a  
        fetch the deposit address for a currency associated with self account
        :see: https://docs.kraken.com/rest/#tag/Funding/operation/getDepositAddresses
        :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>`
        Nr  r  rM  r   r,  r  r3  r   r1   )r  r3  r  z9 privatePostDepositAddresses() returned no addresses for )r*  r  safe_string_upperr  r   r  r/  r  r  r  r  privatePostDepositAddressesr  r!   r1   parse_deposit_address)r  r"  r  r  r  r  defaultDepositMethodsdefaultDepositMethoddepositMethodr  r  entryfirstDepositMethodr-  r  r  firstResults                    r  r  zkraken.fetch_deposit_addressv	  st      !!!!!!!!!==&&((;;??4<R@@""8Wg>>69--FNNG!3!3#:'D $>NPR S S#//0EtLL((;OPP  #'#=#=d#C#CCCCCCCN"q#n"5"566  A ,,^A->IIEzz'**a//(- 0 $%)__^Q%K%K" $ 0 01CX N Nd^#
 
 99$++gv:V:VWWWWWWWW 8R88oofa44 +f!fim!mnnn))+x@@@r  c                     |                      |d          }|                      |d          }|                     d |          }|d         }|                     |           |||d |dS )Nr  r  r"  )r  r  r  r  r  )r  r  check_address)r  depositAddressr  r  r  r"  s         r  r  zkraken.parse_deposit_address	  s     "">9==~u55%%dH557###"
 
 	
r  c                   K   |                      ||          \  }}|                     |           d|v r|                                  d{V  |                     |          }|d         ||d}|                     |                     ||                     d{V }|                     |di           }	|                     |	|          S t          | j	        dz             )a  
        make a withdrawal
        :see: https://docs.kraken.com/rest/#tag/Funding/operation/withdrawFunds
        :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>`
        r  Nr1   )r  r  r  r  zO withdraw() requires a 'key' parameter(withdrawal key name, up on your account))
handle_withdraw_tag_and_paramsr  r*  r  privatePostWithdrawr  r  r  r   r1   )
r  r"  r  r  r  r  r  r-  r  r  s
             r  rx   zkraken.withdraw	  s      99#vFFV7###F??##%%%%%%%%%}}T**H!$ " G
 "55dkk'66R6RSSSSSSSSH ^^Hh;;F))&(;;;DG&wwxxxr  c                 T  K   |                                   d{V  ddd}|                     |                     ||                     d{V }|                     |          }|                     |d          }|                     ||          }|                     |d|d          S )a  
        fetch all open positions
        :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenPositions
        :param str[] [symbols]: not used by kraken fetchPositions()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        Nr-  r  )docalcsconsolidationr  r  F)r*  privatePostOpenPositionsr  re  r}  parse_positionsfilter_by_array_positions)r  rb  r  r-  r  r  resultss          r  fetch_positionszkraken.fetch_positions	  s       !!!!!!!!! %
 

 66t{{7F7S7STTTTTTTT\ %%g..(33&&vw77--gx%PPPr  c                    |                      |d          }|                      |d          }|dk    rdn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          d d d d          S )Nr)  r  r  longshortr  r1   r  notional
marginModeliquidationPrice
entryPriceunrealizedPnlnetrealizedPnlr   	contractsr  r  	markPrice	lastPricer  hedgedr9  r?   r  )rL  lastUpdateTimestampmaintenanceMarginmaintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager  marginRatior  r  )r  safe_positionr]  r   )r  positionr  r  rawSider  s         r  parse_positionzkraken.parse_position"
  s    ##Hf55""8V44!U**vv!! #
H#
$#
 d&&x88#
 	#

 $#
 #
 $#
 T--h>>#
 4#
 $#
 ))(E::#
 D#
 #
 #
 D#
  d!#
" ##
$ #'!%+/!--hAA'+((:>>!#9#
 #
 #
   	r  c                 <    dddd}|                      |||          S )NSpot WalletzFutures Wallet)r>   r@   rA   r  )r  r  accountByTypes      r  parse_account_typezkraken.parse_account_typeR
  s1    !$&
 

 w@@@r  c                 D   K   |                      ||dd|           d{V S )a  
        transfer from spot wallet to futures wallet
        :see: https://docs.kraken.com/rest/#tag/User-Funding/operation/walletTransfer
        :param str code: Unified currency code
        :param float amount: Size of the transfer
        :param dict [params]: Exchange specific parameters
        :returns: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        r>   r@   N)rw   )r  r"  r  r  s       r  transfer_outzkraken.transfer_outZ
  s4       ]]4HHHHHHHHHr  fromAccount	toAccountc                 
  K   |                                   d{V  |                     |          }|                     |          }|                     |          }|                     ||          |||d         d}|dk    r#t	          | j        dz   |z   dz   |z   dz             |                     |                     ||                     d{V }|                     ||          }	|                     |	|||d          S )	a   
        :see: https://docs.kraken.com/rest/#tag/User-Funding/operation/walletTransfer
        transfers currencies between sub-accounts(only spot->swap direction is supported)
        :param str code: Unified currency code
        :param float amount: Size of the transfer
        :param str fromAccount: 'spot' or 'Spot Wallet'
        :param str toAccount: 'swap' or 'Futures Wallet'
        :param dict [params]: Exchange specific parameters
        :returns: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        Nr1   )r  fromtor  r  z transfer cannot transfer from z to zA. Use krakenfutures instead to transfer from the futures account.)r  r  r  )	r*  r  r  currency_to_precisionr   r1   privatePostWalletTransferr  parse_transfer)
r  r"  r  r  r  r  r  r-  r  rw   s
             r  rw   zkraken.transfere
  sN      !!!!!!!!!==&&--k::++I66	00v>>d^	
 
 -''TW'HH;VY__bkk  or  r  s  s  s77GV8T8TUUUUUUUU &&x::{{8&"&
 &
   	r  c           
          |                      |di           }|                     |d          }||d d |                     |d          d d d dd	S )Nr  r  r"  sucess)	r  r1   r9  rL  r  r  r  r  r   )r  r  )r  rw   r  r  r  s        r  r  zkraken.parse_transfer
  sh     8R88  11((6::

 

 
	
r  r   GETc                 N   d| j         z   dz   |z   dz   |z   }|dk    r|r|d|                     |          z   z  }nN|dk    rB|dk    }|                                  t          |                                           }	|r,|                     |                     d|	i|                    }n+|                     |                     d|	i|                    }|                     |	|z             }
|                     |
dd          }|                     |          }| 	                    ||          }| 
                    | j                  }|                     ||t          j        d	          }| j        |d
}|rd|d<   nd|d<   nd|z   }| j        d         |         |z   }||||dS )Nr  r   ?r   r   noncesha256binarybase64)zAPI-KeyzAPI-Signzapplication/jsonzContent-Typez!application/x-www-form-urlencodedr   )urlr3  bodyheaders)r6   urlencode_nestedcheck_required_credentialsr  r  jsonr  encodehashbinary_concatbase64_to_binarysecrethmachashlibsha512apiKeyr   )r  pathr   r3  r  r  r  r  isCancelOrderBatchr  authr  r  binhashr  	signatures                   r  signzkraken.sign
  s   DL 3&,s2T9(?? ;sT226::::I"&*<"<++---

%%E! Tyygu-=v!F!FGG,,T[['59I6-R-RSS;;ut|,,D99T8X66D[[%%F((66G**4;77F		'67>8LLI;% G
 " N*<''*M''*Cis#c)fdwOOOr  c                 *    |                                  S N)milliseconds)r  s    r  r  zkraken.nonce
  s      """r  c
                 (   |dk    r-t          | j        dz   t          |          z   dz   |z             |                    d          dk    rt	          | j        dz   |z             |                    d          dk    rt          | j        dz   |z             |                    d          dk    rt          | j        dz   |z             |                    d          dk    rt          | j        dz   |z             |                    d          dk    rt	          | j        dz   |z             |                    d	          dk    rt          | j        dz   |z             |d S |d         d
k    rt          |t                    sd|v rt          |d                   }
|
rl| j        dz   |z   }t          dt          |d                             D ],}|d         |         }|                     | j        ||           -t          |          d S )Ni  r  zInvalid orderr   zInvalid noncezInsufficient fundszCancel pendingzInvalid arguments:volumezRate limit exceeded{error)r(   r1   r  r  r"   r*   r    r$   r'   r  r  r  throw_exactly_matched_exceptionr  r   )r  r"  reasonr  r3  r  r  r  requestHeadersrequestBody	numErrorsmessager  r  s                 r  handle_errorszkraken.handle_errors
  s    3;;&tw}s4yy'@3'F'OPPP99_%%**tw}t344499_%%**tw}t344499)**a//#DGcMD$899999%&&!++# 455599/00A55tw}t344499*++q00#DGcMD$899947c>>h,, 5h&& #HW$5 6 6I  5"&'C-$"6!&q#hw.?*@*@!A!A b bA$,W$5a$8E @@RWY`aaaa+G444tr  r  )r   rz   r2  )NNN)Z__name__
__module____qualname__r  r  r   r
   r  r   r  r  r   r'  r  r   r.  r,  r   r:  r	   r   rC  r   ra  r   r   rl  rn  r  rs  r  r  r  r   r  r  r  r   r  r  r   r  r  r   r   floatr   r  r  r  r  r  r   r  r  rD  rH  rZ  r^  ra  rg  rj  rm  rr  ru  r~  r  r   r  r  r  r  r  r  r  r  r  r  rx   r  r  r  r  r   rw   r  r  r  r  __classcell__)r  s   @r  r/   r/   "   s
       k k k k kZy y y *, J JV J J J JXG G( G G G G G G  4 -/ ; ;: ; ; ; ;z ;= -6 -6c -6AT -6 -6 -6 -6^
 
 
* *i *	 *en * * * * @DB .8 .8S .8 .8S\ .8 .8 .8 .8`/ /6 /V / / / /b 6:" G G7 G G G G G> 68 1 1 1F 1 1 1 1(
 
 
4 
 
 
 
, 8<$]ajl .J .J .JC .JWZ .Jquvzq{ .J .J .J .J`3 3 31
 1
 1
 1
 1
 1
f .2SW`b (@ (@s (@# (@S (@ (@ (@ (@T BFb ( (3 ( ( ( (6 =A  3 c    [ [ [5 [ [ [ [z <@d[] /? /? /?S /? /?bfglbm /? /? /? /?b) ) ) ) )$ *, , , , , , ,4 mqy{ (( (( ((I ((Y ((X] ((fi (( (( (( ((T( ( (  B: : :: : :L L L5 L L L L\ BFb B! B! B! B!H fjx|  FH 0. 0.3 0. 0.9 0.I 0._b 0.ru 0. 0. 0. 0.d 8<B >E >EC >E >E >E >E >E@ ?CQUdhqs E E3 E E3 E^a E E E EN <@  S    . 37TX\eg 5? 5?C 5?s 5?RU 5? 5? 5? 5?n 9=R  S #    2 6:"  s    . 59 	7 	7c 	7 	7 	7 	7 59tZ^gi ? ?c ? ?TW ?nrsxny ? ? ? ?6 7;\`ik B? B? B?3 B?VY B?ptuzp{ B? B? B? B?H
: 
: 
:C C Ch
 h
x h
; h
 h
 h
 h
TO O3 OVY Oil O O O O 04$UYbd "b "b "bC "bs "bimnyiz "b "b "b "bH ') 7 7 7 7* 37TX\eg Ea EaC Eas EaRU Ealpq|l} Ea Ea Ea EaN   >@ T T T T T T =? %3 %3 %3 %3 %3 %3N =? 3A 3A 3A 3A 3A 3Aj
 
h 
 
 
 
( EIQS  y  y3  y  y  y  y  yD 8<B ?Q ?QW ?Q ?Q ?Q ?QB. .v . . . .`A A A <> 	I 	Is 	I 	I 	I 	I ac & &3 & &C &TW &gt & & & &P
 
 
 
 
 
4 &eBSW !P !P !P !PF# # #      r  r/   )4 ccxt.async_support.base.exchanger   ccxt.abstract.krakenr   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   ccxt.base.decimal_to_precisionr+   r,   ccxt.base.preciser-   r/    r  r  <module>r&     s   6 5 5 5 5 5 , , , , , ,  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 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . + + + + + + ) ) ) ) ) ) * * * * * * * * * * * * ) ) ) ) ) ) + + + + + + . . . . . . 1 1 1 1 1 1 * * * * * * ) ) ) ) ) ) 3 3 3 3 3 3 4 4 4 4 4 4 % % % % % %G+ G+ G+ G+ G+X{ G+ G+ G+ G+ G+r  