
    !:hV6                    X   d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlm Z  d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dl(m)Z) d dl(m*Z* d dl+m,Z,  G d dee      Z-y)    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesCurrencyDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)	BadSymbol)MarketClosed)InsufficientFunds)InvalidAddress)InvalidOrder)DDoSProtection)RateLimitExceeded)ExchangeNotAvailable)BadResponse)TRUNCATE)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdee   fdZde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dFde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dFdededefdZi fdefdZdGdZdd	d	i fd
edededee    fdZ!dFdede fdZ"d	d	d	i fd
edededee#   fdZ$d	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 efd!Z'dFd"e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/dFd+e0de1fd,Z2i fd-ede1fd.Z3d	i fd/edee1   fd0Z4d	i fd-ed'e,d1ede5fd2Z6d	d	d	i fd-edededee5   fd3Z7d	d	d	i fd-edededee5   fd4Z8d	d	d	i fd-ededefd5Z9dFd6ed+e0de5fd7Z:d efd8Z;d	i fd/efd9Z<dFd+e0fd:Z=d; Z>d<d=i d	d	fd>Z?i fd?Z@d-eAd@edAedBedCedDefdEZB xZCS )Hprobitreturnc                    | j                  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dGddHddIddJddKdLdMddNddOddPddQddRddddddddSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdhdidjdkdlgdmdndodpdqdrdrdrdrdrdrdrdrdsidtdrdtdudrdrdrdrdrdrdrdvdwdxdydriidzd{d|dd| j	                  d}      | j	                  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dddddddddddd ddddd ddddrdddddddid	d d dd d ddddt
        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ddi      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fetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsemulatedfetchTransferfetchTransfersfetchWithdrawalfetchWithdrawalsreduceMarginsandbox)setLeveragesetMarginModesetPositionModesignIntransferwithdraw
timeframes1m3m5m10m15m30m1h4h6h12h1D1W1M)r   r   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features)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventioniceberg  i )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   Z   )r   r   r   daysBackCanceledr   r   r   r   r   i  )	rz   rB   createOrdersr_   rc   rb   fetchOrdersrJ   r`   )linearinverse)r7   r9   r:   
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)r   r   BSCETHTRON)BEP20ERC20TRC20)!createMarketBuyOrderRequiresPricer   networkscommonCurrenciesBBz	Baby BaliCBCCryptoBharatCoinCTKCryptykCTTCastweetDKTDAKOTAEGC	EcoG9coinEPSEpanusFXFanzyGMz
GM HoldingGOGOLGOLGoldofirHUSLzThe Hustle AppLANDLandboxSST
SocialSwapTCTzTop Coin TokenTORTorexUNIzUNICORN TokenUNISWAP)deep_extendsuperr)   describeparse_numberr   r   r#   r   r    r"   r   r   r!   r   r&   )self	__class__s    E/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/probit.pyr  zprobit.describe   s   fd < > [A
([A
H[A
 $[A
 	[A

 4[A
  KKK %K 	K
 %K %K UK tK /K $TK ,UK 0K tK (K 'K  (!K" "5#K$ %K& +E'K( )%)K* $T+K, '-K. (/K0 "41K2 &t3K4 (5K6 1%7K8  9K: +D;K< &u=K> #E?K@ *5AKB $UCKD "5EKF *5GKH +EIKJ  KKL %eMKN "5OKP QKR !%SKT  UKV dWKX +EYKZ "4[K\ d]K^ !$_K`  aKb 'cKd $UeKf !%gKh *5iKj (kKl %emKn )%oKp tqKr sKt TuKv twKx "5yKz #E{K| $Z}K~  K@ !%AKB "5CKD #DEKF GKH 5IKJ  %!&#(! UK[A
