
    i`                    `   d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlm Z  d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dl)m*Z* d dl+m,Z,  G d dee          Z-dS )    )Exchange)ImplicitAPIN)Balances
CurrenciesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)ExchangeNotAvailable)OnMaintenance)RequestTimeout)	TICK_SIZE)Precisec                       e Zd Z fdZdFdedefdZdddi fdeded	ede	e         fd
Z
di f fd	Zi fde	e         fdZdefdZi fdZdFdedefdZdi fdedefdZi fdefdZi fdedefdZdFdedefdZddi fdeded	ede	e         fdZdddi fdeded	efdZd ZdFdedefdZd Zd Z dddi fdeded	ede	e         fdZ!di fdede"de#de$d e%f
d!Z&di fd"Z'ddi fd#edede"de#de%d e%fd$Z(di fd#edefd%Z)di fdefd&Z*di fd#edefd'Z+di fd#edefd(Z,dddi fd#ededed	efd)Z-de.fd*Z/i fde.fd+Z0i fde1fd,Z2di fded	ede3fd-Z4i fd.efd/Z5i fd.efd0Z6i fd.ede$d1ed2ede7f
d3Z8dFd4e9fd5Z:di fd.ede$fd6Z;dddi fd.eded	efd7Z<dddi fd.eded	ede	e=         fd8Z>dddi fd.eded	ede	e=         fd9Z?di fd:efd;Z@dGd<ZAdFd4e9fd=ZBdddi fd.eded	ede	e=         fd>ZCd? ZDdFd4e9de=fd@ZEdA ZFdBdCi ddfdDZGdE ZH xZIS )Hpoloniexc                 
   |                      t          t          |                                           dddgdddi dd ddd	d d
dddddddddddddddddddddddddddi ddddddddddddddd dd!dd"dd#dd$dd%dd&dd'dd(dd)dddddddddddddddd*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<id;d=id>d?d@dAdBdCi dDdEdFdGdHdEdIdEdJdEdKdEdLdGdMdGdNdGdOdGdPdGdQdGdRdGdSdGdTdEdUdEdVdEdGdGdGdWii dXdYdZdYd[dYd\dEd]dEd^dYd_dEd`dGdadYdbdEdcdYdddEdedYdfdEdgdEdhdEdidYdYdYdEdYdYdEdYdEdEdEdYdjdYdEdEdEdEdYdEdYdYdk	dYdEdEdYdEdEdldEdEdmdndodC|                     dp          |                     dp          dqi dri dsdtdudvdwdxdydydzd{d|d}d~ddddddddddddddddddddddddddddddd	dddddddddddddddddddiidddddddt
          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt           dt           i dt           dt          dt          dt"          dt"          dt$          dt           dt          dt          dt$          dt          dt          dt$          dt          dt           dt           dt           i dt           dt           dt           dt           dt           dt           dt           dt           dt          dt           dt           dt           dt           dt           dt           dt           dt           i dt           dt           dt           dt           dt           dt          dt          dt          dt           dt           dt           dt           dt           dt           dt           dt           dt          i dt           d t          dt           dt           dt           dt          dt"          dt           dt          dt$          d	t$          d
