
    E#i4                         S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr   " S S\\5      rg)    )Exchange)ImplicitAPIN)AnyIntMarketNumOrder	OrderSide	OrderTypeStrStringsTickerTickers)List)AuthenticationError)ArgumentsRequired)
BadRequest)InsufficientFunds)ExchangeNotAvailable)	TICK_SIZEc                   d  ^  \ rS rSrS\4U 4S jjr0 4S\\   4S jjrS\	S\4S jr
S0 4S\S\4S	 jjr0 4S
\S\4S jjrS1S\4S jjrS0 4S
\S\4S jjrSS0 4S
\S\S\4S jjrS1S\	S\4S jjrSSS0 4S
\S\S\S\4S jjrS1S\S\4S jjr0 4S jrS rS0 4S
\S\S\S\S\4
S jjrS0 4S\S
\ 4S jjr!SSS0 4S
\ S\S\4S  jjr"SSS0 4S\S
\ S\S\4S! jjr#SSS0 4S
\ S\S\4S" jjr$SSS0 4S
\ S\S\S\\%   4S# jjr&S1S$\	S\S\%4S% jjr'S&S'0 SS4S( jr(S)\)S*\S+\S,\S-\	S.\4S/ jr*S0r+U =r,$ )2p2b   returnc                   > U R                  [        [        U ]  5       0 SS_SS_SS/_SS_SS	_S
S_S0 SS _SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_S S_S!S_S"S_S#S_S$S_S%S_S&S_S'S_S(S_S)S_S*S_S+S_S,S_S-S_S.S_S/S_E0 S0S_S1S_S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_E0 SAS_SBS_SCS_SDS_SES_SFS_SGS_SHS_SIS_SJS_SKS_SLS_SMS_SNS_SOS_SPS_SQS_E0 SRS_SSS_STS_SUS_SVS_SWS_SXS_SYS_SZS_S[S_S\S_S]S_S^S_S_S_S`S_SaS_SbS_E0 ScS_SdS_SeS_SfS_SgS_ShS_SiS_SjS_SkS_SlS_SmS_SnS_SoS_SpS_SqS_SrS_SsS_ESSSSSSSSSSSSSSt.E_SuSvSwSxSy._SzS{S|S}S~SS.SSSS._SSSSSSSSSSS.0SSSSSSSSSSSS.
0S._SSSSU R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //S.0_SSSSSS SSS SSSSS.SSSSSSSS.S SSSSSS.S SSSSSS.S SSSSSSSSS.SS0S.	S S S.S S S.S._S0 _S[
        _S0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _E[        [        [        [        [        [        [        S.E_S0 _5      $ )Nidr   name	countriesLT	rateLimitd   versionv2proThasCORSspotmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateMarketOrdercreateOrdercreateOrderscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAccountsfetchAllGreeksfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLedgerfetchLedgerEntryfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChainfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickersfetchTradesfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransfersfetchUnderlyingAssetsfetchVolatilityHistory)fetchWithdrawAddressesfetchWithdrawalfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdraw
timeframes1m1h1d)r   r   r   urlsz.jsonz$https://p2pb2b.com?referral=ee784c53zQhttps://github.com/ccxt/ccxt/assets/43336371/8da13a80-1f0a-49be-bb90-ff8b25164755z$https://api.p2pb2b.com/api/v2/publiczhttps://api.p2pb2b.com/api/v2)publicprivatezhttps://p2pb2b.com/z?https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.mdz https://p2pb2b.com/fee-schedule/)	extensionreferrallogoapiwwwdocfeesr   get   )marketsmarkettickerstickerbookhistoryzdepth/resultzmarket/klinepost)
zaccount/balanceszaccount/balancez	order/newzorder/cancelorderszaccount/market_order_historyzaccount/market_deal_historyzaccount/orderzaccount/order_historyzaccount/executed_historyr   trading0z0.21z0.195z0.1810z0.1725z0.1675z0.15100z0.14150z0.13300z0.12450z0.11500z0.1z0.08z0.06z0.04z0.02z0.01)	tierBased
percentagetakermakerfeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergi )r   limitdaysBack	untilDayssymbolRequired)r   r   triggerr   r   gUUUUUU?)r   r   r   daysBackCanceledr   r   r   r   r   i  )	sandboxr7   r8   rm   
fetchOrderrr   rw   rG   rn   )linearinverse)r'   r)   r*   commonCurrenciesprecisionMode
exceptions1001100210031004100510061007100810091010101110121013101410151016201020202021203020402050205120522060206120622070300130203030304030503060)3070308030903100311040016010options)
deep_extendsuperr   describeparse_numberr   r   r   r   r   )self	__class__s    P/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/p2b.pyr  p2b.describe   s   c4 9 ; z>
%z>
Ez>
 $z>
 	z>

 tz>
 4z>
  ttt %t 	t
 %t %t Ut $Ut 't t "5t tt t $Ut  t  '!t" $U#t$ t%t& 't( &u)t* (+t, '-t. (/t0 "51t2  3t4 !%5t6 7t8 &u9t: "5;t< +E=t> )%?t@ #EAtB ,UCtD $TEtF 'GtH (ItJ KtL &uMtN (OtP 1%QtR  StT +EUtV &uWtX 'YtZ ([t\ #E]t^ *5_t` $Uatb uctd "5etf *5gth +Eitj )%ktl umtn #Eotp  qtr !%stt %eutv $Uwtx &uytz -e{t| /}t~ "5t@ #EAtB +ECtD EtF !%GtH !%ItJ "5KtL &uMtN +EOtP  QtR dStT $UUtV +EWtX %eYtZ "4[t\ u]t^ #E_t` !$atb "5ctd uetf #Dgth  itj 'ktl $Umtn !%otp *5qtr (stt %eutv )%wtx )%ytz t{t| }t~ tt@ %eAtB &uCtD 'EtF $UGtH !%ItJ (KtL )%MtN +0#($) %$)',$"!&#(!!gtz>