d e[A
B tC[A
D ~ =CD
 000 a?E[A
b "#$%23 !"#&'!""#	 &'()&' $%!"&')*)*+,,-" ;"c[A
h !&"&!..w7!..w7	i[A
x $&+(-,1,0).+06: $(#'"'#(	( #($)$)+/27/4#(+$. %)&+!%$*%+*/& ',#($)*.	# ',!%#($)*/( $(&+!%$*,-%'#($)*/	*  #s<| ##
 ##EFy[A
F $7(2+?*;/9%1+<*>&/%1(1(2,:)7%8G[A
l "$m[A
t Yu[A
v 59"# 
 #"#w[A
N  !k!)! y! z	!
 x! {! x! g! l! ! z! (! 	! |! '!  w!!" #!$ 5%!O[A
 [ [	    c                 l    | j                  |      }| j                  |dg       }| j                  |      S )a  

        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=  s9     ''/2 //(FB7!!'**r  r   c                 >   | j                  |d      }| j                  |d      }| j                  |d      }| j                  |      }| j                  |      }| j                  |dd      }| j                  |dd      }| xr |}	| j                  |d      }
t        j                  |
d	      }| j                  |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 | j                  |      | j                  |      d d d d d | j                  | j                  | j                  |d                  | j                  |d      | j                  | j                  | j                  |d                  dd d d | j                  |d!      | j                  |d"      d | j                  |d#      | j                  |d$      d | j                  |d%      | j                  |d&      d d'd |d(S ))Nr,   base_currency_idquote_currency_idclosedF
show_in_uiTtaker_fee_rate100maker_fee_ratesymbol/basequotesettlebaseIdquoteIdsettleIdtyper7   r8   r9   r:   r;   activecontractr   quantity_precisionprice_incrementcost_precision)amountpricecostminmaxmin_quantitymax_quantity	min_price	max_pricemin_costmax_cost)r   r=  r>  r?  )r   r   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,   r4  r5  r1  r2  r*  showInUIr8  takerFeeRater   makerFeeRater   s                 r  parse_marketzprobit.parse_marketb  s   fd+!!&*<=""6+>?&&v.''0%8>>&,=(''0@A""<7''0@A""<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
 f3
  !3
" d#3
$ &&u-&&u- "++D,@,@AQAQRXZnAo,pq))&2CD))$*>*>t?O?OPVXh?i*jk  
  ++FNC++FNC
  ++FK@++FK@
  ++FJ?++FJ?$ e3
 3	
r  c                    | j                  |      }| j                  |dg       }i }t        dt        |            D ]   }||   }| j	                  |d      }| j                  |      }| j                  |d      }	| j	                  |	d      }
| j                  |dg       }| j                  |d      }d}i }t        dt        |            D ]7  }||   }| j	                  |d      }| j                  |      }| j                  |d	      }| j                  |d
      }| }| }|xr |}|r|}| j                  | j	                  |d            }| j                  |dg       }| j                  |di       }t        dt        |            D ]"  }||   }| j	                  |d      }||k(  s |} n |||||| j                  |d      | j                  |      | j                  |d      dd| j                  |d      ddd|d	||<   : || j                  |di       }| j                  |d	      }| j                  |d
      }| } | }!| xr |!}"| j                  |di       }#g }$t        dt        |#            D ]B  }|#|   }%| j                  |%d      }&| j                  |%d      }'|&/|'2|$j                  |%       D | j                  |$d      }(| j                  |(di       })| j                  |)d      }*||||
|"| |!d|*| j                  | j                  | j	                  |d                  ddd| j                  |d      dd| j                  |d      ddd|d||<   # |S )a  

        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_suspendedrN  withdrawal_feecurrency_idr=  min_withdrawal_amountr@  min_deposit_amountr   deposit)	r,   networkr8  rg  r   feerN  rO  rQ  crypto)r=  rg  r   )r,   coderQ  r-   r8  rg  r   r7  ri  rN  rO  r   )publicGetCurrencyWithPlatformr!  rangelenrR  rS  sort_bynetwork_id_to_coderV  rW  r  safe_integerappend)+r  r#  r$  
