
    ei                         d dl mZ d dlmZ d dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlm Z   G d dee          Z!dS )    )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                   j    e Zd Zdef fdZi fdee         fdZdefdZde	fdZ
i fde	fdZdi fded	edefd
Zd6dededefdZdi fdedefdZi fdedefdZd6dededefdZddi fdeded	edee         fdZd6dedefdZdddi fdededed	edee         f
dZd7ded	edefdZdi fdedede de!d e"f
d!Z#di fd"ede$fd#Z%dddi fde$ded	edee&         fd$Z'dddi fde$ded	edee&         fd%Z(d&e$fd'Z)d6d(edede&fd)Z*dddi fde$ded	efd*Z+d+ Z,d,d-i ddfd.Z-d/e.d0ed1ed2ed3ed4efd5Z/ xZ0S )8btcturkreturnc                 $   |                      t          t          |                                           dddgddi ddddd	dd
dddddddddddddddddddddddddddi ddddddddddddddddd dd!dd"dd#dd$dd%dd&dd'dd(di d)dd*dd+dd,dd-dd.dd/dd0dd1dd2dd3dd4dd5dd6dd7dd8dd9di d:dd;dd<dd=dd>dd?dd@ddAddBddCddDddEddFddGddHddIddJdi dKddLddMddNddOddPddQddRddSddTddUddVddWddXddYddZdd[ddddddd\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdnd]dod]d]d]dpid]d]d]d]dqd]d]d]d]drdsd]idtdnd]d]duidjdddd dddd dddddvddddddddwd dddxd_ddyd dd ddddzdd{dxd_dddd|d d}d id~	d d dd d ddd|                     d          |                     d          didt
          t          t          dit          d          S )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   )	sandboxr0   createOrdersr\   
fetchOrderra   re   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    X/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/btcturk.pyr   zbtcturk.describe   s   gt 4 4 = = ? ?[[[ %[ 	[
 %[ %[ 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 5n ## 
 ## w? ?B !..x88!..x88  5F*6+7  'KfB
 fB
 f f f	    c                    K   |                      |           d{V }|                     |di           }|                     |dg           }|                     |          S )a  
        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_marketszbtcturk.fetch_markets   sn       99&AAAAAAAAX ~~h33..y"55!!'***r   c                 T   |                      |d          }|                      |d          }|                      |d          }|                     |          }|                     |          }|                     |dg           }d }d }	d }
d }d }t          dt	          |                    D ]}||         }|                      |d          }|dk    rn|                     |d          }|                     |d	          }	|                     |d
          }
|                     |d          }|                     |d          }|                      |d          }i d|d|dz   |z   d|d|dd d|d|dd ddddddddddddd|d k    d!dd"d d d d d d d |                     |                     |                      |d#                              |                     |                     |                      |d$                              d%d d d&|
|d&||	d&|d d&d'd |d(
S ))Nr   	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_marketzbtcturk.parse_market8  s)   eV,,!!%55""5-88&&v..''00..	266		q#g,,'' 	G 	GAQZF))&,??J^++++FJ??++FJ?? ,,V[AA	 ,,V[AA	**63EFF!!%2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,@,@AQAQRWYiAjAj,k,kll**4+?+?@P@PQVXj@k@k+l+lmm    
 %$ 
 $# 
 #  $ _0
 0
 0
 0	
r   c                    |                      |dg           }|d d d}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d          |d	<   |||<   |                     |          S )
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_balancezbtcturk.parse_balance  s    ~~h33
 

 q#d))$$ 	# 	#AGE))%99J**:66DllnnG#//yAAGG"..uf==GFO"..uh??GFO"F4LL  (((r   c                    K   |                                   d{V  |                     |           d{V }|                     |          S )ad  
        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_balancezbtcturk.fetch_balance  sg       !!!!!!!!!55f========" !!(+++r   Nr   r   c           	      r  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     |d          }|                     ||d         |ddd	d
          S )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   r+  requestr   r   r  s	            r   fetch_order_bookzbtcturk.fetch_order_book  s       !!!!!!!!!V$$&,
 00Wf1M1MNNNNNNNN ~~h33%%dK88	$$T6(+;YPVXY[\]]]r   r   r+  c                    |                      |d          }|                     ||          }|d         }|                     |d          }|                      |d          }|                     i d|d|d|                     |          d|                      |d          d|                      |d          d|                      |d          d	d d
