
    i)                    L   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 d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlm Z  d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dl%m&Z& d dl%m'Z' d dl(m)Z)  G d dee          Z*dS )    )Exchange)ImplicitAPIN)Balances
CurrenciesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)	BadSymbol)BadResponse)InsufficientFunds)InvalidAddress)InvalidOrder)DDoSProtection)RateLimitExceeded)ExchangeNotAvailable)TRUNCATE)	TICK_SIZE)Precisec                   j    e Zd Z fdZi fdee         fdZdefdZi fdefdZ	de
fdZi fde
fdZdi fd	ed
edefdZdi fdedefdZi fd	edefdZd<dedefdZdddi fd	eded
efdZddi fd	eded
edee         fdZd<dedefdZi fdZd=dZdddi fd	eded
edee         fdZd<dedefdZ dddi fd	eded
edee!         fdZ"dddi fd	eded
edee!         fdZ#di fded	efdZ$d Z%d<dede!fd Z&d! Z'di fd	ed"e(d#e)d$e*d%e+f
d&Z,di fded	efd'Z-d<d(e.fd)Z/i fd*efd+Z0di fd,ee         fd-Z1di fd*ed$e*fd.Z2dddi fd*eded
edee3         fd/Z4dddi fd*eded
edee3         fd0Z5dddi fd*eded
efd1Z6d<d(e.de3fd2Z7d3 Z8di fd,efd4Z9d<d(e.fd5Z:d6 Z;d7d8i ddfd9Z<i fd:Z=d; Z> xZ?S )>probitc                    |                      t          t          |                                           i dddddddg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d.dd/di d0dd1dd2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@di dAddBddCddDddEddFddGdHdIddJddKddLddMddNddOddPddQddRddSdidTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdhdidjdkdlgdmdndodpdqdrdrdrdrdrdrdrdrdsidtdrdtdudrdrdrdrdrdrdrdvdwdxdydriidzd{d|dd|                     d}          |                     d}          d~iddt
          t          t          t          t          t          t          t          t          t          t          t          t          t          t
          didddddt          dddddddddddi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddēddƓddȓddʓdd̓ddΓddГddddԜ          S )Nidr&   nameProBit	countriesSCKR	rateLimit2   proThasCORSspotmarginFswapfutureoption	addMargincancelOrdercreateMarketBuyOrderWithCostcreateMarketOrdercreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsemulatedfetchTransferfetchTransfersfetchWithdrawalfetchWithdrawalsreduceMarginsetLeveragesetMarginModesetPositionModesignIntransferwithdraw
