
    E#i                         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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BalancesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypePositionStrStringsTickerFundingRateTradeTradingFeeInterfaceTransactionMarketInterface)List)ExchangeError)ArgumentsRequired)OrderNotFound)OnMaintenance)	TICK_SIZE)Precisec                     ^  \ rS rSrS\4U 4S jjrS rSCS\S\S\S	\S\	4
U 4S
 jjjr
0 4S\\   4S jjrS\4S jr0 4S\4S jjrS0 4S\S\S\4S jjrSDS\S\S\4S jjr0 4S\S\4S jjrSDS\S\S\4S jjrSS0 4S\S\S\S\\   4S jjr0 4S\S\4S jj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 \4S! jr#SDS"\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\S\\$   4S& jjr'SSS$0 4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0 4S*\+S\\,   4S+ jjr-S0 4S,\S\S-\S.\S\.4
S/ jjr/SSS0 4S,\S\S\S\\.   4S0 jjr0SSS0 4S,\S\S\S\\.   4S1 jjr1S2 r2S3 r3SDS4\S5\4S\.4S6 jjr50 4S\S\64S7 jjr7SDS\S\64S8 jjr8S9S:0 SS4S; jr9S,\:S<\S=\S>\S?\S@\4SA jr;SBr<U =r=$ )Ebitflyer   returnc                 T  > U R                  [        [        U ]  5       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S,S-S.0S/S0S1.S2/ S3Q0/ S4Q/ S5QS6.S7.S8U R	                  S95      U R	                  S95      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S=SSS	S@.SS=S S SSS	SA.SS=S S S SSS	SB.S SC.	S S SD.S S SD.SE.SFSG[        00SH.5      $ )INr    bitFlyerJPv1i  zbitflyer.comCORSspotTmarginFswapfutureoptioncancelAllOrderscancelOrdercreateOrderfetchBalancefetchClosedOrdersemulatedfetchCurrenciesfetchDepositsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchMarginModefetchMarketsfetchMyTradesfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionModefetchPositionsfetchTickerfetchTradesfetchTradingFeefetchTradingFeesfetchTransferfetchTransfersfetchWithdrawalstransferwithdrawzOhttps://github.com/user-attachments/assets/d0217747-e54d-4533-8416-0d553dca74bbrestzhttps://api.{hostname}zhttps://bitflyer.comz+https://lightning.bitflyer.com/docs?lang=en)logoapiwwwdocget)
zgetmarkets/usazgetmarkets/eu
getmarketsgetboard	gettickergetexecutions	gethealthgetboardstategetchatsgetfundingrate)getpermissions
getbalancegetbalancehistorygetcollateralgetcollateralhistorygetcollateralaccountsgetaddresses
getcoininsgetcoinoutsgetbankaccountsgetdepositsgetwithdrawalsgetchildordersgetparentordersgetparentorderrS   getpositionsgettradingcommission)sendcoinrI   sendchildordercancelchildordersendparentordercancelparentordercancelallchildorders)rO   post)publicprivatetradingz0.002)makertaker)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventionicebergd   )ry   limitdaysBack	untilDayssymbolRequired)ry   triggerr   r   )ry   r   r   r   r   )ry   r   r   r   r   r   r   )ry   r   r   daysBackCanceledr   r   r   r   )	sandboxr/   createOrdersr:   r<   r;   r>   r1   
fetchOHLCV)linearinverse)r(   r*   r+   exactz-2)idname	countriesversion	rateLimithostnamehasurlsrL   feesprecisionModefeatures
exceptions)deep_extendsuperr    describeparse_numberr   r   )self	__class__s    G/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/bitflyer.pyr   bitflyer.describe   sY   h > @&### %# 	#
 $# %# "4# t# t# # $Z# "5#  # #D# *5#  $U!#" "5##$ %#&  '#( ":)#* j+#, !$-#. t/#0 $U1#2 !$3#4 t5#6 t7#8 "49#: #E;#<  =#> !%?#@ #DA#B EC#D DE#J j4 .D  (+.` !..w7!..w7 '  %&+(-,0,1).+06:#'#'"&#'	( #($)$)27+0/4#()$, %)&+!$$(%)*.& ',#($)*.	# ',!$#($)*.( ',!$$(%)#($)*.$ ',!$$(,0%)#($)*.	* #'AAF ##
 ##OKZ -kzC
 z z	    c                     USS nUSS nUSS nSSSSS	S
