
    E#i                         S SK Jr  S SKJr  S SK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  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      r!g)    )Exchange)ImplicitAPIN)AnyBalancesBoolIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTrade)List)ExchangeError)
BadRequest)InsufficientFunds)InvalidOrder)	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\4S jr	S\
4S jr0 4S\
4S jjrS0 4S	\S
\S\4S jjrS6S\S\S\4S jjrS0 4S\S\4S jjr0 4S	\S\4S jjrS6S\S\S\4S jjrSS0 4S	\S\S
\S\\   4S jjrS6S\S\4S jjrSSS0 4S	\S\S\S
\S\\   4
S jjrS7S\S
\S\4S jjrS0 4S	\S\ S\!S\"S\#4
S  jjr$S0 4S!\S	\%4S" jjr&SSS0 4S	\%S\S
\S\\'   4S# jjr(SSS0 4S	\%S\S
\S\\'   4S$ jjr)S%\%4S& jr*S6S'\S\S\'4S( jjr+SSS0 4S	\%S\S
\4S) jjr,S* r-S+S,0 SS4S- jr.S.\/S/\S0\S1\S2\S3\4S4 jr0S5r1U =r2$ )8btcturk   returnc                   > U R                  [        [        U ]  5       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_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_S&S_S'S_S(S_E0 S)S_S*S_S+S_S,S_S-S_S.S_S/S_S0S_S1S_S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_E0 S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_SBS_SCS_SDS_SES_SFS_SGS_SHS_SIS_SJS_E0 SKS_SLS_SMS_SNS_SOS_SPS_SQS_SRS_SSS_STS_SUS_SVS_SWS_SXS_SYS_SZS_S[S_ESSSSSS\.ES]S^S_S`SaSbScSdSe.SfSgShSiSj.SkSlSm.SnS]SoS]S]S]Sp.0S]S]S]S]Sq.S]S]S]S]Sr.SsS]0St.SnS]S]Su.0Sj.SSSS SSSS SSSSSv.SSSSSSSSw.S SSSxS_SSy.S SS SSSSz.SS{SxS_SSSS|.S S}S 0S~.	S S S.S S S.S.SU R	                  S5      U R	                  S5      S.0S[
        [        [        S.0[        S.5      $ )Nr   BTCTurkTRd   FCORSTspotmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercloseAllPositionsclosePositioncreateDepositAddresscreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChainfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickersfetchTradesfetchVolatilityHistoryreduceMarginrepayCrossMarginrepayIsolatedMarginrepayMargin)setLeverage	setMarginsetMarginModesetPositionModews         <      z1 dz1 wz1 y)1m15m30m1h4h1d1w1yzOhttps://github.com/user-attachments/assets/10e0a238-9f60-4b06-9dda-edfc7602f1d6zhttps://api.btcturk.com/api/v2zhttps://api.btcturk.com/api/v1z https://graph-api.btcturk.com/v1)publicprivategraphzhttps://www.btcturk.comz,https://github.com/BTCTrader/broker-api-docs)logoapiwwwdocgetg?)	orderbooktickertradesohlczserver/exchangeinfo)zusers/balances
openOrders	allOrderszusers/transactions/trade)zusers/transactions/cryptozusers/transactions/fiatorderr-   r   )r   postdelete)ohlcszklines/history)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventiontrailingicebergi )r   limitdaysBack	untilDayssymbolRequired)r   r   triggerr   r     )r   r   r   r   r   r   r   r   )	sandboxr1   createOrdersr]   
fetchOrderrb   rf   fetchClosedOrdersr^   )linearinverse)r$   r&   r'   tradingz0.0005z0.0009)makertakerexact)FAILED_ORDER_WITH_OPEN_ORDERSFAILED_LIMIT_ORDERFAILED_MARKET_ORDER)idname	countries	rateLimitprohas
timeframesurlsr   featuresfees
exceptionsprecisionMode)deep_extendsuperr   describeparse_numberr   r   r   )self	__class__s    T/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/btcturk.pyr   btcturk.describe   s   gt = ?[[[ %[ 	[
 %[ %[ U[ $U[ '[ [ t[ $U[  [ '[ t[  7![" 9%#[$ &u%[& ('[( )[* &u+[, "5-[. +E/[0 )%1[2 #E3[4 ,U5[6 '7[8 (9[: "5;[< &u=[> (?[@ 1%A[B &uC[D 'E[F (G[H #EI[J *5K[L $UM[N uO[P "5Q[R *5S[T +EU[V )%W[X  Y[Z !%[[\ %e][^ $U_[` &ua[b -ec[d /e[f "5g[h #Ei[j +Ek[l m[n !%o[p "5q[r &us[t +Eu[v  w[x dy[z $U{[| +E}[~ %e[@ "4A[B uC[D #EE[F !$G[H tI[J  K[L 'M[N $UO[P !%Q[R *5S[T (U[V %eW[X )%Y[Z )%[[\ t][^ _[` ta[b )%c[d e[f #Eg[h &ui[j uk[l  %"!&#(u[z 	 j>??
 1E	 %&"%"# !/0 +,&'%&45	 6734!"'(	  $ !"*+7!H  %&+(,,0,1).+06:#(#("'#(	( #($)27+0/4$)#()$, %)&+!$$*%'*.& #'&+!%#($)*.( ',!%$*%'#($)*.$ *.#e5n ##
 ##w?B !..x8!..x8 5F*6+7 'KfB
 f f	    c                    #    U R                  U5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      nU R                  U5      $  N;7f)z
retrieves data on all markets for btcturk

https://docs.btcturk.com/public-endpoints/exchange-info

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
Ndatasymbols)publicGetServerExchangeinfo	safe_dict	safe_listparse_markets)r   paramsresponser   marketss        r   fetch_marketsbtcturk.fetch_markets   sY      99&AAX ~~h3..y"5!!'**] Bs   AA<Ac                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      nU R                  US/ 5      nS nS n	S n
S nS n[        S[	        U5      5       H{  nX}   nU R                  US5      nUS:X  d  M!  U R                  US5      nU R                  US	5      n	U R                  US
5      n
U R                  US5      nU R                  US5      nM}     U R                  US5      n0 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 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&.U
US&.UU	S&.US S&.S'.S US(.
E$ ))Nr   	numeratordenominatorfiltersr   
filterTypePRICE_FILTERminPricemaxPrice	minAmount	maxAmountminExchangeValuestatusr   symbol/basequotesettlebaseIdquoteIdsettleIdtyper$   Tr%   Fr&   r'   r(   activeTRADINGcontractr   numeratorScaledenominatorScale)amountprice)minmax)r   r   r   cost)
r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)safe_stringsafe_currency_coder   rangelensafe_numberr   parse_precision)r   entryr   r   r   r   r   r   r   r   r   r   minCostjfilterr   r   s                    r   parse_marketbtcturk.parse_market8  s   eV,!!%5""5-8&&v.''0..	26		q#g,'AZF))&,?J^+++FJ?++FJ? ,,V[A	 ,,V[A	**63EF ( !!%20
"0
dSj5(0
 D0
 U	0

 d0
 f0
 w0
 0
 F0
 D0
 e0
 E0
 e0
 e0
 v*0
  !0
" d#0
$  "++D,@,@AQAQRWYiAj,kl**4+?+?@P@PQVXj@k+lm  
 %$
 $#
 #$ _0
 0	
r   c                    U R                  US/ 5      nUS S S.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	'   XU'   M     U R                  U5      $ )
Nr   )r
  	timestampdatetimer   assetbalancetotalfreelockedused)r   r  r  r  r  accountsafe_balance)	r   r   r   resultir  
currencyIdcoder   s	            r   parse_balancebtcturk.parse_balance  s    ~~h3

 q#d)$AGE))%9J**:6DllnG#//yAGG"..uf=GFO"..uh?GFO"4L %   ((r   c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  U5      $  N. N7f)a>  
query for balance and get the amount of funds available for trading or funds locked in orders

https://docs.btcturk.com/private-endpoints/account-balance

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
N)load_marketsprivateGetUsersBalancesr&  )r   r   r   s      r   fetch_balancebtcturk.fetch_balance  sG      !!!55f==" !!(++% 	"=s   A	AA	AA	A	Nr   r   c           	      >  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XS5      5      I Sh  vN nU R	                  US0 5      nU R                  US5      nU R                  XtS   USSS	S
5      $  N ND7f)a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://docs.btcturk.com/public-endpoints/orderbook

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
N
pairSymbolr   r   r  r   bidsasksr   r}   )r)  marketpublicGetOrderbookextendr   safe_integerparse_order_book)	r   r   r   r   r1  requestr   r   r  s	            r   fetch_order_bookbtcturk.fetch_order_book  s      !!!V$&,
 00W1MNN ~~h3%%dK8	$$T(+;YPVXY[\]]' 	"
 Os"   BB?BBABBr   r1  c                 n   U R                  US5      nU R                  X25      nUS   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 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S _SU R                  US5      _SU_SU_SS _SU R                  US5      _SU R                  US5      _SU R                  US5      _U R                  US5      S US.EU5      $ )Npairr   r  lastr  highlowbid	bidVolumeask	askVolumevwapopenclosepreviousClosechangedaily