timeframes1m3m5m10m15m30m1h4h6h12h1D1W1M)ry   rz   r{   r|   r}   r~   r   r   r   r   1d1wr   versionv1urlszdhttps://user-images.githubusercontent.com/51840849/79268032-c4379480-7ea2-11ea-80b3-dd96bb29fd0d.jpgzhttps://accounts.probit.comz#https://api.probit.com/api/exchange)accountspublicprivatezhttps://www.probit.comzhttps://docs-en.probit.comzhttps://docs-ko.probit.comzFhttps://support.probit.com/hc/en-us/articles/360020968611-Trading-Feesz!https://www.probit.com/r/34608773)logoapiwwwdocfeesreferralr   get   )marketcurrencycurrency_with_platformtimeticker
order_booktradecandle   )	new_ordercancel_order
withdrawal)balanceorder
open_orderorder_historytrade_historydeposit_addressztransfer/payment)postr   r   token)r   r   r   r   tradingz0.002)	tierBased
percentagemakertaker
exceptionsexact)UNAUTHORIZEDINVALID_ARGUMENTTRADING_UNAVAILABLENOT_ENOUGH_BALANCENOT_ALLOWED_COMBINATIONINVALID_ORDERRATE_LIMIT_EXCEEDEDMARKET_UNAVAILABLEINVALID_MARKETMARKET_CLOSEDMARKET_NOT_FOUNDINVALID_CURRENCYTOO_MANY_OPEN_ORDERSDUPLICATE_ADDRESSinvalid_grantrequiredCredentials)apiKeysecretprecisionModeoptionsgtcioc)limitr   BSCETHTRON)BEP20ERC20TRC20)!createMarketBuyOrderRequiresPricetimeInForcenetworkscommonCurrenciesAUTOCubeAZUAzultecBCCBDPBidiPassBIRD	BirdchainBTCBEARBEARBTCBULLBULLCBCCryptoBharatCoinCHEChellitCLRzColor PlatformCTKCryptykCTTCastweetDIPDipperDKTDAKOTAEGC	EcoG9coinEPSEpanusFXFanzyGDTzGorilla DiamondGMz
GM HoldingGOGOLGOLGoldofirGRBzGlobal Reward BankHBCzHybrid Bank CashHUSLzThe Hustle AppLANDLandboxLBKzLegal BlockORCzOracle SystemPXPzPIXSHOP COINPYECreamPYEROOKReckoonSOCz	Soda CoinSST
SocialSwapTCTzTop Coin TokenTORTorexz	Tetra PayzUNICORN TokenUNI)TPAYr	  UNISWAP)deep_extendsuperr&   describeparse_numberr   r   r!   r   r   r    r   r   r   r#   )self	__class__s    Q/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/probit.pyr  zprobit.describe   s   fd 3 3 < < > > bA
(bA
HbA
 $bA
 	bA

 4bA
  FFF %F 	F
 %F %F UF tF /F $TF ,UF 0F tF (F 'F  (!F" "5#F F$ %F& +E'F( )%)F* $T+F, '-F. (/F0 "41F2 &t3F4 (5F6  7F8 +D9F: &u;F< #E=F> *5?F@ $UAFB "5CFD *5EF F FF +EGFH  IFJ %eKFL "5MFN OFP !%QFR  SFT dUFV +EWFX "4YFZ d[F\ !$]F^  _F` $UaFb !%cFd %eeFf )%gF F Fh tiFj kFl TmFn toFp "5qFr #EsFt $ZuFv  wFx !%yFz "5{F| #D}F~ F@ uAFB  CFD "5EFF $GFH EIF FJ DKF FbA
Z  [bA
x tybA
z ~ =CD 
 000 a? {bA
X "#$%23 !"#&'!""#	 	 &'()&'  $%!"&')*)*+,,-  " ;" "YbA
^ !&"&!..w77!..w77	 _bA
n $7(2+?*;/9%1+<*>&/%.(1(2,:)7%8 obA
T "$ $UbA
\ Y]bA
^ 59"#   
 #"#  _bA
v  &!&!y&! u&! z	&!
 &! 6&! 6&! )&! y&! '&! y&! z&! x&! x&! {&!  x!&!" g#&! &!$ (%&!& l'&!( )&!* z+&!, +-&!. )/&!0 (1&!2 	3&!4 }5&!6 7&!8 ~9&!: z;&!< 	=&!> {?&!@ |A&!B 'C&!D wE&! &!F $& K&! &! &!wbA
 b b b	    returnc                     |                      |          }|                     |dg           }|                     |          S )a  
        :see: https://docs-en.probit.com/reference/market
        retrieves data on all markets for probit
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        data)publicGetMarket
safe_valueparse_markets)r  paramsresponsemarketss       r  fetch_marketszprobit.fetch_markets  sB     ''//2 //(FB77!!'***r  c                    |                      |d          }|                      |d          }|                      |d          }|                     |          }|                     |          }|                     |dd          }|                      |d          }t          j        |d          }	|                      |d          }
t          j        |
d          }i d|d	|d
z   |z   d|d|dd d|d|dd ddddddddddddd| dddd d |                     |	          |                     |          d d d d d |                     |                     |                      |d                              |                     |d          |                     |                     |                      |d                              dd d d|                     |d           |                     |d!          d|                     |d"          |                     |d#          d|                     |d$          |                     |d%          dd&d |d'S )(Nr(   base_currency_idquote_currency_idclosedFtaker_fee_rate100maker_fee_ratesymbol/basequotesettlebaseIdquoteIdsettleIdtyper3   Tr4   r5   r6   r7   activecontractlinearquantity_precisionprice_incrementcost_precision)amountpricecostminmaxmin_quantitymax_quantity	min_price	max_pricemin_costmax_cost)leverager4  r5  r6  )inverser   r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)safe_stringsafe_currency_code	safe_boolr$   
string_divr  parse_precisionsafe_number)r  r   r(   r*  r+  r'  r(  r!  takerFeeRater   makerFeeRater   s               r  parse_marketzprobit.parse_market&  s+   fd++!!&*<==""6+>??&&v..''00%88''0@AA"<77''0@AA"<773
"3
dSj5(3
 D3
 U	3

 d3
 f3
 w3
 3
 F3
 D3
 e3
 E3
 e3
 e3
 &j3
  !3
" d#3
$ &&u--&&u-- "++D,@,@AQAQRXZnAoAo,p,pqq))&2CDD))$*>*>t?O?OPVXh?i?i*j*jkk    
  ++FNCC++FNCC 
  ++FK@@++FK@@ 
  ++FJ??++FJ??  $ e3
 3
 3
 3	
r  c                     |                      |          }|                     |dg           }i }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                     |d          }	|                     |	d          }
|                     |dg           }|                     |d          }d}i }t          dt          |                    D ]v}||         }|                     |d          }|                     |          }|                     |d	          }|                     |d
          }| }| }|o|}|r|}|                     |                     |d                    }|                     |dg           }|                     |di           }t          dt          |                    D ]*}||         }|                     |d          }||k    r|} n+|||||| 	                    |d          | 
                    |          | 	                    |d          dd| 	                    |d          ddd|d	||<   x||                     |di           }|                     |d	          }|                     |d
          }| } | }!| o|!}"|                     |di           }#g }$t          dt          |#                    D ]O}|#|         }%| 	                    |%d          }&|                     |%d          }'|&|'|$                    |%           P|                     |$d          }(|                     |(di           })| 	                    |)d          }*||||
