
    iMP                       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 d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlm Z  d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dlm)Z) d dlm*Z* d dlm+Z+ d dlm,Z, d dlm-Z- d dl.m/Z/ d dl0m1Z1  G d dee          Z2dS )    )Exchange)ImplicitAPIN)Balances
CurrenciesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountNotEnabled)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)CancelPending)NotSupported)NetworkError)RateLimitExceeded)ExchangeNotAvailable)OnMaintenance)InvalidNonce)RequestTimeout)	TICK_SIZE)Precisec                       e Zd Z fdZi fdZi fdee         fdZdefdZd Z	i fde
fdZdi fd	ed
edefdZdEdedefdZi fd	edefdZdi fdedefdZdEdedefdZddi fd	eded
edee         fdZdEdedefdZdddi fd	eded
edee         fdZd Zi fdefdZd Zd Z i f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#de$de!d e%f
d"Z'di fd#ed	e(fd$Z)d% Z*di fd	e(fd&Z+d' Z,dEd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*Z0dddi fd	e(ded
edee-         fd+Z1dEd,e2fd-Z3i fd.efd/Z4i fd.efd0Z5i fd.ede!d1ed2ede6f
d3Z7dEd,e2fd4Z8d5 Z9di fd.ede!fd6Z:dddi fd.e(ded
edee;         fd7Z<dddi fd.e(ded
edee;         fd8Z=d9 Z>dEd,e2de;fd:Z?dddi fd	e(ded
efd;Z@dddi fd#ed	e(ded
efd<ZAdddi fd.e(ded
efd=ZBd> ZCdEd,e2fd?ZDd@dAi ddfdBZEdC ZFdD ZG xZHS )Fokcoinc                    |                      t          t          |                                           i dddddddgdd	d
ddddi dd dddddddddd ddddddddddddddddddddd di d!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0d d1dddddddd dddddddd2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHidIdJdKdLdGdMidNdOdPdQdQdRdRdRdSdTdUdVddQdTdWii dXdYdZdYd[dRd\dRd]dYd^d_d`dTdadQdbdQdcdQdddedfdedgdTdhdidjdidkdedldei dmdedndedodedpdidqdidrdUdsdUdtdidudvdwdidxdidydidzdd{did|did}did~dUdUdUdUdUdi dXdYddddYddddYdddadQddQddQddedddeddeddeddeddeddiddidididUdddddddddddddddddi 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          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt
          dt          dt          dt          d t          dt          i 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          dt          dt          i 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
          d"t
          d#t          i d$t          d%t          d&t          d't          d(t          d)t          d*t          d+t          d,t          d-t          d.t          d/t          d0t          d1t          d2t          d3t          d4t          i d5t          d6t          d7t          d8t          d9t          d:t          d;t          d<t          d=t          d>t          d?t          d@t          dAt          dBt          dCt          dDt          dEt          i dFt          dGt          dHt          dIt          dJt          dKt          dLt
          dMt
          dNt          dOt          dPt          dQt          dRt          dSt$          dTt$          dUt$          dVt          i dWt          dXt          dYt          dZt
          d[t          d\t          d]t&          d^t          d_t          d`t           dat          dbt          dct          ddt          det          dft          dgt          i dht          dit          djt$          dkt          dlt          dmt          dnt          dot           dpt          dqt          drt          dst          dtt          dut          dvt          dwt          dxt          i dyt          dzt          d{t          d|t          d}t          d~t          dt          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          t
          t
          t          t*          t          t
          t
          t
          t          t
          t
          t
          dΜt          t          dϜdМdt,          dҐdӐdiddgddddՐdՐd֐dלddؐdِdڜdېdܐdېdېdېdݜddސdސdid
ddddddddddd	          S (  Nidr.   nameOKCoin	countriesCNUSversionv5	rateLimit   proThasCORSspotmarginFswapfutureoptioncancelOrdercreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCurrenciesfetchDepositAddressfetchDepositsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchLedgerfetchMarketsfetchMyTrades
fetchOHLCVfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchOrderTrades)fetchPositionfetchPositionsfetchTickerfetchTickers	fetchTimefetchTradesfetchTransactionsfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMargin	setMargintransferwithdraw
timeframes1m3m5m15m30m1H2H4H6H12H1D1W1M3M)rm   rn   ro   rp   rq   1h2h4h6h12h1d1wry   rz   hostnamez
okcoin.comurlszdhttps://user-images.githubusercontent.com/51840849/87295551-102fbf00-c50e-11ea-90a9-462eebba5829.jpgrestzhttps://www.{hostname}zhttps://www.okcoin.comzhttps://www.okcoin.com/docs/en/z https://www.okcoin.com/coin-feeszIhttps://www.okcoin.com/account/register?flag=activity&channelId=600001513zhttps://testnet.okex.com)logoapiwwwdocfeesreferraltestr   get   g      ?g?   
   2   )zmarket/tickerszmarket/tickerzmarket/bookszmarket/candleszmarket/history-candleszmarket/tradeszmarket/history-tradeszmarket/platform-24-volumezmarket/open-oraclezmarket/exchange-ratezpublic/instrumentszpublic/timeztrade/ordergUUUUUU?ztrade/orders-pendingztrade/orders-historyztrade/orders-history-archiveztrade/fillsztrade/fills-historyg@ztrade/fills-archiveztrade/order-algoztrade/orders-algo-pendingztrade/orders-algo-historyzotc/rfq/trade   zotc/rfq/historyzaccount/balancezaccount/billsg?zaccount/bills-archivezaccount/configzaccount/max-sizezaccount/max-avail-sizezaccount/trade-feezaccount/max-withdrawalzasset/currencieszasset/balanceszasset/asset-valuationzasset/transfer-statezasset/billszasset/deposit-lightning   zasset/deposit-addresszasset/deposit-historyzasset/withdrawal-historyzasset/deposit-withdraw-statuszfiat/deposit-historyzfiat-withdraw-historyzfiat-channelzusers/subaccount/list)zusers/subaccount/apiKeyzaccount/subaccount/balanceszasset/subaccount/balanceszasset/subaccount/billsztrade/batch-ordersg?ztrade/cancel-orderztrade/cancel-batch-ordersztrade/amend-orderztrade/amend-batch-ordersgO贁N{?ztrade/cancel-algosztrade/cancel-advance-algoszotc/rfq/quotezasset/transferzasset/withdrawalzasset/withdrawal-lightningzasset/withdrawal-cancelzfiat/depositzfiat/cancel-deposit)zfiat/withdrawalzfiat/cancel-withdrawalzasset/subaccount/transfer)r   post)publicprivater   gMb`?gMbP?)takermakerg~jtX?)tradingr=   requiredCredentials)apiKeysecretpassword
exceptions1250000500015000250004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050032500335003550036500375003850039500415004450100501015010250103501045010550106501075010850109501105011150112501135011450115510005100151002510035100451005510065100751008510095101051011510125101451015510165101751018510195102051023510245102551026510305103151032510335103751038510445104651047510485104951050510515105251053510545105651058510595110051102511035110851109511105111151112511135111551116511175111851119511205112151122511245112551126511275112851129511305113151132511335113451135511365113751138511395115651159511625116351166511745120151202512035120451205512505125151252512535125451255512565125751258512595126051261512625126351264512655126751268512695127051271512725127351274512755127651277512785127951280513215132251323513245132551327513285132951330514005140151402514035140451405514065140751408514095141051500515015150251503515065150851509515105151151600516015160251603517325173351734517355173652000540005400158000580015800258003580045800558006580075810058101581025810358104581055810658107581085810958110581115811258114581155811658117581255812658127581285820058201582025820358204582055820658207582085820958210582115821258213582215822258224582275822858229583005835059000590015910059101591025910359104591055910659107591085910959128592005920159216593005930159313594015950059501595025950359504595055950659507595086000160002600036000460005600066000760008600096001060011)600126001360014600156001660017600186001963999700107001370016)zInternal Server Errorzserver error)exactbroadprecisionModeoptionstypeCandles618)classicr=   fundingmainunifiedr  r  )r   r  r  r   r   )time
currenciesinstrumentsratez{instrument_id}/constituentsERC20Ethereum)
rX   !createMarketBuyOrderRequiresPricerV   defaultTypeaccountsByTypeaccountsByIdauth)warnOnFetchCurrenciesWithoutAuthorizationdefaultNetworknetworkscommonCurrenciesAETDefiBoxzHydro ProtocolHCMaggiezSuper BitcoinUnitradeYOYOWWinToken)	AEBOXHOTHSRMAGSBTCTRADEYOYOWIN)deep_extendsuperr.   describer   r   r(   r*   r'   r   r   r&   r   r)   r   r!   r   r   r"   r#   r    r%   r+   )self	__class__s    _/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/okcoin.pyr	  zokcoin.describe%   s   fd 3 3 < < > > A	A
(A	A
HA	A
 $A	A
 t	A	A
 A	A
 4A	A
  111 %1 	1
 $1 $1 t1 /1 ,U1 01 t1 1 &u1 "51 +E1  )%!1" #E#1 1$ ,U%1& $T'1( "4)1* &t+1,  -1. &u/10 #E112 *5314 t516 718  91: d;1< "4=1> d?1@ !$A1B tC1D #DE1 1F "'"'# $!#%)$( %$)',"  a1 1 1A	A
v  wA	A
V WA	A
X ~4 08:g6 YA	A
r *+)*(-*/27).1257.002./'( "-%u- /- /	-
 7- &u- .s- .q- +A- 4Q- 4Q- (- *1-  *1!-" (#-$ 0%-& )!'-( +A)- -* 1!+-, ,Q--. 1!/-2 +E3-4 )%5-6 07-8 /9-: &u;-< 21=-> 0?-@ 0A-B 3EC-D 8E-H /I-J 0K-L 'M-P 0Q- -R 46795724Y- - -\%u -f -e	
 4V ,U 3G +A -a 5a ( ( )!  +A!" 5a#$ 21%( ')* .u+, ,127573  _J J#\ \sA	A
l "" 
 $# 	 	mA	A
@ " $ $AA	A
J H H 	H
 ZH ]H ZH ^H 1H ZH -H 0H -H ]H .H  ]!H" 1#H$ Z%H& ]'H H( ])H* ]+H, ]-H. ]/H0 ]1H2 ]3H4 ]5H6 ]7H8 Z9H: ];H< 1=H> -?H@ ]AHB ]CHD -EHF -GHH -IH H HJ ZKHL ZMHN ZOHP ]QHR ]SHT ]UHV ZWHZ ][H\ 0]H^ \_H` 0aHb 0cHd 0eHf 0gHh 0iHj ]kHl ]mH H Hn -oHp 0qHr 0sHt 0uHv 0wHx ZyH| Z}H~ YH@ YAHB ZCHD \EHF \GHH \IHJ \KHL .MHN -OHP .QH H HR \SHT YUHV YWHX YYHZ \[H\ ]]H^ ]_H` ]aHb \cHd ]eHf -gHh ]iHj YkHl \mHn \oHp \qHr \sH H Ht \uHv \wHx \yHz \{H| \}H~ \H@ \AHB \CHD \EHF \GHH \IHJ ZKHL \MHN \OHP \QHR \SHT \UH H HV \WHX \YHZ \[H\ \]H^ Z_H` \aHb .cHd \eHf \gHh \iHj \kHl .mHn \oHp \qHr \sHt \uHv \wH H Hx \yHz .{H| \}H~ \H@ YAHB .CHD \EHF \GHH \IHJ \KHL \MHN \OHP \QHR \SHT ZUHV ZWHX \YH H HZ \[H\ \]H^ \_H` \aHb \cHd \eHf \gHh \iHj \kHl \mHn \oHp \qHr \sHt \uHv \wHx \yHz \{H H H| \}H~ \H@ \AHB \CHD \EHF \GHH \IHJ \KHL \MHN \OHP \QHR \SHT \UHV \WHX \YHZ \[H\ \]H H H^ \_H` \aHb \cHd \eHf \gHh \iHj ZkHl ZmHn \oHp \qHr \sHt \uHv \wHx ]yHz ]{H| ]}H~ \H H H@ \AHB ]CHD ]EHF ZGHH ]IHJ ]KHL ]MHN ]OHP ]QHR .SHT ]UHV ]WHX ]YHZ ][H\ ]]H^ ]_H` ]aH H Hb ]cHd ]eHf ]gHh 0iHj 0kHl 0mHn ]oHp .qHt ]uHx ]yHz ]{H~ ]H@ 0AHB -CHD ]EHF -GHH ]IH H HJ ]KHL ]MHN ]OHP -QHR .SHT ]UHV ]WHX ]YHZ ][H\ ]]H^ ]_H` ]aHb ]cHd ]eHf ]gHh ]iHj ]kH H Hl ]mHn ]oHp ZqHr ZsHt ZuHv ZwHx ]yHz ]{H| ]}H~ ^H@ -AHB ]CHD ]EHF ^GHH ]IHJ ]KHL ]MH H HN ]OHP ]QHR 0SHT ZUHV ZWHX ZYHZ Z[H\ Z]H^ ._H` ]aHb .cHf ]gHh ]iHj ]kHl ]mHn ]oHp .qH H Hr ]sHt ]uHv ]wHx ]yHz .{H| ]}H~ \H@	 .A	HB	 .C	HD	 ZE	HF	 ]G	HH	 ]I	HJ	 ]K	HL	 ]M	HN	 ]O	HP	 ]Q	HR	 ]S	H H HT	 ]U	HV	 ]W	HX	 ]Y	HZ	 ][	H\	 ]]	H^	 -_	Hb	 0c	Hd	 0e	Hf	 0g	Hh	 0i	Hj	 0k	Hl	 \m	Hn	 0o	Hp	 0q	Hr	 0s	Ht	 0u	Hv	 0w	H Hx	 ('.)1'''*'''O
H H HT
 .B$8 U
N NKA	A
h YiA	A
j I 6:!'%""## #  "#! ! %"+#+$4<  >C")Z9 kA	A
j  ''#!! !kA	A
 A	 A	 A		    c                    K   |                      |           d{V }|                     |                     |d                    S )a  
        fetches the current integer timestamp in milliseconds from the exchange server
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        Niso)publicGetPublicTime	parse8601safe_string)r
  paramsresponses      r  
fetch_timezokcoin.fetch_timei  sQ       11&99999999 ~~d..x??@@@r  returnc                    K   ddi}|                      |                     ||                     d{V }|                     |dg           }|                     |          S )a+  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-public-data-get-instruments
        retrieves data on all markets for okcoin
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        instTypeSPOTNdata)publicGetPublicInstrumentsextend
safe_valueparse_markets)r
  r  requestr  marketss        r  fetch_marketszokcoin.fetch_marketsx  sr       
 88Wf9U9UVVVVVVVV//(FB77!!'***r  c                 l   |                      |d          }|                     |d          }|dk    rd}|dk    }|dk    }|dk    }|dk    }|p|p|}|                      |d          }	|                      |d	          }
|                     |	          }|                     |
          }|d
z   |z   }|                      |d          }|                     | j        |di           }|                      |dd          }t          j        |d          }|                     |d          }|                     |i d|d|d|d|dd d|	d|
dd d|d|d|ot          j	        |d          dddddddddddd d |r|                     |d          nd d d d d | 
                    |d           |                     |d!          |                     |          d"|                     d          |                     |          d#|                     |d$          d d#d d d#d |rd n|d#d%|d&
          S )'NinstIdr  futuresr@   r=   r?   rA   baseCcyquoteCcy/tickSzr   leverr   maxMktSzr0   symbolbasequotesettlebaseIdquoteIdsettleIdr  r>   FactiveTcontractlinearctVallistTimelotSz)amountpriceminmaxminSz)leverager8  r9  cost)
inversecontractSizeexpiryexpiryDatetimestrike
optionTypecreated	precisionlimitsinfo)r  safe_string_lowersafe_currency_codesafe_value_2r   r,   
string_maxsafe_numberr  	string_gtsafe_integerparse_number)r
  marketr0   r  r=   r@   r?   rA   r3  r/  r0  r,  r-  r+  tickSizer   maxLeveragemaxSpotCosts                     r  parse_marketzokcoin.parse_market  sA    fh//%%fj999D("("+6+V!!&)44""6:66&&v..''00e###FH55  D)R@@&&vw<<(c::&&vz::{{4 0"
"0"
f0"
 D0"
 U	0"

 d0"
 f0"
 w0"
 0"
 D0"
 D0"
 dD 1+s C C0"
 E0"
 e0"
 e0"
 d0"
  !0"
" d#0"
$ AISD,,VW===t"((<<**67;;**844   ,,S11,,[99 
  ++FG<< 
   
  #+<44  $ _0"
 0"
 0"
 0 0 0	r  c                 <    dddd}|                      |||          S )NBTCOMNITRC20)BitcoinOmniTRONr  )r
  	networkIdnetworksByIds      r  safe_networkzokcoin.safe_network  s1    
 

 iCCCr  c                   K   |                      d          s&| j        d         rt          | j        dz             dS |                     |           d{V }|                     |dg           }i }|                     |d          }t          |                                          }t          dt          |                    D ].}||         }|                     |          }	|	d         }
||         }i }d}d}d}d}t          dt          |                    D ]}||         }|                     |d	          }|r|n|}|                     |d
          }|r|n|}|                     |d          }|r|r|rdnd}|r|n|}|                     |d          }| |                    d          dk    r|                    d          }|                     |d|          }|                     |          }|                     |                     |d                    }||}nt#          j        ||          }||||||                     |d          |                     |          d|                     |d          |                     |d          di|d	||<   |                     |d          }||
||                     |d          |||d|                     |          ddddi|d||
<   0|S )z
        fetches all available currencies on an exchange
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Fr  z fetchCurrencies() is a private API endpoint that requires authentication with API keys. Set the API keys on the exchange instance or exchange.options["warnOnFetchCurrenciesWithoutAuthorization"] = False to suppress self warning message.Nr  ccyr   codecanDepcanWdcanInternalTchain-r   wdTickSzminFeerk   minWdmaxWdr:  )	r0   networkr2  depositrk   feerG  rH  rI  r1   r8  )rI  rd  r0   r1   r2  ro  rk   rp  rG  rH  r  )check_required_credentialsr  r   r0   privateGetAssetCurrenciesr  group_bylistkeysrangelensafe_currencyr  findsplitra  parse_precisionr,   
string_minrN  rQ  )r
  r  r  r  resultdataByCurrencyIdcurrencyIdsi
currencyIdcurrencyrd  chainsr  currencyActivedepositEnabledwithdrawEnabledmaxPrecisionjrh  
canDepositcanWithdrawrg  r2  r_  parts	chainPartnetworkCoderG  
firstChains                                r  fetch_currencieszokcoin.fetch_currencies  s      ..u55 J	|GH _#DG  /^  %^  _  _  _4!;;FCCCCCCCCH??8VR88DF#}}T599/446677K1c+..// ? ?(^
--j99')*5!&!&"'#q#f++.. " "A"1IE!%!A!AJ4>%SZZ^N"&//%"A"AK6A&WkkO"&//%"G"GK&0\[\[\TTW\F06%KVV^N $ 0 0 @ @I!-INN34G4G14L4L ) 4 4$($4$4UAy$I$I	&*&7&7	&B&B$($8$89I9I%Q[9\9\$]$]	'/+4LL+2+=lI+V+VL"+'2&,'1(3#'#3#3E8#D#D)-):):9)E)E *+/+;+;E7+K+K+/+;+;E7+K+K-" -"' %*1 1-  "__VQ77
" $ ,,Z@@,- /!%!2!2<!@!@ #'#'# # !)!   t$ Mr  Nr+  limitc                   K   |                                   d{V  |                     |          }d|d         i}|dn|}|||d<   |                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     |d          }	|                     |||	          S )	aH  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-market-data-get-order-book
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        Nr#  r0   r9   szr  r   ts)load_marketsrR  publicGetMarketBooksr  r  rP  parse_order_book)
r
  r+  r  r  rR  r  r  r  first	timestamps
             r  fetch_order_bookzokcoin.fetch_order_book2  s       !!!!!!!!!V$$fTl
 }5!GDM224;;w3O3OPPPPPPPP, x44a,,%%eT22	$$UFI>>>r  rR  c                 :   |                      |d          }|                     |d          }|                     ||d          }|d         }|                     |d          }|                     |d          }|                     |dd          }|r|                     |d	          n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 |          S )!Nr  r#  ri  r+  lastopen24hr=   F	volCcy24hvol24hhigh24hlow24hr  datetimehighlowbidbidPx	bidVolumebidSzaskaskPx	askVolumeaskSzvwapopenclosepreviousClosechange
percentageaverage)
baseVolumequoteVolumerI  )rP  r  safe_market	safe_boolsafe_tickeriso8601)r
  tickerrR  r  marketIdr+  r  r  r=   r  r  r  r  s                r  parse_tickerzokcoin.parse_ticker^  s<   * %%fd33	##FH55!!(FC88!//	22~~ffe44?CMd&&v{;;;%%fh77
	22vx00 !
f!
!
 Y//!
 D	!

 3!
 4##FG44!
 ))&'::!
 4##FG44!
 ))&'::!
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
 !
 !
* +  	r  c                 ^  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     ||          S )a  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-market-data-get-ticker
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr#  r0   r  r   )r  rR  publicGetMarketTickerr  r  r  )r
  r+  r  rR  r  r  r  r  s           r  fetch_tickerzokcoin.fetch_ticker  s       !!!!!!!!!V$$fTl
 33DKK4P4PQQQQQQQQx44a,,6   ///r  symbolsc                    K   |                      |          }ddi}|                     |                     ||                     d{V }|                     |dg           }|                     |||          S )a#  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-market-data-get-tickers
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        r  r  Nr  )market_symbolspublicGetMarketTickersr  	safe_listparse_tickers)r
  r  r  r  r  r  s         r  fetch_tickerszokcoin.fetch_tickers  s       %%g..
 44T[[&5Q5QRRRRRRRR~~h33!!$888r  c                    |                      |d          }|                      |d          }|                     ||d          }|d         }|                     |d          }|                     |dd          }|                     |dd	          }|                      |d
          }	|                      |d          }
|                      |d          }d }|Dt	          j        |          }|                      |d          }|                     |          }||d}|                      |d          }|dk    rd}n|dk    rd}|                     |||                     |          |||
d ||	||d |d|          S )NtradeIdr#  ri  r+  r  fillPxpxfillSzr  sideordIdrp  feeCcyr?  r  execTypeTr   Mr   )rI  r  r  r+  r0   orderr  takerOrMakerr  r9  r8  r?  rp  )	r  r  rP  safe_string_2r,   
string_negrK  
safe_trader  )r
  traderR  r0   r  r+  r  r9  r8  r  orderIdfeeCostStringrp  feeCostSignedfeeCurrencyIdfeeCurrencyCoder  s                    r  parse_tradezokcoin.parse_trade  s   B eY//##E844!!(FC88!%%eT22	""5(D99##E8T::v..""5'22((66$#.}==M ,,UH==M"55mDDO%+ C ''z::3"LLS  "L"Y//( 
  
   	r  sincec                   K   |                                   d{V  |                     |          }||dk    rd}d|d         i}d}|                     |ddd          \  }}d}|dk    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |dg           }	|                     |	|||          S )	a  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-market-data-get-trades
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-market-data-get-trades-history
        get the list of most recent trades for a particular symbol
        :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>`
        Nd   r#  r0   rc   methodpublicGetMarketTradesr  )r  rR  handle_option_and_paramsr  r  publicGetMarketHistoryTradesr  parse_trades)
