
    E#i|                    \   S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S SKJ r   S SKJ!r!  S S	KJ"r"  S S
KJ#r#  S SKJ$r$  S SKJ%r%  S SKJ&r&  S SKJ'r'  S SKJ(r(  S SKJ)r)  S SKJ*r*  S SKJ+r+  S SK,J-r-  S SK.J/r/   " S S\\5      r0g)    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesCurrencyDepositAddressIntLedgerEntryMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeeInterfaceTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)
BadRequest)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)NotSupported)ExchangeNotAvailable)OnMaintenance)InvalidNonce)	TICK_SIZE)Precisec                     ^  \ rS rSrS\4U 4S jjr0 4S\\   4S jjrS r	0 4S jr
0 4S\4S jjrS0 4S	\S
\S\4S jjrSZS\S\S\4S jjr0 4S	\S\4S jjrS0 4S\S\4S jjrS rS rSZS\S\S\4S jjrSS0 4S	\S\S
\S\\   4S jjrSZS\S\4S jjrSSS0 4S	\S\S\S
\S\\   4
S jjrS\ 4S jr!0 4S\ 4S jjr"0 4S	\S\#4S jjr$SZS\S\S\#4S  jjr%S! r&0 4S\'4S" jjr(S0 4S#\4S$ jjr)SZS% jr*S0 4S& jr+SZS' jr,S0 4S	\S(\-S)\.S*\/S+\04
S, jjr1S0 4S-\S	\24S. jjr3S0 4S	\24S/ jjr4S0\24S1 jr5S0 4S-\S	\24S2 jjr6S0 4S-\S	\24S3 jjr7SSS0 4S	\2S\S
\4S4 jjr8SSS0 4S5\2S\S
\S\\9   4S6 jjr:SSS0 4S5\2S\S
\S\\9   4S7 jjr;SZS8\S9\<S\94S: jjr=S0\24S; jr>SZS<\S\S\?4S= jjr@S> rASZS?\S9\<S\B4S@ jjrCSSS0 4S5\2S\S
\S\\B   4SA jjrDSSS0 4S	\2S\S
\S\\?   4SB jjrESC rFSD rG0 4S5\S\H4SE jjrIS0 4S5\S*\/SF\SG\2S\94
SH jjrJ0 4S5\S*\/SI\SJ\S\K4
SK jjrLSZSL jrMS0\2S\24SM jrNSN rOSOSP0 SS4SQ jrPSR\QSS\ST\SU\SV\SW\4SX jrRSYrSU =rT$ )[bitstamp   returnc                   > U R                  [        [        U ]  5       0 SS_SS_SS/_SS_S	S
_SU R                  S   _SS_S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S S_S!S_0 S"S_S#S_S$S_S%S_S&S_S'S_S(S_S)S_S*S_S+S_S,S_S-S_S.S_S/S_S0S_S1S_S2S_E0 S3S_S4S5_S6S_S7S_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_SBS_SCS_SDS_E0 SES_SFS_SGS_SHS_SIS_SJS_SKS_SLS_SMS_SNS_SOS_SPS_SQS_SRS_SSS_STS_SUS_E0 SVS_SWS_SXS_SYS_SZS_S[S_S\S_S]S_S^S_S_S_S`S_SaS_SbS_ScS_SdS_SeS_SfS_E0 SgS_ShS_SiS_SjS_SkS5_SlS_SmS_SnS_SoS_SpS_SqS_SrS_SsS_StS_SuS_SvS_E_SwSxSySySz.S{SyS|._S}S~SSSSSSSSSSSS._SSSS._SSSSSSSSSSSSS.
0SSSSS.0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_E0 SS_SS_SS_SS_SS_SS_SS_SS_GS S_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GS	S_GS
S_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GS S_GS!S_GS"S_GS#S_GS$S_GS%S_GS&S_GS'S_GS(S_GS)S_GS*S_E0 GS+S_GS,S_GS-S_GS.S_GS/S_GS0S_GS1S_GS2S_GS3S_GS4S_GS5S_GS6S_GS7S_GS8S_GS9S_GS:S_GS;S_E0 GS<S_GS=S_GS>S_GS?S_GS@S_GSAS_GSBS_GSCS_GSDS_GSES_GSFS_GSGS_GSHS_GSIS_GSJS_GSKS_GSLS_E0 GSMS_GSNS_GSOS_GSPS_GSQS_GSRS_GSSS_GSTS_GSUS_GSVS_GSWS_GSXS_GSYS_GSZS_GS[S_GS\S_GS]S_E0 GS^S_GS_S_GS`S_GSaS_GSbS_GScS_GSdS_GSeS_GSfS_GSgS_GShS_GSiS_GSjS_GSkS_GSlS_GSmS_GSnS_E0 GSoS_GSpS_GSqS_GSrS_GSsS_GStS_GSuS_GSvS_GSwS_GSxS_GSyS_GSzS_GS{S_GS|S_GS}S_GS~S_GSS_ESSSGS.EGS.Sz._GSSSU R                  GS5      U R                  GS5      U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      //U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      /U R                  GS5      U R                  GS5      //GS.GS.SS0 GSGSGSGSGSGSGSGSGSGS.	GS.GS._GS[        _GSGSGS0_GSGS0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGSGS.E0_GS0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _[        [         ["        [        GS.GS._GSSSSS SSSS SSSSGS.SSSSSSSGS.S SGSS GSSGS.SSSSGS.SS SSSGS.S S GSGS0GS.	S S GS.S S GS.GS.0E5      $ (  Nidr,   nameBitstamp	countriesGB	rateLimitK   versionv2	userAgentchromeproThasCORSspotmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercloseAllPositionsclosePositioncreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsWithdrawalsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLedgerfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickersfetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeesfetchTransactionsfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModetransferwithdrawurlszOhttps://github.com/user-attachments/assets/d5480572-1fee-43cb-b900-d38c522d0024zhttps://www.bitstamp.net/api)publicprivatezhttps://www.bitstamp.net)logoapiwwwdoc
timeframes6018030090018003600720014400216004320086400259200)1m3m5m15m30m1h2h4h6h12h1d1wrequiredCredentials)apiKeysecretr   get   )
zohlc/{pair}/zorder_book/{pair}/zticker/zticker_hour/{pair}/zticker/{pair}/ztransactions/{pair}/ztrading-pairs-info/zcurrencies/zeur_usd/ztravel_rule/vasps/)travel_rule/contacts/zcontacts/{contact_uuid}/zearn/subscriptions/zearn/transactions/zaccount_balances/zaccount_balances/{currency}/zbalance/zbalance/{pair}/zbch_withdrawal/zbch_address/zuser_transactions/zuser_transactions/{pair}/zcrypto-transactions/
open_orderzopen_orders/all/zopen_orders/{pair}/zorder_status/zcancel_order/zcancel_all_orders/zcancel_all_orders/{pair}/zbuy/{pair}/zbuy/market/{pair}/zbuy/instant/{pair}/zsell/{pair}/zsell/market/{pair}/zsell/instant/{pair}/ztransfer-to-main/ztransfer-from-main/zmy_trading_pairs/zfees/trading/zfees/trading/{market_symbol}zfees/withdrawal/zfees/withdrawal/{currency}/zwithdrawal-requests/zwithdrawal/open/zwithdrawal/status/zwithdrawal/cancel/zliquidation_address/new/zliquidation_address/info/zbtc_unconfirmed/zwebsockets_token/zbtc_withdrawal/zbtc_address/zripple_withdrawal/zripple_address/zltc_withdrawal/zltc_address/zeth_withdrawal/zeth_address/zxrp_withdrawal/zxrp_address/zxlm_withdrawal/zxlm_address/zpax_withdrawal/zpax_address/zlink_withdrawal/zlink_address/zusdc_withdrawal/zusdc_address/zomg_withdrawal/zomg_address/zdai_withdrawal/zdai_address/zknc_withdrawal/zknc_address/zmkr_withdrawal/zmkr_address/zzrx_withdrawal/zzrx_address/zgusd_withdrawal/zgusd_address/zaave_withdrawal/zaave_address/zbat_withdrawal/zbat_address/zuma_withdrawal/zuma_address/zsnx_withdrawal/zsnx_address/zuni_withdrawal/zuni_address/zyfi_withdrawal/zyfi_address/zaudio_withdrawal/zaudio_address/zcrv_withdrawal/zcrv_address/zalgo_withdrawal/zalgo_address/zcomp_withdrawal/zcomp_address/zgrt_withdrawal/zgrt_address/zusdt_withdrawal/zusdt_address/zeurt_withdrawal/zeurt_address/zmatic_withdrawal/zmatic_address/zsushi_withdrawal/zsushi_address/zchz_withdrawal/zchz_address/zenj_withdrawal/zenj_address/zalpha_withdrawal/zalpha_address/zftt_withdrawal/zftt_address/zstorj_withdrawal/zstorj_address/zaxs_withdrawal/zaxs_address/zsand_withdrawal/zsand_address/zhbar_withdrawal/zhbar_address/zrgt_withdrawal/zrgt_address/zfet_withdrawal/zfet_address/zskl_withdrawal/zskl_address/zcel_withdrawal/zcel_address/zsxp_withdrawal/zsxp_address/zada_withdrawal/zada_address/zslp_withdrawal/zslp_address/zftm_withdrawal/zftm_address/zperp_withdrawal/zperp_address/zdydx_withdrawal/zdydx_address/zgala_withdrawal/zgala_address/zshib_withdrawal/zshib_address/zamp_withdrawal/zamp_address/zsgb_withdrawal/zsgb_address/zavax_withdrawal/zavax_address/zwbtc_withdrawal/zwbtc_address/zctsi_withdrawal/zctsi_address/zcvx_withdrawal/zcvx_address/zimx_withdrawal/zimx_address/znexo_withdrawal/znexo_address/zust_withdrawal/zust_address/zant_withdrawal/zant_address/zgods_withdrawal/zgods_address/zrad_withdrawal/zrad_address/zband_withdrawal/zband_address/zinj_withdrawal/zinj_address/zrly_withdrawal/zrly_address/zrndr_withdrawal/zrndr_address/zvega_withdrawal/zvega_address/z1inch_withdrawal/z1inch_address/zens_withdrawal/zens_address/zmana_withdrawal/zmana_address/zlrc_withdrawal/zlrc_address/zape_withdrawal/zape_address/zmpl_withdrawal/zmpl_address/zeuroc_withdrawal/zeuroc_address/zsol_withdrawal/zsol_address/zdot_withdrawal/zdot_address/znear_withdrawal/znear_address/zdoge_withdrawal/zdoge_address/zflr_withdrawal/zflr_address/zdgld_withdrawal/zdgld_address/zldo_withdrawal/zldo_address/r   zearn/subscribe/zearn/subscriptions/setting/zearn/unsubscribezwecan_withdrawal/zwecan_address/ztrac_withdrawal/ztrac_address/zeurcv_withdrawal/zeurcv_address/zpyusd_withdrawal/zpyusd_address/zlmwr_withdrawal/zlmwr_address/zpepe_withdrawal/zpepe_address/zblur_withdrawal/zblur_address/zvext_withdrawal/zvext_address/zcspr_withdrawal/zcspr_address/zvchf_withdrawal/zvchf_address/zveur_withdrawal/zveur_address/ztruf_withdrawal/ztruf_address/zwif_withdrawal/zwif_address/zsmt_withdrawal/zsmt_address/zsui_withdrawal/zsui_address/zjup_withdrawal/zjup_address/zondo_withdrawal/zondo_address/zboba_withdrawal/)zboba_address/zpyth_withdrawal/zpyth_address/)r   postfeesz0.004010000z0.003100000z0.002500000z0.00181500000z0.00165000000z0.001220000000z0.00150000000z0.0008	100000000z0.0006	250000000z0.0005
1000000000z0.0003z0.0001)takermaker)	tierBased
percentager   r   tiersr   g      @)	BTCBCHLTCETHXRPXLMPAXUSDEUR)r   r   r   deposit)tradingfundingprecisionModecommonCurrenciesUSTUSTCoptionsnetworksByIdzbitcoin-cashr   bitcoinr   ethereumERC20litecoinr   stellarr   xrplr   tronTRC20algorandALGOflareFLRhederaHBARcardanaADAsongbirdzavalanche-c-chainAVAXsolanaSOLpolkadotDOTnearNEARdogeDOGESUICSRP)suicasper
exceptionszNo permission foundzAPI key not foundzIP address not allowedzInvalid noncezInvalid signaturezAuthentication failedz+Missing key, signature and nonce parameterszWrong API key formatzYour account is frozenzIPlease update your profile with your FATCA information, before using API.zOrder not found.z*Price is more than 20% below market price.z@Bitstamp.net is under scheduled maintenance. We'll be back soon.zOrder could not be placed.zInvalid offset.z2Trading is currently unavailable for your account.)zMinimum order size isz'Check your account balance for details.zEnsure self value has at leastz"Ensure that there are no more than)exactbroadfeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventioniceberg     )r  limitdaysBack	untilDayssymbolRequired)r  triggerr  r(  )r  r%  r)  r  r(  r%  )	sandboxrK   createOrdersr~   r   r   fetchOrdersfetchClosedOrdersr   )linearinverse)r>   r@   rA   )deep_extendsuperr,   describe
userAgentsparse_numberr)   r   r   r(   r$   r#   r'   r&   r    r   r!   r"   )self	__class__s    G/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/bitstamp.pyr2  bitstamp.describe   s   h > @ ~C
*~C
J~C
 $~C

 ~C
 t~C
 2~C
 4~C
  fff %f 	f
 %f %f Uf $Uf 'f f "4f tf $Uf  f tf  7!f" 9%#f$ (%f& ''f( ()f* "5+f, -f. &u/f0 "51f2 +E3f4 )%5f6 #E7f8 ,U9f: ';f< (=f> "4?f@ &tAfB (CfD 1%EfF +DGfH *:IfJ +DKfL &uMfN 'OfP (QfR #ESfT *5UfV $UWfX uYfZ "5[f\ *5]f^ +E_f` )%afb tcfd  eff !%gfh %eifj $Ukfl &umfn -eofp /qfr "5sft #Eufv +Ewfx yfz !%{f| "5}f~ &uf@ +EAfB  CfD dEfF $UGfH +EIfJ %eKfL "4MfN uOfP #EQfR dSfT !$UfV  WfX 'YfZ $U[f\ !%]f^ *5_f` (afb %ecfd )%eff )%gfh tifj kfl tmfn "4ofp #Dqfr 'sft $Zufv )%wfx #Dyfz {f| #E}f~ &uf@ uAfB UCfD  EfF "5GfH DIfJ DKf~C
` i<= 25a~C
r s~C
N "$O~C
V ()./#$/0*+01/0'($%./  2345/0./	s+Qs6s #As *1	s
 *1s 's -as 4Qs /s %as +As .qs (s (s -as  4Q!s" &q#s$ -a%s& .q's( ')s* .q+s, /-s. ,Q/s0 .q1s2 ,Q3s4 (5s6 77s8 +A9s: 6q;s< /=s> +A?s@ -aAsB -aCsD 3AEsF 4QGsH +AIsJ ,QKsN *1OsP 'QsR -aSsT *1UsV *1WsX 'YsZ *1[s\ ']s^ *1_s` 'asb *1csd 'esf *1gsh 'isj +Aksl (msn +Aosp (qsr *1sst 'usv *1wsx 'ysz *1{s| '}s~ *1s@ 'AsB *1CsD 'EsF +AGsH (IsJ +AKsL (MsN *1OsP 'QsR *1SsT 'UsV *1WsX 'YsZ *1[s\ ']s^ *1_s` 'asb ,Qcsd )!esf *1gsh 'isj +Aksl (msn +Aosp (qsr *1sst 'usv +Awsx (ysz +A{s| (}s~ ,Qs@ )!AsB ,QCsD )!EsF *1GsH 'IsJ *1KsL 'MsN ,QOsP )!QsR *1SsT 'UsV ,QWsX )!YsZ *1[s\ ']s^ +A_s` (asb +Acsd (esf *1gsh 'isj *1ksl 'msn *1osp 'qsr *1sst 'usv *1wsx 'ysz *1{s| '}s~ *1s@ 'AsB *1CsD 'EsF +AGsH (IsJ +AKsL (MsN +AOsP (QsR +ASsT (UsV *1WsX 'YsZ *1[s\ ']s^ +A_s` (asb +Acsd (esf +Agsh (isj *1ksl 'msn *1osp 'qsr +Asst (usv *1wsx 'ysz *1{s| '}s~ +As@ (AsB *1CsD 'EsF +AGsH (IsJ *1KsL 'MsN *1OsP 'QsR +ASsT (UsV +AWsX (YsZ ,Q[s\ )!]s^ *1_s` 'asb +Acsd (esf *1gsh 'isj *1ksl 'msn *1osp 'qsr ,Qsst )!usv *1wsx 'ysz *1{s| '}s~ +As@ (AsB +ACsD (EsF *1GsH 'IsJ +AKsL (MsN *1OsP 'QsR 0SsT *1UsV 6qWsX +AYsZ ,Q[s\ )!]s^ +A_s` (asb ,Qcsd )!esf ,Qgsh )!isj +Aksl (msn +Aosp (qsr +Asst (usv +Awsx (ysz +A{s| (}s~ +As@ (AsB +ACsD (EsF +AGsH (IsJ *1KsL 'MsN *1OsP 'QsR *1SsT 'UsV *1WsX 'YsZ +A[s\ (]s^ +A_s` *+,-)*es{KW~C
n !%"&!..w7!..w7 "..s3T5F5Fw5OP!..w79J9J79ST!..x8$:K:KG:TU!..x8$:K:KH:UV!..y94;L;LX;VW!..y94;L;LX;VW!..z:D<M<Mg<VW!..z:D<M<Mh<WX!..{;T=N=Nx=XY!..{;T=N=Nx=XY!..|<d>O>OPX>YZ" "..s3T5F5Fw5OP!..w79J9J79ST!..x8$:K:KG:TU!..x8$:K:KH:UV!..y94;L;LX;VW!..y94;L;LX;VW!..z:D<M<Mg<VW!..z:D<M<Mh<WX!..{;T=N=Ns=ST!..{;T=N=Ns=ST!..|<d>O>OPS>TU"!F "'"' "       " 
 	G3o~C
V YW~C
X v!Y~C
`  !"E!u! ! 	!
 u! E! G! ! U! f! u! ! (! e! !  F!!" F#!$ !$'!a~C
N )+;')< -.> $\	
 ()< ,-@ BCV +,? -.> `aq ' A, WXe 12F &z  IJZ!& .:?P6D:F	'O~C
B $&+(-,0,1).+06:#'#'"&#'	( #($)$)+027/4#()$, %)&+!%$(%'*/& ',#($)*/	# ',!%#($)*/( $()-#_2h ##
 ##q<C~C
 ~ ~	    c                    U R                  U5      n/ n[        S[        U5      5       GH  nX$   nU R                  US5      nUR	                  S5      u  pxUR                  5       n	UR                  5       n
U R                  U5      nU R                  U5      nU R                  US5      nUR	                  S5      nU R                  US5      nUR                  0 SU R                  US5      _S	U	S
-   U
-   _SUS-   U-   _SU_SU_SS_SU	_SU
_SS_SS_SS_SS_SS_SS_SS_SUS:H  _SS_SSSSSSSU R                  U R                  U R                  US5      5      5      U R                  U R                  U R                  US5      5      5      S .SSS!.SSS!.SSS!.U R                  US5      SS!.S".SUS#.E5        GM     U$ )$a  
retrieves data on all markets for bitstamp

https://www.bitstamp.net/api/#tag/Market-info/operation/GetTradingPairsInfo

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
r   r1   /minimum_order r   r0   
url_symbolmarketId_symbolbasequotesettleNbaseIdquoteIdsettleIdtyper>   Tr?   FrA   r@   rB   activeEnabledcontractbase_decimalscounter_decimals)amountpriceminmax)r  rN  rO  cost)r.  r/  contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)fetch_markets_from_cacherangelensafe_stringsplitlowersafe_currency_codeappendr4  parse_precisionsafe_number)r5  paramsresponseresultimarketr1   rB  rC  rE  rF  minimumOrderpartsstatuss                 r7  fetch_marketsbitstamp.fetch_markets_  s    008 q#h-(A[F##FF3D**S/KDZZ\FkkmG**40D++E2E++FODL &&s+E%%fi8FMM 1d&&v|<1FSL721 $*u,1 	1
 1 $1 &1 71 D1 1 1 %1 %1 1 %1  6Y.!1" E#1$  $"&""//0D0DTEUEUV\^mEn0op!..t/C/CDDTDTU[]oDp/qr  $#!
  $#
  $#
  $//q9#$  a1 1 )z r9  c                 &   SnU R                  5       nU R                  U5      (       a  SnU R                  U R                  U R	                  U5      5      5      n	UUUUUSS S U R                  US   S   S   U5      U	U	S S.U	S S.US S.S S S.S.0 S	.$ )
NcryptofiatTr   r   r   rP  )rN  rO  rS  r   )r0   coder\  rH  r1   rI  r   r   feerY  rZ  networks)r2  is_fiatr4  re  number_to_stringrf  )
r5  r0   rt  r1   rY  minCostoriginalPayloadcurrencyTypedescriptiontickSizes
             r7  construct_currency_object"bitstamp.construct_currency_object  s    mmo<<!L$$T%9%9$:O:OPY:Z%[\# ##K$7	$B:$NPTU! $
 $
 #
  $ ;
 	
r9  c                 `   U R                  U R                  S0 5      nU R                  US5      nU R                  USS5      nU R                  5       nUb  XS-
  U:  a3  U R	                  U5      nU R                  UUUS.5      U R                  S'   U R                  U R                  S   S5      $ )Nry   	timestampexpiresr#  )rh  r  rh  )
safe_valuer   safe_integermillisecondspublicGetTradingPairsInfoextend)r5  rg  r   r  r  nowrh  s          r7  r]  !bitstamp.fetch_markets_from_cache  s     //$,,C%%g{;	##GY=!COw#>55f=H+/;;w$ A ,DLL( t||N;ZHHr9  c           
         U R                  U5      n0 n[        S[        U5      5       GH)  nX$   nU R                  US5      nUR	                  S5      u  pxUR                  5       n	UR                  5       n
U R                  U5      nU R                  U5      nU R                  US5      nUR	                  S5      u  pU R                  US5      nUR	                  S5      nUS   nXs;  a)  U R                  US5      nU R                  XUUS	U5      X7'   X;  d  M  U R                  US
5      nU R                  XUUU R                  U5      U5      X8'   GM,     U$ )a  
fetches all available currencies on an exchange

https://www.bitstamp.net/api/#tag/Market-info/operation/GetTradingPairsInfo

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
r   r1   r;  r|  z / r<  r=  rL  NrM  )
r]  r^  r_  r`  ra  rb  rc  r  r~  r4  )r5  rg  rh  ri  rj  rk  r1   rB  rC  rE  rF  r|  baseDescriptionquoteDescriptionrl  rm  rS  baseDecimalscounterDecimalss                      r7  fetch_currenciesbitstamp.fetch_currencies  sr    008 q#h-(A[F##FF3D**S/KDZZ\FkkmG**40D++E2E**6=AK0;0A0A%0H-O++FODL &&s+E8DN#00I#==fO]ikoqwxO"&"3"3F<N"O $ > >wO_aprv  sD  sD  EI  sJ  LR  !S% )& r9  NrA  r%  c                    U R                  5         U R                  U5      nSUS   0nU R                  U R                  XS5      5      nU R	                  US5      nU R                  US-  5      nU R                  XdS   U5      n	XyS'   U	$ )a	  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://www.bitstamp.net/api/#tag/Order-book/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
pairr0   microtimestampr#  rA  nonce)load_marketsrk  publicGetOrderBookPairr  r  parse_to_intparse_order_book)
r5  rA  r%  rg  rk  requestrh  r  r  	orderbooks
             r7  fetch_order_bookbitstamp.fetch_order_book  s     	V$F4L
 ..t{{7/KL" **85EF%%nt&;<	))(84DiP	+'r9  tickerrk  c                 Z   U R                  US5      nU R                  X2S 5      nU R                  US5      nU R                  US5      nU R                  US5      n[        R                  " Xv5      nU R                  US5      n	U R                  0 SU_SU_SU R                  U5      _SU R                  US5      _S	U R                  US	5      _S
U R                  US
5      _SS _SU R                  US5      _SS _SU_SU R                  US5      _SU	_SU	_SS _SS _SS _SS _UUUS.EU5      $ )Nr  r  vwapvolumelastrA  datetimehighlowbid	bidVolumeask	askVolumeopenclosepreviousClosechanger   average)
baseVolumequoteVolumer\  )r`  safe_symbolsafe_timestampr*   
string_mulsafe_tickeriso8601)
r5  r  rk  r?  rA  r  r  r  r  r  s
             r7  parse_tickerbitstamp.parse_tickerA  s   " ##FF3!!(D9''<	/%%fh7
((:/ !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 !
 4##FE2!
 !
 D!
 D$$VV4!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
* + 	r9  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  XS5      $ )a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://www.bitstamp.net/api/#tag/Tickers/operation/GetMarketTicker

:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
r  r0   )r  rk  publicGetTickerPairr  r  )r5  rA  rg  rk  r  r  s         r7  fetch_tickerbitstamp.fetch_tickerp  s\     	V$F4L
 ))$++g*FG    00r9  symbolsc                 f    U R                  5         U R                  U5      nU R                  X15      $ )a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://www.bitstamp.net/api/#tag/Tickers/operation/GetCurrencyPairTickers

:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
)r  publicGetTickerparse_tickers)r5  r  rg  rh  s       r7  fetch_tickersbitstamp.fetch_tickers  s3     	''/" !!(44r9  c                 :   U R                  US5      nUb  U$ U R                  U/ SQ5      n[        UR                  5       5      n[	        S[        U5      5       H>  nX4   nUR                  S5      S:  d  M  U R                  X5      nUc  M4  US:w  d  M<  Us  $    g )Ncurrency)ru  rO  r  rH  rn  r0   r   r@  )safe_string_loweromitlistkeysr^  r_  findr  )r5  transaction
currencyIdidsrj  r0   values          r7   get_currency_id_from_transaction)bitstamp.get_currency_id_from_transaction  s     ++KD
!ii .
  ;##%&q#c(#ABwws|a))+:%EQJI $ r9  c                    U R                  U/ SQ5      n[        UR                  5       5      n[        U5      nUS:  a?  [	        U R
                  S-   U R                  U5      -   S-   U R                  U5      -   5      eUS:X  aV  US   US   -   nX@R                  ;   a  U R                  U5      $ US   US   -   nX@R                  ;   a  U R                  U5      $ g )N)ru  rO  r  tidrH  order_idside   z% getMarketFromTrade() too many keys: z in the trade: r   r   )	r  r  r  r_  r   r0   jsonmarkets_by_idsafe_market)r5  tradecurrencyIdsnumCurrencyIdsr?  s        r7  get_market_from_tradebitstamp.get_market_from_trade  s    		% "
  5::<([)A*Q QTXT]T]^iTj jm~ ~  BF  BK  BK  LQ  BR  !R  S  SQ"1~A6H---''11"1~A6H---''11r9  r  c                    U R                  USS5      nS nS nU R                  US5      nU R                  US5      nU R                  US5      nS n	U R                  US5      n
S nUcl  [        UR                  5       5      n[	        S[        U5      5       H:  nX   nUS:w  d  M  UR                  S5      S:  d  M&  UnU R                  XS5      nM<     Uc  U R                  U5      nU R                  US	5      nUS
   nUb  UOUS   nU R                  UUU5      nU R                  XS   U5      nU R                  XS   U
5      n
US   nU R                  USS5      nS nUb7  UR                  S5      S:  a  U R                  U5      nO[        U5      nUS-  nSU;   a=  Ub9  [        R                  " US5      nU(       a  Sn[        R                  " U5      nO)SnO&U R                  US5      nUS:X  a  SnOUS:X  a  SnOS nU
b  [        R                  " U
5      n
S nUb  UUS.nU R                  UUUU R!                  U5      UUU	US UUU
US.U5      $ )Nr0   r  rO  rN  r  rS  r   r@  ru  rC  r?  rE  rF  rA  dater  r=  r#  r   sellbuyrH  1)rS  r  )r0   r\  r  r  rA  orderrH  r  takerOrMakerrO  rN  rS  ru  )safe_string_2r`  r  r  r^  r_  r  r  r  	parse8601intr*   	string_lt
string_neg
string_abs
safe_trader  )r5  r  rk  r0   rA  r  priceStringamountStringorderIdrH  
costStringrawMarketIdr  rj  
currentKeyfeeCostStringfeeCurrencypriceIddatetimeStringr  isAmountNegru  s                         r7  parse_tradebitstamp.parse_trade  s   P tU3&&ug6''x8""5*5%%eV4
>