|"| |!|*| 
                    |                     |                     |d                              ddd| 	                    |d          dd| 	                    |d          ddd|d||<   |S )a  
        :see: https://docs-en.probit.com/reference/currency
        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
        r  r   r(   display_namezen-usplatformpriorityNdeposit_suspendedwithdrawal_suspendedrG  withdrawal_feecurrency_idr4  min_withdrawal_amountr7  min_deposit_amountrw   deposit)	r(   networkr.  r_  rw   feerG  rH  rJ  )r4  r_  rw   )r(   coderJ  r)   r.  r_  rw   ra  rG  rH  r   )publicGetCurrencyWithPlatformr  rangelenrK  rL  sort_bynetwork_id_to_coderO  rP  r  safe_integerappend)+r  r  r  
currenciesresultir   r(   rb  displayNamer)   	platformsplatformsByPriorityrV  networkListjr`  idInnernetworkCodecurrentDepositSuspendedcurrentWithdrawalSuspendedcurrentDepositcurrentWithdrawcurrentActiverG  withdrawFee
networkFeekwithdrawPlatformfeeCurrencyIddepositSuspendedwithdrawalSuspendedr_  rw   r.  withdrawalFeesr   withdrawalFeeInnerr4  rW  withdrawalFeesByPrioritywithdrawalFeera  s+                                              r  fetch_currencieszprobit.fetch_currenciesf  s    55f==r __Xvr::
q#j//** _	 _	A!!}H!!(D11B**2..D//(NCCK##K99D*bAAI"&,,y*"E"EHK1c"56677 ' '-a0**7D99"55g>>*.//'CV*W*W'-1__WF\-]-]*%<!<&@"@ . B?  '&H 001A1A';1W1WXX	"oog7GLL!__[!R@@
q#k"2"233  A'21~$$($4$45E}$U$UM$**%5
 + "*+- /++JAA!%!2!29!=!= $(#3#3G=T#U#U#'% %
 $(#3#3G=Q#R#R#'$ $	 	 $%, ,K((( ??+>2FF#x9LMM"&//(<R"S"S**G..H)F!__X7GLLND 1c.1122 4 4%3A%6"))*<hGG,,-?LL&X-AKK 2333'+||D*'E'E$ OO,DaLLM""=(;;C  "$!..t/C/CDDTDTU]_jDkDk/l/lmm  $# 
  $//:NOO#   
  $//:QRR#! !  (1 F4LL4 r  c                    |d d d}|                      |dg           }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )N)rJ  	timestampdatetimer  r   r[  total	availablefree)r  rd  re  rK  rL  accountsafe_balance)	r  r  rk  r  rl  r   
currencyIdrb  r  s	            r  parse_balancezprobit.parse_balance
  s    
 

 x44q#d))$$ 	# 	#A1gG))'=AAJ**:66DllnnG#//AAGG"..wDDGFO"F4LL  (((r  c                 ~    |                                   |                     |          }|                     |          S )a\  
        :see: https://docs-en.probit.com/reference/balance
        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>`
        )load_marketsprivateGetBalancer  )r  r  r  s      r  fetch_balancezprobit.fetch_balance  s?     	))&11 !!(+++r  Nr%  r   c           	      V   |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |dg           }|                     |d          }|                     ||d         dddd	d
          S )a1  
        :see: https://docs-en.probit.com/reference/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
        	market_idr(   r  sider%  Nbuysellr5  quantity)r  r   publicGetOrderBookextendr  group_byparse_order_book)	r  r%  r   r  r   requestr  r  
dataBySides	            r  fetch_order_bookzprobit.fetch_order_book1  s     	V$$
 **4;;w+G+GHH x44]]400
$$Z1A4PVX_aklllr  symbolsc                 8   |                                   i }|-|                     |          }d                    |          |d<   |                     |                     ||                    }|                     |dg           }|                     ||          S )a  
        :see: https://docs-en.probit.com/reference/ticker
        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>`
        N,
market_idsr  )r  r  joinpublicGetTickerr  	safe_listparse_tickers)r  r  r  r  	marketIdsr  r  s          r  fetch_tickerszprobit.fetch_tickersM  s     	00I$'HHY$7$7GL!''GV(D(DEE" ~~h33!!$000r  c                 r   |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |dg           }|                     |d          }|t          | j        dz             |                     ||          S )a  
        :see: https://docs-en.probit.com/reference/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>`
        r  r(   r  r   Nz) fetchTicker() returned an empty response)r  r   r  r  r  r   r(   parse_ticker)r  r%  r  r   r  r  r  r   s           r  fetch_tickerzprobit.fetch_tickern  s     	V$$&,
 ''GV(D(DEE" x44q))>dg(SSTTT  000r  r   c                 r   |                      |                     |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|          S )Nr   r  -lastchangebase_volumequote_volumer%  r  r  highlowbid	bidVolumeask	askVolumevwapopenclosepreviousCloser   average)
baseVolumequoteVolumerJ  )	parse8601rK  safe_symbolsafe_tickeriso8601)
r  r   r   r  marketIdr%  r  r  r  r  s
             r  r  zprobit.parse_ticker  s    NN4#3#3FF#C#CDD	##FK88!!(FC88  00!!&(33%%fm<<