r
  r+  r  r  r  rR  r  r  r  r  s
             r  fetch_tradeszokcoin.fetch_trades  s-      !!!!!!!!!V$$Mus{{EfTl
 66v}hXopp,,,!77GV8T8TUUUUUUUUHH!>>t{{7TZ?[?[\\\\\\\\H~~h33  vue<<<r  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   r   r      r   r   )rP  rN  )r
  ohlcvrR  s      r  parse_ohlcvzokcoin.parse_ohlcv6  s     eQ''UA&&UA&&UA&&UA&&UA&&
 	
r  rm   c                   K   |                                   d{V  |                     |          }|                     |          }|                     | j        di           }|                     | j        ||          }	|                     |dd          }
|
dk    r|dk    r|	|
                                z  }	|d         |	d}|||d<   d}|                     |dd	d
          \  }}d}|d
k    r0| 	                    | 
                    ||                     d{V }n/|                     | 
                    ||                     d{V }|                     |dg           }|                     |||||          S )a  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-market-data-get-candlesticks
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-market-data-get-candlesticks-history
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        NrX   timezoneUTCi`T  r0   )r#  barr  r  publicGetMarketCandlesr  )r  rR  parse_timeframer  r  r  rl   lowerr  r  r  publicGetMarketHistoryCandlesr  parse_ohlcvs)r
  r+  	timeframer  r  r  rR  durationr  r  r  r  r  r  r  s                  r  fetch_ohlcvzokcoin.fetch_ohlcvM  s      !!!!!!!!!V$$''	22//$,bAAt	9EE##GZ??H$5$58>>###CTl
 
 $GG66v|XWopp---!88Wf9U9UVVVVVVVVHH!??GU[@\@\]]]]]]]]H~~h33  vy%GGGr  c                    |d d d}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d          |d	<   |||<   |                     |          S )
N)rI  r  r  r   r  balancetotalholdused	availablefree)rv  rw  r  rK  accountsafe_balance)r
  r  r}  r  r  r  rd  r  s           r  parse_account_balancezokcoin.parse_account_balanceq  s    V 
 

 q#h--(( 	# 	#AqkG))':>>J**:66DllnnG#//CCGG"..w??GFO"..wDDGFO"F4LL  (((r  c                   K   |                                   d{V  |                     dd|          \  }}i }d}|dk    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|dk    r|                     |          S |                     |          S )a!  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        NrG   r  )r  handle_market_type_and_paramsprivateGetAssetBalancesr  privateGetAccountBalanceparse_funding_balanceparse_trading_balance)r
  r  
marketTypequeryr  r  s         r  fetch_balancezokcoin.fetch_balance  s       !!!!!!!!! >>~tU[\\
E
 ""!99$++gu:U:UVVVVVVVVHH!::4;;wPU;V;VWWWWWWWWH& ""--h777--h777r  c                    d|i}|                      |dg           }|                      |di           }|                     |d          }|                      |dg           }t          dt          |                    D ]}||         }|                     |d          }	|                     |	          }
|                                 }|                     |d          }|                     |d          }||3|                     |d	          |d
<   |                     |d          |d<   n
||d<   ||d
<   |||
<   ||d<   |                     |          |d<   |                     |          S )NrI  r  r   uTimedetailsrc  eqavailEqavailBalr  	frozenBalr  r  r  r  )	r  rP  rv  rw  r  rK  r  r  r  )r
  r  r}  r  r  r  r  r  r  r  rd  r  r  r  s                 r  r  zokcoin.parse_trading_balance  sv   (#x44a,,%%eW55	//%B77q#g,,'' 	# 	#AajG))'599J**:66DllnnG!!'400B&&w	::G
"&"2"27J"G"G"&"2"27K"H"H#% ")"F4LL'{!\\)44z  (((r  c                    d|i}|                      |dg           }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d	          |d
<   |||<   |                     |          S )NrI  r  r   rc  balr  r  r  r  r  )r  rv  rw  r  rK  r  r  )	r
  r  r}  r  r  r  r  rd  r  s	            r  r  zokcoin.parse_funding_balance  s    (#x44q#d))$$ 		# 		#A1gG))'599J**:66DllnnG#//??GG"..w
CCGFO"..wDDGFO"F4LL  (((r  r?  c                    K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d<   d|d<   |                     |dd	|d|           d{V S )
a  
        create a market buy order by providing the symbol and cost
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-place-order
        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr=   z9 createMarketBuyOrderWithCost() supports spot orders onlyFr  	quote_ccytgtCcyrR  buy)r  rR  r$   r0   create_order)r
  r+  r?  r  rR  s        r  !create_market_buy_order_with_costz(okcoin.create_market_buy_order_with_cost  s       !!!!!!!!!V$$f~ 	ftw)ddeee6;23&x&&vxdFSSSSSSSSSr  r  r  r8  r9  c                   K   |                                   d{V  |                     |          }|                     ||||||          }|                     | j        dd          }	|                     |d          }
|
dk    s|
dk    s|dk    s|dk    s|d	k    s|d
k    rd}	|	dk    r|g}d}|	dk    r|                     |           d{V }n[|	dk    r|                     |           d{V }n9|	dk    r|                     |           d{V }nt          | j	        dz             | 
                    |dg           }| 
                    |d          }|                     ||          }||d<   ||d<   |S )a	  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-place-order
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-place-algo-order
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-place-multiple-orders
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-cancel-advance-algo-order
        create a trade order
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float price: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param bool [params.reduceOnly]: MARGIN orders only, or swap/future orders in net mode
        :param bool [params.postOnly]: True to place a post only order
        :param float [params.triggerPrice]: conditional orders only, the price at which the order is to be triggered
        :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only)
        :param float [params.takeProfit.triggerPrice]: take profit trigger price
        :param float [params.takeProfit.price]: used for take profit limit orders, not used for take profit market price orders
        :param str [params.takeProfit.type]: 'market' or 'limit' used to specify the take profit price type
        :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only)
        :param float [params.stopLoss.triggerPrice]: stop loss trigger price
        :param float [params.stopLoss.price]: used for stop loss limit orders, not used for stop loss market price orders
        :param str [params.stopLoss.type]: 'market' or 'limit' used to specify the stop loss price type
        :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>`
        NrF   privatePostTradeBatchOrdersordTypetriggerconditionalocomove_order_stopicebergtwapprivatePostTradeOrderAlgoprivatePostTradeOrderz createOrder() self.options["createOrder"] must be either privatePostTradeBatchOrders or privatePostTradeOrder or privatePostTradeOrderAlgor  r   r  r  )r  rR  create_order_requestr  r  r#  r"  r  r   r0   r  parse_order)r
  r+  r  r  r8  r9  r  rR  r  r  requestOrdTyper  r  r  r  s                  r  r  zokcoin.create_order  s     6 !!!!!!!!!V$$++FD$vVV!!$,?\]]))'9==i''^}-L-LRVZ_R_R_eim~e~e~  EI  MV  EV  EV  \`  dj  \j  \j0F222 iG,,,!77@@@@@@@@HH222!;;GDDDDDDDDHH444!==gFFFFFFFFHH  +x  !x  y  y  yx44a((  //ffr  c                    |                      |          }|d         ||d}|                     |g d          }	|                     |dd          }