t$          dt          dt          dt          dt          i dd          S (  Nr)   PoloniexUS   FTCORSspotmarginswapfutureoptioncancelAllOrderscancelOrdercreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrder	editOrderfetchBalancefetchClosedOrderfetchCurrenciesfetchDepositAddressfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingRatefetchMarginModefetchMarketsfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrderTrades)fetchPositionfetchPositionModefetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchTransferfetchTransfersfetchWithdrawalstransferwithdrawMINUTE_1MINUTE_5	MINUTE_10	MINUTE_15	MINUTE_30HOUR_1HOUR_2HOUR_4HOUR_6HOUR_12DAY_1DAY_3WEEK_1MONTH_1)1m5m10m15m30m1h2h4h6h12h1d3d1w1Mzchttps://user-images.githubusercontent.com/1294454/27766817-e9456312-5ee6-11e7-9b3c-b628ca5626a5.jpgrestzhttps://api.poloniex.comz*https://sand-spot-api-gateway.poloniex.comzhttps://www.poloniex.comzhttps://docs.poloniex.comzhttps://poloniex.com/feesz&https://poloniex.com/signup?c=UBFZJRPJ)logoapitestwwwdocfeesreferralgetmarkets   zmarkets/{symbol}   
currencieszcurrencies/{currency}zv2/currencieszv2/currencies/{currency}	timestampzmarkets/pricezmarkets/{symbol}/pricezmarkets/markPricezmarkets/{symbol}/markPricez$markets/{symbol}/markPriceComponentszmarkets/{symbol}/orderBookzmarkets/{symbol}/candleszmarkets/{symbol}/tradeszmarkets/ticker24hzmarkets/{symbol}/ticker24h)zmarkets/collateralInfoz!markets/{currency}/collateralInfozmarkets/borrowRatesInfoaccounts   zaccounts/balanceszaccounts/{id}/balanceszaccounts/activityaccounts/transferzaccounts/transfer/{id}feeinfozaccounts/interest/historysubaccountszsubaccounts/balanceszsubaccounts/{id}/balancessubaccounts/transferzsubaccounts/transfer/{id}zwallets/addresseszwallets/addresses/{currency}zwallets/activityzmargin/accountMargin)zmargin/borrowStatuszmargin/maxSizeordersorders/{id}zorders/killSwitchStatussmartorderssmartorders/{id}zorders/historyzsmartorders/historytradeszorders/{id}/trades)	r   r   zwallets/addresszwallets/withdrawzv2/wallets/withdrawr   zorders/batchzorders/killSwitchr   )r   zorders/cancelByIdsr   r   zsmartorders/cancelByIdsr   )r   r   )r   postdeleteput)publicprivatez0.0009)feeSidemakertaker)tradingfundingAIRAirCoinAPHAphroditeCoinBCCBTCtalkcoinBCHABCBDG
BadgercoinBTMBitmarkCONCoinoETHTRONETHGOLD
GoldEaglesGPUCGPUHOTHotcoinITCzInformation CoinKEYKEYCoinMASKzNFTX Hashmasks IndexMEMEzDegenerator MemePLXParallaxCoinREPV2REPXLMSOCCUnitradeTRXzAPI CoinUSDTUSTC)	STRSOCTRADETRXETHXAPUSDTBSCUSDTTRONUSDTETHUSTBSCTRON)BEP20ERC20TRC20costming-C6?g      ?d   gQ?)BTCr   r   r   BNBUSDCUSDJTUSDDAIPAXBUSDfutures)r/   r2   )exchanger   )!createMarketBuyOrderRequiresPricenetworkslimitsaccountsByTypeaccountsById50060360141560221604216002160521102211002170421700217052170721708216012171121709250000250001250002250003250004250005250008250012211101004010060100201004121340213412134221343213512135221353213542135921360241062420121301213022130421305213072130921310213112131221314213152131721319213202132121322213242132721328213302133521336213372134421345213462134821347213492135021355213562410124102241032410424105250202500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019)exactbroad)idname	countries	rateLimit	certifiedprohas
timeframesurlsr}   r   commonCurrenciesoptionsprecisionMode
exceptions)deep_extendsuperr)   describeparse_numberr&   r#   r%   r   r   r   r   r   r   r   r$   r    r   r!   )self	__class__s    a/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/poloniex.pyrX  zpoloniex.describe   s   h 5 5 > > @ @111 $1 	1
 %1 %1 "41 t1 '1 /1 ,U1 01 t1 T1 1  #E!1" "4#1 1$ &t%1&  '1( +D)1* *:+1, +D-1. #E/10 "5112 314  516 d718 +E91: !%;1< "4=1> d?1@ !$A1B "5C1D #DE1 1F "'%*# $!##($(%/!&"'$(  a1 1 1f ! """  " ~6 H 223D   !2*A %b 0	
 ( 3B $Q ( 1! ,Q 5a ? 5a 3A 22  ,R!" 5b#$ 34=>34)  2"A+Q 1! ,R	
 ,R 1! "2 4Q &q / 4Q / 4Q ,R 7  +B!" /#$ 01*+"$'(34'),-*,/1"$./9  > ./02+-,./1"#(*-.'(
 
 ().0"$,-35')  (*,. e6 63P Pf  %!..x88!..x88	   $!y$!$! }$! (	$!
 |$! y$! w$! 5$! $! $! y$! )$! y$! .$! *$!  ~!$!" #$!$ #! ""!G$! $! $!L 6:""#  #)#)$'#&#'$'$'$*#&#&$'   $ #'# #
 !''! !9   B 'k/k >k :	k
 =k ,k Zk 0k 0k ]k 0k 0k Zk Zk  ]!k" Z#k$ -%k& ]'k k( .)k* m+k, j-k. j/k0 j1k2 j3k4 /5k6 j7k8 m9k< Z=k> Y?k@ ]AkB YCkD YEkF ]GkH \IkJ \Kk k kL \MkN -OkP YQkR -SkT -UkV ]WkX \YkZ Z[k\ 1]k` ]akb ]ckd ]ekf ]gkh ]ikj \kkl \mkn \ok k kp \qkr \skt \ukv \wkx \ykz \{k| \}k~ \k@ ZAkB \CkD \EkF \GkH \IkJ \KkL \MkN \OkP \Qk k kR \SkT \UkV \WkX \YkZ \[k\ ]]k^ Z_k` Yakb \ckd \ekf \gkh \ikj \kkn \okp \qkr \skt ]uk k kv \wkx ]ykz \{k| \}k~ \k@ ]AkB -CkD \EkF ]GkH ]IkJ ]KkL ]MkN ]OkP ]QkR ZSkT YUk kX[o oqhC
 hC
 h h h	    Nmarketreturnc           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )N      r   r      r-   )safe_integersafe_number)rZ  ohlcvr^  s      r\  parse_ohlcvzpoloniex.parse_ohlcv  s    , eR((UA&&UA&&UA&&UA&&UA&&
 	
r]  rm   symbolsincelimitc           	        K   |                                   d{V  d}|                     |ddd          \  }}|r!|                     d|||||d           d{V S |                     |          }|d         |                     | j        ||          d}|||d<   |||d	<   |                     d
||          \  }}|                     |                     ||                     d{V }	| 	                    |	||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://docs.poloniex.com/#public-endpoints-market-data-candles
        :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
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        NFrI   paginatei  rI  )rh  interval	startTimerj  endTime)
load_marketshandle_option_and_params"fetch_paginated_call_deterministicr^  safe_stringrP  handle_until_optionpublicGetMarketsSymbolCandlesextendparse_ohlcvs)
rZ  rh  	timeframeri  rj  paramsrl  r^  requestresponses
             r\  fetch_ohlcvzpoloniex.fetch_ohlcv  sZ      !!!!!!!!!88z[`aa& 	}@@vW\^cenpvx{|||||||||V$$Tl(()YOO
 
 #(GK $GG229gvNN;;DKKQW<X<XYYYYYYYY*   69eUKKKr]  Fc                    K   t          t          |                               ||           d {V }|                     | j        d          }||r#|                     | j        d          | j        d<   |S )NcurrenciesByNumericId	numericId)rW  r)   rp  
safe_valuerS  index_byr   )rZ  reloadry  r   r~  r[  s        r\  rp  zpoloniex.load_markets  s}      h--::66JJJJJJJJ $>U V V!)f)48MM$/S^4_4_DL01r]  c                 f   K   |                      |           d{V }|                     |          S )a3  
        retrieves data on all markets for poloniex
        :see: https://docs.poloniex.com/#public-endpoints-reference-data-symbol-information
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        N)publicGetMarketsparse_markets)rZ  ry  r   s      r\  fetch_marketszpoloniex.fetch_markets  sC       --f555555550 !!'***r]  c                 N   |                      |d          }|                      |d          }|                      |d          }|                     |          }|                     |          }|                      |d          }|dk    }|                     |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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 )#Nrh  baseCurrencyNamequoteCurrencyNamestateNORMALsymbolTradeLimitrI  /basequotesettlebaseIdquoteIdsettleIdtyper/   Tr0   Fr1   r2   r3   activecontractlinearquantityScale
priceScale)amountpriceminQuantityr   max	minAmount)r  r  r   tradableStartTime)
inversecontractSizeexpiryexpiryDatetimestrike
optionType	precisionr   createdinfo)rs  safe_currency_coder  rY  parse_precisionre  rd  )
rZ  r^  rI  r  r  r  r  r  r  r  s
             r\  parse_marketzpoloniex.parse_market  s   fh//!!&*<==""6+>??&&v..''00  11("??63EFF,
",
dSj5(,
 D,
 U	,

 d,
 f,
 w,
 ,
 F,
 D,
 e,
 E,
 e,
 e,
 f,
  !,
" d#,
$  "++D,@,@AQAQRbdsAtAt,u,uvv**4+?+?@P@PQaco@p@p+q+qrr   ++,<mLL 
   
  ++,<kJJ   ((1DEEW,
 ,
 ,
 ,	
r]  c                 h   K   |                      |           d{V }|                     |d          S )al  
        fetches the current integer timestamp in milliseconds from the exchange server
        :see: https://docs.poloniex.com/#public-endpoints-reference-data-system-timestamp
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        N
serverTime)publicGetTimestamprd  )rZ  ry  r{  s      r\  
fetch_timezpoloniex.fetch_time<  sC       0088888888  <888r]  c           	      H   |                      |d          }|                     |d          }|                     |          }|                     |d          }|                     |d          }t          j        |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|          S )Ntsrh  closedailyChange100bidQuantityaskQuantityrI  r   datetimehighlowbid	bidVolumeask	askVolumevwapopenlastpreviousClosechange
percentagequantityr  )average
baseVolumequoteVolumer  )rd  rs  safe_marketr'   
string_mulsafe_tickeriso8601)
rZ  tickerr^  r   marketIdr  relativeChanger  r  r  s
             r\  parse_tickerzpoloniex.parse_tickerF  s/   . %%fd33	##FH55!!(++  11))&-@@'>>
$$V];;	$$V];;	 !
(!
fX&!
 !
 Y//	!

 D$$VV44!
 4##FE22!
 4##FE22!
 !
 4##FE22!
 !
 D!
 D$$VV44!
 U!
 E!
 T!
  d!!
" *#!
$ **6:>>++FH==+!
 !
 !
, -  	r]  symbolsc                    K   |                                   d{V  |                     |          }|                     |           d{V }|                     ||          S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://docs.poloniex.com/#public-endpoints-market-data-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>`
        N)rp  market_symbolspublicGetMarketsTicker24hparse_tickers)rZ  r  ry  r{  s       r\  fetch_tickerszpoloniex.fetch_tickers}  s|       !!!!!!!!!%%g..77????????2 !!(G444r]  c                   K   |                      |                     |ddi                     d{V }i }t          dt          |                    D ]-}|                     ||          }t          |                                          }|                     |d          }|                     ||          }|                     |          }	|                     |d          }