&&v~>> !
f!
!
 Y//!
 D$$VV44	!

 4##FE22!
 4!
 !
 4!
 !
 D!
 D!
 U!
 E!
 T!
 f!
  $!!
" t#!
$ %&)!
 !
 !
* +  	r  sincec                 <   |                                   d}|                                 }d|                     |dz
            |                     |          d}| |                     |          }|d         |d<   |A|                     |          |d<   |                     t	          ||dz                       |d<   |||d	<   |                     |                     ||                    }|                     |d
g           }	|                     |	|||          S )a  
        :see: https://docs-en.probit.com/reference/trade
        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>`
        Nd   l    ,b/ )r   
start_timeend_timer(   r  r  r  r   r  )	r  millisecondsr  r   r8  privateGetTradeHistoryr  r  parse_trades)
r  r%  r  r   r  r   nowr  r  r  s
             r  fetch_my_tradeszprobit.fetch_my_trades  s(    	!!,,s['899S))
 

 [[((F#)$<GK $(LL$7$7GL!"&,,s38K/L/L"M"MGJ$GG..t{{7F/K/KLL( ~~h33  vue<<<r  c                    |                                   |                     |          }|d         d|                     |                                           d}||                     |          |d<   |t	          |d          |d<   nd|d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )	a  
        :see: https://docs-en.probit.com/reference/trade-1
        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>`
        r(   z1970-01-01T00:00:00.000Z)r  r  r  Nr    r   r  )	r  r   r  r  r8  publicGetTrader  r  r  )	r  r%  r  r   r  r   r  r  r  s	            r  fetch_tradeszprobit.fetch_trades  s     	V$$4T%6%6%8%899
 

 $(LL$7$7GL!"5$//GG#GG&&t{{7F'C'CDD. ~~h33  vue<<<r  c                    |                      |                     |d                    }|                     |d          }d }|+|                    d          }|                     |d          }|                     |d|          }|                     ||d          }|                     |d          }|                     |d          }	|                     |d	          }
|                     |d
          }|                     |d          }d }|0|                     |d          }|                     |          }||d}|                     ||||                     |          ||d |d |	|
d |d|          S )Nr   r(   :r   r  r  r  r5  r  order_id
fee_amountfee_currency_id)r6  r   )r(   rJ  r  r  r%  r   r-  r  takerOrMakerr5  r4  r6  ra  )r  rK  splitr  rL  
safe_trader  )r  r   r   r  r(   r  partsr%  r  priceStringamountStringorderIdfeeCostStringra  r}  feeCurrencyCodes                   r  parse_tradezprobit.parse_trade  s   : NN4#3#3E6#B#BCC	eT**>HHSMME''q11H##E;AA!!(FC88v..&&ug66''z::""5*55((==$ ,,U4EFFM"55mDDO%+ C "Y//  " 
  
   	r  c                     |                      |          }|                     |                     |d                    }|S )aJ  
        :see: https://docs-en.probit.com/reference/time
        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
        r  )publicGetTimer  rK  )r  r  r  r  s       r  
fetch_timezprobit.fetch_timea  s@     %%f-- NN4#3#3Hf#E#EFF	r  Fc                 b   |                      |          }|dk    r|                     |          }|                    d          }|                     |d          }|                     |d          }d }	|r#|                     |t          d                    }	|dk     rdt          |          z   }	|dz   |	z   dz   S |dk    r|                     |d	z            }d
}
||
z
  }t          t          j
        ||z                      }|                     |
||z            }|r|                     ||          }|                     |d	z            S |                     |d	z            }||                     ||z            z  }|r|                     ||          }|                     |d	z            S )Nr   r  r   r   
   0z-01T00:00:00.000Zr   r  i )parse_timeframer  r  rK  rh  sumstrparse_to_intintmathfloor)r  r  	timeframeafterdurationr  r  yearmonthmonthStringfirstSunday