|                     |dd          }|                     |d|          }|                     |d	d
          }|                     |dd          }|                     |d|          }|                     |dd
          }|                     |dd          }|                     |d          }|d u}|                     |d          }|d u}|                     | j        ddd          }|                     |dd          }d}|	|dk    rd}n|}|                     |dd          }|rE|dk    r|d         n|d         }|                     |d|          }|                     |          |d<   |r|nd}||d<   |dk    }d}| 	                    ||d k    |          \  }}| 
                    |g d!          }|
d"k    p|d#k    }|
d$k    p|d%k    }|	d up|d&k    } |d up	|d up|d'k    }!|r|p|d(k    }"|                     | j        d)d*          }#|                     |d)|#          }$|s|$|d)<   |s|"r:d|d+<   |dk    r|$d,k    rd }%d}&|                     |d-d.d          \  }&}|                     |d/d0          }'| 
                    |d/d0g          }|'|                     ||'          }%n|&ro|t          | j        d1z             |                     |          }(|                     |          })t#          j        |(|)          }*|                     ||*          }%n|                     ||          }%|%|d0<   nj|                     ||          |d0<   nP|                     ||          |d0<   n6|                     ||          |d0<   | s|!s|                     ||          |d2<   |rd |d+<   n|r	|"sd#|d+<   ny|rd%|d+<   np|s|r|rK|                     |g d3          }+|+t          | j        d4z             |                     ||+          |d<   |                     |g d5          },|                     |d6          }-|-h|-d7k    }.|-dk    }/|.s|/st          | j        d8z             |.r3|,t          | j        d9z             |                     ||,          |d<   n-|-dk    rd:|d<   n!|,|                     ||,          |d<   nd:|d<   |                     |d;dd
          }0|0.|0d