|                     |d          }d}|| 	                    ||	          }|                     |d          }|                     |d          d	k    }|                     |d
          d	k    }|                     |d          d	k    }| o|o|o|}| 
                    |d          }|                     |d          }|                     |d          }|du }|                     ||	          0||	d|
||||                     |          dddddddddddd
||	<   |                     ||	         d          }|||nt          j        ||          }|                     ||	         d          }|r|n|}|                     ||	         d          }|r|n|}|                     ||	         di           }|1|||||||||                     |          dddddddddddd||<   |||	         d<   |                     ||	         dg           }i }|||<   |                    |           |||	         d<   |r|||	         d<   |
||	         d<   |o|||	         d<   |||	         d<   |||	         d<   |                     |          ||	         d<   /|S )a3  
        fetches all available currencies on an exchange
        :see: https://docs.poloniex.com/#public-endpoints-reference-data-currency-information
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        includeMultiChainCurrenciesTNr   rJ  
blockchaindelistedwalletStateENABLEDwalletDepositStatewalletWithdrawalStaterI  withdrawalFeeparentChainr  )r  depositr^   )
rI  coder  rJ  r  r  r^   feer  r   r  r  r^   r   )r  r^   r  )r  rI  network
currencyIdr  r  r^   r  r  r  r   r  r  )publicGetCurrenciesrv  rangelenr  listkeysr  rs  network_id_to_coderd  rY  r'   
string_minappend)rZ  ry  r{  resultiitemidsrI  currencyr  rJ  	networkIdnetworkCoder  walletEnableddepositEnabledwithdrawEnabledr  r  	feeStringr  noParentChainminFeeStringdepositAvailablewithdrawAvailabler   r  rawInfos                               r\  fetch_currencieszpoloniex.fetch_currencies  s_      11$++fGdfjFk2l2lmmmmmmmm4 q#h--(( ]	B ]	BA??8Q//Dtyy{{##Ca((BtR00H**2..D##Hf55D((<@@IK$"55iFFx<<H ,,X}EERM!--h8LMMQZZN"..x9PQQU^^O!\ZmZZ?F))(D99I((?CCI//(MBBK'4/Mvt,,4   $- /,,Y77!% $(#'# #
 $(#'$ $
 $(#'% %    t2  ++F4L%@@L$-9-AyyHZ[dfrHsHs#vd|YGG2@W~~GW $tj I I4C [J[vd|ZDDH&$#*"$!*- /$,,Y77!% $(#'# #
 $(#'% %
 $(#'$ $ ) )%4 (0F4L$??6$<<<DG"GBKKK   #'F4L  ,%'tT"'+tV$%5%K:KF4L"&6F4L#'8F4L$"&"3"3L"A"AF4Lr]  c                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://docs.poloniex.com/#public-endpoints-market-data-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>`
        Nrh  rI  )rp  r^  publicGetMarketsSymbolTicker24hrv  r  )rZ  rh  ry  r^  rz  r{  s         r\  fetch_tickerzpoloniex.fetch_ticker$  s       !!!!!!!!!V$$fTl
 ==dkk'SY>Z>Z[[[[[[[[.   6222r]  c                    |                      |dd          }|                     |d          }|                     |dd          }|                     |d          }|                     ||d          }|d         }|                     |dd	          }d }	|                     |d
          }
|                     |d          }|                     |d          }|                     |d          }|                     |d          }||                     |          }||d}	|                     ||||                     |          |||                     |d          ||                     |d          |
|||	d|          S )NrI  tradeIDorderIdr  
createTimerh  _side	takerSider  r  r  feeCurrency	feeAmount)r   r  r  	matchRole)rI  r  r   r  rh  orderr  r  takerOrMakerr  r  r   r  )	safe_string_2rs  safe_integer_2r  safe_string_lower_2r  
safe_trader  safe_string_lower)rZ  trader^  rI  r  r   r  rh  r  r  priceStringamountString
costStringfeeCurrencyIdfeeCostStringfeeCurrencyCodes                   r\  parse_tradezpoloniex.parse_tradeJ  s   n tY77""5)44''t\BB	##E844!!(FC88!''v{CC&&ug66''z::%%eX66
((>>((<<$"55mDDO%+ C "Y//**5&99 225+FF " 
  
   	r]  c                   K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     ||||          S )a*  
        get the list of most recent trades for a particular symbol
        :see: https://docs.poloniex.com/#public-endpoints-market-data-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>`
        Nrh  rI  rj  )rp  r^  publicGetMarketsSymbolTradesrv  parse_trades)rZ  rh  ri  rj  ry  r^  rz  r   s           r\  fetch_tradeszpoloniex.fetch_trades  s       !!!!!!!!!V$$fTl
 $GG88Wf9U9UVVVVVVVV   >>>r]  c                   K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S d}||                     |          }i }|||d<   |||d<   |                     d||          \  }}|                     |                     ||                     d{V }|                     ||||          }	|	S )aL  
        fetch all trades made by the user
        :see: https://docs.poloniex.com/#authenticated-endpoints-trades-trade-history
        :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
        :param int [params.until]: the latest time in ms to fetch entries for
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        NFrH   rl  rn  rj  ro  )rp  rq  fetch_paginated_call_dynamicr^  rt  privateGetTradesrv  r  )
rZ  rh  ri  rj  ry  rl  r^  rz  r{  r  s
             r\  fetch_my_tradeszpoloniex.fetch_my_trades  s;      !!!!!!!!!88R\]]& 	j::?FTY[`bhiiiiiiiii[[((F
 #(GK $GG229gvNN..t{{7F/K/KLLLLLLLL, ""8VUEBBr]  c                 D    dddddddd}|                      |||          S )Nr  closedcanceled)NEWPARTIALLY_FILLEDFILLEDPENDING_CANCELPARTIALLY_CANCELEDCANCELEDFAILEDrs  rZ  statusstatusess      r\  parse_order_statuszpoloniex.parse_order_status  s=     &("," 
 
 &&999r]  c           	         |                      |dd          }|)|                     |                     |d                    }|                     |d          }|                     ||d          }|d         }|                     |d          }t          |t                    s+|                     ||                     |d|                    }|                     |dd	          }|                     |d
          }|                     |d          }	|                     |                     |d                    }
| 	                    |d          }|                     |d          }| 
                    |          }|                     |g d          }d }|                     |d          }d }d }|                     |d          }||dk    r|d         n|d         }n+|                     |          }|                     |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$|          S )%Nr   r  daterh  r  resultingTradesrI  r  rater  filledQuantityr  r  r  )orderNumberrI  r  tokenFeeCurrencyr  buyr  r  tokenFee)r5  r   r  clientOrderIdtriggerPrice	stopPricer  r  lastTradeTimestamp
updateTimer/  timeInForcepostOnlyr   r  avgPrice)r  filled	remainingr   r  )r  	parse8601rs  r  r  
isinstancer  r  r1  r  parse_order_typesafe_string_nr  
safe_orderr  rd  )rZ  r  r^  r   r  rh  r4  r  r  rC  r/  r  rawTyper  rI  r  r	  feeCostr  r5  r;  r<  s                         r\  parse_orderzpoloniex.parse_order  s   f ''{LII	t'7'7v'F'FGGI##E844!!(FC88!//%1BCC/400 	i"ooot?O?OPVX\^f?g?ghhO""5'6::!!%44!!%)9::(()9)9%)I)IJJ%%eV44""5&11$$W--'G'G'GHH&&u.@AA#u--15fVnnVG_OO #55kBBO&&uj99G+ C
 ((@@))%MM  
E 
" 
 ] 
 	 

 Y// 
 !$"3"3E<"H"H 
 f 
 f 
 D 
 4++E=AA 
  
 D 
 U 
  
 L 
  D! 
" t''z::# 
$ %- 
  
  
. /  	r]  c                 >    ddddd}|                      |||          S )Nr^  rj  )MARKETLIMITz
STOP-LIMITzSTOP-MARKETr-  r.  s      r\  rG  zpoloniex.parse_order_typew  s4    !#	
 
 &&999r]  c           	          t          dt          |                    D ]Z}||         }|                     |dd|d         |d         d          }|                    |                     ||                     [|S )Nr   r  rj  r  r5  )r/  r  r  r  )r  r  rv  r  rL  )rZ  r   r^  r  r  r  extendeds          r\  parse_open_orderszpoloniex.parse_open_orders  s    q#f++&& 	> 	>A1IE{{5 fv	+ +  H MM$**8V<<====r]  c                   K   |                                   d{V  d}i }| |                     |          }|d         |d<   |||d<   |                     |dd          }|                     |ddg          }d}|r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }ddi}	|                     |||||	          S )	a  
        fetch all unfilled currently open orders
        :see: https://docs.poloniex.com/#authenticated-endpoints-orders-open-orders
        :see: https://docs.poloniex.com/#authenticated-endpoints-smart-orders-open-orders  # trigger 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
        :param boolean [params.stop]: set True to fetch trigger orders instead of regular orders
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        NrI  rh  rj  triggerstopr/  r  )rp  r^  safe_value_2omitprivateGetSmartordersrv  privateGetOrdersparse_orders)
rZ  rh  ri  rj  ry  r^  rz  	isTriggerr{  	extensions
             r\  fetch_open_orderszpoloniex.fetch_open_orders  s8      !!!!!!!!![[((F &tGH$GG%%fi@@	6Iv#677 	Q!77GV8T8TUUUUUUUUHH!224;;w3O3OPPPPPPPPH0 v&	  65%KKKr]  r  r  r  r  c           	      \  K   |                                   d{V  |                     |          }|d         s#t          | j        dz   |d         z   dz             |d         |d}|                     |dd	          }	|                     |||||||          \  }}d}
|	0|                     |                     ||                     d{V }
n/|                     |                     ||                     d{V }
|                     |
d|i          }
| 	                    |
|          S )
a  
        create a trade order
        :see: https://docs.poloniex.com/#authenticated-endpoints-orders-create-order
        :see: https://docs.poloniex.com/#authenticated-endpoints-smart-orders-create-order  # trigger orders
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.triggerPrice]: *spot only* The price at which a trigger order is triggered at
        :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr/   z  createOrder() does not support r  & orders, only spot orders are acceptedrI  )rh  r  r=  r<  )
rp  r^  r"   rI  safe_number_2order_requestprivatePostSmartordersrv  privatePostOrdersrL  )rZ  rh  r  r  r  r  ry  r^  rz  r<  r{  s              r\  create_orderzpoloniex.create_order  s      !!!!!!!!!V$$f~ 	Itw)KKfU[n\  `H   H  I  I  ITl
 
 ))&+~NN,,VT4RWY_``#!88Wf9U9UVVVVVVVVHH!33DKK4P4PQQQQQQQQH ;;xD*
   &111r]  c                    |                                 }|dk    }	|                     |	|dk    |          }