differencenumWeekspreviousSundays                 r  normalize_ohlcv_timestampz probit.normalize_ohlcv_timestampo  s   ''	22ll9--GMM#&&E##E1--D%%eQ//E#K 6"hhuc!ff55rzz!CJJ.#:+.AAA$)))d*:;;I K"[0J4:j8&;<<==H!XXk8h3FGGN D!%.(!C!C<< 5666)))d*:;;I 4#4#4Y5I#J#JJI : HHY99	<<	D 0111r  ry   c                    |                                   |                     |          }|                     | j        ||          }|dn|}|                     |d          }t          d|          }|d         |d|d}	|                                 }
|                     |          }|}|
}|||}|
||z  dz  z
  }n5||
}n0|                     ||                     |d          |z  dz            }|                     ||          }|                     ||d          }||	d	<   ||	d
<   | 	                    | 
                    |	|                    }|                     |dg           }|                     |||||          S )a  
        :see: https://docs-en.probit.com/reference/candle
        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
        Nr  r   r  r(   asc)r  intervalsortr   Tr  r  r  )r  r   rK  rx   r  r8  r  r  r  publicGetCandler  r  parse_ohlcvs)r  r%  r  r  r   r  r   r  requestLimitr  r  r  	startTimeendTimestartTimeNormalizedendTimeNormalizedr  r  s                     r  fetch_ohlcvzprobit.fetch_ohlcv  s    	V$$##DOY	JJExxq))4.. , !	
 
 !!''	22	=}$eh.55II}((5$((5!*<*<x*G$*NOO"<<Y	RR ::7ItTT 3/
''GV(D(DEE$ ~~h33  vy%GGGr  c           	      (   |                      |                     |d                    |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr  r  r  r  r  r  )r  rK  rP  )r  ohlcvr   s      r  parse_ohlcvzprobit.parse_ohlcv  s     NN4++E<@@AAUF++UF++UE**UG,,UM22
 	
r  c                 N   |                                   |                     |          }i }d}| |                     |          }|d         |d<   |                     |                     ||                    }|                     |d          }|                     ||||          S )a  
        :see: https://docs-en.probit.com/reference/open_order-1
        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
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr(   r  r  )r  r  r   privateGetOpenOrderr  r  parse_orders	r  r%  r  r   r  r  r   r  r  s	            r  fetch_open_orderszprobit.fetch_open_orders  s     	u%%[[((F#)$<GK ++DKK,H,HII~~h//  vue<<<r  c                    |                                   |                     d          |                     |                                           dd}d}| |                     |          }|d         |d<   |r|                     |          |d<   |r||d<   |                     |                     ||                    }|                     |d	          }|                     ||||          S )
a-  
        :see: https://docs-en.probit.com/reference/order
        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
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r   r  )r  r  r   Nr(   r  r  r   r  )r  r  r  r   privateGetOrderHistoryr  r  r  r  s	            r  fetch_closed_orderszprobit.fetch_closed_orders  s     	,,q//T%6%6%8%899
 

 [[((F#)$<GK  	8$(LL$7$7GL! 	%$GG..t{{7F/K/KLL~~h//  vue<<<r  r(   c                    |t          | j        dz             |                                  |                     |          }d|d         i}|                     |dd          }|||d<   n||d<   |                     |ddg          }|                     |                     ||                    }|                     |dg           }	| 	                    |	d	          }
| 
                    |
|          S )
az  
        :see: https://docs-en.probit.com/reference/order-3
        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  r(   clientOrderIdclient_order_idr  r  r   )r   r(   r  r   safe_string_2omitprivateGetOrderr  r  	safe_dictparse_order)r  r(   r%  r  r   r  r  queryr  r  r   s              r  fetch_orderzprobit.fetch_order  s    >#DG.X$XYYYV$$
 **6?DUVV$)6G%&&"$GJ		&?4E"FGG''GU(C(CDDx44tQ''v...r  c                 <    dddd}|                      |||          S )Nr  canceledr!  )r  	cancelledfilledrK  r  statusstatusess      r  parse_order_statuszprobit.parse_order_status+  s1    #
 

 &&999r  c                    |                      |                     |d                    }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     ||d          }|                     |                     |d                    }	|                     |d          }
|                     |d	          }|                     |d
          }|                     |d          }|t	          j        ||          }|                     |dt	          j        ||                    }|                     |dd          }|dk    rd }
|                     |d          }|                     |d          }|                     i d|d|d|d|	d| 	                    |	          dd d|d|d|d|d|d|
dd dd d|d|d|d |d d d|          S ) Nr!  r(   r-  r  r  r  r   limit_pricefilled_quantityopen_quantitycancelled_quantityr  filled_costr6  r   r  time_in_forcerJ  r  r  r  lastTradeTimestampr%  r   r5  	stopPricetriggerPricer4  r  	remaining)r  r6  ra  trades)
r#  rK  r  r  r$   
string_addr  safe_string_upper
safe_orderr  )r  r   r   r!  r(   r-  r  r  r%  r  r5  r  r.  canceledAmountr4  r6  r  r   s                     r  r  zprobit.parse_order3  s   ( (()9)9%)J)JKKeT**v..v..##E;77!!(FC88NN4#3#3E6#B#BCC	  66!!%):;;$$UO<<	))%1EFF%*9nEEI!!%W5GPY5Z5Z[[!!%??8E((0ABB,,UODD  
" 
E 
 ] 
 	 

 Y// 
 !$ 
 f 
 D 
 ; 
 D 
 f 
 U 
  
 D 
 f 
  f! 
" # 
$ + 
  
  
, -  	r  c                 t    |                      |t          | j        |         d         d         | j                  S )NrG  r6  )decimal_to_precisionr"   r  r   )r  r%  r6  s      r  cost_to_precisionzprobit.cost_to_precisionr  s2    ((xf9Mk9Z[a9bdhdvwwwr  r-  r  r4  r5  c                    |                                   |                     |          }|                     | j        d          }|                     ||          }	|                     |dd|	          }
|d         |||
d}|                     |dd          }|||d<   d}|dk    r4|                     ||          |d	<   |                     ||          |d
<   n|dk    r|dk    rd}|                     |ddd          \  }}|                     |d          }| 	                    |d          }|| 
                    ||          }n|ro|t          | j        dz             |                     |          }|                     |          }t          j        ||          }| 
                    ||          }n| 
                    ||          }||d<   n|                     ||          |d