k    r#|0d<k    r|0d=k    rt          | j        d>z             |0|d<   |rK|                     |g d?          }1|1t          | j        d@z             |                     ||1          |d<   |                     |g dA          }2|                     |d6          }3|3h|3d7k    }4|3dk    }5|4s|5st          | j        dBz             |4r3|2t          | j        dCz             |                     ||2          |d<   n-|3dk    rd:|d<   n!|2|                     ||2          |d<   nd:|d<   |                     |d;d	d
          }6|6.|6d
k    r#|6d<k    r|6d=k    rt          | j        dDz             |6|d	<   n| r<d&|d+<   |                     ||	          |dE<   |rd:n|                     ||          |dF<   n|!rd'|d+<   |d uo|d u}7|7rdG|d+<   |;|                     ||          |d<   |d:n|                     ||          |d<   ||d	<   |;|                     ||          |d<   |d:n|                     ||          |d<   ||d<   |=|                     | j        dH          }8|8|8|                                 z   |d<   |8|dI<   n||d<   | 
                    |ddg          }|                     ||          S )JNr0   )r#  r  r  )triggerPrice	stopPrice	triggerPxtimeInForceGTCtakeProfitPricetpTriggerPxtpOrdPxtpTriggerPxTyper  stopLossPriceslTriggerPxslOrdPxslTriggerPxTypeclOrdIdclientOrderIdstopLoss