%D1c$i(!W
+
0D0I",K!--k3GF	 ) >//6F((6Wo"-"9+z@R&&ug{C''h/?N%%eI->
K
!++E6:F	%""3'1, NN>:	  /	%,	5='%//cB!D#*#5#5l#CL D##E62Ds{! ++J7J$%'C "Y/  " 
  	r9  sincec                     U R                  5         U R                  U5      nUS   SS.nU R                  U R                  Xd5      5      nU R	                  XuX#5      $ )a  
get the list of most recent trades for a particular symbol

https://www.bitstamp.net/api/#tag/Transactions-public/operation/GetTransactions

: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>`
r0   hour)r  time)r  rk  publicGetTransactionsPairr  parse_trades)r5  rA  r  r%  rg  rk  r  rh  s           r7  fetch_tradesbitstamp.fetch_trades^  s_     	V$4L
 11$++g2NO&   5@@r9  c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )Nr  r  r  r  r  r  )r  rf  )r5  ohlcvrk  s      r7  parse_ohlcvbitstamp.parse_ohlcv  sn     {3UF+UF+UE*UG,UH-
 	
r9  r   	timeframec                 n   U R                  5         U R                  U5      nUS   U R                  U R                  X"5      S.nU R	                  U5      nUcB  Uc  SUS'   O}SnU R                  US-  5      n	XS'   U R                  XUS-
  -  5      US'   XGS'   ODUb2  U R                  US-  5      n	XS'   U R                  XUS-
  -  5      US'   [        US5      US'   U R                  U R                  Xu5      5      n
U R                  U
S0 5      nU R                  US	/ 5      nU R                  XX#U5      $ )
aW  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://www.bitstamp.net/api/#tag/Market-info/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
:returns int[][]: A list of candles ordered, open, high, low, close, volume
r0   )r  stepr#  r%  startr   enddataohlc)r  rk  r`  r   parse_timeframer  sumrQ  publicGetOhlcPairr  r  	safe_listparse_ohlcvs)r5  rA  r  r  r%  rg  rk  r  durationr  rh  r  r  s                r7  fetch_ohlcvbitstamp.fetch_ohlcv  sL    	V$4L$$T__iK
 ''	2=}#' ))%$,7#( !%%UQY1G!H#(  ))%$,7#( !%%UQY1G!H"5$/GG))$++g*FG x4~~dFB/  yGGr9  c                 f   US S S.nUc  / n[        S[        U5      5       H}  nX   nU R                  US5      nU R                  U5      nU R	                  5       nU R                  US5      US'   U R                  US5      US'   U R                  US5      US'   XrU'   M     U R                  U5      $ )	N)r\  r  r  r   r  	availablefreereservedusedtotal)r^  r_  r`  rc  accountsafe_balance)r5  rh  ri  rj  currencyBalancer  currencyCoder  s           r7  parse_balancebitstamp.parse_balance  s    

 Hq#h-(A&kO))/:FJ22:>LllnG"..LGFO"..