<   | 	                    |g d          }|                     |                     ||                    }|                     |d          }|                     ||          }|dk    r(|dk    r"d|d<   |                     |          |d<   d|d<   |S )a  
        create a trade order
        :see: https://docs-en.probit.com/reference/order-1
        :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 you want to trade in units of the base currency
        :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r   r*  r(   )r  r-  r  r*  r  r  Nr   r%  r  r   r  Tr>   r   r6  z 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 in the amount argument)r   r*  r  r  r  r4  r.  )r  r   r  r   r  price_to_precisionamount_to_precisionhandle_option_and_paramsrK  r  r6  r   r(   number_to_stringr$   
string_mulprivatePostNewOrderr  r  r  )r  r%  r-  r  r4  r5  r  r   r   defaultTimeInForcer   r  r  quoteAmountr   r6  r  r  costRequestr  r  r  r   s                          r  create_orderzprobit.create_orderu  s    	V$$//$,>>!__Wd;;((Qcdd(	
 
 **6?DUVV$)6G%&7??%)%<%<VU%K%KGM""&":":66"J"JGJXu}}481<@<Y<YZ`bo  rU  W[  =\  =\916''776622#"&"8"8"F"FKK6 	I}*47  6q  ,q  r  r  r'+'<'<V'D'D&*&;&;E&B&B&-&8{&S&S&*&<&<V[&Q&Q"&"8"8"H"HK"-&*&>&>vv&N&N
#		&"f"f"fgg++DKK,G,GHH, x00  v.. H45=="E(O --k::E&M!%E+r  c                 D   |t          | j        dz             |                                  |                     |          }|d         |d}|                     |                     ||                    }|                     |d          }|                     |          S )a  
        :see: https://docs-en.probit.com/reference/order-2
        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
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) cancelOrder() requires a symbol argumentr(   )r  r  r  )r   r(   r  r   privatePostCancelOrderr  r  r  )r  r(   r%  r  r   r  r  r  s           r  r   zprobit.cancel_order  s     >#DG.Y$YZZZV$$
 
 ..t{{7F/K/KLL~~h//%%%r  r   c                 (   |                      |d          }|                      |d          }|                      |d          }|                     ||          }|d         }|                      |d          }|                     |           |||||dS )Naddressdestination_tagr[  rb  platform_id)r   rE  tagr`  rJ  )rK  safe_currencycheck_address)r  depositAddressr   rE  rH  r  rb  r`  s           r  parse_deposit_addresszprobit.parse_deposit_address  s    "">9==~/@AA%%nmDD
%%j(;;"">=AA7###"
 
 	
r  rb  c                 >   |                                   |                     |          }d|d         i}|                     | j        di           }|                     |d          }|                     |||          }|||d<   |                     |d          }|                     |                     ||                    }|                     |dg           }|                     |d          }	|	t          | j
        d	z             |                     |	|          S )
a|  
        :see: https://docs-en.probit.com/reference/deposit_address
        fetch the deposit address for a currency associated with self account
        :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>`
        r[  r(   r   r`  NrG  r  r   z1 fetchDepositAddress() returned an empty response)r  r   r  r   r1  rK  r  privateGetDepositAddressr  r   r(   rL  )
r  rb  r  r   r  r   r`  r  r  firstAddresss
             r  fetch_deposit_addresszprobit.fetch_deposit_address  s    	==&&8D>
 ??4<R@@((;;""8Wg>>%,GM"YYv}55F00Wf1M1MNN0 x44tQ// +^!^___)),AAAr  codesc                    |                                   i }|rpg }t          dt          |                    D ]8}|                     ||                   }|                    |d                    9d                    |          |d<   |                     |                     ||                    }|                     |dg           }| 	                    ||          S )a  
        :see: https://docs-en.probit.com/reference/deposit_address
        fetch deposit addresses for multiple currencies and chain types
        :param str[]|None codes: list of unified currency codes, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `address structures <https://docs.ccxt.com/#/?id=address-structure>`
        r   r(   r  r[  r  )
r  rd  re  r   ri  r  rN  r  r  parse_deposit_addresses)	r  rQ  r  r  currencyIdsrl  r   r  r  s	            r  fetch_deposit_addresseszprobit.fetch_deposit_addresses"  s     	 	5K1c%jj)) 3 3==q22""8D>2222%(XXe__GM"00Wf1M1MNN~~h33++D%888r  c                 n   |                      ||          \  }}|                     |           |                                  |                     |          }|d}|d         |||                     |          d}|                     | j        di           }|                     |d          }	|                     ||	|	          }	|	|	|d<   | 	                    |d          }| 
                    |                     ||                    }