takeProfitdefaultMarginMode
marginModecrosstdModeFcashTr>   r  r-  r,  rc  rR  	post_only)r  rc  r:  r+  r)  r(  r6  r1  r-  r3  r/  r>   r7  r8  IOCiocFOKfokr  r  optimal_limit_iocr  base_ccyr  r  rF   r  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)  r2  z createOrder() requires a trigger price in params["stopLoss"]["triggerPrice"], or params["stopLoss"]["stopPrice"], or params["stopLoss"]["slTriggerPx"] for a stop loss order)r9  r1  r3  r  r  zL createOrder() params["stopLoss"]["type"] must be either "limit" or "market"z createOrder() requires a limit price in params["stopLoss"]["price"] or params["stopLoss"]["slOrdPx"] for a stop loss limit order-1triggerPriceTypeindexmarkzT createOrder() stop loss trigger price type must be one of "last", "index" or "mark")r(  r)  r.  z createOrder() requires a trigger price in params["takeProfit"]["triggerPrice"], or params["takeProfit"]["stopPrice"], or params["takeProfit"]["tpTriggerPx"] for a take profit order)r9  r-  r/  zN createOrder() params["takeProfit"]["type"] must be either "limit" or "market"z createOrder() requires a limit price in params["takeProfit"]["price"] or params["takeProfit"]["tpOrdPx"] for a take profit limit orderzV createOrder() take profit trigger price type must be one of "last", "index" or "mark"r*  orderPxr  brokerIdtag)rR  safe_value_nr  rL  r  r  r  r  rK  handle_post_onlyomitr  safe_number_2cost_to_precisionr!   r0   number_to_stringr,   
string_mulamount_to_precisionprice_to_precisionuuid16r  )9r
  r+  r  r  r8  r9  r  rR  r  r(  r+  r-  r/  r0  r1  r3  r4  r6  r7  stopLossDefinedr8  takeProfitDefinedr9  r:  r>   defaultCurrencyr  	tradeModeisMarketOrderpostOnlyr@  rB  r  r  	marketIOCdefaultTgtCcyr  quoteAmountr  r?  amountStringpriceStringcostRequeststopLossTriggerPricestopLossLimitPricestopLossOrderTypestopLossLimitOrderTypestopLossMarketOrderTypestopLossTriggerPriceTypetakeProfitTriggerPricetakeProfitLimitPricetakeProfitOrderTypetakeProfitLimitOrderTypetakeProfitMarketOrderTypetakeProfitTriggerPriceTypetwoWayConditionrJ  s9                                                            r  r$  zokcoin.create_order_requestB  s   V$$Tl 
 
4 ((1[1[1[\\&&v}eDD++F4E}UU//&)U;;**63DfMM))&/=QQ//&)U;;**63DfMM**69oNN??6:66#4/__V\::
't3 ..t|=PR^`ghh''hGG
"v)=)=FF*J^^FHe<<F 	?26%--fWoofVnO''GGH!44X>>GEN"(4JJf	%(00@SU[\\&6  $`  $`  $`  a  ae#7e#7t+C1B$D0moT6QmW[_lWl"*sL8K0K	((xLL!!&(MBB 	' &GH  	GI  	G!)GIu}} [(("&K8<5@D@]@]^dfs  vY  [_  A`  A`=5v--ffdCCD!YYv~>>F'&*&<&<VT&J&J: 	M =".tw  :E  0E  #F  #F  F+/+@+@+H+HL*.*?*?*F*FK*1*<\;*W*WK*.*@*@*U*UKK&*&<&<VV&L&L$/GDMM$($<$<VV$L$LGDMM $ 8 8 H H 44VVDDGDM Gk G $ 7 7 F F Q	=!,GI O	= O	=!&GI M	=!&GI K	= 1 K	= J'+'8'8CoCoCo'p'p$'/&tw  2a  (a  b  b  b)-)@)@I])^)^&%)%6%6xAfAfAf%g%g"$($4$4Xv$F$F!$0.?7.J*/@H/L+2 2=T 2*47  6D  ,D  E  E  E/ 2-5".tw  :}  0}  #~  #~  ~151H1HQc1d1dGI..*h66-1	*'3)-)@)@I[)\)\GI&&)-GI&+/+=+=hHZ\mou+v+v(+70F::AY]dAdAd  lD  HN  lN  lN*47  6L  ,L  M  M  M1IG-.  L)-):)::GsGsGs)t)t&)1&tw  2i  (i  j  j  j)-)@)@I_)`)`&'+'8'8ElElEl'm'm$&*&6&6z6&J&J#&20Cw0N,1D1P-4 2?X 2*47  6F  ,F  G  G  G1 2/7".tw  :C  0C  #D  #D  D151H1HQe1f1fGI..,88-1	*)5)-)@)@I])^)^GI&&)-GI&-1-?-?
L^`qsy-z-z*-92f<<C]ahChCh  pJ  NT  pT  pT*47  6N  ,N  O  O  O1KG-. 	=!*GI#'#:#:6<#P#PGK )6!bD<S<STZ\a<b<bGI 	=!.GI /t ;\-W[B[O  +%*	"*)-)@)@)Y)Y&.5oTTDD[D[\bdkDlDl	"-<)*()-)@)@)W)W&.5oTTDD[D[\bdkDlDl	"-<)* ''jAAH#%-%=	"!)!.GIYYv	?'CDDF{{7F+++r  r0   c                   K   |t          | j        dz             |                                  d{V  |                     |dd          }|                     |d          }|s|r4|                     |g||           d{V }|                     |d          S |                     |          }d|d         i}|                     |d	d
          }	|	|	|d	<   nt          |          |d<   | 	                    |d	d
g          }
| 
                    |                     ||
                     d{V }|                     |dg           }|                     |d          }|                     ||          S )a  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-cancel-order
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-cancel-algo-order
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-cancel-advance-algo-order
        cancels an open order
        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param bool [params.stop]: True if cancel trigger or conditional orders
        :param bool [params.advanced]: True if canceling advanced orders only
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) cancelOrder() requires a symbol argumentstopr  advancedr   r#  r0   r5  r6  r  r  )r   r0   r  rL  r  cancel_ordersrR  r  strrN  privatePostTradeCancelOrderr  	safe_dictr%  )r
  r0   r+  r  rp  rq  
orderInnerrR  r  r6  r  r  r  r  s                 r  cancel_orderzokcoin.cancel_order  s      >#DG.Y$YZZZ!!!!!!!!!  ;;??6:66 	28 	2#112$GGGGGGGGJ??:q111V$$fTl

 **69oNN$!.GI"2wwGG		&9o">??99$++gu:U:UVVVVVVVVx44tQ''v...r  c                 Z    t          |t                    r|                    d          S |S )zq
         * @ignore
        :param string[]|str ids: order ids
        :returns str[]: list of order ids
        ,)
isinstancers  rz  )r
  idss     r  	parse_idszokcoin.parse_ids*  s+     c3 	99S>>!Jr  c                   K   |t          | j        dz             |                                  d{V  |                     |dd          }|                     |d          }|                     |g d          }|                     |          }g }|                     |                     |dd                    }|                     |                     |d	                    }	||                     |          }|	Dt          d
t          |	                    D ]&}
|
                    |	|
         |d         d           't          d
t          |                    D ]O}
|s|r%|
                    ||
         |d         d           +|
                    ||
         |d         d           PnDt          d
t          |                    D ]&}
|
                    |d         ||
         d           'd}|r|                     |           d{V }n9|r|                     |           d{V }n|                     |           d{V }|                     |dg           }|                     ||dd|          S )a8  
        cancel multiple orders
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-cancel-multiple-orders
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-cancel-algo-order
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-cancel-advance-algo-order
        :param str[] ids: order ids
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz* cancelOrders() requires a symbol argumentrp  r  rq  )rp  r  rq  r5  r6  algoIdr   r0   )r~  r#  )r  r#  )r#  r5  r  )r   r0   r  rL  r  rN  rR  r|  rv  rw  appendprivatePostTradeCancelAlgos"privatePostTradeCancelAdvanceAlgos!privatePostTradeCancelBatchOrdersr  parse_orders)r
  r{  r+  r  rp  rq  rR  r  clientOrderIdsalgoIdsr  r  
ordersDatas                r  rr  zokcoin.cancel_orders5  s      >#DG.Z$Z[[[!!!!!!!!!  ;;??6:666#B#B#BCCV$$(9(9&)_(](]^^..!B!BCC!..%%C"q#g,,//  ANN")!*"(,$ $     1c#hh'' 
 
 	8 	NN"%a&"(,$ $    
 NN!$Q"(,$ $    
 1c.1122  $Tl-a0         	M!==gFFFFFFFFHH 	M!DDWMMMMMMMMHH!CCGLLLLLLLLH" ^^Hfb99
  VT4HHHr  c                 @    dddddd}|                      |||          S )Ncanceledr  closed)r  livepartially_filledfilled	effectiver^  r
  statusstatusess      r  parse_order_statuszokcoin.parse_order_status}  s7    " &!
 
 &&999r  c                 v   |                      |dd          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }d }	d }