|                      |d
          dd dd d|                      |d          d|d|dd d|                      |d          d|                      |d          d|                      |d          |                      |d          d |d|          S )Npairr   r  lastr  highlowbid	bidVolumeask	askVolumevwapopenclosepreviousClosechangedaily
percentagedailyPercentaveragevolume)
baseVolumequoteVolumer  )r  safe_marketr.  safe_tickeriso8601)r   r   r+  marketIdr   r  r4  s          r   parse_tickerzbtcturk.parse_ticker  s   * ##FF33!!(F33!%%fk::	// !
f!
!
 Y//!
 D$$VV44	!

 4##FE22!
 4##FE22!
 !
 4##FE22!
 !
 D!
 D$$VV44!
 T!
 D!
 T!
 d&&vw77!
  $**6>BB!!
" t''	::#!
$ **68<<)!
 !
 !
* +  	r   r   c                    K   |                                   d{V  |                     |           d{V }|                     |d          }|                     ||          S )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_tickerszbtcturk.fetch_tickers   sz       !!!!!!!!!--f55555555..622!!'7333r   c                    K   |                                   d{V  |                     |g|           d{V }|                     ||          S )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$  rP  
safe_value)r   r   r   rO  s       r   fetch_tickerzbtcturk.fetch_ticker  si       !!!!!!!!!**F8V<<<<<<<<w///r   tradec                    |                      |dd          }|                     |dd          }|                     |d          }|                     |d          }t          j        |                     |d                    }|                     |d          }|                     ||          }	|                     |d	d
          }
d }|                     |d          }|@|                     |d          }t          j        |          |                     |          d}|                     |||||                     |          |	d |
d ||d |d|          S )Ndater  tidr   orderIdr   r   r3  side	orderTypefeedenominatorSymbol)r   currency)r  r   r   r  r  r   r   rY  takerOrMakerr   r   r   r[  )	safe_integer_2safe_string_2r  r   
string_abssafe_symbolr	  
safe_traderI  )r   rT  r+  r  r   r   priceStringamountStringrJ  r   rY  r[  feeAmountStringfeeCurrencys                 r   parse_tradezbtcturk.parse_trade  sx   : ''v{CC	ud33  	22&&ug66)$*:*:5(*K*KLL##E622!!(F33!!%==**5%88&**52EFFK*?;; 33K@@ C "Y//  " 
  
   	r   sincec                 @  K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     |d          }|                     ||||          S )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   r4  r   )r$  r+  publicGetTradesr-  r   parse_trades	r   r   ri  r   r   r+  r0  r   r   s	            r   fetch_tradeszbtcturk.fetch_tradesZ  s       !!!!!!!!!V$$ &,
 #GFO--dkk'6.J.JKKKKKKKK$ ~~h//  vue<<<r   c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr  r<  r5  r6  r=  rD  )safe_timestampr  )r   ohlcvr+  s      r   parse_ohlcvzbtcturk.parse_ohlcv  s     {33UF++UF++UE**UG,,UH--
 	
r   r   	timeframec                 F  K   |                                   d{V  |                     |          }|d         |                     | j        ||          d}|                     |d|                                           }|                     |dz            |d<   ||                     |dz            |d<   n|d}|t          |d	          }|d
k    rt          | j	        dz             | 
                    |          }	|	|dz
  z  }