KGFO#//IGG#*<  )   ((r9  c                 f    U R                  5         U R                  U5      nU R                  U5      $ )aS  
query for balance and get the amount of funds available for trading or funds locked in orders

https://www.bitstamp.net/api/#tag/Account-balances/operation/GetAccountBalances

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
)r  privatePostAccountBalancesr  r5  rg  rh  s      r7  fetch_balancebitstamp.fetch_balance  s3     	226: !!(++r9  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US5      nU R                  XcS   5      nU R                  Xs5      $ )a5  
fetch the trading fees for a market

https://www.bitstamp.net/api/#tag/Fees/operation/GetTradingFeesForCurrency

: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>`
market_symbolr0   currency_pair)r  rk  privatePostFeesTradingr  index_by	safe_dictparse_trading_fee)r5  rA  rg  rk  r  rh  tradingFeesByMarketId
tradingFees           r7  fetch_trading_feebitstamp.fetch_trading_fee  s     	V$VD\
 ..t{{7/KL !%h H^^$9$<H
%%j99r9  ru  c                     U R                  US5      nU R                  US0 5      nUU R                  X25      U R                  US5      U R                  US5      S S S.$ )Nrk  r   r   r   )r\  rA  r   r   r   r   )r`  r'  r  rf  )r5  ru  rk  r?  r   s        r7  r(  bitstamp.parse_trading_fee  sg    ##C2~~c62.&&x8%%dG4%%dG4
 	