|                     |dd          }|                     |g d          }||dnd}||d<   n|
rd}||d<   |	r|d	k    rd }d
}|                     |ddd
          \  }}|                     |d          }|                     |d          }||                     ||          }n|ro|t          | j        dz             | 	                    |          }| 	                    |          }t          j        ||          }|                     ||          }n|                     ||          }||d<   nL|                     ||          |d<   n2|                     ||          |d<   |                     ||          |d<   |                     |d          }|||d<   |                     |d          }||gS )NrN  LIMIT_MAKERr=  r<  )rA  r<  r=  STOP
STOP_LIMITr  r9  Tr:   r   r   a	   createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend(quote quantity) in the amount argumentr  r  r  r;  )upperis_post_onlyr`  rW  rq  re  cost_to_precisionr    rI  number_to_stringr'   r  amount_to_precisionprice_to_precisionrs  )rZ  rh  r  r  r  rz  r  ry  upperCaseTypeisMarket
isPostOnlyr<  quoteAmountr   r   r  r  costRequestr;  s                      r\  ra  zpoloniex.order_request  sh   

 H,&&x-1OQWXX
))&+~NN6#L#L#LMM#',}FF<M#/GK   	*)M' 	Fu}}"481<@<Y<YZ`bo  rU  W[  =\  =\916''776622#"&"8"8"F"FKK6 	I}*47  6A  ,A  B  B  B'+'<'<V'D'D&*&;&;E&B&B&-&8{&S&S&*&<&<V[&Q&Q"&"8"8"H"HK$/!!&*&>&>vv&N&N
##"&":":66"J"JGJ#66vuEEGG((AA$'4GO$YYv77F  r]  rI  c           	      N  K   |                                   d{V  |                     |          }|d         s#t          | j        dz   |d         z   dz             d|i}	|                     |dd          }
|                     |||||	||          \  }	}d}|
0|                     |                     |	|                     d{V }n/|                     |                     |	|                     d{V }|                     |d|i          }| 	                    ||          S )	a  
        edit a trade order
        :see: https://docs.poloniex.com/#authenticated-endpoints-orders-cancel-replace-order
        :see: https://docs.poloniex.com/#authenticated-endpoints-smart-orders-cancel-replace-order
        :param str id: order id
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float [amount]: how much of the currency you want to trade in units of the base currency
        :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.triggerPrice]: The price at which a trigger order is triggered at
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr/   z editOrder() does not support r  r_  rI  r=  r<  )
rp  r^  r"   rI  r`  ra  privatePutSmartordersIdrv  privatePutOrdersIdrL  )rZ  rI  rh  r  r  r  r  ry  r^  rz  r<  r{  s               r\  
edit_orderzpoloniex.edit_order  sv      !!!!!!!!!V$$f~ 	Gtw)IIFSYNZ  ^F   F  G  G  G"
 ))&+~NN,,VT4RWY_``#!99$++gv:V:VWWWWWWWWHH!44T[[&5Q5QRRRRRRRRH ;;xD*
   &111r]  c                   K   |                                   d {V  i }|                     |d          }||}||d<   |                     |dd          }|                     |g d          }d }|r0|                     |                     ||                     d {V }n/|                     |                     ||                     d {V }|                     |          S )Nr;  rI  rT  rU  )r;  rT  rU  )rp  r  rV  rW  privateDeleteSmartordersIdrv  privateDeleteOrdersIdrL  )rZ  rI  rh  ry  rz  r;  r[  r{  s           r\  cancel_orderzpoloniex.cancel_orderB  s      !!!!!!!!!@@$B%%fi@@	6#G#G#GHH 	V!<<T[[RX=Y=YZZZZZZZZHH!77GV8T8TUUUUUUUUH )))r]  c                   K   |                                   d{V  dg i}d}|!|                     |          }|d         g|d<   |                     |dd          }|                     |ddg          }d}|r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     ||          S )ax  
        cancel all open orders
        :see: https://docs.poloniex.com/#authenticated-endpoints-orders-cancel-all-orders
        :see: https://docs.poloniex.com/#authenticated-endpoints-smart-orders-cancel-all-orders  # trigger orders
        :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
        :param boolean [params.trigger]: True if canceling trigger orders
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr  rI  rT  rU  )rp  r^  rV  rW  privateDeleteSmartordersrv  privateDeleteOrdersrZ  )rZ  rh  ry  rz  r^  r[  r{  s          r\  cancel_all_orderszpoloniex.cancel_all_ordersg  s+      !!!!!!!!! r
 [[((Ft"GI %%fi@@	6Iv#677 	T!::4;;wPV;W;WXXXXXXXXHH!55dkk'66R6RSSSSSSSSH$   6222r]  c                   K   |                                   d{V  t          |          }d|i}|                     |dd          }|                     |ddg          }d}|rF|                     |                     ||                     d{V }|                     |d          }n/|                     |                     ||                     d{V }|                     |          }||d<   |S )aH  
        fetch an order by it's id
        :see: https://docs.poloniex.com/#authenticated-endpoints-orders-order-details
        :see: https://docs.poloniex.com/#authenticated-endpoints-smart-orders-open-orders  # trigger orders
        :param str id: order id
        :param str symbol: unified market symbol, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.trigger]: True if fetching a trigger order
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        NrI  rT  rU  r   )	rp  strrV  rW  privateGetSmartordersIdrv  r  privateGetOrdersIdrL  )rZ  rI  rh  ry  rz  r[  r{  r  s           r\  fetch_orderzpoloniex.fetch_order  s       !!!!!!!!!WW"
 %%fi@@	6Iv#677 	S!99$++gv:V:VWWWWWWWWHx33HH!44T[[&5Q5QRRRRRRRRH,   **dr]  c                    K   |                                   d {V  |                     |d d |           d {V }|                     |d          }||v rdndS )NrI  r  r$  )rp  r]  r  )rZ  rI  rh  ry  r   indexeds         r\  fetch_order_statuszpoloniex.fetch_order_status  sz      !!!!!!!!!--fdD&IIIIIIII------vvh6r]  c                    K   |                                   d{V  d|i}|                     |                     ||                     d{V }|                     |          S )a1  
        fetch all the trades made from a single order
        :see: https://docs.poloniex.com/#authenticated-endpoints-trades-trades-by-order-id
        :param str id: order id
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        NrI  )rp  privateGetOrdersIdTradesrv  r  )rZ  rI  rh  ri  rj  ry  rz  r   s           r\  fetch_order_tradeszpoloniex.fetch_order_trades  s       !!!!!!!!!"
 44T[[&5Q5QRRRRRRRR,   (((r]  c                 *   |d d d}t          dt          |                    D ]}|                     ||i           }|                     |d          }t          dt          |                    D ]}|                     ||          }|                     |d          }|                     |          }	|                                 }