|5|                     |dz            |
z   }t          |d         |          |d<   n|                     d          |
z
  |d<   |                     |                     ||                     d{V }|                     |||||          S )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$  r+  rR  r   r.  millisecondsparse_to_intr   r   r   parse_timeframegraphGetKlinesHistoryr-  parse_ohlcvs)r   r   rs  ri  r   r   r+  r0  rv  secondslimitSecondsrw  r   s                r   fetch_ohlcvzbtcturk.fetch_ohlcv  s      !!!!!!!!!V$$Tl//$/9iPP
 
 !!&'43D3D3F3FGG))54<99"//==GFOO]Eu%%ED   +s!sttt**955G"eai0L &&ut|44|C #GDM2 6 6"&"3"3H"="="L33DKK4P4PQQQQQQQQH   69eUKKKr   r   Ftailc           
         g }|                      |dg           }|                      |dg           }	|                      |dg           }
|                      |dg           }|                      |dg           }|                      |dg           }t          dt          |                    D ]}|                     ||          |                     |	|          |                     |
|          |                     ||          |                     ||          |                     ||          d}|                    |                     ||                     |                     |d          }|                     |||d|          S )	Ntholcvr   )r  r5  r<  r6  r=  rD  )	r   r
  r  r.  r  appendrr  sort_byfilter_by_since_limit)r   ohlcvsr+  rs  ri  r   r  resultsr  r5  r<  r6  r=  rD  r  rq  sorteds                    r   r}  zbtcturk.parse_ohlcvs  sx   NN6333	~~fc2..~~fc2..nnVS"--vsB//R00q#i..)) 		< 		<A!..y!<<((q11((q11''Q//))%33**6155 E NN4++E6::;;;;gq))))&%4HHHr   r   rY  r   r   c                   K   |                                   d{V  |                     |          }|||d         |                     ||          d}|dk    r|                     ||          |d<   d|v r|d         |d<   nd|vr|                                 |d<   |                     |                     ||                     d{V }	|                     |	d          }
|                     |
|          S )	a  
        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   )rZ  orderMethodr(  quantityr+  r   clientOrderIdnewClientOrderIdr   )	r$  r+  amount_to_precisionprice_to_precisionuuidprivatePostOrderr-  r   parse_order)r   r   r   rY  r   r   r   r+  r0  r   r   s              r   create_orderzbtcturk.create_order  s(      !!!!!!!!!V$$ ,00@@	
 
 8#66vuEEGGf$$*0*AG&''$..*.))++G&'..t{{7F/K/KLLLLLLLL~~h//f---r   r   c                    K   d|i}|                      |                     ||                     d{V }|                     d|i          S )as  
        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  )privateDeleteOrderr-  
safe_order)r   r   r   r   r0  r   s         r   cancel_orderzbtcturk.cancel_order  sk       "
 00Wf1M1MNNNNNNNN H 
   	r   c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     |di           }|                     |dg           }	|                     |dg           }
|                     |                     |	|
          |||          S )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)  r*  )r$  r+  privateGetOpenOrdersr-  r   r   parse_ordersarray_concat)r   r   ri  r   r   r0  r+  r   r   r)  r*  s              r   fetch_open_orderszbtcturk.fetch_open_orders1  s       !!!!!!!!![[((F$*4LGL!224;;w3O3OPPPPPPPP~~h33~~dFB//~~dFB//  !2!24!>!>uUUUr   c                   K   |                                   d{V  |                     |          }d|d         i}|||d<   |'t          t          j        |dz                      |d<   |                     |                     ||                     d{V }|                     |d          }|                     ||||          S )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   r4  r   	startTimer   )	r$  r+  intmathfloorprivateGetAllOrdersr-  r   r  rm  s	            r   fetch_orderszbtcturk.fetch_ordersI  s       !!!!!!!!!V$$&,
 #GFO#&tz%$,'?'?#@#@GK 11$++gv2N2NOOOOOOOO* ~~h//  vue<<<r   r   c                 >    ddddd}|                      |||          S )Nr<  canceledclosed)	UntouchedPartialCanceledClosed)r  )r   r   statusess      r   parse_order_statuszbtcturk.parse_order_statusw  s4    "	
 
 &&999r   r   c                    |                      |d          }|                      |d          }|                     |dd          }t          j        |          }|                      |d          }|                      |d          }|                     ||          }	|                      |d          }