r9  c                 ~    SU0n[        S[        U5      5       H  nU R                  X   5      nUS   nXBU'   M!     U$ )Nr\  r   rA  )r^  r_  r(  )r5  r   ri  rj  ru  rA  s         r7  parse_trading_feesbitstamp.parse_trading_fees&  sI    ~q#d)$A((1C]F 6N % r9  c                 f    U R                  5         U R                  U5      nU R                  U5      $ )a5  
fetch the trading fees for multiple markets

https://www.bitstamp.net/api/#tag/Fees/operation/GetAllTradingFees

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
)r  r%  r0  r  s      r7  fetch_trading_feesbitstamp.fetch_trading_fees.  s3     	..v6 &&x00r9  codesc                 f    U R                  5         U R                  U5      nU R                  U5      $ )ai  
@deprecated
       please use fetchDepositWithdrawFees instead

       https://www.bitstamp.net/api/#tag/Fees

       :param str[]|None codes: list of unified currency codes
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns dict[]: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
       )r  privatePostFeesWithdrawalparse_transaction_fees)r5  r5  rg  rh  s       r7  fetch_transaction_feesbitstamp.fetch_transaction_feesI  s3     	11&9 **844r9  c                 j   0 nU R                  US5      n[        UR                  5       5      n[        S[	        U5      5       Hl  nXV   nU R                  X0 5      nU R                  U5      n	Ub  U R                  X5      (       d  ME  U R                  US5      0 U R                  XG5      S.X9'   Mn     U$ )Nr  r   ru  )withdraw_feer   r\  )
r&  r  r  r^  r_  r  rc  in_arrayrf  r'  )
r5  rh  r5  ri  
currenciesr  rj  r0   r   rt  s
             r7  r8  bitstamp.parse_transaction_feesb  s    ]]8Z8
:??$%q#c(#AB??83D**2.D!4==+E+E $ 0 0u =z6FL $ r9  c                     U R                  5         U R                  U5      nU R                  US5      nU R                  XA5      $ )aF  
fetch deposit and withdraw fees

https://www.bitstamp.net/api/#tag/Fees/operation/GetAllWithdrawalFees

:param str[]|None codes: list of unified currency codes
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
r  )r  r7  group_byparse_deposit_withdraw_fees)r5  r5  rg  rh  responseByCurrencyIds        r7  fetch_deposit_withdraw_fees$bitstamp.fetch_deposit_withdraw_feess  sE     	11&9  $}}XzB//0DLLr9  c                    U R                  U5      n[        S[        U5      5       HU  nX   nU R                  US5      nU R	                  U5      nU R                  US5      nUS S.US'   US S.S S S.S.US   U'   MW     U$ )Nr   networkru  )ru  r   r   )r   r   rv  )deposit_withdraw_feer^  r_  r`  network_id_to_coderf  )	r5  ru  r  ri  jnetworkEntry	networkIdnetworkCodewithdrawFees	            r7  parse_deposit_withdraw_fee#bitstamp.parse_deposit_withdraw_fee  s    **3/q#c(#A6L((yAI11)<K**<?K"""F: '"&
  "&	/F:{+ $& r9  rH  r  rN  rO  c                    U R                  5         U R                  U5      nUS   U R                  X5      S.nU R                  USS5      n	U	b  XS'   U R	                  US/5      nSn