currenciesresultir   r,   rk  displayNamer-   	platformsplatformsByPriorityr^  networkListjrh  idInnernetworkCodecurrentDepositSuspendedcurrentWithdrawalSuspendedcurrentDepositcurrentWithdrawcurrentActiverN  withdrawFee
networkFeekwithdrawPlatformfeeCurrencyIddepositSuspendedwithdrawalSuspendedrg  r   r8  withdrawalFeesr   withdrawalFeeInnerr=  r_  withdrawalFeesByPrioritywithdrawalFeeri  s+                                              r  fetch_currencieszprobit.fetch_currencies  s    55f=r __Xvr:
q#j/* `	A!!}H!!(D1B**2.D//(NCK##K9D*bAI"&,,y*"EH "K1c"567 '-a0**7D9"55g>*.//'CV*W'-1__WF\-]*%<!<&@"@ . B? &H 001A1A';1WX	"oog7GL!__[!R@
q#k"23 A'21~$$($4$45E}$UM$*%5
 "*+- /++JA!%!2!29!= $(#3#3G=T#U#'%
 $(#3#3G=Q#R#'$	 $%,K()'P ??+>2F#x9LM"&//(<R"S**G..H)F!__X7GLND 1c.12 4%3A%6"))*<hG,,-?L&X-AKK 234 (,||D*'E$ OO,DaLM""=(;C  "$ !..t/C/CDDTDTU]_jDk/lm  $#
  $//:NO# 
  $//:QR#! (3F4LM`	B r  c                 X   |d d d}| j                  |dg       }t        dt        |            D ]i  }||   }| j                  |d      }| j	                  |      }| j                         }| j                  |d      |d<   | j                  |d      |d<   |||<   k | j                  |      S )N)rQ  	timestampdatetimer  r   rc  total	availablefree)r!  rm  rn  rR  rS  accountsafe_balance)	r  r$  rt  r  ru  r   
currencyIdrk  r  s	            r  parse_balancezprobit.parse_balanceK  s    

 x4q#d)$ 	#A1gG))'=AJ**:6DllnG#//AGG"..wDGFO"F4L	#   ((r  c                 f    | j                          | j                  |      }| j                  |      S )aX  

        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\  s3     	))&1 !!(++r  Nr/  r   c           	         | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |dg       }| j                  |d      }| j                  ||d   dddd	d
      S )a-  

        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sellr>  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_bookt  s     	V$
 **4;;w+GH x4]]40