|dk    rd	}	d
}n|dk    rd}
d
}n
|dk    rd}
d
}|                     |d          }|                     ||          }|                     ||d          }|                     |d          }|                      |dd          }|                     |d          }|                     |                     |d                    }|                     |d          }d }d }|                     | j        dd          }|                     |d|          }|dk    r#|dk    r|dk    r|                     |d          }n|                     |d          }d }|Wt          j        |          }|                     |d          }| 	                    |          }| 
                    |          |d}|                     |d          }|t          |          d k     rd }|                     |d!d"          }|                     |d#d$          }|                     |d%d&g          }|                     |d'          }d(}||d)k    }|                     i d*|d+|d,|d-|d.|                     |          d/|d0|d1|d2|d3|
d4|	d|d5|d6|d7|d8|d9|||||d ||d |d:	|          S );Nr~  r  cTimer  fillTimer  r  r>  Tr  rB  rA  r@  r?  r#  ri  	accFillSzr  ordPxavgPxstaterp  r  rD  r  rR  r  r  r  r  r5  r   r2  r3  r.  r/  r*  moveTriggerPx
reduceOnlyFtruerI  r0   r6  r  r  lastTradeTimestamplastUpdateTimestampr+  r  r+  r[  r9  r1  r-  r)  r(  )	r  r?  r8  r  	remainingr  rp  tradesr  )r  rP  r  r  safe_symbolr  r  r,   r  rK  rQ  rw  rO  safe_number_n
safe_orderr  ) r
  r  rR  r0   r  r  r  r  r  r[  r+  r  r+  r  r9  r  r  r  r8  r?  r]  r  rp  r  r  r  r6  r1  r-  r)  reduceOnlyRawr  s                                    r  r%  zokcoin.parse_order  s<   T x99%%eW55	"//w??!..ujAAv..y11;HDDU]]KDDU]]KD##E844!!(F33!!(FC88!!%55""5$88""5'22(()9)9%)I)IJJ((66 ((xLL!!%=AAEMM 0 0v7L7L##E400DD %%eT22F$#.}==M ,,UH==M"55mDDO))-88+ C ((	::%C,>,>,B,B M**5-KK,,UM9MM&&u{O.LMM	((==
!'61J  
E 
" 
 ] 
 	 

 Y// 
 !"4 
 "#6 
 f 
 D 
 ; 
  
 D 
 U 
 ] 
  
  ! 
" I# 
$ $5 
  
  
6 7  	r  c                   K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}|                     |dd          }|                     |dd          }|r|||d	<   n||d
<   n|||d<   n||d<   |                     |g d          }d}	|r0|                     |                     ||                     d{V }	n/| 	                    |                     ||                     d{V }	| 
                    |	dg           }
|                     |
d          }|                     |          S )a  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-get-order-details
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-get-algo-order-list
        fetches information on an order made by the user
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz( fetchOrder() requires a symbol argumentr#  r0   r5  r6  rp  r  algoClOrdIdr~  r  )r6  rp  r  r  r   )r   r0   r  rR  r  rL  rN  privateGetTradeOrderAlgor  privateGetTradeOrderr  ru  r%  )r
  r0   r+  r  rR  r  r6  rp  r  r  r  r  s               r  fetch_orderzokcoin.fetch_orderF  s      >#DG.X$XYYY!!!!!!!!!V$$fTl

 **69oNN  ;; 		&()6&&$&!!(%2	""#% 		&"F"F"FGG 	T!::4;;wPU;V;VWWWWWWWWHH!66t{{7E7R7RSSSSSSSSHx44tQ''&&&r  c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |||d<   |                     |d          }|                     |d          p|                     |d          du}|r|d|d<   |                     |dg          }d}	|r0|                     |                     ||                     d{V }	n/|                     |                     ||                     d{V }	|                     |	dg           }
| 	                    |
|||          S )	a+  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-get-order-list
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-get-algo-order-list
        fetch all unfilled currently 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
        :param bool [params.stop]: True if fetching trigger or conditional orders
        :param str [params.ordType]: "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr0   r#  r  r  rp  r  r  )
r  rR  r  r  rN   privateGetTradeOrdersAlgoPendingr  privateGetTradeOrdersPendingr  r  )r
  r+  r  r  r  r  rR  r  rp  r  r  s              r  fetch_open_orderszokcoin.fetch_open_ordersn  s      !!!!!!!!!
 [[((F &tGH$GG""6955vv..c43C3CFI3V3V^b3b 	+W_!*GI6F8,, 	]!BB4;;wX^C_C_````````HH!>>t{{7TZ?[?[\\\\\\\\H~~h33  vue<<<r  c                   K   |                                   d{V  ddi}d}| |                     |          }|d         |d<   |                     |d          }|                     |d          p|                     |d          du}|r|d|d<   |                     |dg          }d}	|r0|                     |                     ||                     d{V }	nd}
|                     |d	d
d          \  }
}|
dk    r0|                     |                     ||                     d{V }	n/| 	                    |                     ||                     d{V }	| 
                    |	dg           }|                     ||||          S )a  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-get-algo-order-history
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-get-order-history-last-3-months
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-get-order-history-last-7-days
        fetches information on multiple closed orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param bool [params.stop]: True if fetching trigger or conditional orders
        :param str [params.ordType]: "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr  r  r0   r#  r  rp  r  rN   r  privateGetTradeOrdersHistoryr  )r  rR  r  r  rN   privateGetTradeOrdersAlgoHistoryr  r  r  #privateGetTradeOrdersHistoryArchiver  r  )r
  r+  r  r  r  r  rR  r  rp  r  r  r  s               r  fetch_closed_orderszokcoin.fetch_closed_orders  s      !!!!!!!!!
 [[((F &tGH""6955vv..c43C3CFI3V3V^b3b 	+W_!*GI6F8,, 	h!BB4;;wX^C_C_````````HHF!::6CVX`  cA  B  BNFF777!%!B!B4;;wX^C_C_!`!```````!%!I!I$++V]_eJfJf!g!gggggggT ~~h33  vue<<<r  r  c                    |                      |d          }|                     |g d          }|-|                     |di           }|                      |d          }|                      |d          }|                     ||          }|d         }|                      |d          }|                    |dz   d	          }	|                     |	          }
|                     |           ||||
|d
S )Naddr)rK  pmtIdmemoaddrExcommentrc  rd  rh  ri   )r  addressrK  rn  rI  )r  safe_string_nr  rx  replacenetwork_id_to_codecheck_address)r
  depositAddressr  r  rK  r  r  rd  rh  r_  rn  s              r  parse_deposit_addresszokcoin.parse_deposit_address  s   : "">6::  1I1I1IJJ;__^XrBBF""6955C%%ne<<
%%j(;;  99MM*s"2B77	)))44T 	7###"
 
 	
r  rd  c                   K   |                                   d{V  |                     | j        dd          }|                     |d|          }|                     |          }|                     |d          }|                     ||           d{V }|                     ||          }| t          | j        dz   |z   dz   |z             |S )a  
        fetch the deposit address for a currency associated with self account
        :see: https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-deposit-address
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        Nr  r  rn  z# fetchDepositAddress() cannot find z deposit address for )	r  r  r  r  rN  "fetch_deposit_addresses_by_networkr  r    r0   )r
  rd  r  r  r_  r  r  r}  s           r  fetch_deposit_addresszokcoin.fetch_deposit_addressB  s       !!!!!!!!!))$,8H'RR$$VYGG	--i8869--@@vNNNNNNNN;77> +P!PS^!^ax!x{!  A  A  Ar  c                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     |dd          }|                     ||d         gd          }|                     |d	          S )
a  
        fetch a dictionary of addresses for a currency, indexed by network
        :see: https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-deposit-address
        :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: a dictionary of `address structures <https://docs.ccxt.com/#/?id=address-structure>` indexed by the network
        Nrc  r0   r  selectedTrd  Frn  )r  r  privateGetAssetDepositAddressr  r  	filter_byparse_deposit_addressesindex_by)	r
  rd  r  r  r  r  r  filteredparseds	            r  r  z)okcoin.fetch_deposit_addresses_by_networkU  s       !!!!!!!!!==&&8D>
 ;;DKKQW<X<XYYYYYYYY, x44>>$
D99--h&9I8JERR}}VY///r  fromAccount	toAccountc                 4  K   |                                   d{V  |                     |          }|                     | j        di           }|                     |||          }|                     |||          }	|d         |                     ||          d||	d}
|dk    r?d|
d<   |	|
d	<   |                     |d
d          |
d
<   |                     |dd          |
d<   nD|	dk    r>d|
d<   ||
d	<   |                     |d
d          |
d
<   |                     |dd          |
d<   |                     |                     |
|                     d{V }|                     |dg           }|                     |di           }| 	                    ||          S )a$  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-funding-funds-transfer
        transfer currency internally between wallets on the same account
        :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  r0   0)rc  amtr  fromtomasterr   r  subAcctr  r  r  r   r  r   )