U R                  U5      nUS:X  aH  US:X  a!  U R                  U R                  X5      5      n
OU R                  U R                  X5      5      n
OUS:X  aH  US:X  a!  U R                  U R                  X5      5      n
O|U R                  U R                  X5      5      n
O[U R                  X5      US	'   US:X  a!  U R                  U R                  X5      5      n
O U R                  U R                  X5      5      n
U R                  X5      nX,S
'   U$ )a  
create a trade order

https://www.bitstamp.net/api/#tag/Orders/operation/OpenInstantBuyOrder
https://www.bitstamp.net/api/#tag/Orders/operation/OpenMarketBuyOrder
https://www.bitstamp.net/api/#tag/Orders/operation/OpenLimitBuyOrder
https://www.bitstamp.net/api/#tag/Orders/operation/OpenInstantSellOrder
https://www.bitstamp.net/api/#tag/Orders/operation/OpenMarketSellOrder
https://www.bitstamp.net/api/#tag/Orders/operation/OpenLimitSellOrder

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r0   )r  rN  client_order_idclientOrderIdNrk  BuyinstantrO  rH  )r  rk  amount_to_precisionr  r  
capitalizeprivatePostBuyMarketPairr  privatePostSellMarketPairprivatePostBuyInstantPairprivatePostSellInstantPairprice_to_precisionprivatePostBuyPairprivatePostSellPairparse_order)r5  rA  rH  r  rN  rO  rg  rk  r  rS  rh  capitalizedSider  s                r7  create_orderbitstamp.create_order  su   & 	V$4L..v>
 **63DoV$)6%&YYv'89F//$/8%'88W9UV99$++g:VWY%'99$++g:VW::4;;w;WX#66vEGG%'224;;w3OP33DKK4PQ  2fr9  r0   c                     U R                  5         SU0nU R                  U R                  XC5      5      nU R                  U5      $ )aU  