percentagedailyPercentaveragevolume)
baseVolumequoteVolumer
  )r  safe_marketr4  safe_tickeriso8601)r   r   r1  marketIdr   r  r;  s          r   parse_tickerbtcturk.parse_ticker  s   * ##FF3!!(3!%%fk:	/ !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 !
 4##FE2!
 !
 D!
 D$$VV4!
 T!
 D!
 T!
 d&&vw7!
  $**6>B!!
" t''	:#!
$ **68<)!
* + 	r   r   c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US5      nU R                  XA5      $  N@ N)7f)a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://docs.btcturk.com/public-endpoints/ticker

: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)  publicGetTickerr   parse_tickers)r   r   r   r   tickerss        r   fetch_tickersbtcturk.fetch_tickers   sU      !!!--f55..62!!'33 	"5s   AAAA(AAc                    #    U R                  5       I Sh  vN   U R                  U/U5      I Sh  vN nU R                  X15      $  N0 N7f)a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://docs.btcturk.com/public-endpoints/ticker

:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
N)r)  rX  
safe_value)r   r   r   rW  s       r   fetch_tickerbtcturk.fetch_ticker  sG      !!!**F8V<<w// 	"<s   AAAA	A	Atradec                 N   U R                  USS5      nU R                  USS5      nU R                  US5      nU R                  US5      n[        R                  " U R                  US5      5      nU R                  US5      nU R                  X5      n	U R                  US	S
5      n
S nU R                  US5      nUb:  U R                  US5      n[        R                  " U5      U R                  U5      S.nU R                  UUUUU R                  U5      U	S U
S UUS US.U5      $ )Ndater  tidr   orderIdr   r   r:  side	orderTypefeedenominatorSymbol)r  currency)r
  r   r   r  r  r   r   rc  takerOrMakerr   r   r  re  )	safe_integer_2safe_string_2r  r   