SSSSSSS.nU R                  XS5      nU R                  US-   U-   S-   U-   S-   5      $ )Nr         	   010203040506070809101112)JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC-z
T00:00:00Z)safe_string	parse8601)r   expiryday	monthNameyearmonthsmonths          r   parse_expiry_datebitflyer.parse_expiry_date   s    Qqk1QK	a{
   3~~dSj5036<|KLLr   NmarketIdmarket	delimiter
marketTypec                 .   > [         [        U ]  XUS5      $ )Nr(   )r   r    safe_market)r   r   r   r   r   r   s        r   r   bitflyer.safe_market   s     Xt09fUUr   c                    U R                  U5      nU R                  U5      nU R                  U5      nU R                  X#5      nU R                  XT5      n/ n[	        S[        U5      5       GHt  nXW   nU R                  US5      n	U	R                  S5      n
U R                  US5      nUS:H  nUS:H  nU(       + =(       a    U(       + nSnSnSnSnSnU(       a%  U R                  U
S5      nU R                  U
S	5      nOU(       a'  S
nU R                  U
S	5      nU R                  U
S5      nOU(       a  U R                  US5      nUc!  U	SS nU	SS nU	SS nU R                  U5      nOaUR                  S5      nU R                  US5      nUSS nUSS nU	R                  U5      nU R                  US	5      nU R                  U5      nSnU R                  U5      nU R                  U5      nUS-   U-   nU R                  S   S   nU R                  S   S   nU=(       d    UnU(       a,  SnSnSnUS-   U-   nU(       a  US-   U R                  U5      -   nUR                  0 SU	_SU_SU_SU_SU_SU_S U_S!S_S"U_SU_S#S$_S
U_SU_S%S$_S&S'_S(U_S)U(       a  SOS'_U(       a  SOS$UUSUU R                  U5      SSSSS*.SSS+.SSS+.SSS+.SSS+.S,.SUS-.E5        GMw     U$ ).z
retrieves data on all markets for bitflyer

https://lightning.bitflyer.com/docs?lang=en#market-list

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
r   product_code_market_typeFXFuturesr(   N   r*   r   alias      ir+   /rr   rt   rs   g        JPY:r   r   symbolbasequotesettlebaseIdquoteIdsettleIdtyper)   Fr,   activeTcontractr   )amountprice)minmax)r   r   r   cost)r   rt   rs   contractSizer   expiryDatetimestrike
optionType	precisionlimitscreatedinfo)publicGetGetmarketspublicGetGetmarketsUsapublicGetGetmarketsEuarray_concatrangelenr   splitr   safe_currency_coder   yymmddappendiso8601)r   params
jp_markets
us_markets
eu_marketsmarketsresultir   r   
currenciesr   r*   r+   r(   r   r   r   r   r   r   
expiryDate
splitAliascurrencyIdssplitIdr   r   r   rt   rs   r   s                                  r   fetch_marketsbitflyer.fetch_markets   s    --f5
" 008
 //7
 ##J;##G8q#g,'AZF!!&.9B#J))&-@J$&D I-F8*F
DDFFGF))*a8**:q9))*a8**:q9((9=  !WF 1gG!#BCJ!33J?F!&S!1J"&"2"2:q"AK(2.F)"#.G hh{3G!%!1!1'1!=J!33J?F**62D++G4ECZ%'FIIi(1EIIi(1E~vH#.#c\DKK,??FMM 2b2&2 2 	2
 &2 &2 72 D2 2 2 %2 2 &2 %2 $2  H!2" $$D#2$ $(4U $ "&,,v"6""!  $#!
  $#
  $#
  $#$  c2 2k (P r   c                 .   SU0n[        S[        U5      5       Hh  nX   nU R                  US5      nU R                  U5      nU R	                  5       nU R                  US5      US'   U R                  US5      US'   XrU'   Mj     U R                  U5      $ )Nr   r   currency_coder   total	availablefree)r  r  r   r  accountsafe_balance)r   responser  r  balance
currencyIdcoder  s           r   parse_balancebitflyer.parse_balance  s    )q#h-(AkG))'?CJ**:6DllnG#//BGG"..wDGFO"4L )   ((r   c                 f    U R                  5         U R                  U5      nU R                  U5      $ )aI  
query for balance and get the amount of funds available for trading or funds locked in orders

https://lightning.bitflyer.com/docs?lang=en#get-account-asset-balance

: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privateGetGetbalancer!  )r   r  r  s      r   fetch_balancebitflyer.fetch_balance  s3     	,,V4( !!(++r   r   r   c           	          U R                  5         U R                  U5      nSUS   0nU R                  U R                  XS5      5      nU R	                  XdS   SSSSS5      $ )	a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://lightning.bitflyer.com/docs?lang=en#order-book

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
r   r   r   Nbidsasksr   size)r$  r   publicGetGetboardextendparse_order_book)r   r   r   r  r   request	orderbooks          r   fetch_order_bookbitflyer.fetch_order_book  sl     	V$F4L
 **4;;w+GH	$$Yx0@$PVX_aghhr   tickerc                    U R                  S U5      nU R                  U R                  US5      5      nU R                  US5      nU R                  0 SU_SU_SU R	                  U5      _SS _SS _SU R                  US5      _S	S _S