|                     |
d          }|                     ||          S )	a  
        :see: https://docs-en.probit.com/reference/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>`
        N r(   )r[  rE  rF  r4  r   r`  rG  r  )handle_withdraw_tag_and_paramsrJ  r  r   r;  r  r   r1  rK  r  privatePostWithdrawalr  r  parse_transaction)r  rb  r4  rE  rH  r  r   r  r   r`  r  r  s               r  rw   zprobit.withdraw6  s<    99#vFFV
 	7###==&&;C#D>"++F33
 
 ??4<R@@((;;""8Wg>>%,GM"YYvy11F--dkk'6.J.JKK~~h//%%dH555r  c           	      f    ddi}|                      ||||                     ||                    }|S )a  
        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 transaction 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>`
        r-  r_  fetch_transactionsr  r  rb  r  r   r  r  rk  s          r  fetch_depositszprobit.fetch_depositsa  s?     I
 ((ueT[[RX=Y=YZZr  c           	      f    ddi}|                      ||||                     ||                    }|S )a  
        fetch all withdrawals made to 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 transaction 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>`
        r-  r   r\  r^  s          r  fetch_withdrawalszprobit.fetch_withdrawalsp  s?     L
 ((ueT[[RX=Y=YZZr  c                    |                                   d}i }| |                     |          }|d         |d<   ||                     |          |d<   n|                     d          |d<   |                     |dd          }|1|                     |          |d<   |                     |ddg          }n*|                     |                                           |d<   |||d	<   nd
|d	<   |                     |                     ||                    }|                     |dg           }	| 	                    |	|||          S )ah  
        fetch history of deposits and withdrawals
        :see: https://docs-en.probit.com/reference/transferpayment
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch transactions for
        :param int [limit]: the maximum number of transaction structures to retrieve
        :param int [params.until]: the latest time in ms to fetch transactions for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr(   r[  r  r   tilluntilr  r   r  r  )
r  r   r  safe_integer_2r  r  privateGetTransferPaymentr  r  parse_transactions)
r  rb  r  r   r  r   r  rd  r  r  s
             r  fetch_deposits_withdrawalsz!probit.fetch_deposits_withdrawals  sV    	!}}T**H%-d^GM"$(LL$7$7GL!!$(LLOOGL!##FFG<<"&,,u"5"5GJYYv'899FF"&,,t/@/@/B/B"C"CGJ$GG"GG11$++gv2N2NOO2 ~~h33&&tXueDDDr  c                 f   |                      |d          }|                      |d          }|                     |          }|                     |d          }|                      |d          }|                      |d          }|                      |d          }	|                     |                      |d                    }
|                      |d          }|                      |d	          }|                     |          }|                     |                      |d
                    }|                      |d          }d }||dk    r||                     |          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S )Nr(   rG  r4  rE  rF  hashr   r-  r[  r!  ra  r  )r   r6  r   r`  addressFrom	addressTotagFromrH  tagTotxidr  r  updatedinternal)commentra  rJ  )rK  rg  rP  r  rL  parse_transaction_statusr  r  )r  transactionr   r(   	networkIdrs  r4  rE  rH  ro  r  r-  r  rb  r!  r  ra  s                    r  rZ  zprobit.parse_transaction  sY   * k400$$[-@@	--i88!!+x88"";	::{,=>>V44NN4#3#3K#H#HII	V44%%k=AA
&&z22..t/?/?X/V/VWW((e<<$#)=)= ))-88 C
"

 f
 {	

 4
 w
 
 t
 3
 S
 f
 D
 D
 
 Y//
  t!
" #
$ )
 
 
 	
r  c           	      F    ddddddddd}|                      |||          S )Npendingokr  )	requestedrw  
confirming	confirmedapplyingdoner  
cancellingr  r   s      r  rs  zprobit.parse_transaction_status  s@    " #"!#$	
 	
 &&999r  c                     |                                   |                     |          }|                     |d          }|                     ||d          S )ac  
        :see: https://docs-en.probit.com/reference/currency
        fetch deposit and withdraw fees
        :param str[]|None codes: list of unified currency codes
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `fees structures <https://docs.ccxt.com/#/?id=fee-structure>`
        r  r(   )r  rc  r  parse_deposit_withdraw_fees)r  rQ  r  r  r  s        r  fetch_deposit_withdraw_feesz"probit.fetch_deposit_withdraw_fees  sW     	55f==p ~~h////eTBBBr  c                    |                      i           }|                     |dg           }d d d}t          dt          |                    D ]}||         }|                     |d          }|                     ||d                   }	|                     |di           }
|                     |
d         d          }t          |
          r"||dnd d}|dk    r||d	<   ||d