r  r  r  r  r  currency_to_precisionprivatePostAssetTransferr  ru  parse_transfer)r
  rd  r8  r  r  r  r  r  fromIdtoIdr  r  r  rawTransfers                 r  rj   zokcoin.transfer}  s      !!!!!!!!!==&&7GLL!!.+{KK	9EED>--dF;;

 

 X!GFO!%GI"..vvsCCGFO ,,VT3??GDMMX!GFO!'GI"..vvsCCGFO ,,VT3??GDM66t{{7F7S7STTTTTTTT  x44nnT1b11"";999r  c                    |                      |dd          }|                     |d          }|                     ||          }|                     |d          }|                     |d          }|                     |d          }|                     | j        di           }	|                     |d|                                           }
|                     |d	          }|'|                     t          j
        |                    }|||
|                     |
          |||                     |	|          |                     |	|          |                     |                     |d
                    d	S )NtransIdbillIdrc  r  r  r  r  r  r  r  )	rI  r0   r  r  r  r8  r  r  r  )r  r  rK  rN  r  r  rP  millisecondsrQ  r,   
string_absr  parse_transfer_status)r
  rj   r  r0   r  rd  r8  fromAccountIdtoAccountIdr  r  balanceChanges               r  r  zokcoin.parse_transfer  sl   j )X>>%%h66
&&z8<<!!(E22((6::&&x66t|^RHH%%hd6G6G6I6IJJ	((488$&&w'9-'H'HIIF"Y//++L-HH)),DD001A1A(G1T1TUU

 

 
	
r  c                 8    ddi}|                      |||          S )Nsuccessokr^  r  s      r  r  zokcoin.parse_transfer_status	  s(    t
 &&999r  c                 D  K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }|t	          |          dk    r|dz   |z   }|d         |d|                     |          d}|                     |d          }|l|                     | j        di           }	|                     |	|	                                |          }|d         d	z   |z   |d
<   | 
                    |d          }|                     |d          }
|
_|                     |d         |                     |          i           }|                     |d          }
|
t          | j        dz             |                     |
          |d<   |                     |                     ||                     d{V }|                     |dg           }|                     |d          }|                     ||          S )a  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-funding-withdrawal
        make a withdrawal
        :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>`
        Nr   :r0   4)rc  toAddrdestr  rn  r  ri  rh  rp  u    withdraw() requires a "fee" string parameter, network transaction fee must be ≥ 0. Withdrawals to OKCoin or OKX are fee-free, please set "0". Withdrawing to external digital asset address requires network transaction fee.r  )handle_withdraw_tag_and_paramsr  r  r  rw  rQ  r  r  r  upperrN  r  r   r0   privatePostAssetWithdrawalr  ru  parse_transaction)r
  rd  r8  r  rK  r  r  r  rn  r  rp  targetNetworkr  r  transactions                  r  rk   zokcoin.withdraw	  s@      99#vFFV7###!!!!!!!!!==&&O#c((Q,,mc)GD>((00	
 
 ""6955t|ZDDH&&x'JJG'~3g=GGYYvy11Fvu--; OOHZ,@$BYBYZaBbBbdfggM""=%88C{'  3U  )U  V  V  V..s3388Wf9U9UVVVVVVVV x44nnT1--%%k8<<<r  c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |t          |dz
  d          |d<   |||d<   |                     d||          \  }}|                     |                     ||                     d{V }|                     |d	g           }|                     |||||          S )
a  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-funding-get-deposit-history
        fetch all deposits made to an account
        :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>`
        Nr0   rc  r   r   beforer  afterr  )r  r  r<  handle_until_optionprivateGetAssetDepositHistoryr  r  parse_transactions	r
  rd  r  r  r  r  r  r  r  s	            r  fetch_depositszokcoin.fetch_deposits>	  s      !!!!!!!!!
 }}T**H%d^GEN #EAIq 1 1GH$GG227GVLL;;DKKQW<X<XYYYYYYYYN ~~h33&&tXueVLLLr  c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |t          |dz
  d          |d<   |||d<   |                     d||          \  }}|                     |                     ||                     d{V }|                     |d	g           }|                     |||||          S )
a+  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-funding-get-withdrawal-history
        fetch all withdrawals made from an account
        :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>`
        Nr0   rc  r   r   r  r  r  r  )r  r  r<  r   privateGetAssetWithdrawalHistoryr  r  r  r  s	            r  fetch_withdrawalszokcoin.fetch_withdrawals	  s      !!!!!!!!!
 }}T**H%d^GEN #EAIq 1 1GH$GG227GVLL>>t{{7TZ?[?[\\\\\\\\> ~~h33&&tXueVLLLr  c           
      H    dddddddddd	}|                      |||          S )Npendingr  failedr  )	z-3z-2rE  r  r   r   3r  5r^  r  s      r  parse_transaction_statuszokcoin.parse_transaction_status	  sE    2 

 

 &&999r  c                 <   d }d }|                      |d          }|                      |d          }|                      |d          }|}|                     |dd          }	|                     |d|	          }	|d}|}n|                      |d          }d	}|                      |d
          }
|                     |
          }|                     |d          }|                     |                      |d                    }|                      |d          }|                     |d          }d }|d	k    rd}n|                     |d          }i d|d|d|d|dd d|d|d|dd d|	d|	d|d|dd d|d|d |                     |          d d ||d!d"S )#NwdIdr  r  rK  r  r  
withdrawaldepIdro  rc  r  r  txIdr  r   rp  rI  r0   r  r8  rn  addressFrom	addressTor  tagFromtagTor  r  updatedtxidr  r  )r  r?  )r  internalrp  )r  r  rK  rN  r  rP  r  )r
  r  r  r  r0   withdrawalIdr  r  r  r
  r  rd  r8  r  r  r  feeCosts                    r  r  zokcoin.parse_transaction	  sj   P ''V<<&&{F;;$$[$77	"";v>>"";??#DBB !!+w77BD%%k599
&&z22!!+u55..t/?/?W/U/UVVV44%%k488	9GG&&{E::G
K
"
 
 f	

 t
 ;
 
 w
 t
 U
 5
 f
 D
 t
 D
  !
" Y//#
$   )
 
 
 	
r  c                   K   |                                   d{V  ddi}||dk    rd}d}| |                     |          }|d         |d<   d}|                     |ddd	          \  }}d}|d	k    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |d
g           }	|                     |	|||          S )a  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-get-transaction-details-last-3-days
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-get-transaction-details-last-3-months
        fetch all trades made by the user
        :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  r0   r#  rW   r  privateGetTradeFillsHistoryr  )r  rR  r  r  r  privateGetTradeFillsr  r  )
r
  r+  r  r  r  r  rR  r  r  r  s
             r  fetch_my_tradeszokcoin.fetch_my_tradesB
  sD      !!!!!!!!!
 ECKKE[[((F &tGH66vPXZwxx222!==dkk'SY>Z>Z[[[[[[[[HH!66t{{7F7S7STTTTTTTTH~~h33  vue<<<r  c           	      r   K   d|i}|                      ||||                     ||                     d{V S )a  
        fetch all the trades made from a single order
        :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>`
        order_idN)r  r  )r
  r0   r+  r  r  r  r  s          r  fetch_order_tradeszokcoin.fetch_order_tradesa
  sQ       
 ))&%GU[@\@\]]]]]]]]]r  c                   K   |                                   d{V  d}|                     |ddd          \  }}i }|||d<   d}| |                     |          }|d         |d<   |                     d||          \  }}d}|d	k    r0|                     |                     ||                     d{V }ne|d