|                     |d          |
d<   |                     |d          |
d<   |
||	<   |                     |          S )	N)r  r   r  r   balancesr  	availablefreeholdused)r  r  r  rs  r  accountsafe_balance)rZ  r{  r  r  r  r  jbalancer  r  
newAccounts              r\  parse_balancezpoloniex.parse_balance  s!   
 

 q#h--(( 
	* 
	*Aooh266Gw
;;H1c(mm,, * *//(A66!--gzBB
..z::!\\^^
%)%5%5g{%K%K
6"%)%5%5gv%F%F
6")t*   (((r]  c                    K   |                                   d{V  ddi}|                     |                     ||                     d{V }|                     |          S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://docs.poloniex.com/#authenticated-endpoints-accounts-all-account-balances
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        NaccountTypeSPOT)rp  privateGetAccountsBalancesrv  r  )rZ  ry  rz  r{  s       r\  fetch_balancezpoloniex.fetch_balance  s       !!!!!!!!!6
 88Wf9U9UVVVVVVVV" !!(+++r]  c                 D  K   |                                   d{V  |                     |           d{V }i }t          dt          | j                            D ]C}| j        |         }|||                     |d          |                     |d          ddd||<   D|S )ac  
        fetch the trading fees for multiple markets
        :see: https://docs.poloniex.com/#authenticated-endpoints-accounts-fee-info
        :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
        Nr   	makerRate	takerRateT)r  rh  r   r   r  	tierBased)rp  privateGetFeeinfor  r  r  re  )rZ  ry  r{  r  r  rh  s         r\  fetch_trading_feeszpoloniex.fetch_trading_fees%  s       !!!!!!!!!//77777777 q#dl++,, 		 		A\!_F  ))(K@@))(K@@"! F6NN r]  c                   K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     |d          }|                     |d          }|                     |d          }	g }
g }t          dt          |                    D ]b}|d	z  d
k     rW|                     ||          }|                     || 	                    |d
                    }|

                    ||g           ct          dt          |	                    D ]b}|d	z  d