|d         |	<   ||d<   |S )NrV  )ra  r   r   r(   rb  rZ  r4  Frw   r^  r   rJ  )deposit_withdraw_feer  rd  re  rK  rg  rP  )r  ra  r   depositWithdrawFeern  depositResultrl  r`  ru  rs  r  ry  withdrawResults                r  parse_deposit_withdraw_feez!probit.parse_deposit_withdraw_feeJ  s;   F "66r::OOCR88	
 
 q#i..)) 	 	AlG(($77I11)Xf=MNNK!__W6FKKN**>!+<hGGK>"" 
&,7,C%%$" " 665C&z2 .,? ?":.{; &)6"!!r  c                 *    |                                  S N)r  )r  s    r  noncezprobit.nonce  s      """r  r   GETc                    | j         d         |         dz   }|                     ||                     |                    }|dk    ru|                                  ||                     ||          z  }| j        dz   | j        z   }	|                     |	          }
d|
z   dd}|r|                     |          }n-|| j	        dz   z  }|dk    r7||                     ||          z  }|r|d	| 
                    |          z   z  }n|d
k    r|                                 }|                                  |                     | j        d          }|||k     rt          | j        dz             |                     | j        d          }dd|z   i}||                     ||          z  }|dk    r|r|d	| 
                    |          z   z  }n|r|                     |          }d|d<   ||||dS )Nr   r&  r   r  zBasic zapplication/json)AuthorizationContent-Typer   ?r   expiresz+ access token expired, call signIn() methodaccessTokenr  zBearer r  r  )urlmethodbodyheaders)r   r  extract_paramscheck_required_credentialsimplode_paramsr   r   string_to_base64jsonr   	urlencoder  rh  r   r   r(   rK  )r  pathr   r  r  r  r  r  r  authauth64r  r  r  s                 r  signzprobit.sign  s0   is#c)		&$"5"5d";";<<*++---4&&tV444C;$t{2D**400F!)F!2 2 G  (yy''4<#%%Cht**4888 73!6!666C	!!''))//111++DL)DDO3-dg8e.efff"..t|]KK#Y%< t**4888U?? ;sT^^E%:%::: A99U++D.@GN+fdwOOOr  c                 Z   |                                   ddi}|                     |                     ||                    }|                     |d          }|                     |d          }|| j        d<   |                     |                                 |dz            | j        d<   |S )a  
        :see: https://docs-en.probit.com/reference/token
        sign in, must be called prior to using other authenticated methods
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns: response from exchange
        
grant_typeclient_credentials
expires_inaccess_tokenr  r  r  )r  accountsPostTokenr  rh  rK  r   r  r  )r  r  r  r  	expiresInr  s         r  sign_inzprobit.sign_in  s     	''))).
 ))$++gv*F*FGG %%h==	&&x@@&1]#"&((4+<+<+>+>	D@P"Q"QYr  c
                 2   |d S d|v r|                      |d          }
|                      |d          }|
`| j        dz   |z   }|                     | j        d         ||           |                     | j        d         |
|           t          |          d S )N	errorCodemessage r   )rK  r(   throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr   )r  rb  reasonr  r  r  r  r  requestHeadersrequestBodyr  r  feedbacks                r  handle_errorszprobit.handle_errors  s    4(""((;??I&&x;;G$7S=4/44T_W5MwX`aaa44T_W5MyZbccc#H---tr  r  )F)@__name__
__module____qualname__r  r   r	   r  rS  r   r  r   r  r  r  r   r   r  r   r   r  r   r  r  r   r  r   r  r  r  r  listr  r  r   r  r  r  r#  r  r6  r   r   floatr
   rA  r   r   rL  rP  rU  rw   r   r_  ra  rh  rZ  rs  r  r  r  r  r  r  __classcell__)r  s   @r  r&   r&      s       c c c c cJ $& !+ !+$v, !+ !+ !+ !+F>
f >
 >
 >
 >
@ ') b bZ b b b bH) ) ) ) )" $& , ,( , , , ,, :>b m ms m3 mY m m m m8 04B 1 1W 17 1 1 1 1B 02 "1 "13 "1f "1 "1 "1 "1H) )6 )V ) ) ) )V -1tRV_a /= /=c /= /=C /= /= /= /=b 6:UW /= /=3 /=s /=# /=\`af\g /= /= /= /=b@ @ @5 @ @ @ @D !#    2 2 2 2: 26DW[df ;H ;H# ;Hc ;HQT ;Hkoptku ;H ;H ;H ;Hz
 
 
4 
 
 
 
. /3TXac = = =3 =c =hlmrhs = = = =* 154VZce = =# =S =PS =jnotju = = = =8 26b / /c /3 / / / /4: : := = =5 = = = =~x x x gksu T T3 Ti Ty TRW T`c T T T Tl 37r & &s &C & & & &*
 
h 
 
 
 
  79 0B 0B# 0B 0B 0B 0Bd :>b 9 9T#Y 9 9 9 9( ?C2 )6 )6S )6% )6 )6 )6 )6V *.Dt\^  3 c  cghsct     -1tRV_a  c  C fjkvfw     6:[_hj 9E 9Es 9E# 9EUX 9E 9E 9E 9Ev=
 =
x =
; =
 =
 =
 =
~: : : <@ BC BC BC BC BC BCH;" ;" ;" ;" ;" ;"z# # # &eBSW %P %P %P %PN      2      r  r&   )+ccxt.base.exchanger   ccxt.abstract.probitr   r  ccxt.base.typesr   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!   ccxt.base.decimal_to_precisionr"   r#   ccxt.base.preciser$   r&    r  r  <module>r     sl   ( ' ' ' ' ' , , , , , ,  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h       * * * * * * 0 0 0 0 0 0 . . . . . . ' ' ' ' ' ' & & & & & & ( ( ( ( ( ( . . . . . . + + + + + + ) ) ) ) ) ) + + + + + + . . . . . . 1 1 1 1 1 1 3 3 3 3 3 3 4 4 4 4 4 4 % % % % % %y y y y yX{ y y y y yr  