$$Z1A4PVX_akllr  symbolsc                     | j                          i }|%| j                  |      }dj                  |      |d<   | j                  | j	                  ||            }| j                  |dg       }| j                  ||      S )a  

        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>`
        ,
market_idsr  )r  r  joinpublicGetTickerr  	safe_listparse_tickers)r  r  r#  r  	marketIdsr$  r  s          r  fetch_tickerszprobit.fetch_tickers  s~     	0I$'HHY$7GL!''GV(DE" ~~h3!!$00r  c                 6   | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |dg       }| j	                  |d      }|t        | j                  dz         | j                  ||      S )a  

        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   z) 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_ticker  s     	V$&,
 ''GV(DE" x4q)>dgg(SSTT  00r  r   c                    | j                  | j                  |d            }| j                  |d      }| j                  ||d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  i d|d	|d
| j	                  |      d| j                  |d      d| j                  |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quoteVolumerQ  )	parse8601rR  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D	##FK8!!(FC8  0!!&(3%%fm<
&&v~> !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4!
 !
 4!
 !
 D!
 D!
 U!
 E!
 T!
 f!
  $!!
" t#!
$ %&)!
* + 	r  sincec                    | j                          d}| j                         }d| j                  |dz
        | j                  |      d}|| j                  |      }|d   |d<   |5| j                  |      |d<   | j                  t	        ||dz               |d<   |||d	<   | j                  | j                  ||            }| j                  |d
g       }	| j                  |	|||      S )a  

        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   rA  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S)

 [[(F#)$<GK $(LL$7GL!"&,,s38K/L"MGJ$GG..t{{7F/KL( ~~h3  vue<<r  c                 z   | j                          | j                  |      }|d   d| j                  | j                               d}|| j                  |      |d<   |t	        |d      |d<   nd|d<   | j                  | j                  ||            }| j                  |dg       }| j                  ||||      S )a  

        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  r  r   r   r  )	r  r   r  r  rA  publicGetTrader  r  r  )	r  r/  r  r   r#  r   r  r$  r  s	            r  fetch_tradeszprobit.fetch_trades9  s     	V$4T%6%6%89

 $(LL$7GL!"5$/GG#GG&&t{{7F'CD. ~~h3  vue<<r  r   c                 l   | j                  | j                  |d            }| j                  |d      }d }|#|j                  d      }| j                  |d      }| j                  |d|      }| j                  ||d      }| j                  |d      }| j                  |d      }	| j                  |d	      }
| j                  |d
      }| j                  |d      }d }|(| j                  |d      }| j	                  |      }||d}| j                  |||| j                  |      ||d |d |	|
d |d|      S )Nr   r,   :r   r  r  r  r>  r  order_id
fee_amountfee_currency_id)r?  r   )r,   rQ  r  r  r/  r   r7  r  takerOrMakerr>  r=  r?  ri  )r  rR  splitr  rS  
safe_trader  )r  r   r   r  r,   r  partsr/  r  priceStringamountStringorderIdfeeCostStringri  r  feeCurrencyCodes                   r  parse_tradezprobit.parse_tradel  sd   : NN4#3#3E6#BC	eT*>HHSME''q1H##E;A!!(FC8v.&&ug6''z:""5*5((=$ ,,U4EFM"55mDO%+C "Y/  " 
  	r  c                 j    | j                  |      }| j                  | j                  |d            }|S )aF  

        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  rR  )r  r#  r$  r  s       r  
fetch_timezprobit.fetch_time  s7     %%f- NN4#3#3Hf#EF	r  c                    | j                  |      }|dk(  r| j                  |      }|j                  d      }| j                  |d      }| j	                  |d      }d }	|r| j                  |t        d            }	|dk  rdt        |      z   }	|dz   |	z   dz   S |dk(  ry| j                  |d	z        }d
}
||
z
  }t        t        j                  ||z              }| j                  |
||z        }|r| j                  ||      }| j                  |d	z        S | j                  |d	z        }|| j                  ||z        z  }|r| j                  ||      }| j                  |d	z        S )Nr   r  r   r   
   0z-01T00:00:00.000Zr   r   i )parse_timeframer  r  rR  rq  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_timestamp  sv   ''	2ll9-GMM#&E##E1-D%%eQ/E#K"hhuc!f5rz!CJ.#:+.AAA$)))d*:;I K"[0J4::j8&;<=H!XXk8h3FGN!%.(!C<< 566)))d*:;I 4#4#4Y5I#JJI HHY9	<<	D 011r  r   c                    | j                          | j                  |      }| j                  | j                  ||      }|dn|}| j	                  |d      }t        d|      }|d   |d|d}	| j                         }
| j                  |d      }| j                  |      dz  }|}|||z
  n|
}|||}|dz
  }|||z  z
  }n#|!| j	                  |||z        }t        ||      }| j                  ||      }| j                  ||d      }||	d	<   ||	d
<   | j                  | j                  |	|            }| j                  |dg       }| j                  |||||      S )a  

        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
        :param str [params.until]: timestamp in ms of the earliest candle to fetch
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r  r   r   r,   asc)r  intervalsortr   untilTr  r  r  )r  r   rR  r   r  rA  r  rq  r  r  publicGetCandler  r  parse_ohlcvs)r  r/  r  r  r   r#  r   r  requestLimitr  r  r  durationMilliseconds	startTimeendTime
startLimit
endByLimitstartTimeNormalizedendTimeNormalizedr$  r  s                        r  fetch_ohlcvzprobit.fetch_ohlcv  s    	V$##DOOY	JExxq)4. , !	
 !!!&'2#33I>E	383D%..3=}$J*/C"CCI !XXeU5I-IJ
gz2"<<Y	R ::7ItT 3/
''GV(DE$ ~~h3  vy%GGr  c           	          | j                  | j                  |d            | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Nr  r  r  r  r  r  )r  rR  rW  )r  ohlcvr   s      r  parse_ohlcvzprobit.parse_ohlcv  sw     NN4++E<@AUF+UF+UE*UG,UM2
 	
r  c                    | j                          | j                  |      }i }d}|| j                  |      }|d   |d<   | j                  | j	                  ||            }| j                  |d      }| j                  ||||      S )a  

        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_orders3  s     	u%[[(F#)$<GK ++DKK,HI~~h/  vue<<r  c                    | j                          | j                  d      | j                  | j                               dd}d}|| j                  |      }|d   |d<   |r| j                  |      |d<   |r||d<   | j	                  | j                  ||            }| j                  |d	      }| j                  ||||      S )
a)  

        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_ordersJ  s     	,,q/T%6%6%89

 [[(F#)$<GK $(LL$7GL!$GG..t{{7F/KL~~h/  vue<<r  r,   c                    |t        | j                  dz         | j                          | j                  |      }d|d   i}| j	                  |dd      }|||d<   n||d<   | j                  |ddg      }| j                  | j                  ||            }| j                  |dg       }	| j                  |	d      }
| j                  |
|      S )	a  

        https://docs-en.probit.com/reference/order-3

        fetches information on an order made by the user
        :param str id: the 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>`
        z( 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_orderh  s     >#DGG.X$XYYV$
 **6?DUV$)6G%&"$GJ		&?4E"FG''GU(CDx4tQ'v..r  statusc                 4    dddd}| j                  |||      S )Nr  canceledr*  )r  	cancelledfilledrR  r  r'  statusess      r  parse_order_statuszprobit.parse_order_status  s)    #

 &&99r  r   c                 z   | j                  | j                  |d            }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  ||d      }| j                  | j                  |d            }	| j                  |d      }