cancels an open order

https://www.bitstamp.net/api/#tag/Orders/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>`
r0   )r  privatePostCancelOrderr  r_  )r5  r0   rA  rg  r  rh  s         r7  cancel_orderbitstamp.cancel_order  sJ     	"
 ..t{{7/KL ))r9  c                 .   U R                  5         Sn0 nSnUb:  U R                  U5      nUS   US'   U R                  U R                  XB5      5      nO U R	                  U R                  XB5      5      nU R                  US5      nU R                  U5      $ )a  
cancel all open orders

https://www.bitstamp.net/api/#tag/Orders/operation/CancelAllOrders
https://www.bitstamp.net/api/#tag/Orders/operation/CancelOrdersForMarket

: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>`
Nr0   r  canceled)r  rk  privatePostCancelAllOrdersPairr  privatePostCancelAllOrdersr  parse_orders)r5  rA  rg  rk  r  rh  rh  s          r7  cancel_all_ordersbitstamp.cancel_all_orders  s     	[[(F$TlGFO::4;;w;WXH66t{{77STH  >>(J7  **r9  rn  c                 4    SSSSS.nU R                  X!U5      $ )Nr  closedrh  )zIn QueueOpenFinishedCanceledr`  r5  rn  statusess      r7  parse_order_statusbitstamp.parse_order_status  s*     "	
 &99r9  c                    U R                  5         U R                  USS5      n0 nUb  XES'   U R                  USS/5      nOXS'   U R                  U R	                  XS5      5      nU R                  U R                  US5      5      $ )NrR  rS  r0   rn  )r  safe_value_2r  privatePostOrderStatusr  rv  r`  )r5  r0   rA  rg  rS  r  rh  s          r7  fetch_order_statusbitstamp.fetch_order_status!  s    ))&2C_U$)6%&YYv(9?'KLFDM..t{{7/KL&&t'7'7('KLLr9  c                    U R                  5         SnUb  U R                  U5      nU R                  USS5      n0 nUb  XVS'   U R                  USS/5      nOXS'   U R	                  U R                  Xc5      5      nU R                  Xt5      $ )aw  
fetches information on an order made by the user

https://www.bitstamp.net/api/#tag/Orders/operation/GetOrderStatus

:param str id: the order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NrR  rS  r0   )r  rk  ry  r  rz  r  r_  )r5  r0   rA  rg  rk  rS  r  rh  s           r7  fetch_orderbitstamp.fetch_order-  s     	[[(F))&2C_U$)6%&YYv(9?'KLFDM..t{{7/KL& 11r9  c                    U R                  5         0 nSnSnUb  U R                  U5      nUS   US'   US-  nUb  X5S'   [        X5      " U R                  XT5      5      nU R	                  USS5      n	U R                  XX#5      $ )	a3  
fetch all trades made by the user

https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactions
https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactionsForMarket

: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>`
privatePostUserTransactionsNr0   r  Pairr%  rH  2)r  rk  getattrr  	filter_byr  )
r5  rA  r  r%  rg  r  methodrk  rh  ri  s
             r7  fetch_my_tradesbitstamp.fetch_my_tradesX  s     	.[[(F$TlGFOfF$G4(W)EF&#6  >>r9  rt  c                     U R                  5         0 nUb  X5S'   U R                  U R                  XT5      5      nSnUb  U R                  U5      nU R	                  USSS/S5      nU R                  XX#5      $ )aC  
fetch history of deposits and withdrawals

https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactions

:param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
:param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
:param int [limit]: max number of deposit/withdrawals to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr%  rH  r   r  F)r  r  r  r  filter_by_arrayparse_transactions)	r5  rt  r  r%  rg  r  rh  r  transactionss	            r7  fetch_deposits_withdrawals#bitstamp.fetch_deposits_withdrawalss  s     	$G33DKK4PQ6 }}T*H++HfsCj%P&&|uLLr9  c                     U R                  5         0 nUb  U R                  5       U-
  US'   OSUS'   U R                  U R                  XT5      5      nU R	                  USX#5      $ )a  
fetch all withdrawals made from an account

https://www.bitstamp.net/api/#tag/Withdrawals/operation/GetWithdrawalRequests

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch withdrawals for
:param int [limit]: the maximum number of withdrawals structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
N	timedeltai)r  r  privatePostWithdrawalRequestsr  r  )r5  rt  r  r%  rg  r  rh  s          r7  fetch_withdrawalsbitstamp.fetch_withdrawals  sm     	#'#4#4#6#>GK #+GK 55dkk'6RS2 &&xuDDr9  r  r  c                    U R                  U R                  US5      5      nU R                  U5      nU R                  XB5      nU R                  US5      nS nS nSU;   a  U R                  US5      nO8Ub  U R                  XS   U5      nUS   nOUb  Ub  U R                  XU5      nUnUb  [        R
                  " U5      nSn	SU;   a!  U R                  U R                  US5      5      n	S n