U R                  US5      _SS _SS _SS _SU_SU_SS _SS _SS _SS _U R                  US5      S US.EU5      $ )N	timestampltpr   datetimehighlowbidbest_bid	bidVolumeaskbest_ask	askVolumevwapopencloselastpreviousClosechange
percentageaveragevolume_by_product)
baseVolumequoteVolumer   )safe_symbolr   r   safe_tickerr  )r   r3  r   r   r5  rC  s         r   parse_tickerbitflyer.parse_ticker  sg   !!$/NN4#3#3FK#HI	. !
f!
!
 Y/!
 D	!

 4!
 4##FJ7!
 !
 4##FJ7!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **63FG)!
* + 	r   c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  XS5      $ )a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://lightning.bitflyer.com/docs?lang=en#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>`
r   r   )r$  r   publicGetGettickerr-  rM  r   r   r  r   r/  r  s         r   fetch_tickerbitflyer.fetch_ticker  sZ     	V$F4L
 **4;;w+GH  22r   tradec                    U R                  US5      nUb  [        U5      S:  a  S nS nUb  US-   nXQ;   a  X   nUc  U R                  US5      nU R                  U R                  US5      5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R	                  S U5      nU R                  U	UUU R                  U5      US	   US US UUS S S
.U5      $ )Nsider   _child_order_acceptance_idchild_order_acceptance_id	exec_dater   r+  r   r   )r   r   r5  r7  r   orderr   rV  takerOrMakerr   r   r   fee)safe_string_lowerr  r   r   r   
safe_trader  )
r   rT  r   rV  rZ  idInnerr5  priceStringamountStringr   s
             r   parse_tradebitflyer.parse_trade  s   6 %%eV44y1}99G=$$U,GHENN4#3#3E;#GH	&&ug6''v6eT*!!$/"Y/X&  " 
  	r   sincec                     U R                  5         U R                  U5      nSUS   0nUb  X6S'   U R                  U R                  Xd5      5      nU R	                  XuX#5      $ )a  
get the list of most recent trades for a particular symbol

https://lightning.bitflyer.com/docs?lang=en#list-executions

: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   r   count)r$  r   publicGetGetexecutionsr-  parse_tradesr   r   rd  r   r  r   r/  r  s           r   fetch_tradesbitflyer.fetch_trades)  sl     	V$F4L
 $G..t{{7/KL   5@@r   c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US5      nUUS   UUSSS.$ )a-  
fetch the trading fees for a market

https://lightning.bitflyer.com/docs?lang=en#get-trading-commission

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
r   r   commission_rater   N)r   r   rs   rt   rF  	tierBased)r$  r   privateGetGettradingcommissionr-  safe_number)r   r   r  r   r/  r  r\  s          r   fetch_trading_feebitflyer.fetch_trading_feeL  s     	V$F4L
 66t{{77ST x):;X&
 	
r   r   rV  r   r   c                    U R                  5         U R                  U5      UR                  5       UR                  5       UUS.nU R                  U R	                  Xv5      5      nU R                  US5      n	U R                  U	US.5      $ )aV  
create a trade order

https://lightning.bitflyer.com/docs?lang=en#send-a-new-order

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
)r   child_order_typerV  r   r+  rX  )r   r   )r$  	market_idupperprivatePostSendchildorderr-  r   
safe_order)
r   r   r   rV  r   r   r  r/  r  r   s
             r   create_orderbitflyer.create_orderk  s     	 NN62 $

JJL
 //G0LMf&AB 
  	r   r   c                     Uc  [        U R                  S-   5      eU R                  5         U R                  U5      US.nU R	                  U R                  XC5      5      nU R                  SU05      $ )aO  