| j                  |d	      }| j                  |d
      }| j                  |d      }|t	        j
                  ||      }| j                  |dt	        j
                  ||            }| j                  |dd      }|dk(  rd }
| j                  |d      }| j                  |d      }| j                  i d|d|d|d|	d| j                  |	      dd d|d|d|d|d|d|
dd d|d|d|dd |d d d|      S ) Nr'  r,   r7  r  r  r  r   limit_pricefilled_quantityopen_quantitycancelled_quantityr  filled_costr?  r   r  time_in_forcerQ  r  r  r  lastTradeTimestampr/  r   r>  r   r=  r+  	remainingr  )r?  ri  trades)
r/  rR  r  r  r'   
string_addr   safe_string_upper
safe_orderr  )r  r   r   r'  r,   r7  r  r  r/  r  r>  r+  r8  canceledAmountr=  r?  r  r   s                     r  r$  zprobit.parse_order  s^   ( (()9)9%)JKeT*v.v.##E;7!!(FC8NN4#3#3E6#BC	  6!!%):;$$UO<	))%1EF%**9nEI!!%W5G5GPY5Z[!!%?8E((0AB,,UOD  
" 
E 
 ] 
 	 

 Y/ 
 !$ 
 f 
 D 
 ; 
 D 
 f 
 U 
 D 
 f 
 f 
  ! 
" t# 
$ ) 
* + 	r  c                 l    | j                  |t        | j                  |   d   d   | j                        S )NrN  r?  )decimal_to_precisionr%   r%  r   )r  r/  r?  s      r  cost_to_precisionzprobit.cost_to_precision  s4    ((xf9Mk9Z[a9bdhdvdvwwr  r7  r  r=  r>  c                 Z   | j                          | j                  |      }| j                  | j                  d      }| j                  ||      }	| j	                  |dd|	      }
|d   |||
d}| j	                  |dd      }|||d<   d}|dk(  r+| j                  ||      |d	<   | j                  ||      |d
<   n|dk(  r|dk(  rd}| j                  |ddd      \  }}| j                  |d      }| j                  |d      }|| j                  ||      }ny|re|t        | j                  dz         | j                  |      }| j                  |      }t        j                  ||      }| j                  ||      }n| j                  ||      }||d<   n| j                  ||      |d
<   | j                  |g d      }| j!                  | j#                  ||            }| j                  |d      }| j%                  ||      }|dk(  r#|dk(  rd|d<   | j'                  |      |d<   d|d<   |S )a  
        create a trade order

        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 fulfilled, 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   r6  r,   )r  r7  r  r6  r  r  Nr   r1  r  r   r  TrB   r   r?  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   r6  r  r  r  r=  r8  )r  r   r!  r   r   price_to_precisionamount_to_precisionhandle_option_and_paramsrR  r!  r@  r    r,   number_to_stringr'   