k     rW|                     |	|          }|                     |	| 	                    |d
                    }|
                    ||g           c|d         |                     |dd          |                     |
d          ||                     |          ddS )aD  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://docs.poloniex.com/#public-endpoints-market-data-order-book
        :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
        Nrh  rI  rj  timeasksbidsr   rb  r   T)rh  r  r  r   r  nonce)rp  r^  publicGetMarketsSymbolOrderBookrv  rd  r  r  r  re  sumr  sort_byr  )rZ  rh  rj  ry  r^  rz  r{  r   r  r  
asksResult
bidsResultr  r  r  s                  r\  fetch_order_bookzpoloniex.fetch_order_bookC  s       !!!!!!!!!V$$fTl
 $GG==dkk'SY>Z>Z[[[[[[[[ %%h77	x00x00

q#d))$$ 	3 	3AA{{((q11))$A??!!5&/222q#d))$$ 	3 	3AA{{((q11))$A??!!5&/222X&LLQ55LLQ//"Y//
 
 	
r]  r  c                   K   |                                   d{V  |                     |          }d|d         i}|                     | j        di           }|                     |d          }|                     |||          }|'|dxx         |z  cc<   |                     |d          }n)|d         dk    rt          | j        dz   |z   dz             | 	                    | 
                    ||                     d{V }|                     |d	          }d}	|                     |           |"|                     |d
         d          }
|
|}	|
}|||	||dS )a  
        create a currency deposit address
        :see: https://docs.poloniex.com/#authenticated-endpoints-wallets-deposit-addresses
        :param str code: unified currency code of the currency for the deposit address
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        Nr  rI  r   r  r   z7 createDepositAddress requires a network parameter for .addressr  depositAddressr  r  tagr  r  )rp  r  r  rS  safe_string_upperrs  rW  r   rI  privatePostWalletsAddressrv  check_addressrZ  r  ry  r  rz  r   r  r{  r  r  r  s              r\  create_deposit_addresszpoloniex.create_deposit_addressu  s      !!!!!!!!!==&&
 ??4<R@@((;;""8Wg>>J7*YYvy11FF~'''2k(knr(rux(xyyy77GV8T8TUUUUUUUU ""8Y777###!--hv.>@PQQN)(
 
 	
r]  c                   K   |                                   d{V  |                     |          }d|d         i}|                     | j        di           }|                     |d          }|                     |||          }|'|dxx         |z  cc<   |                     |d          }n)|d         dk    rt          | j        dz   |z   dz             | 	                    | 
                    ||                     d{V }|                     ||d                   }d}	|                     |           |"|                     |d	         d
          }
|
|}	|
}|||	||dS )a  
        fetch the deposit address for a currency associated with self account
        :see: https://docs.poloniex.com/#authenticated-endpoints-wallets-deposit-addresses
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        Nr  rI  r   r  r   z6 fetchDepositAddress requires a network parameter for r  r  r  r  )rp  r  r  rS  r  rs  rW  r   rI  privateGetWalletsAddressesrv  r  r  s              r\  fetch_deposit_addresszpoloniex.fetch_deposit_address  s      !!!!!!!!!==&&
 ??4<R@@((;;""8Wg>>J7*YYvy11FF~'''2j(jmq(qtw(wxxx88Wf9U9UVVVVVVVV ""8WZ-@AA7###!--hv.>@PQQN)(
 
 	
r]  fromAccount	toAccountc                   K   |                                   d{V  |                     |          }|                     ||          }|                     | j        di           }|                     |||          }|                     |||          }	||d         ||	d}
|                     |                     |
|                     d{V }|                     ||          S )a/  
        transfer currency internally between wallets on the same account
        :see: https://docs.poloniex.com/#authenticated-endpoints-accounts-accounts-transfer
        :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>`
        Nr   rI  )r  r  r  r  )	rp  r  currency_to_precisionr  rS  rs  privatePostAccountsTransferrv  parse_transfer)rZ  r  r  r  r  ry  r  r   fromIdtoIdrz  r{  s               r\  r]   zpoloniex.transfer  s      !!!!!!!!!==&&++D&997GLL!!.+{KK	;GG !	
 
 99$++gv:V:VWWWWWWWW ""8X666r]  r  c           
      j    ||                      |d          d d |                      |d          d d d d d	S )N
transferIdrI  )	r  rI  r   r  r  r  r  r  r/  r-  )rZ  r]   r  s      r\  r  zpoloniex.parse_transfer  sN     ""8\::((488

 

 
	
r]  c                 R  K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }|d         ||d}|||d<   |                     | j        di           }|                     |d          }	|                     ||	|	          }	|	&|dxx         |	z  cc<   |                     |d          }| 	                    | 
                    ||                     d{V }
|                     |
|          S )a  
        make a withdrawal
        :see: https://docs.poloniex.com/#authenticated-endpoints-wallets-withdraw-currency
        :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>`
        NrI  )r  r  r  	paymentIdr   r  r  )handle_withdraw_tag_and_paramsr  rp  r  r  rS  r  rs  rW  privatePostWalletsWithdrawrv  parse_transaction)rZ  r  r  r  r  ry  r  rz  r   r  r{  s              r\  r^   zpoloniex.withdraw  sW      99#vFFV7###!!!!!!!!!==&& 
 

 ?#&GK ??4<R@@((;;""8Wg>>J7*YYvy11F88Wf9U9UVVVVVVVV %%h999r]  c                   K   |                                   d {V  d}|                                 }||                     |dz            n|d|z  z
  }||d}|                     |                     ||                     d {V }	|	S )Ni i  
   )startend)rp  secondsparse_to_intprivateGetWalletsActivityrv  )