cancels an open order

https://lightning.bitflyer.com/docs?lang=en#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>`
z) cancelOrder() requires a symbol argument)r   rX  r   )r   r   r$  ru  privatePostCancelchildorderr-  rx  )r   r   r   r  r/  r  s         r   cancel_orderbitflyer.cancel_order  sx     >#DGG.Y$YZZ NN62)+
 33DKK4PQ H 
  	r   statusc                 6    SSSSSS.nU R                  X!U5      $ )NrA  closedcanceled)ACTIVE	COMPLETEDCANCELEDEXPIREDREJECTEDr   r   r  statusess      r   parse_order_statusbitflyer.parse_order_status  s-    !"!"
 &99r   rZ  c                    U R                  U R                  US5      5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  U R                  US5      5      nU R                  US5      n	U R                  US5      n
U R                  US	5      nU R	                  X5      nS nU R                  US
5      nUb  US S S.nU R                  US5      nU R                  0 SU_SS _SU_SU_SU R                  U5      _SS _SU_SU_SU	_SS _SS _SU
_SU_SS _SS _SU_SU_UUS S S.EU5      $ )Nchild_order_dater   r+  executed_sizeoutstanding_sizechild_order_statert  rV  r   total_commission)r   currencyraterX  r   clientOrderIdr   r5  r7  lastTradeTimestampr  r   r   r   postOnlyrz   r   r   filled)	remainingr\  rG  trades)r   r   r  r]  rK  rp  rx  r  )r   rZ  r   r5  r   r   r  r  r  r   rV  r   r   r\  feeCostr   s                   r   parse_orderbitflyer.parse_order  s   NN4#3#3E;M#NO	  0!!%0!!%9$$U,>?	(()9)9%AT)UV%%e-?@%%eV4##E>:!!(3""5*<= C
 e%@A  
" 
T 
 E 
 	 

 Y/ 
 !$ 
 f 
 f 
 D 
 4 
  
 D 
 U 
 D 
 D 
  f! 
" f# 
$ #+ 
, - 	r   r   c                    Uc  [        U R                  S-   5      eU R                  5         U R                  U5      nUS   US.nU R	                  U R                  Xd5      5      nU R                  XuX#5      nUb  U R                  USU5      nU$ )a  
fetches information on multiple orders made by the user

https://lightning.bitflyer.com/docs?lang=en#list-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
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
z) fetchOrders() requires a symbol argumentr   )r   rf  r   )r   r   r$  r   privateGetGetchildordersr-  parse_orders	filter_by)	r   r   rd  r   r  r   r/  r  orderss	            r   fetch_ordersbitflyer.fetch_orders  s     >#DGG.Y$YZZV$"4L
 00W1MN""8UB^^FHf=Fr   c           	      L    SS0nU R                  XX0R                  XT5      5      $ )a  
fetch all unfilled currently open orders