string_mulprivatePostNewOrderr  r$  r  )r  r/  r7  r  r=  r>  r#  r   r   defaultTimeInForcer   r  r  quoteAmountr   r?  r  r  costRequestr%  r$  r  r   s                          r  create_orderzprobit.create_order  sx    	V$//$,,>!__Wd;((Qcd(	
 **6?DUV$)6G%&7?%)%<%<VU%KGM""&":":66"JGJXu}481<@<Y<YZ`bo  rU  W[  =\916''7662#"&"8"8"FK6}*477  6q  ,q  r  r'+'<'<V'D&*&;&;E&B&-&8&8{&S&*&<&<V[&Q"&"8"8"HK"-&*&>&>vv&N
#		&"fg++DKK,GH, x0  v. H45="E(O --k:E&M!%E+r  c                    |t        | j                  dz         | j                          | j                  |      }|d   |d}| j	                  | j                  ||            }| j                  |d      }| j                  |      S )a{  

        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>`
        z) 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     >#DGG.Y$YZZV$
 ..t{{7F/KL~~h/%%r  r   c                     | j                  |d      }| j                  |d      }| j                  |d      }| j                  ||      }|d   }| j                  |d      }| j                  |       |||||dS )Naddressdestination_tagrc  rk  platform_id)rQ  r   rh  rO  tag)rR  safe_currencycheck_address)r  depositAddressr   rO  rR  r  rk  rh  s           r  parse_deposit_addresszprobit.parse_deposit_address=  s    "">9=~/@A%%nmD
%%j(;"">=A7#"
 	
r  rk  c                    | j                          | j                  |      }d|d   i}| j                  | j                  di       }| j	                  |d      }| j                  |||      }|||d<   | j                  |d      }| j                  | j                  ||            }| j                  |dg       }| j                  |d      }	|	t        | j                  dz         | j                  |	|      S )	ax  

        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>`
        rc  r,   r   rh  rQ  r  r   z1 fetchDepositAddress() returned an empty response)r  r   r!  r   r;  rR  r!  privateGetDepositAddressr  r   r,   rV  )
r  rk  r#  r   r  r   rh  r$  r  firstAddresss
             r  fetch_deposit_addresszprobit.fetch_deposit_addressM  s     	==&8D>
 ??4<<R@((;""8Wg>%,GM"YYv}5F00Wf1MN0 x4tQ/ +^!^__)),AAr  codesc                 f   | j                          i }|rXg }t        dt        |            D ]*  }| j                  ||         }|j	                  |d          , dj                  |      |d<   | j                  | j                  ||            }| j                  |dg       }| j                  ||      S )a  

        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  rc  r  )
r  rm  rn  r   rr  r  rX  r  r  parse_deposit_addresses)	r  r[  r#  r  currencyIdsru  r   r$  r  s	            r  fetch_deposit_addresseszprobit.fetch_deposit_addresses  s     	K1c%j) 3==q2""8D>23 &)XXe_GM"00Wf1MN~~h3++D%88r  rO  c                 
   | j                  ||      \  }}| j                  |       | j                          | j                  |      }|d}|d   ||| j	                  |      d}| j                  | j                  di       }| j                  |d      }	| j                  ||	|	      }	|	|	|d<   | j                  |d      }| j                  | j                  ||            }