|                      |d          }|                      |d	          }|                     |d
d          }|                      |d          }|                     |          }|                     i d|d|d|d|d|dd dd dd d|d|
d|d|d|d|                     |          d|	dd |          S )Nr   r   r   r  
leftAmountr(  r   methodorderClientId
updateTimer  r   r  	remainingfilledr   rC  rY  r  r  r   r[  )	r  r`  r   ra  rb  r_  r  r  rI  )r   r   r+  r   r   re  r   r  rJ  r   rY  r   r  r  	rawStatusr   s                   r   r  zbtcturk.parse_order  s   D eT**  00))%:FF#L11$$UL99	##E<88!!(F33v..x00((@@''|ZHH	$$UH55	((33  
E 
" 
 U 
 f	 

  
 d 
 D 
 t 
 f 
 D 
 D 
 ] 
  
 Y// 
 f 
  4! 
" #  	r   c                    K   |                                   d{V  d}||                     |          }|                                  d{V }|                     |d          }|                     ||||          S )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$  r+   privateGetUsersTransactionsTrader   rl  )r   r   ri  r   r   r+  r   r   s           r   fetch_my_tradeszbtcturk.fetch_my_trades  s       !!!!!!!!![[((F>>@@@@@@@@, ~~h//  vue<<<r   c                 *    |                                  S N)ry  )r   s    r   noncezbtcturk.nonce  s      """r   r   GETc                 @   | j         dk    rt          | j         dz             | j        d         |         dz   |z   }|dk    s|dk    r|r|d|                     |          z   z  }n|                     |          }|dk    r|                                  t          |                                           }|                     | j	                  }	| j
        |z   }
| j
        ||                     |                     |
          |	t          j        d	          d
d}||||dS )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   signzbtcturk.sign  s*   7k!!*] ]^^^is#c)D0eOO8!3!3 4sT^^F333399V$$D)++---

%%E**4;77F;&D #yyT):):FGNT\]] 2	 G fdwOOOr   r!  reasonr  r  r  r  c
                    |                      |dd          }
|                      |d          }||n|}|                     | j        d         || j        dz   |z              |
dk    r |
dk    rt	          | j        dz   |z             d S )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_errorszbtcturk.handle_errors  s    $$Xvs;;	""8Y77!/,,T_W-EwPTPWZ]P]`fPfggg9	#9#9# 6777tr   r  )Nr   NNF)1__name__
__module____qualname__r   r   r   r	   r   r  r   r"  r&  r  r   r   r1  dictr   rK  r   r   rP  rS  r   rh  rn  listrr  r  r   r}  r   r   floatr
   r  r   r  r   r  r  r  r  r  r  r  r  r  __classcell__)r   s   @r   r   r      s       g# g g g g g gR *, 7+ 7+V 7+ 7+ 7+ 7+rF
V F
 F
 F
 F
P) ) ) ) )$ *, , , , , , ,: @DB ^ ^S ^ ^S\ ^ ^ ^ ^@/ /4 / /6 / / / /b 6:" 4 47 4 4 4 4 4 68 0 0 0F 0 0 0 0; ; ;v ; ; ; ; ;z <@d[] '= '= '=S '= '=bfglbm '= '= '= '=R
 
 
4 
 
 
 
( ?CQUdhqs IL IL IL IL3 IL^a ILx|  ~B  yC IL IL IL ILVI Is IZ] Ilp I I I I* mqy{ . . .I .Y .X] .fi . . . .@ 9=R  S #    4 59tZ^gi V Vc V VTW Vnrsxny V V V V0 04$UYbd ,= ,= ,=C ,=s ,=imnsit ,= ,= ,= ,=\: : : : :@ @ @v @ @ @ @ @D 37TX\eg '= '=C '=s '=RU '= '= '= '=R# # # &eBSW P P P 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   <module>r     s   6 5 5 5 5 5 - - - - - -   P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P       * * * * * * ' ' ' ' ' ' . . . . . . ) ) ) ) ) ) 4 4 4 4 4 4 % % % % % %w w w w wh w w w w wr   