https://lightning.bitflyer.com/docs?lang=en#list-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>`
r  r  r  r-  r   r   rd  r   r  r/  s         r   fetch_open_ordersbitflyer.fetch_open_orders  s.      
   {{77STTr   c           	      L    SS0nU R                  XX0R                  XT5      5      $ )a  
fetches information on multiple closed orders made by the user

https://lightning.bitflyer.com/docs?lang=en#list-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
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
r  r  r  r  s         r   fetch_closed_ordersbitflyer.fetch_closed_orders  s.      
   {{77STTr   c                     Uc  [        U R                  S-   5      eU R                  U5      nU R                  US5      nX;   a  XQ   $ [	        U R                  S-   U-   5      e)am  
fetches information on an order made by the user

https://lightning.bitflyer.com/docs?lang=en#list-orders

: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   z No order found with id )r   r   r  index_byr   )r   r   r   r  r  
ordersByIds         r   fetch_orderbitflyer.fetch_order  sf     >#DGG.X$XYY""6*]]640
>!DGG&@@2EFFr   c                     Uc  [        U R                  S-   5      eU R                  5         U R                  U5      nSUS   0nUb  X6S'   U R	                  U R                  Xd5      5      nU R                  XuX#5      $ )a  
fetch all trades made by the user

https://lightning.bitflyer.com/docs?lang=en#list-executions

: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>`
z+ fetchMyTrades() requires a symbol argumentr   r   rf  )r   r   r$  r   privateGetGetexecutionsr-  rh  ri  s           r   fetch_my_tradesbitflyer.fetch_my_trades(  s     >#DGG.[$[\\V$F4L
 $G//G0LM   5@@r   symbolsc                     Uc  [        U R                  S-   5      eU R                  5         SU R                  U5      0nU R	                  U R                  X25      5      nU$ )aE  
fetch all open positions

https://lightning.bitflyer.com/docs?lang=en#get-open-interest-summary

:param str[] symbols: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
zO fetchPositions() requires a `symbols` argument, exactly one symbol in an arrayr   )r   r   r$  
market_idsprivateGetGetpositionsr-  )r   r  r  r/  r  s        r   fetch_positionsbitflyer.fetch_positionsN  sg     ?#DGG.$  A  ADOOG4
 ..t{{7/KL& r   r   addresstagc                 8   U R                  U5        U R                  5         US:w  a*  US:w  a$  US:w  a  [        U R                  S-   U-   S-   5      eU R	                  U5      nUS   US.nU R                  U R                  Xu5      5      nU R                  X5      $ )a  
make a withdrawal

https://lightning.bitflyer.com/docs?lang=en#withdrawing-funds

: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   USDEURz( allows withdrawing JPY, USD, EUR only, z is not supportedr   )r  r   )check_addressr$  r   r   r  privatePostWithdrawr-  parse_transaction)	r   r   r   r  r  r  r  r/  r  s	            r   rI   bitflyer.withdraws  s     	7#5=TU]tu}*T TW[ [^q qrr==&%d^

 ++DKK,HI %%h99r   c                     U R                  5         Sn0 nUb  U R                  U5      nUb  X6S'   U R                  U R                  Xd5      5      nU R	                  XuX#5      $ )a  
fetch all deposits made to an account

https://lightning.bitflyer.com/docs?lang=en#get-crypto-assets-deposit-history

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch deposits for
:param int [limit]: the maximum number of deposits structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
Nrf  )r$  r  privateGetGetcoininsr-  parse_transactionsr   r   rd  r   r  r  r/  r  s           r   fetch_depositsbitflyer.fetch_deposits  sj     	}}T*H$G,,T[[-IJ &&x5HHr   c                     U R                  5         Sn0 nUb  U R                  U5      nUb  X6S'   U R                  U R                  Xd5      5      nU R	                  XuX#5      $ )a  
fetch all withdrawals made from an account

https://lightning.bitflyer.com/docs?lang=en#get-crypto-assets-transaction-history

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch withdrawals for
:param int [limit]: the maximum number of withdrawals structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
Nrf  )r$  r  privateGetGetcoinoutsr-  r  r  s           r   fetch_withdrawalsbitflyer.fetch_withdrawals  sj     	}}T*H$G--dkk'.JK" &&x5HHr   c                 0    SSS.nU R                  X!U5      $ Npendingok)PENDINGr  r  r  s      r   parse_deposit_statusbitflyer.parse_deposit_status  $     
 &99r   c                 0    SSS.nU R                  X!U5      $ r  r  r  s      r   parse_withdrawal_status bitflyer.parse_withdrawal_status  r  r   transactionr  c                    U R                  USS5      nU R                  US5      nU R                  US5      nU R                  XR5      nU R                  U R                  US5      5      nU R	                  US5      nU R                  US5      n	U R                  US5      n
S nS nS nS	U;   a_  S
nU R                  U
5      nU R                  US	5      nU R                  US5      nX`R                  [        R                  " X5      5      S.nOSnU R                  U
5      n0 SU_SU_SU	_SU_SU R                  U5      _SS _SU_SU_SS _SS _SS _SS _SU_SU_SU_SU_SS _S S US.E$ )Nr   
message_idr  r  
event_dater   tx_hashr  r\  
withdrawaladditional_fee)r  r   depositr   txidr5  r7  network	addressToaddressFromr  tagTotagFromr   r  updated)commentinternalr\  )safe_string_2r   r  r   rp  r  r   r   
string_addr  r  )r   r  r  r   r  r  r   r5  r   txId	rawStatusr   r  r\  r  additionalFees                   r   r  bitflyer.parse_transaction  s   H T<@"";	:%%k?C
&&z<NN4#3#3K#NO	!!+x8Y7$$[(;	KD11)<F&&{E:G ,,[:JKM#->->w?Q?QRY?i-jkCD..y9F
K
"
 D
 	

 Y/
 t
 w
 
 4
 4
 T
 t
 D
 f
 
  f!