string_abssafe_symbolr  
safe_traderP  )r   r^  r1  r  r   r   priceStringamountStringrQ  r   rc  re  feeAmountStringfeeCurrencys                 r   parse_tradebtcturk.parse_trade  sC   : ''v{C	ud3  	2&&ug6))$*:*:5(*KL##E62!!(3!!%=**5%8&**52EFK**?; 33K@C "Y/  " 
  	r   sincec                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X6S'   U R                  U R                  Xd5      5      I Sh  vN nU R	                  US5      nU R                  XX#5      $  No N*7f)a  
get the list of most recent trades for a particular symbol

https://docs.btcturk.com/public-endpoints/trades

: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>`
Nr.  r   r;  r   )r)  r1  publicGetTradesr3  r   parse_trades	r   r   rt  r   r   r1  r6  r   r   s	            r   fetch_tradesbtcturk.fetch_tradesZ  s      !!!V$ &,
 #FO--dkk'.JKK$ ~~h/  u<<7 	" Ls"   B
BAB
B)B
B
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  rC  r<  r=  rD  rK  )safe_timestampr  )r   ohlcvr1  s      r   parse_ohlcvbtcturk.parse_ohlcv  sn     {3UF+UF+UE*UG,UH-
 	
r   r   	timeframec                   #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  U R                  X"5      S.nU R	                  USU R                  5       5      nU R                  US-  5      US'   Ub  U R                  US-  5      US'   OUc  SnUb  [        US	5      nUS
:X  a  [        U R                  S-   5      eU R                  U5      n	XS-
  -  n
Ub*  U R                  US-  5      U
-   n[        US   U5      US'   OU R                  S5      U
-
  US'   U R                  U R                  Xu5      5      I Sh  vN nU R                  XX#U5      $  GNT N7f)a  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://docs.btcturk.com/public-endpoints/get-kline-data

:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: the maximum amount of candles to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest candle to fetch
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nr   )r   
resolutionuntilr   tofromr"   i*  r   zF fetchOHLCV() does not accept a limit parameter when timeframe == "1y"r}   g        )r)  r1  r[  r   r4  millisecondsparse_to_intr   r   r   parse_timeframegraphGetKlinesHistoryr3  parse_ohlcvs)r   r   r  rt  r   r   r1  r6  r  secondslimitSecondsr  r   s                r   fetch_ohlcvbtcturk.fetch_ohlcv  s}     !!!V$Tl//$//9P
 !!&'43D3D3FG))54<9"//=GFO]Eu%ED  +s!stt**95G"ai0L &&ut|4|C #GDM2 6"&"3"3H"="L33DKK4PQQH   9UKKw 	". Rs"   E/E*D;E/E-E/-E/tailc           
      t   / nU R                  US/ 5      nU R                  US/ 5      n	U R                  US/ 5      n
U R                  US/ 5      nU R                  US/ 5      nU R                  US/ 5      n[        S[        U5      5       H  nU R                  X5      U R	                  X5      U R	                  X5      U R	                  X5      U R	                  X5      U R	                  X5      S.nUR                  U R                  X5      5        M     U R                  US5      nU R                  UXESU5      $ )	Ntholcvr   )r  r<  rC  r=  rD  rK  )	r   r  r  r4  r  appendr~  sort_byfilter_by_since_limit)r   ohlcvsr1  r  rt  r   r  resultsr  r<  rC  r=  rD  rK  r#  r}  sorteds                    r   r  btcturk.parse_ohlcvs  s%   NN633	~~fc2.~~fc2.nnVS"-vsB/R0q#i.)A!..y<((1((1''/))%3**65E NN4++E:; * gq)))&%4HHr   r   rc  r   r   c                   #    U R                  5       I Sh  vN   U R                  U5      nUUUS   U R                  X5      S.nUS:w  a  U R                  X5      US'   SU;   a	  US   US'   OSU;  a  U R	                  5       US'   U R                  U R                  X5      5      I Sh  vN n	U R                  U	S5      n
U R                  X5      $  N N)7f)	aQ  
create a trade order

https://docs.btcturk.com/private-endpoints/submit-order

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   )rd  orderMethodr.  quantityr1  r   clientOrderIdnewClientOrderIdr   )	r)  r1  amount_to_precisionprice_to_precisionuuidprivatePostOrderr3  r   parse_order)r   r   r   rc  r   r   r   r1  r6  r   r   s              r   create_orderbtcturk.create_order  s      !!!V$ ,00@	
 8#66vEGGf$*0*AG&'$.*.))+G&'..t{{7/KLL~~h/--! 	" Ms"   CCBC*C+(CCr   c                    #    SU0nU R                  U R                  XC5      5      I Sh  vN nU R                  SU05      $  N7f)a=  
cancels an open order

https://docs.btcturk.com/private-endpoints/cancel-order

:param str id: order id
:param str symbol: not used by btcturk cancelOrder()
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r   Nr
  )privateDeleteOrderr3  
safe_order)r   r   r   r   r6  r   s         r   cancel_orderbtcturk.cancel_order  sT      "
 00W1MNN H 
  	 Os   (AAAc                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   U R                  U R                  XT5      5      I Sh  vN nU R	                  US0 5      nU R                  US/ 5      n	U R                  US/ 5      n
U R                  U R                  X5      XbU5      $  N Na7f)a  
fetch all unfilled currently open orders

https://docs.btcturk.com/private-endpoints/open-orders

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch open orders for
:param int [limit]: the maximum number of  open orders structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr   r.  r   r/  r0  )r)  r1  privateGetOpenOrdersr3  r   r   parse_ordersarray_concat)r   r   rt  r   r   r6  r1  r   r   r/  r0  s              r   fetch_open_ordersbtcturk.fetch_open_orders1  s      !!![[(F$*4LGL!224;;w3OPP~~h3~~dFB/~~dFB/  !2!24!>uUU 	" Qs#   CB>ACC A C Cc                 h  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X6S'   Ub%  [        [        R                  " US-  5      5      US'   U R                  U R                  Xd5      5      I Sh  vN nU R                  US5      nU R                  XX#5      $  N N*7f)a  
fetches information on multiple orders made by the user

https://docs.btcturk.com/private-endpoints/all-orders

:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr.  r   r;  r   	startTimer   )	r)  r1  intmathfloorprivateGetAllOrdersr3  r   r  rx  s	            r   fetch_ordersbtcturk.fetch_ordersI  s      !!!V$&,
 #FO#&tzz%$,'?#@GK 11$++g2NOO* ~~h/  u<<A 	" Ps"   B2B.A.B2B0)B20B2r   c                 4    SSSSS.nU R                  X!U5      $ )NrC  canceledclosed)	UntouchedPartialCanceledClosed)r  )r   r   statusess      r   parse_order_statusbtcturk.parse_order_statusw  s*    "	
 &99r   r   c                    U R                  US5      nU R                  US5      nU R                  USS5      n[        R                  " U5      nU R                  US5      nU R                  US5      nU R	                  X5      n	U R                  US5      n
U R                  US5      nU R                  US	5      nU R                  US
S5      nU R                  US5      nU R                  U5      nU R                  0 SU_SU_SU_SU_SU_SS _SS _SS _SU_SU
_SU_SU_SU_SU R                  U5      _SU	_SS _U5      $ )Nr   r   r   r  
leftAmountr.  r   methodorderClientId
updateTimer  r   r
  	remainingfilledr  rJ  rc  r  r  r   re  )	r  rj  r   rk  rl  ri  r  r  rP  )r   r   r1  r   r   ro  r   r  rQ  r   rc  r   r  r  	rawStatusr   s                   r   r  btcturk.parse_order  s   D eT*  0))%:F##L1$$UL9	##E<8!!(3v.x0((@''|ZH	$$UH5	((3  
E 
" 
 U 
 f	 

  
 d 
 D 
 t 
 f 
 D 
 D 
 ] 
  
 Y/ 
 f 
  4! 
" # 	r   c                    #    U R                  5       I Sh  vN   SnUb  U R                  U5      nU R                  5       I Sh  vN nU R                  US5      nU R	                  XuX#5      $  NV N*7f)a  
fetch all trades made by the user

https://docs.btcturk.com/private-endpoints/user-transactions

: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>`
Nr   )r)  r1   privateGetUsersTransactionsTrader   rw  )r   r   rt  r   r   r1  r   r   s           r   fetch_my_tradesbtcturk.fetch_my_trades  ss      !!![[(F>>@@, ~~h/  u<<7 	" As!   A1A--A1A/)A1/A1c                 "    U R                  5       $ N)r  )r   s    r   noncebtcturk.nonce  s      ""r   r   GETc                 6   U R                   S:X  a  [        U R                   S-   5      eU R                  S   U   S-   U-   nUS:X  d  US:X  a  U(       a  USU R                  U5      -   -  nOU R	                  U5      nUS:X  a  U R                  5         [        U R                  5       5      nU R                  U R                  5      n	U R                  U-   n
U R                  UU R                  U R                  U
5      U	[        R                  S	5      S
S.nXsXeS.$ )N	btctraderz1 is an abstract base API for BTCExchange, BTCTurkr   r   r  DELETE?r   base64zapplication/json)zX-PCKzX-StampzX-SignaturezContent-Type)urlr  bodyheaders)r   r   r   	urlencodejsoncheck_required_credentialsstrr  base64_to_binarysecretapiKeyhmacencodehashlibsha256)r   pathr   r  r   r  r  r  r  r  auths              r   signbtcturk.sign  s    77k!*] ]^^iis#c)D0eO8!3sT^^F33399V$D)++-