k    r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |dg           }	| 	                    |	|||          S )a,  
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-funding-asset-bills-details
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-account-get-bills-details-last-7-days
        :see: https://www.okcoin.com/docs-v5/en/#rest-api-account-get-bills-details-last-3-months
        fetch the history of changes, actions done by the user or operations that altered balance of the user
        :param str code: unified currency code, default is None
        :param int [since]: timestamp in ms of the earliest ledger entry, default is None
        :param int [limit]: max number of ledger entrys to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
        NrU   r  privateGetAccountBillsr  r0   rc  endprivateGetAccountBillsArchiveprivateGetAssetBillsr  )
r  r  r  r  r  r  r  r  r  parse_ledger)
r
  rd  r  r  r  r  r  r  r  r  s
             r  fetch_ledgerzokcoin.fetch_ledgert
  s      !!!!!!!!!66v}hXpqq
 $GG}}T**H%d^GEN225'6JJ444!??GU[@\@\]]]]]]]]HH---!66t{{7F7S7STTTTTTTTHH!88Wf9U9UVVVVVVVVHb x44  x>>>r  c                 L    dddddddddddd}|                      |||          S )Nrj   r  rebaterp  )r   r   r  r  r   r  7891011r^  )r
  r  typess      r  parse_ledger_entry_typezokcoin.parse_ledger_entry_type
  sI    
 
 tT222r  c                    |                      |d          }d }|                      |d          }d }|                     |                      |d                    }|                     |                      |d          |          }|                      |d          }	|                     |	          }
|                     |d          }|                      |d          }d }|*|                     t          j        |                    |d}d }|                      |d	          }|                     |          }d
}|                      |d          }|                     |d d          }||||                     |          |||||||
||||dS )Nr  r  r  rc  balChgr  rp  r  r  r  r#  ri  )r0   rI  r  r  r  referenceIdreferenceAccountr  r  r+  r8  r  r  r  rp  )	r  r&  rK  rQ  rP  r,   r  r  r  )r
  itemr  r0   r  r)  r*  r  rd  r_  r8  r  r  rp  r  afterStringr  r  r  r+  s                       r  parse_ledger_entryzokcoin.parse_ledger_entry
  s   J dH--&&tW55++D,<,<T6,J,JKK&&t'7'7e'D'DhOO''h77""<00%%dD11	((u55$))'*<]*K*KLL  C &&tU33!!+..##D(33!!(D#66"Y//& 0
 
 	
r  r   GETc                 `   t          |t                    }d| j        z   dz   |                     ||          z   }|                     ||                     |                    }	|                     | j        d         d                   |z   }
|dk    r|	r|
d|                     |	          z   z  }
n|dk    r| 	                                 | 
                    |                                           }| j        | j        |d}||z   |z   }|d	k    r%|	r"d|                     |	          z   }|
|z  }
||z  }n#|s|	r|                     |	          }||z  }d
|d<   |                     |                     |          |                     | j                  t$          j        d          }||d<   |
|||dS )Nz/api/r'  r   r   r   ?r   )zOK-ACCESS-KEYzOK-ACCESS-PASSPHRASEzOK-ACCESS-TIMESTAMPr.  zapplication/jsonzContent-Typebase64zOK-ACCESS-SIGN)urlr  bodyheaders)rz  rt  r6   implode_paramsrN  extract_paramsimplode_hostnamer   	urlencoderq  r  r  r   r   jsonhmacencoder   hashlibsha256)r
  pathr   r  r  r4  r3  isArrayr  r  r2  r  r  urlencodedQuery	signatures                  r  signzokcoin.sign-  s   VT**DL(3.1D1DT61R1RR		&$"5"5d";";<<##DIe$4V$<==G(?? 3sT^^E2222I++---T%6%6%8%899I!%(,'0 G v%/D ,&)DNN5,A,A&AO?*CO+D !e !99U++DDLD*<'		$++d"3"3T[[5M5Mw~_ghhI(1G$%fdwOOOr  c                 b    |dk    r|                      |          S |                     |          S )Nr  )r  r  )r
  r  r  s      r  parse_balance_by_typezokcoin.parse_balance_by_typeO  s5    9--h777--h777r  c
                     |sd S |                      |d          }
|
dk    r| j        dz   |z   }|                     |dg           }t          dt	          |                    D ]z}||         }|                      |d          }|                      |d          }|                     | j        d         ||           |                     | j        d	         ||           {|                     | j        d         |
|           t          |          d S )
Nrd  r   r  r   sCodesMsgr  r  )	r  r0   r  rv  rw  throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr   )r
  httpCodereasonr2  r  r4  r3  r  requestHeadersrequestBodyrd  feedbackr  r  error	errorCodemessages                    r  handle_errorszokcoin.handle_errorsU  s    	4* &113;;w}t+H??8VR88D1c$ii(( b bQ ,,UG<<	**5&9944T_W5MyZbccc44T_W5MwX`aaaa001I4QYZZZ)))tr  )N)I__name__
__module____qualname__r	  r  r   r	   r!  rV  ra  r   r  rs  r   r   r  r   r  r  r   r   r  r   r  r  rt  r  r  r   r   r	  r  r  floatr  r   r   r
   r  r$  r   rw  r|  rr  r  r   r%  r  r  r  r   r  r  r  r   rj   r  r  rk   r   r  r  r  r  r  r  r  r&  r-  rB  rD  rS  __classcell__)r  s   @r  r.   r.   #   s       B	 B	 B	 B	 B	H ') A A A A *, + +V + + + +Pf P P P PdD D D -/ P P: P P P Pd @DB *? *?S *? *?S\ *? *? *? *?X5 56 5V 5 5 5 5n 68 *0 *0 *0F *0 *0 *0 *0X 6:" 9 97 9 9 9 9 9 G G G5 G G G GR <@d[] = = =S = =bfglbm = = = =8
 
 
4 
 
 
 
. 8<$]ajl "H "H "HC "HWZ "Hquvzq{ "H "H "H "HH8) 8) 8)t *, %8 %8 %8 %8 %8 %8N) ) )2) ) ) XZ T Tc T T T T T" mqy{ 5 5 5I 5Y 5X] 5fi 5 5 5 5n os{} , ,3 ,i ,y ,Z_ ,hk , , , ,B 9=R %/ %/S %/# %/ %/ %/ %/N	 	 	 6:" FI FIs FI FI FI FIP: : :} } }5 } } } }~ 8<B &' &'C &' &' &' &' &'P 59tZ^gi '= '=c '= '=TW '=nrsxny '= '= '= '=R 7;\`ik O= O= O=3 O=VY O=ptuzp{ O= O= O= O=bX
 X
h X
 X
 X
 X
t =?      & JL &0 &0S &0 &0 &0 &0P ac 7: 7:3 7: 7:C 7:TW 7:gt 7: 7: 7: 7:rJ
 J
 J
 J
 J
 J
X: : : EIQS 4= 4=3 4= 4= 4= 4= 4=l 04$UYbd CM CM CMC CMs CMimnyiz CM CM CM CMJ 37TX\eg ;M ;MC ;Ms ;MRU ;Mlpq|l} ;M ;M ;M ;Mz#: #: #:J[
 [
x [
; [
 [
 [
 [
z 37TX\eg = =C =s =RU = = = => ?CQUdhqs ^ ^3 ^ ^3 ^^a ^ ^ ^ ^& .2SW`b Z? Z?s Z?# Z?S Z? Z? Z? Z?x3 3 3 K
 K
 K
 K
 K
 K
Z &eBSW  P  P  P  PD8 8 8# # # # # # #r  r.   )3 ccxt.async_support.base.exchanger   ccxt.abstract.okcoinr   r<  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   ccxt.base.decimal_to_precisionr+   ccxt.base.preciser,   r.    r  r  <module>ra     s   6 5 5 5 5 5 , , , , , ,  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w  w       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . + + + + + + ) ) ) ) ) ) * * * * * * * * * * * * ) ) ) ) ) ) ) ) ) ) ) ) . . . . . . 1 1 1 1 1 1 * * * * * * ) ) ) ) ) ) + + + + + + 4 4 4 4 4 4 % % % % % %U- U- U- U- U-X{ U- U- U- U- U-r  