x yz>
B $BkD> -X:Cz>
Z #$"##$"# !#$()()	 ,-+,%&()"#8978)*1245[z>
R !%"&**3/1B1B51IJ**3/1B1B61JK**3/1B1B61JK**40$2C2CF2KL**40$2C2CF2KL**40$2C2CF2KL**5143D3DV3LM**5143D3DV3LM**5143D3DV3LM**5143D3DV3LM**5143D3DU3KL **3/1B1B51IJ**3/1B1B61JK**3/1B1B61JK**40$2C2CF2KL**40$2C2CF2KL**40$2C2CE2JK**5143D3DV3LM**5143D3DV3LM**5143D3DV3LM**5143D3DV3LM**5143D3DV3LM!Sz>
R $&+(-,1,0).+06:#'#'"&#(	( #($)$)+027/4#()$, %)&+!$$*%&*.& #'&+!$#($)*.( $(&+!$$*,2%&#($)*/	*  #g6p ##
 ##y@Sz>
T  !Uz>
X YYz>
Z  *+*+* +* +	*
 +* +* +* +* +* +* +* +* +* +* +*  +!*" 
#*$ 
%*& 
'*( 
)** )+*, 
-*. 
/*0 
1*2 
3*4 
5*6 
7*8 
9*: 
;*< 
=*> 
?*@ 
A*B 
C*D 
E*F #"""",)S*[z>
p	  q	z>
 z z	    c                    #    U R                  U5      I Sh  vN nU R                  US/ 5      nU R                  U5      $  N(7f)z
retrieves data on all markets for bigone

https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#markets

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
Nresult)publicGetMarkets
safe_valueparse_markets)r  paramsresponser   s       r  fetch_marketsp2b.fetch_marketsR  sD      ..v66< //(Hb9!!'**? 7s   AA )Ar   c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      nU R                  US5      nU R                  US5      nU R                  US5      n	0 SU_SUS	-   U-   _S
U_SU_SS _SU_SU_SS _SS_SS_SS_SS_SS_SS_SS_SS_SS _S S S S S S U R                  US5      U R                  US5      S.S S S.U R                  US5      U R	                  U R                  U5      5      S.U R                  US 5      U R	                  U R                  U	5      5      S.S S S.S!.S US".
E$ )#Nr   stockmoneylimits
max_amount	max_pricer   symbol/basequotesettlebaseIdquoteIdsettleIdtyper'   Tr(   Fr)   r*   r+   activecontractr   	step_size	tick_size)amountprice)minmax
min_amount	min_price)r   r1  r2  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionr!  createdinfo)safe_stringsafe_currency_coder  safe_numberr  	omit_zero)
r  r   marketIdr)  r*  r&  r'  r!  	maxAmountmaxPrices
             r  parse_marketp2b.parse_market|  s)   ##FF3!!&'2""673&&v.''02$$V\:	##FK80
(0
dSj5(0
 D0
 U	0

 d0
 f0
 w0
 0
 F0
 D0
 e0
 E0
 e0
 e0
 d0
  !0
" d#0
$  "**6;?))&+>  
  ++FLA,,T^^I-FG
  ++FK@,,T^^H-EF
  $ _0
 0	
r  Nsymbolsc                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US0 5      nU R                  XA5      $  NA N*7f)a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://futures-docs.poloniex.com/#get-real-time-ticker-of-all-symbols

:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr  )load_marketspublicGetTickersr  parse_tickers)r  rI  r  r  r  s        r  fetch_tickersp2b.fetch_tickers  sY      !!!..v664 8R8!!&229 	"6   AAAA)AAr$  c                 r  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  USS5      nU R                  XpR                  U5      S.U R                  Xc5      5      $  N N^7f)a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#ticker

:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr   r   r  
cache_time  )	timestampdatetime)rK  r   publicGetTickerextendr  safe_integer_productiso8601parse_ticker)r  r$  r  r   requestr  r  rT  s           r  fetch_tickerp2b.fetch_ticker  s      !!!V$fTl
 --dkk'.JKK* 8R8--hdK	{{#i1HIf-
 	
9 	"
 Ls"   B7B3?B7B5AB75B7c                 R   U R                  USS5      nSU;   a  U R                  US5      nU R                  US5      nU R                  0 SU R                  US5      _SU_SU R	                  U5      _SU R                  US5      _S	U R                  US	5      _S
U R                  US
5      _SS _SU R                  US5      _SS _SS _SU R                  US5      _SU_SU_SS _SS _SU R                  US5      _SS _U R                  USS5      U R                  US5      US.EU5      $ )NatrS  r   lastr$  rT  rU  highlowbid	bidVolumeask	askVolumevwapopenclosepreviousClosechanger   averagevolvolumedeal)
baseVolumequoteVolumer?  )rX  r  r@  safe_tickerrY  safe_string_2)r  r   r   rT  r`  s        r  rZ  p2b.parse_ticker
  s   @ --fdDA	v__VX6F/ !
d&&vx8!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 !
 4##FE2!
 !
 D!
 D$$VV4!
 T!
 D!
 T!
 d!
  $**68<!!
" t#!
$ ,,VUHE++FF;)!
* + 	r  r   c           	      N  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X%S'   U R                  U R                  XS5      5      I Sh  vN nU R	                  US0 5      nU R                  USS5      nU R                  XtS   US	S
SS5      $  N NE7f)a  
       fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

       https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#depth-result

       :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

EXCHANGE SPECIFIC PARAMETERS
       :param str [params.interval]: 0(default), 0.00000001, 0.0000001, 0.000001, 0.00001, 0.0001, 0.001, 0.01, 0.1, 1
       :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
       Nr   r   r   r  current_timerS  r$  bidsasksr   r   )rK  r   publicGetDepthResultrW  r  rX  parse_order_book)	r  r$  r   r  r   r[  r  r  rT  s	            r  fetch_order_bookp2b.fetch_order_bookE  s      !!!V$fTl
 $G224;;w3OPP4 8R8--hM	$$VH-=y&RXZ[]^__G 	" Qs#   B%B!AB%B#AB%#B%sincec                 v  #    U R                  5       I Sh  vN   U R                  US5      nUc  [        U R                  S-   5      eU R	                  U5      nUS   US.nUb  X7S'   U R                  U R                  Xt5      5      I Sh  vN nU R                  US/ 5      n	U R                  XX#5      $  N N+7f)a  
get the list of most recent trades for a particular symbol

https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#history

: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]: 1-100, default=50
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int params['lastId']: order id
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
NlastIdz; fetchTrades() requires an extra parameter params["lastId"]r   )r   r  r   r  )	rK  safe_integerr   r   r   publicGetHistoryrW  	safe_listparse_trades)
r  r$  r}  r   r  r  r   r[  r  r  s
             r  fetch_tradesp2b.fetch_tradesx  s      !!!""684>#DGG.k$kllV$Tl
 $G..t{{7/KLL( (B7  >>A 	" Ms"   B9B5A4B9B7*B97B9tradec                    U R                  USSS5      nU R                  US5      nUS:X  a  SnOUS:X  a  SnU R                  UU R                  US	S
5      UU R	                  U5      U R                  US5      U R                  USS5      S U R                  USS5      UU R                  US5      U R                  US5      U R                  US5      US   U R                  USS5      S.S.U5      $ )Ntime	deal_timerS  roler   r   2r   r   deal_idr$  dealOrderIddeal_order_idr,  sider2  r1  ro  r'  feedeal_feecurrencyr7  )r?  r   rT  rU  r$  orderr,  r  takerOrMakerr2  r1  r7  r  )safe_integer_product_2r@  
safe_traders  rY  )r  r  r   rT  r  s        r  parse_tradep2b.parse_trade  s   R //v{DQ	''v63"LS "L$$UD)<"Y/&&vx8''}oN&&uff=(%%eW5&&uh7$$UF3"7O**5%D 
" # 	r  r   	timeframec                   #    U R                  5       I Sh  vN   U R                  U5      nUS   US.nUb  XGS'   U R                  U R                  Xu5      5      I Sh  vN nU R	                  US/ 5      n	U R                  XX#U5      $  Nr N,7f)a}  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#kline

:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: 1m, 1h, or 1d
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: 1-500, default=50
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.offset]: default=0, with self value the last candles are returned
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nr   )r   intervalr   r  )rK  r   publicGetMarketKlinerW  r  parse_ohlcvs)
r  r$  r  r}  r   r  r   r[  r  r  s
             r  fetch_ohlcvp2b.fetch_ohlcv  s      !!!V$Tl!
 $G224;;w3OPP. (B7  5IIA 	" Qs"   BB	ABB+BBc           	          U R                  USS5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )Nr   rS  r               )rX  rB  )r  ohlcvr   s      r  parse_ohlcvp2b.parse_ohlcv  sp     %%eQ5UA&UA&UA&UA&UA&
 	
r  c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US0 5      nU R                  U5      $  NA N*7f)aP  
query for balance and get the amount of funds available for trading or funds locked in orders

https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#all-balances

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nr  )rK  privatePostAccountBalancesr  parse_balance)r  r  r  r  s       r  fetch_balancep2b.fetch_balance/  sY      !!!88@@$ 8R8!!&))) 	"@rP  c                 "   SU0n[        UR                  5       5      n[        S[        U5      5       HI  nX4   nX   nU R	                  U5      nU R                  US5      nU R                  US5      n	U	US.n
XU'   MK     U R                  U5      $ )Nr?  r   freeze	available)freeused)listkeysrangelenrA  r@  safe_balance)r  r  r  r  i
currencyIdbalancecoder  r  accounts              r  r  p2b.parse_balanceN  s     H
 HMMO$q#d)$AJ*G**:6D##GX6D((+>I!G #4L %   ((r  r,  r  r1  r2  c                   #    U R                  5       I Sh  vN   US:X  a  [        U R                  S-   5      eU R                  U5      nUS   UU R	                  X5      U R                  X5      S.nU R                  U R                  X5      5      I Sh  vN n	U R                  U	S5      n
U R                  X5      $  N N)7f)aF  
create a trade order

https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#create-order

:param str symbol: unified symbol of the market to create an order in
:param str type: must be 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float price: the price at which the order is to be fulfilled, in units of the quote currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   z7 createOrder() can only accept orders with type "limit"r   )r   r  r1  r2  r  )
rK  r   r   r   amount_to_precisionprice_to_precisionprivatePostOrderNewrW  	safe_dictparse_order)r  r$  r,  r  r1  r2  r  r   r[  r  r  s              r  create_orderp2b.create_orderl  s      !!!8TWW'``aaV$Tl..v>,,V;	
 11$++g2NOO. (3//E 	" Ps"   CB=A>CB?(C?Cr   c                 @  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   US.nU R	                  U R                  XS5      5      I Sh  vN nU R                  US5      nU R                  U5      $  Nh N)7f)ac  
cancels an open order

https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#cancel-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   orderIdr  )r   r   rK  r   privatePostOrderCancelrW  r  r  )r  r   r$  r  r   r[  r  r  s           r  cancel_orderp2b.cancel_order  s      >#DGG.Y$YZZ!!!V$Tl
 44T[[5QRR. (3''= 	" Ss"   /BBA B2B3(BBc                 P  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X6S'   U R	                  U R                  Xd5      5      I Sh  vN nU R                  US/ 5      nU R                  XX#5      $  Np N+7f)a  
       fetch all unfilled currently open orders

       https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#open-orders

       :param str symbol: unified market symbol of the market orders were made in
       :param int [since]: the earliest time in ms to fetch orders for
       :param int [limit]: the maximum number of order structures to retrieve
       :param dict [params]: extra parameters specific to the exchange API endpoint

EXCHANGE SPECIFIC PARAMETERS
       :param int [params.offset]: 0-10000, default=0
       :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
       Nz/ fetchOpenOrders() requires the symbol argumentr   r   r   r  )r   r   rK  r   privatePostOrdersrW  r  parse_orders)	r  r$  r}  r   r  r   r[  r  r  s	            r  fetch_open_ordersp2b.fetch_open_orders  s      >#DGG._$_``!!!V$fTl
 $G//G0LMM4 (B7  >>E 	" Ns"   /B&B"AB&8B$9*B&$B&c                 :  #    U R                  5       I Sh  vN   U R                  U5      nSU0nUb  XGS'   U R                  U R                  Xu5      5      I Sh  vN nU R	                  US0 5      n	U R                  U	S/ 5      n
U R                  XX45      $  N N>7f)af  
       fetch all the trades made from a single order

       https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#deals-by-order-id

       :param str id: order id
       :param str symbol: unified market symbol
       :param int [since]: the earliest time in ms to fetch trades for
       :param int [limit]: 1-100, default=50
       :param dict [params]: extra parameters specific to the exchange API endpoint

EXCHANGE SPECIFIC PARAMETERS
       :param int [params.offset]: 0-10000, default=0
       :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
       Nr  r   r  records)rK  safe_marketprivatePostAccountOrderrW  r  r  r  )r  r   r$  r}  r   r  r   r[  r  r  r  s              r  fetch_order_tradesp2b.fetch_order_trades   s       !!!!!&)r
 $G55dkk'6RSS0 8R8..B7  %??C 	" Ts"   BBABB=BBc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  US5      nU R	                  US5      nUc  Uc  U R                  5       nOUS-   nUc  US-
  nXR-
  S:  a  [        U R                  S-   5      eU R                  U5      nUS   U R                  US-  5      U R                  US-  5      S.nUb  X7S	'   U R                  U R                  Xt5      5      I Sh  vN nU R                  US
0 5      n	U R                  U	S/ 5      n
U R                  XX#5      $  GN N?7f)a  
       fetch all trades made by the user, only the transaction records in the past 3 month can be queried, the time between since and params["until"] cannot be longer than 24 hours

       https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#deals-history-by-market

       :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, default = params["until"] - 86400000
       :param int [limit]: 1-100, default=50
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param int [params.until]: the latest time in ms to fetch orders for, default = current timestamp or since + 86400000

EXCHANGE SPECIFIC PARAMETERS
       :param int [params.offset]: 0-10000, default=0
       :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
       Nz+ fetchMyTrades() requires a symbol argumentuntil \&z[ fetchMyTrades() the time between since and params["until"] cannot be greater than 24 hoursr   rS  )r   	startTimeendTimer   r  deals)r   r   rK  r  omitmillisecondsr   r   parse_to_int#privatePostAccountMarketDealHistoryrW  r  r  r  )r  r$  r}  r   r  r  r   r[  r  r  r  s              r  fetch_my_tradesp2b.fetch_my_trades3  sb      >#DGG.[$[\\!!!!!&'267+=}))+(=H$EMX%TWW  (E  E  F  FV$Tl**54<8((6

 $GAA$++gB^__6 8R8vw3  ==c 	"( `s"   /EECEE=EEc                   #    U R                  5       I Sh  vN   U R                  US5      nU R                  US5      nSnUb  U R                  U5      nUc  Uc  U R	                  5       nOUS-   nUc  US-
  nXR-
  S:  a  [        U R                  S-   5      eU R                  US-  5      U R                  US-  5      S.nUb  US   US'   Ub  X7S	'   U R                  U R                  Xt5      5      I Sh  vN nU R                  US
5      n	/ n
[        U	R                  5       5      n[        S[        U5      5       H.  nX   nX   nU R                  XX#5      nU R!                  X5      n
M0     U
$  GN\ N}7f)aq  
       fetches information on multiple closed orders made by the user, the time between since and params["untnil"] cannot be longer than 24 hours

       https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#orders-history-by-market

       :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, default = params["until"] - 86400000
       :param int [limit]: 1-100, default=50
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param int [params.until]: the latest time in ms to fetch orders for, default = current timestamp or since + 86400000

EXCHANGE SPECIFIC PARAMETERS
       :param int [params.offset]: 0-10000, default=0
       :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
       Nr  r  z_ fetchClosedOrders() the time between since and params["until"] cannot be greater than 24 hoursrS  )r  r  r   r   r   r  r   )rK  r  r  r   r  r   r   r  privatePostAccountOrderHistoryrW  r  r  r  r  r  r  array_concat)r  r$  r}  r   r  r  r   r[  r  r  r   r  r  rD  marketOrdersparsedOrderss                   r  fetch_closed_ordersp2b.fetch_closed_ordersx  s      !!!!!&'267+[[(F=}))+(=H$EMX%TWW  (I  I  J  J**54<8((6
  &tGH$G<<T[[=YZZ6 84FKKM"q#d)$AwH!+L,,\5PL&&v<F	 %
 u 	". [s#   E7E2C E77E58A;E75E7r  c           
      :   U R                  USSS5      nU R                  US5      nU R                  XB5      nU R                  0 SU_SU R	                  USS5      _SS _SU_S	U R                  U5      _S
S _SUS   _SU R                  US5      _SS _SS _SU R                  US5      _SU R                  US5      _SS _SU R                  US5      _SS _SS _SU R                  US5      _U R                  US5      S US   U R                  US5      S.S S.EU5      $ )NrT  ctimerS  r   r?  r   r  clientOrderIdrU  lastTradeTimestampr$  r,  r   postOnlyr  r2  r   r1  r7  rl  filled	dealStockleftr'  dealFeer  )	remainingstatusr  trades)r  r@  r  
safe_orderrs  rY  )r  r  r   rT  rD  s        r  r  p2b.parse_order  s   L //{GTR	##E84!!(3  
E 
$$$UD)< 
 T 
 	 

 Y/ 
 !$ 
 fX& 
 D$$UF3 
 4 
  
 D$$UF3 
 T%%eW5 
 D 
 d&&uh7 
 D 
  t! 
" d&&uk:# 
$ ))%8"7O((	: 1 
2 3 	r  r   GETc           	      H   U R                   S   U   S-   U R                  X5      -   nU R                  X@R                  U5      5      nUS:X  a  U(       a  USU R	                  U5      -   -  nUS:X  a  SU-   US'   [        U R                  5       5      US'   U R                  U R                  U5      5      nS	U R                  UU R                  U R                  U5      U R                  U R                  5      [        R                  5      S
.nU R                  U5      nXsXeS.$ )Nr   r%  r  ?r   z/api/v2/r[  noncezapplication/json)zContent-TypezX-TXC-APIKEYzX-TXC-PAYLOADzX-TXC-SIGNATURE)urlmethodbodyheaders)r   implode_paramsr  extract_params	urlencodestrr  string_to_base64jsonapiKeyhmacencodesecrethashlibsha512)	r  pathr   r  r  r  r  r  payloads	            r  signp2b.sign  s   iis#c)D,?,?,MM6#6#6t#<=U?sT^^F333) *T 1F9!$**,/F7O++DIIf,=>G 2 $!(#'99T[[-A4;;t{{C[]d]k]k#l	G 99V$DdOOr  r  reasonr  r  r  r  c
                     Uc  g US:X  aa  U R                  US5      n
U R                  U
S5      nU R                  S-   U R                  U5      -   nU R	                  U R
                  X5        g )Ni  errorr   )r  r@  r   r  throw_exactly_matched_exceptionr   )r  r  r  r  r  r  r  r  requestHeadersrequestBodyr  	errorCodefeedbacks                r  handle_errorsp2b.handle_errors  sf    3;OOHg6E((7Iww}tyy'::H00)Vr   )N)-__name__
__module____qualname____firstlineno__r   r  r   r   r  dictrG  r   r   rN  r  r   r\  rZ  r   r{  r  r  r  r  r  r  r  r   r
   floatr   r  r   r  r  r  r  r	   r  r  r  intr  __static_attributes____classcell__)r  s   @r  r   r      s   {# {z	 *, (+V (+T9
4 9
F 9
v 6:" &37 &3 &3P 68 )
 )
F )
V96 9v @DB 1`S 1` 1`f <@d[] -? -?S -? -?^@ @v @D ?CQUdhqs .J .J .J3 .J^a .J`
 
4 
, *, *>)< mqy{ 00 00I 00Y 00X] 00fi 00d 9=R +(S +(# +(Z 59tZ^gi 3?c 3? 3?TW 3?j ?CQUdhqs 1@3 1@ 1@3 1@^a 1@f 37TX\eg C>C C>s C>RU C>J 7;\`ik J J3 JVY Jptuzp{ JXB Bv B BH &eBSW P&	# 	s 	 	c 	TX 	`c 	 	r  r   ) ccxt.async_support.base.exchanger   ccxt.abstract.p2br   r	  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   ccxt.base.decimal_to_precisionr   r   r  r  r  <module>r*     sA    6 )  m m m m  0 . ' . 1 4Q(K Qr  