| j                  |
d      }| j                  ||      S )a  

        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>`
         r,   )rc  rO  rP  r=  r   rh  rQ  r  )handle_withdraw_tag_and_paramsrT  r  r   rE  r!  r   r;  rR  r!  privatePostWithdrawalr  r#  parse_transaction)r  rk  r=  rO  rR  r#  r   r  r   rh  r$  r  s               r  r   zprobit.withdraw  s    99#vFV
 	7#==&;C#D>"++F3
 ??4<<R@((;""8Wg>%,GM"YYvy1F--dkk'6.JK~~h/%%dH55r  c           	      V    ddi}| j                  |||| j                  ||            }|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>`
        r7  rg  fetch_transactionsr  r  rk  r  r   r#  r  rt  s          r  fetch_depositszprobit.fetch_deposits  s9     I
 ((ueT[[RX=YZr  c           	      V    ddi}| j                  |||| j                  ||            }|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>`
        r7  r   rf  rh  s          r  fetch_withdrawalszprobit.fetch_withdrawals  s9     L
 ((ueT[[RX=YZr  c                    | j                          d}i }|| j                  |      }|d   |d<   || j                  |      |d<   n| j                  d      |d<   | j                  |d      }|(| j                  |      |d<   | j	                  |dg      }n"| j                  | j                               |d<   |||d<   nd	|d<   | j                  | j                  ||            }| j                  |d
g       }	| j                  |	|||      S )ad  
        fetch history of deposits and withdrawals

        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 dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch transactions for
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr,   rc  r  r   r  r  r   r  r  )
r  r   r  rq  r!  r  privateGetTransferPaymentr  r  parse_transactions)
r  rk  r  r   r#  r   r  r  r$  r  s
             r  fetch_deposits_withdrawalsz!probit.fetch_deposits_withdrawals  s     	!}}T*H%-d^GM"$(LL$7GL!$(LLOGL!!!&'2"&,,u"5GJYYvy1F"&,,t/@/@/B"CGJ$GG"GG11$++gv2NO2 ~~h3&&tXueDDr  transactionc                    | j                  |d      }| j                  |d      }| j                  |      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  | j                  |d            }
| j                  |d      }| j                  |d	      }| j	                  |      }| j                  | j                  |d
            }| j                  |d      }d }||dk7  r|| j                  |      d}i d|d|d|d|dd d|d|dd d|d|d
|d|d|	d|
d| j                  |
      dd dd d ||dS )Nr,   rQ  r=  rO  rP  hashr   r7  rc  r'  ri  r  )r   r?  r   rh  addressFrom	addressTotagFromrR  tagTotxidr  r  updatedinternal)commentri  rQ  )rR  rp  rW  r  rS  parse_transaction_statusr  r  )r  rp  r   r,   	networkIdr|  r=  rO  rR  rw  r  r7  r  rk  r'  r  ri  s                    r  rd  zprobit.parse_transaction  s   * k40$$[-@	--i8!!+x8"";	:{,=>V4NN4#3#3K#HI	V4%%k=A
&&z2..t/?/?X/VW((e<$#)= ))-8C
"

 f
 {	

 4
 w
 
 t
 3
 S
 f
 D
 D
 
 Y/
  t!
" #
$ )
 	
r  c           	      >    ddddddddd}| j                  |||      S )Npendingokr)  )	requestedr~  
confirming	confirmedapplyingdoner*  
cancellingr,  r-  s      r  r{  zprobit.parse_transaction_status^  s8    " #"!#$	
 &&99r  c                     | j                          | j                  |      }| j                  |d      }| j                  ||d      S )a_  

        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  rl  r  parse_deposit_withdraw_fees)r  r[  r#  r$  r  s        r  fetch_deposit_withdraw_feesz"probit.fetch_deposit_withdraw_feesk  sH     	55f=p ~~h///eTBBr  c                    | j                  i       }| j                  |dg       }d d d}t        dt        |            D ]  }||   }| j	                  |d      }| j                  ||d         }	| j                  |di       }
| j                  |
d   d      }t        |
      sc||dnd d}|dk(  r||d	<   ||d
|d   |	<    ||d<   |S )Nr^  )ri  r   r   r,   rk  rb  r=  Fr   rf  r   rQ  )deposit_withdraw_feer!  rm  rn  rR  rp  rW  )r  ri  r   depositWithdrawFeerw  depositResultru  rh  r|  r|  r  r  withdrawResults                r  parse_deposit_withdraw_feez!probit.parse_deposit_withdraw_fee  s   F "66r:OOCR8	
 q#i.) 	AlG(($7I11)Xf=MNK!__W6FKN**>!+<hGK>"&,7,C%$( 65C&z2 .,?":.{;	" &)6"!!r  c                 "    | j                         S N)r  )r  s    r  noncezprobit.nonce  s      ""r  r   GETc                    | j                   d   |   dz   }| j                  || j                  |            }|dk(  rp| j                          || j	                  ||      z  }| j
                  dz   | j                  z   }	| j                  |	      }
d|
z   dd}|r(| j                  |      }n|| j                  dz   z  }|dk(  r/|| j	                  ||      z  }|r|d	| j                  |      z   z  }n|d
k(  r| j                         }| j                          | j                  | j                  d      }|||k  rt        | j                  dz         | j!                  | j                  d      }dd|z   i}|| j	                  ||      z  }|dk(  r|r0|d	| j                  |      z   z  }n|r| j                  |      }d|d<   ||||dS )Nr   r0  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  rq  r   r   r,   rR  )r  pathr   r  r#  r  r  r  r%  authauth64r  r  r  s                 r  signzprobit.sign  s   iis#c)		&$"5"5d";<*++-4&&tV44C;;$t{{2D**40F!)F!2 2G yy'4<<#%%Cht**4883!666C	!'')//1++DLL)DO3-dgg8e.eff"..t||]K#Y%< t**488U?sT^^E%:::99U+D.@GN+fdwOOr  c                 6   | j                          ddi}| j                  | j                  ||            }| j                  |d      }| j	                  |d      }|| j
                  d<   | j                  | j                         |dz        | j
                  d<   |S )a  

        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  rq  rR  r   r  r  )r  r#  r  r$  	expiresInr  s         r  sign_inzprobit.sign_in  s     	'').
 ))$++gv*FG %%h=	&&x@&1]#"&((4+<+<+>	D@P"QYr  reasonr  r  r  r  c
                    |y d|v r| j                  |d      }
|
| j                  |dd      }| j                  |d      }| j                  dz   |
z   dz   |z   dz   | j                  |      z   }d| j                  v r | j                  | j                  d   |
|       d| j                  v r | j                  | j                  d   ||       t        |      y )N	errorCodemessagera  details r   broad)rR  r!  r,   r  r   throw_exactly_matched_exceptionthrow_broadly_matched_exceptionr   )r  rk  r  r  r  r  r  r$  requestHeadersrequestBodyr  
errMessager  feedbacks                 r  handle_errorszprobit.handle_errors3  s    ("((;?I$!--h	2F
//(I>77S=94s:ZG#MPTPYPYZaPbbdoo-889QS\^fgdoo-889QS]_gh#H--r  r  )F)D__name__
__module____qualname__r   r  r   r   r&  dictr[  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$  r@  r   r   floatr   rK  r   r   r	   rV  rZ  r_  r   r   ri  rk  ro  rd  r{  r  r  r  r  r  r  r  __classcell__)r  s   @r  r)   r)      s   \# \| $& #+$v, #+J@
4 @
F @
D ') eZ eN) )" $& ,( ,0 :>b ms m3 mY m< 04B !1W !17 !1F 02 $13 $1f $1L)4 ) )6 )V -1tRV_a 1=c 1= 1=C 1=f 6:UW 1=3 1=s 1=# 1=\`af\g 1=f@ @v @ @D !# s  2: 26DW[df ?H# ?Hc ?HQT ?Hkoptku ?HB
 
4 
. /3TXac = =3 =c =hlmrhs =. 154VZce =# =S =PS =jnotju =< 26b /c /3 /:: :< <v < <|x gksu V3 Vi Vy VRW V`c Vp 37r &s &C &.
h 
R` 
  79 2B# 2B^ 2Bh 8<B 9W 94P^K_ 9, DHPR +6S +6% +6# +6Wb +6Z *.Dt\^ 3 c  cghsct  -1tRV_a c  C fjkvfw  6:[_hj ;Es ;E# ;EUX ;Ez=
T =
X =
Q\ =
~:s : <@ DC DCL;" ;"z# &eBSW %PN   6# s  c TX `c 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   r   r   typingr   ccxt.base.errorsr   r   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     sq    ( ,  }  }  }  }  }  * 0 . ' & ) . + ) + . 1 ( 3 4 %dX{ dr  