%E**4;;7F;;&D #yyT):FGNNT\] 2	G dOOr   r%  reasonr  r  r  r  c
                    U R                  USS5      n
U R                  US5      nUc  UOUnU R                  U R                  S   XR                  S-   U-   5        U
S:w  a!  U
S:w  a  [	        U R                  S-   U-   5      eg )Nr%  0messager    SUCCESS)r  throw_exactly_matched_exceptionr   r   r   )r   r%  r  r  r  r  r  r   requestHeadersrequestBody	errorCoder  outputs                r   handle_errorsbtcturk.handle_errors  s    $$Xvs;	""8Y7!/,,T__W-EwPWPWZ]P]`fPfg9	#9# 677r    r  )Nr   NNF)3__name__
__module____qualname____firstlineno__r   r   r   r	   r   r  r   r&  r+  r  r   r   r7  dictr   rR  r   r   rX  r\  r   rr  ry  listr~  r  r   r  r   r   floatr
   r  r   r  r   r  r  r  r  r  r  r  r  r  __static_attributes____classcell__)r   s   @r   r   r      s   g# gR *, 7+V 7+rF
V F
P) )$ *, , ,: @DB ^S ^ ^S\ ^@/4 / /6 /b 6:" 47 4 4 68 0 0F 0; ;v ; ;z <@d[] '= '=S '= '=bfglbm '=R
 
4 
( ?CQUdhqs IL IL IL3 IL^a ILx|  ~B  yC ILVIs IZ] Ilp I* mqy{ . .I .Y .X] .fi .@ 9=R S # 4 59tZ^gi Vc V VTW Vnrsxny V0 04$UYbd ,= ,=C ,=s ,=imnsit ,=\: :@ @v @ @D 37TX\eg '=C '=s '=RU '=R# &eBSW P,# s  c TX `c  r   r   )" ccxt.async_support.base.exchanger   ccxt.abstract.btcturkr   r  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r   r  r   r   <module>r     sV    6 -   P  P  P  P  P  * ' . ) 4 %wh wr   