SU;   a$  U R                  US5      nUS	:X  a  S
n
OUS:X  a  Sn
OSn
S nU R                  US5      nUb,  UR                  S5      n[        U5      nUS:  a
  US   nUS   nS S S S.nUb  UUS S.n0 SU_SU R                  US5      _SU R                  US5      _SU
_SU_SS _SU R                  U5      _SU	_SU_SU R                  U5      _SU_SS _SU_SU_SS _SU_SS _S S US.E$ )Nr  ru  rN  r0   rt  okrn  rH  r   r   r  
withdrawaladdressz?dt=r   r   )r  rS  rater\  txidtransaction_idr  rG  r  addressFrom	addressTotagtagFromtagToupdated)commentinternalru  )r  r`  r  rc  r*   r  parse_transaction_statusra  r_  r4  r  )r5  r  r  r  r  rt  feeCostr  rN  rn  rH  rawTyper  r  addressPartsnumPartsru  s                    r7  parse_transactionbitstamp.parse_transaction  s   P NN4#3#3K#LM	::;G
&&z<"";6{"%%k8<F!%%kD>6JF"6*KZ%;%%kvFFK''/F{"2243C3CKQY3Z[F[ &&{F;G#~ C#  D"";	:"==0L<(H!|&q/"1o

 'C

K
$"";5
 D$$[2BC
 D	

 
 t
 d''/
 f
 
 Y/
 w
 4
 
 3
 t
  S!
" t#
$ )
 	
r9  c                 6    SSSSSS.nU R                  X!U5      $ )Npendingr  rh  failed)r   r  r  34rs  rt  s      r7  r  !bitstamp.parse_transaction_statusC  s/     
 &99r9  r  c                 x   U R                  US5      nU R                  US5      nU R                  US5      nUb
  US:X  a  SOSnU R                  U R                  US5      5      nU R                  US5      nU R                  XrS	5      nU R	                  U R                  US
5      5      n	U R                  US5      n
U R                  US/ 5      nU R                  US5      nU R                  0 SU_SU_SU R                  U5      _SU_SS _S
U	_SU_SS _SS _SS _SU_SU_SS _SS _SU
_SS _SS _US US S.EU5      $ )Nr0   rR  rH  r  r  r  r  r$  r;  rn  rN  r  rO  rS  r  lastTradeTimestamprA  r  postOnlyr  r  rS  filled	remaining)tradesru  r\  r  )r`  r  r  r  rv  r  
safe_orderr  )r5  r  rk  r0   rS  r  r  r?  rA  rn  rN  r  rO  s                r7  r_  bitstamp.parse_orderQ  s   d eT*((0ABv."ck6DNN4#3#3E:#FG	))%A!!(C8(()9)9%)JK!!%2unbA  0  
" 
] 
 Y/ 
 	 

 !$ 
 f 
 f 
 D 
 4 
  
 D 
 U 
 D 
 D 
 f 
  d! 
" # 
$ #+ 
, - 	r9  c                 4    SSSSS.nU R                  X!U5      $ )Nr  r  r   )r   r  r  14rs  )r5  rH  typess      r7  parse_ledger_entry_type bitstamp.parse_ledger_entry_type  s*    	
 T22r9  itemc                    U R                  U R                  US5      5      nUS:X  a  U R                  U5      nS n[        UR	                  5       5      n[        S[        U5      5       HA  nXg   R                  S5      S:  d  M  Xg   R                  SS5      nU R                  X5      nMC     Uc  U R                  U5      nUS   S:X  a  SOS	n	U R                  UUS
   US   US   U	S US   S UUS   US   S S SUS   S.U5      $ U R                  X5      n
S n	SU;   a3  U R                  US5      n[        R                  " US5      (       a  SOS	n	OcSU
;   a]  U
S   bW  U R                  U
S5      nU R                  U5      nU R                  XS
   5      n[        R                  " US5      (       a  SOS	n	U R                  UU
S
   U
S   U
S   U	S U
S   S UU
S   U
S   S S U
S   U
S   S.U5      $ )NrH  r  r   r@   r  r  inoutr0   r  r  r  rB  rN  r  ru  )r\  r0   r  r  	directionr  referenceIdreferenceAccountrH  r  rN  beforeafterrn  ru  r   r  r  rn  )r  r`  r  r  r  r^  r_  r  replacer  r  safe_ledger_entryr  r*   	string_gtr  )r5  r  r  rH  parsedTraderk  r  rj  r?  r  parsedTransactionrN  r  s                r7  parse_ledger_entrybitstamp.parse_ledger_entry  sL   6 ++D,<,<T6,JK7?**40KF		$D1c$i(7<<$)#wsB7H!--h?F ) ~33D9!,V!4!=EI))!$'(5'
3&*73$("6N%h/"5)+  ! $ !% 6 6t FI4))$9$+$5$5fc$B$BD	 117H7T7`#//0A:N==6))$?$+$5$5fc$B$BD	))'-.{;-j9&08$(-j9+H5+H5(/+  ! r9  c                     U R                  5         0 nUb  X5S'   U R                  U R                  XT5      5      nSnUb  U R                  U5      nU R	                  XgX#5      $ )a0  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactions

:param str [code]: unified currency code, default is None
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
:param int [limit]: max number of ledger entries to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
Nr%  )r  r  r  r  parse_ledger)r5  rt  r  r%  rg  r  rh  r  s           r7  fetch_ledgerbitstamp.fetch_ledger  sh     	$G33DKK4PQ}}T*H  UBBr9  c           	          SnU R                  5         Ub  U R                  U5      nU R                  U5      nU R                  XeX#SSS.5      $ )a   
fetch all unfilled currently open orders

https://www.bitstamp.net/api/#tag/Orders/operation/GetAllOpenOrders
https://www.bitstamp.net/api/#tag/Orders/operation/GetOpenOrdersForMarket

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch open orders for
:param int [limit]: the maximum number of  open orders structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r%  )rn  rH  )r  rk  privatePostOpenOrdersAllrk  )r5  rA  r  r%  rg  rk  rh  s          r7  fetch_open_ordersbitstamp.fetch_open_orders  s^     [[(F008   5B
  	r9  c                 "    UR                  5       $ )zm
@ignore
       :param str code: Unified currency code
       :returns str: lowercase version of code
       )rb  r5  rt  s     r7  get_currency_namebitstamp.get_currency_nameB  s     zz|r9  c                 <    US:H  =(       d    US:H  =(       d    US:H  $ )Nr   r   GBP r  s     r7  rw  bitstamp.is_fiatJ  s    u}>>>r9  c                 X   U R                  U5      (       a  [        U R                  S-   U-   S-   5      eU R                  U5      nSU R	                  U5      -   S-   n[        X5      " U5      nU R                  US5      nU R                  USS5      nU R                  U5        UUSUUS	.$ )
a`  
fetch the deposit address for a currency associated with self account

https://www.bitstamp.net/api/#tag/Deposits/operation/GetCryptoDepositAddress

: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>`
z  fiat fetchDepositAddress() for z is not supported!privatePostAddressr  memo_iddestination_tagN)r\  r  rG  r  r  )	rw  r%   r0   r  rW  r  r`  r  check_address)r5  rt  rg  r1   r  rh  r  r  s           r7  fetch_deposit_addressbitstamp.fetch_deposit_addressM  s     <<tww)KKdRUiijj%%d+!66B4(0""8Y7  96GH7#
 	
r9  r  r  c                    U R                  XE5      u  pEU R                  5         U R                  U5        SU0nSnSnU R                  U5      (       dN  U R	                  U5      n	SU R                  U	5      -   S-   nUS:X  a  Ub  XFS'   OUS:X  d  US:X  a  Ub  XFS	'   X6S
'   OSnU R                  U5      nX6S'   US   US'   [        X5      " U R                  Xe5      5      n
U R                  X5      $ )a  
make a withdrawal

https://www.bitstamp.net/api/#tag/Withdrawals/operation/RequestFiatWithdrawal
https://www.bitstamp.net/api/#tag/Withdrawals/operation/RequestCryptoWithdrawal

: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>`
rN  Nr  
Withdrawalr   r  r   r   r  r  privatePostWithdrawalOpenibanr0   account_currency)
handle_withdraw_tag_and_paramsr  r  rw  r  rW  r  r  r  r  )r5  rt  rN  r  r  rg  r  r  r  r1   rh  s              r7  r   bitstamp.withdrawg  s	     99#F7#f
 ||D!!))$/D"T__T%::\IFu}?14-.$&.?),I&!(I0F}}T*H%FO*24.G&'4(W)EF%%h99r9  fromAccount	toAccountc                    U R                  5         U R                  U5      nU R                  U R                  X5      5      US   R	                  5       S.nSnUS:X  a%  XGS'   U R                  U R                  Xu5      5      nOCUS:X  a%  X7S'   U R                  U R                  Xu5      5      nO[        U R                  S-   5      eU R                  X5      n	X)S'   X9S'   XIS	'   U	$ )