" t#
$ )
 	
r   c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  XS5      $ )a(  
fetch the current funding rate

https://lightning.bitflyer.com/docs#funding-rate

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
r   r   )r$  r   publicGetGetfundingrater-  parse_funding_raterQ  s         r   fetch_funding_ratebitflyer.fetch_funding_rate9  s\     	V$F4L
 //G0LM &&x88r   c                    U R                  US5      nU R                  U5      n0 SU_SU R                  US5      _SS _SS _SS _SS _SS _S	S _S
S _SS _SS _SU R                  US5      _SU_SU R                  U5      _SS _SS _SS _SS 0E$ )Nnext_funding_rate_settledater   r   	markPrice
indexPriceinterestRateestimatedSettlePricer5  r7  fundingRatefundingTimestampfundingDatetimenextFundingRatecurrent_funding_ratenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimeinterval)r   r   rp  r  )r   r   r   r  r  s        r   r  bitflyer.parse_funding_rateQ  s,    #..x9WX#~~.AB
H
d&&vx8
 
 $	

 D
 #D
 
 
 4
 
 t
 t//:PQ
 #$8
 "4<<0D#E
 "4
  '!
" &t#
$ %
 	
r   rp   GETc                 X   SU R                   -   S-   nUS:X  a  US-  nXq-  nUS:X  a  U(       a  USU R                  U5      -   -  nU R                  U R                  S   S   5      nX-   n	US:X  a  U R	                  5         [        U R                  5       5      n
SR                  XU/5      nU(       a  US:w  a  U R                  U5      nX-  nU R                  U
U R                  U R                  U5      U R                  U R                  5      [        R                  5      S	S
.nXXeS.$ )Nr   rq   zme/r  ?rL   rJ    zapplication/json)z
ACCESS-KEYzACCESS-TIMESTAMPzACCESS-SIGNzContent-Type)urlmethodbodyheaders)r   	urlencodeimplode_hostnamer   check_required_credentialsstrnoncejoinjsonapiKeyhmacencodesecrethashlibsha256)r   pathrL   r  r  r  r  r/  baseUrlr  r  auths               r   signbitflyer.signo  s   $s*)uGU?3!777''		%(8(@A)++-

%E77E734DU?99V,DLD"kk$)#yyT):DKK<TV]VdVde 2	G dOOr   reasonr  r  r  r  c
                     Uc  g U R                   S-   U-   n
U R                  US5      nU R                  US5      nUb*  U R                  U R                  S   X5        [        U
5      eg )N error_messager  r   )r   r   safe_integerthrow_exactly_matched_exceptionr   r   )r   r   r"  r  r  r  r  r  requestHeadersrequestBodyfeedbackerrorMessage
statusCodes                r   handle_errorsbitflyer.handle_errors  sn    77S=4'''/B&&x:
#001I:`))r    )NNNN)N)>__name__
__module____qualname____firstlineno__r   r   r   r   r	   r   r   r   r  r   r!  r&  r  r   r   r1  dictr   rM  rR  r   rb  rj  r   rq  r   r   floatr
   ry  r}  r  r   r  r  r  r  r  r  r   r   r  r   rI   r  r  r  r  r   r  r   r  r  r   intr-  __static_attributes____classcell__)r   s   @r   r    r       s   {# {zM*VC V VRU Vjm V  zI V V $& S$v, Sj
) 
) $& ,( ,@ :>b is i3 iY i&4  6 6 02 33 3f 3$9 9v 9 9v 6:UW !A3 !As !A# !A\`af\g !AF 57 
 
;N 
> gksu 3 i y RW `c < 37r s C 4: :* *v * *X *.Ds[] 3 c  bfglbm 4 /3TW`b U U3 Uc Ugklqgr U" 154VYbd U# US UPS Uimnsit U" 26b Gc G3 G& -1tRV_a $Ac $A $AC $AL 26b #w #T(^ #J KOWY :S :% :# :C :^i :> *.Dt\^ "I3 "Ic "I "Icghsct "IH -1tRV_a $Ic $I $IC $Ifjkvfw $IL::M
T M
X M
Q\ M
^ 68 9 9K 90
6 
[ 
< &eBSW P4
# 
s 
 
c 
TX 
`c 
 
r   r    )%ccxt.base.exchanger   ccxt.abstract.bitflyerr   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r    r/  r   r   <module>r@     sY    ( .  U  U  U  U  U  U  * . * * 4 %@x @r   