rZ  r  ri  rj  ry  yearnowr  rz  r{  s
             r\  fetch_transactions_helperz"poloniex.fetch_transactions_helper$  s      !!!!!!!!!llnn494E!!%$,///CRTW[R[O
 
 77GV8T8TUUUUUUUUP r]  c                   K   |                                   d{V  |                     ||||           d{V }d}||                     |          }|                     |dg           }|                     |dg           }|                     ||||          }	|                     ||||          }
|                     |
|	          }|                     |                     |d          |||          S )a  
        fetch history of deposits and withdrawals
        :see: https://docs.poloniex.com/#authenticated-endpoints-wallets-wallets-activity-records
        :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>`
        Nwithdrawalsdepositsr   )rp  r  r  r  parse_transactionsarray_concatfilter_by_currency_since_limitr  )rZ  r  ri  rj  ry  r{  r  r  r  withdrawalTransactionsdepositTransactionstransactionss               r\  fetch_deposits_withdrawalsz#poloniex.fetch_deposits_withdrawalsw  s      !!!!!!!!!77eUFSSSSSSSS!}}T**HoohrBB??8Z<<!%!8!8hPUW\!]!]"55h%QVWW(()<>TUU224<<k3Z3Z\`bginooor]  c                   K   |                      ||||           d{V }d}||                     |          }|                     |dg           }|                     ||||          }|                     ||||          S )a4  
        fetch all withdrawals made from an account
        :see: https://docs.poloniex.com/#authenticated-endpoints-wallets-wallets-activity-records
        :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>`
        Nr  r  r  r  r  r  )	rZ  r  ri  rj  ry  r{  r  r  r  s	            r\  fetch_withdrawalszpoloniex.fetch_withdrawals  s       77eUFSSSSSSSS!}}T**HoohrBB..{HeUSS22<ueTTTr]  codesc                   K   |                                   d{V  |                     |                     |ddi                     d{V }i }t          dt	          |                    D ]L}||         }t          |                                          }|                     |d          }||         ||<   M|                     ||          S )a  
        fetch deposit and withdraw fees
        :see: https://docs.poloniex.com/#public-endpoints-reference-data-currency-information
        :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 `fees structures <https://docs.ccxt.com/#/?id=fee-structure>`
        Nr  Tr   )	rp  r  rv  r  r  r  r  rs  parse_deposit_withdraw_fees)	rZ  r  ry  r{  datar  entryr   r  s	            r\  fetch_deposit_withdraw_feesz$poloniex.fetch_deposit_withdraw_fees  s       !!!!!!!!!11$++fGdfjFk2l2lmmmmmmmm0 q#h--(( 	1 	1AQKEejjll++J))*a88J$Z0D//e<<<r]  c                 d   i }|                      |          }t          |                                          }t          dt	          |                    D ]X}||         }|                     |          }||         }	||                     ||          r|                     |          }
|                     |	|
          ||<   | 	                    |	d          }t	          |          }|dk    rt          dt	          |                    D ]}||         }|
                    |d          }|                     |          }| 	                    ||          }i }|                     |d          }||dnd dd d dd||<   |                     ||         d         |          ||         d<   Z|S )	Nr   childChains r  Fr  r  r^   r  r   )market_codesr  r  r  r  r  in_arrayr  parse_deposit_withdraw_feer  replacer  re  rv  )rZ  r{  r  currencyIdKeydepositWithdrawFeesresponseKeysr  r  r  feeInfor  r  chainsLengthr  r  r  networkInfonetworkObjectwithdrawFees                      r\  r  z$poloniex.parse_deposit_withdraw_fees  s   , !!!%((HMMOO,,q#l++,, 	B 	BA%aJ**:66Dz*G4==u#=#===..,0,K,KGU],^,^#D)"oog}EE";//!##"1c+&6&677 B B$/N	$-$5$5dB$?$?	&*&=&=i&H&H&*ooh	&J&J(*&*&6&6{O&T&T (38C8OeeVZ) )
 (,.2( (	6 	6k2 AEL_`dLefpLq  tA  AB  AB+D1*==""r]  c                     |                      i           }||d         |d         <   |                     |d          }|                     |d          }||dnd d}d d d}||d<   ||d<   |                     |          }||d	|d
         |<   |S )Nr  r  r  r  Fr  r^   r  r  r   )deposit_withdraw_feers  re  r  )	rZ  r  r  depositWithdrawFeer  r  withdrawResultdepositResultr  s	            r\  r  z#poloniex.parse_deposit_withdraw_fee  s    !66r::7:6"8F#34$$S,77	&&sO<<$/$;%%$
 

 
 
 *8:&(59%--i88&$7
 7
:&{3 "!r]  c                   K   |                      ||||           d{V }d}||                     |          }|                     |dg           }|                     ||||          }|                     ||||          S )a)  
        fetch all deposits made to an account
        :see: https://docs.poloniex.com/#authenticated-endpoints-wallets-wallets-activity-records
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch deposits for
        :param int [limit]: the maximum number of deposits structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr  r  )	rZ  r  ri  rj  ry  r{  r  r  r  s	            r\  fetch_depositszpoloniex.fetch_deposits  s       77eUFSSSSSSSS}}T**H??8Z<<..x5%PP22<ueTTTr]  c           	      F    ddddddddd}|                      |||          S )Nokpendingfailed)COMPLETE	COMPLETEDzAWAITING APPROVALAWAITING_APPROVALPENDING
PROCESSINGzCOMPLETE ERRORCOMPLETE_ERRORr-  r.  s      r\  parse_transaction_statusz!poloniex.parse_transaction_status'  s@    !*!* #&&	
 	
 &&999r]  c                    |                      |d          }|                     |d          }|                     |          }|                     |dd          }|                     |          }|                     |d          }d|v rdnd}|                     |dd	          }	|                     |d
          }
|                     |d          }|                     |d          }|                     |d          }|dk    rt          j        ||          }i d|d|	d|d|                     |          dd d
|
dd dd d|dd dd d|d|dd d|d|d|                     |          d d ||                     |          d ddS )Nr   r  r/  r  txidwithdrawalRequestsId
withdrawalr  depositNumberr  	paymentIDr  r  r  rI  r  	addressToaddressFromr  tagTotagFromr  updatedr  )r  r   r5  )commentinternalr  )	safe_timestamprs  r  r	  r  r'   
string_subrY  r  )rZ  transactionr  r   r  r  r/  r  r  rI  r  r  r  r  s                 r\  r  zpoloniex.parse_transaction4  sA   H ''[AA	%%k:>>
&&z22!!+xCC..v66V44 6+ E E||I-C_UU"";	::{K88''X>>((e<<<"-lMJJL
K
"
 
 d''55	

 t
 w
 
 4
 3
 T
 t
 f
 D
 t
 D
  !
" Y//#
$  ))-88 )
 
 
 	
r]  c                 *    |                                  S N)milliseconds)rZ  s    r\  r  zpoloniex.nonce  s      """r]  r   GETc                    | j         d         d         }|                     ||                     |                    }|                     ||          }	|dk    r'|d|	z   z  }|r|d|                     |          z   z  }nJ|                                  t          |                                           }
|dz   }|d|	z   z  }|d|	z   z  }|dk    s|dk    s|d	k    r0|dz  }|r |                     |          }|d
|z   dz   z  }|d|
z   z  }ne| 	                    d|
i|          }| 
                    |          }|d|                     |          z   z  }|r|d|                     |          z   z  }|                     |                     |          |                     | j                  t          j        d          }d| j        |
|d}||||dS )Nr}   r{   r   r  ?
POSTPUTDELETEzrequestBody=&zsignTimestamp=signTimestampbase64zapplication/json)zContent-Typekeyr%  	signature)urlmethodbodyheaders)rQ  rW  extract_paramsimplode_params	urlencodecheck_required_credentialsr  r  jsonrv  keysorthmacencodesecrethashlibsha256apiKey)rZ  pathr}   r*  ry  r,  r+  r)  queryimplodedPathr   authsortedQueryr(  s                 r\  signzpoloniex.sign  s   iv&		&$"5"5d";";<<**488(??3%%C 3sT^^E2222++---DJJLL))ID=D3%%CC,&&D&  foo6X;M;M 899U++DNT1C77D(944"kk?I*FNN"ll;77t~~k:::: 73!6!666C		$++d"3"3T[[5M5Mw~_ghhI 2{!*&	 G fdwOOOr]  c
                 F   |d S |                      |d          }
|
|
dk    r~|d         }|                      |d          }| j        dz   |z   }|                     | j        d         ||           |                     | j        d         ||           t          |          d S )Nr  200message rG  rH  )rs  rI  throw_exactly_matched_exceptionrU  throw_broadly_matched_exceptionr   )rZ  r  reasonr)  r*  r,  r+  r{  requestHeadersrequestBodyresponseCode	codeInnerrA  feedbacks                 r\  handle_errorszpoloniex.handle_errors  s    4 ''&99$<5+@+@ (I&&x;;Gw}t+H001I9V^___001I7T\]]])))tr]  r  )NN)J__name__
__module____qualname__rX  r	   r  rg  r  r   r   r|  rp  r  r  r  r   r  r   r   r  r   r  r  r   r  r  r   r"  r1  r   rL  rG  rR  r]  r   r   floatr
   rd  ra  rw  r{  r  r  r  r  r   r  r  r   r  r   r  r  r  r   r]   r   r  r^   r  r   r  r  r  r  r  r  r	  r  r  r>  rK  __classcell__)r[  s   @r\  r)   r)      s       i i i i iV
 
 
4 
 
 
 
< 8<$]ajl 2L 2L 2LC 2LWZ 2Lquvzq{ 2L 2L 2L 2Lh ).b       *, + +V + + + +B6
f 6
 6
 6
 6
p ') 9 9 9 95 56 5V 5 5 5 5n 6:" #5 #57 #5 #5 #5 #5 #5J -/ @ @: @ @ @ @D 68 $3 $3 $3F $3 $3 $3 $3LX X X5 X X X Xt <@d[] ? ? ?S ? ?bfglbm ? ? ? ?B 37TX\eg 4 4C 4s 4RU 4 4 4 4l
: 
: 
:n n n5 n n n n`: : :
 
 
 59tZ^gi 3L 3Lc 3L 3LTW 3Lnrsxny 3L 3L 3L 3Lj mqy{ *2 *2 *2I *2Y *2X] *2fi *2 *2 *2 *2X HLTV *! *! *! *!X fjx|  FH '2 '23 '2 '29 '2I '2_b '2ru '2 '2 '2 '2R 9=R #* #*S #*# #* #* #* #*J 59 -3 -3c -3 -3 -3 -3^ 8<B / /C / / / / /b ?C2 7 73 7 7 7 7 7 ?CQUdhqs %) %)3 %) %)3 %)^a %) %) %) %)N) ) ) ) )& *, , , , , , ,< /1  [    < @DB 0
 0
S 0
 0
S\ 0
 0
 0
 0
d >@ *
 *
 *
 *
 *
 *
X =? *
 *
 *
 *
 *
 *
X ac 7 73 7 7C 7TW 7gt 7 7 7 7>
 
 
 
 
 
$ EIQS $: $:3 $: $: $: $: $:L ;?T`dmo Q QC Qs QZ] Q Q Q Qf <@daenp p pS p p[^ puy  {F  vG p p p p, 37TX\eg U UC Us URU Ulpq|l} U U U U$ BFb '= '=w '= '= '= '=R5# 5# 5# 5#n" " " " " ", 04$UYbd U U UC Us Uimnyiz U U U U$: : :K
 K
x K
; K
 K
 K
 K
Z# # # &eBSW !P !P !P !PF      r]  r)   ). ccxt.async_support.base.exchanger   ccxt.abstract.poloniexr   r6  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   ccxt.base.decimal_to_precisionr&   ccxt.base.preciser'   r)    r]  r\  <module>rY     s   6 5 5 5 5 5 . . . . . .  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D  D       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) 1 1 1 1 1 1 * * * * * * + + + + + + 4 4 4 4 4 4 % % % % % %[" [" [" [" ["x [" [" [" [" ["r]  