a1  
transfer currency internally between wallets on the same account

https://www.bitstamp.net/api/#tag/Sub-account/operation/TransferFromMainToSub
https://www.bitstamp.net/api/#tag/Sub-account/operation/TransferFromSubToMain

:param str code: unified currency code
:param float amount: amount to transfer
:param str fromAccount: account to transfer from
:param str toAccount: account to transfer to
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
r0   )rN  r  Nmain
subAccountz) transfer() only supports from or to mainrN  r  r  )r  r  parse_to_numericcurrency_to_precisionupperprivatePostTransferFromMainr  privatePostTransferToMainr    r0   parse_transfer)
r5  rt  rN  r  r  rg  r  r  rh  r   s
             r7  r   bitstamp.transfer  s     	==&++D,F,Ft,TU ,,.
 & $-L!77G8TUH& $/L!55dkk'6RSHTWW'RRSS &&x:#"- )r9  c                 b    U R                  US5      nUS S S US   S S S U R                  U5      S.	$ )Nrn  rt  )	r\  r0   r  r  r  rN  r  r  rn  )r`  parse_transfer_status)r5  r   r  rn  s       r7  r  bitstamp.parse_transfer  sK     !!(H5 (008

 
	
r9  c                 0    SSS.nU R                  X!U5      $ )Nr  r  )r  errorrs  rt  s      r7  r  bitstamp.parse_transfer_status  s$    
 &99r9  c                 "    U R                  5       $ N)r  )r5  s    r7  r  bitstamp.nonce  s      ""r9  r   GETc                 *   U R                   S   U   S-   nXpR                  S-   -  nXpR                  X5      -  nU R                  X@R	                  U5      5      nUS:X  a   U(       a  USU R                  U5      -   -  nGOU R                  5         SU R                  -   n	U R                  5       n
[        U R                  5       5      nSnSnU	U
UUS.nUS	:X  a8  U(       a  U R                  U5      nS
nXS'   OU R                  SS05      nS
nXS'   U(       a  UOSnX-   UR                  SS5      -   U-   U
-   U-   U-   U-   nU R                  U R                  U5      U R                  U R                  5      [        R                   5      nUUS'   XsXeS.$ )Nr   r;  r   ?z	BITSTAMP r8   r  )zX-AuthzX-Auth-NoncezX-Auth-TimestampzX-Auth-VersionPOSTz!application/x-www-form-urlencodedzContent-Typefoobarzhttps://zX-Auth-Signature)urlr  bodyheaders)r   r7   implode_paramsr  extract_params	urlencodecheck_required_credentialsr   uuidstrr  r  hmacencoder   hashlibsha256)r5  pathr   r  rg  r
  r	  r  queryxAuth
xAuthNoncexAuthTimestampxAuthVersioncontentTypeauthBodyauth	signatures                    r7  signbitstamp.sign  s   iis#c)||c!!""400		&"5"5d";<(?sT^^E222++-$++-EJ !2!2!45NLK *$2".	G >>%0D"EK.9N+  >>5%.9D"EK.9N+#tH>CKK
B$??+MPZZ]kknzz  ~F  FD		$++d"3T[[5Mw~~^I*3G&'dOOr9  httpCodereasonr  r  r
  r	  c
                    Uc  g U R                  US5      n
U R                  US5      nU
S:X  d  UGb  / n[        U[        5      (       a  UR	                  U5        OUb  [        UR                  5       5      n[        S[        U5      5       HR  nX   nU R                  X5      n[        U[
        5      (       a  U R                  UU5      nMA  UR	                  U5        MT     U R                  US0 5      n[        U[        5      (       a  UR	                  U5        OCU R                  US/ 5      n[        S[        U5      5       H  nUR	                  UU   5        M     U R                  US5      nUS:X  a  [        U R                  S-   5      eU R                  S	-   U-   n[        S[        U5      5       HG  nX   nU R                  U R                  S
   UU5        U R                  U R                  S   UU5        MI     [        U5      eg )Nrn  r  r   r"  __all__rt  API0005zL invalid signature, use the uid for the main account if you have subaccountsr=  r  r  )r`  r  
isinstancer  rd  r  r  r^  r_  array_concatr   r0   throw_exactly_matched_exceptionr  throw_broadly_matched_exceptionr   )r5  r!  r"  r  r  r
  r	  rh  requestHeadersrequestBodyrn  r  errorsr  rj  keyr  reasonInnerallrt  feedbacks                        r7  handle_errorsbitstamp.handle_errors  s    !!(H5'2g5#4F%%%e$"EJJL)q#d),A'C OOE7E!%..!%!2!265!Ae, - //(HbAK+s++k*ook9bAq#c(+AMM#a&) ,##Hf5Dy )$''  5C  +C  D  Dww}t+H1c&k*	44T__W5MuV^_44T__W5MuV^_ +  ))r9  r  r   )U__name__
__module____qualname____firstlineno__r   r2  r   r   ro  r~  r]  r   r  r  r
   r   r  dictr   r  r  r   r   r  r  r  r   r  r  r  r   r  r   r  r   r   r+  r(  r0  r   r3  r9  r8  rD  rO  r   r   floatr   ra  r   re  rl  rv  r{  r~  r  r   r  r  r   r  r  r   r_  r  r   r  r  r  r  rw  r	   r  r   r   r   r  r  r  r  r  r1  __static_attributes____classcell__)r6  s   @r7  r,   r,      s   # B $& V$v, Vp$
L /1 I ') ,Z ,\ :>b %s %3 %Y %N-4 - -6 -^ 02 13 1f 1B 04B 5W 57 5< D.t tv t tl 6:UW %A3 %As %A# %A\`af\g %AN
 
4 
( 9=4^bkm 2H# 2H# 2HS 2HX[ 2Hrvw{r| 2Hh) )& $& ,( ,0 57  :  :;N  :D

T 

6 

EX 

 )+ 1{ 16 7;2 5G 52" 15R M2. gksu 13 1i 1y 1RW 1`c 1f 37r *s *C *6 /32 %+ %+N: : 9=R 
MS 
M# 
M 26b )2c )23 )2V -1tRV_a ?c ? ?C ?6 6:[_hj /Ms /M# /MUX /Most  pA /Mb -1tRV_a +Ec +E +EC +Efjkvfw +EZp
T p
X p
Q\ p
d:s :U Uv U Un3Ut Ux U; Un (,$TZ\ C CC Cs Caefqar C, /3TXac " "3 "c "hlmrhs "H? 79 
# 
^ 
4 KOWY (:S (:% (:# (:C (:^i (:T [] $S $% $c $c $an $L
":C :C :# &eBSW &PP'c '3 'S '# 'X\ 'dg ' 'r9  r,   )1ccxt.base.exchanger   ccxt.abstract.bitstampr   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   ccxt.base.decimal_to_precisionr)   ccxt.base.preciser*   r,   r  r9  r7  <module>rB     st    ( .  {  {  {  {  {  {  * 0 - - ' . + ) * ) 1 * ) 4 %E$x E$r9  