
    iޢ                         d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlm Z   G d dee          Z!dS )    )Exchange)ImplicitAPIN)BalancesCurrencyIntMarketMarketInterfaceNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTradeTradingFeeInterfaceTransaction)List)ExchangeError)ArgumentsRequired)OrderNotFound)OnMaintenance)	TICK_SIZE)Precisec                       e Zd Z fdZd Zd3dededededef
 fd	Zi fde	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d4dedefdZi fdedefdZd4dedefdZddi fdededede	e         fdZi fdedefdZdi fdededededef
dZdi fdedefdZd Z d4d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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ddi fdededefd$Z'di fd%e(fd&Z)di fd'edefd(Z*dddi fd'ededede	e+         fd)Z,dddi fd'ededede	e+         fd*Z-d+ Z.d, Z/d4d-e0de+fd.Z1d/d0i ddfd1Z2d2 Z3 xZ4S )5bitflyerc                    |                      t          t          |                                           dddg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d	d	dd	d	d	d	dddd	dd	ddddidd d!d"g d#ig d$g d%d&d'd(|                     d)          |                     d)          d*it
          d+d,t          iid-          S ).Nr   bitFlyerJPv1i  zbitflyer.comCORSspotTmarginFswapfutureoptioncancelAllOrderscancelOrdercreateOrderfetchBalancefetchClosedOrdersemulatedfetchDepositsfetchMarginModefetchMarketsfetchMyTradesfetchOpenOrders
fetchOrder)fetchOrderBookfetchOrdersfetchPositionModefetchPositionsfetchTickerfetchTradesfetchTradingFeefetchTradingFeesfetchTransferfetchTransfersfetchWithdrawalstransferwithdrawzchttps://user-images.githubusercontent.com/1294454/28051642-56154182-660e-11e7-9b0d-6042d1e6edd8.jpg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)getpermissions
getbalancegetbalancehistorygetcollateralgetcollateralhistorygetcollateralaccountsgetaddresses
getcoininsgetcoinoutsgetbankaccountsgetdepositsgetwithdrawalsgetchildordersgetparentordersgetparentorderrJ   getpositionsgettradingcommission)sendcoinr@   sendchildordercancelchildordersendparentordercancelparentordercancelallchildorders)rF   post)publicprivatetradingz0.002)makertakerexactz-2)idname	countriesversion	rateLimithostnamehasurlsrC   feesprecisionMode
exceptions)deep_extendsuperr   describeparse_numberr   r   )self	__class__s    a/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/bitflyer.pyry   zbitflyer.describe   s   h 5 5 > > @ @& % 	
 $ % "4 t t  $Z   "5     ":!" j#$ #'#%*"&###'$)!&"'$(! =  B ~4 .D   
 
 
  (  + - -^ !..w77!..w77  '-IiC
 iC
 i i i	    c                     |dd         }|dd         }|dd         }ddddd	d
ddddddd}|                      ||          }|                     |dz   |z   dz   |z   dz             S )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_datezbitflyer.parse_expiry_date   s    QqSk1Q3K	ac{
 
   33~~dSj5036<|KLLLr~   NmarketIdmarket	delimiter
marketTypereturnc                 Z    t          t          |                               |||d          S )Nr#   )rx   r   safe_market)r{   r   r   r   r   r|   s        r}   r   zbitflyer.safe_market   s)     Xt$$0069fUUUr~   c                   K   |                      |           d{V }|                     |           d{V }|                     |           d{V }|                     ||          }|                     ||          }g }t	          dt          |                    D ]}||         }|                     |d          }	|	                    d          }
|                     |d          }|dk    }|dk    }| o| }d}d}d}d}d}|r.|                     |
d          }|                     |
d	          }n |r/d
}|                     |
d	          }|                     |
d          }n|r|                     |d          }|4|	dd         }|	dd         }|	dd         }|                     |          }n|                    d          }|                     |d          }|dd         }|dd         }|	                    |          }|                     |d	          }|                     |          }d}| 	                    |          }| 	                    |          }|dz   |z   }| j
        d         d         }| j
        d         d         }|p|}|r+d}d}d}|dz   |z   }|r|dz   |                     |          z   }|                    i d|	d|d|d|d|d|d |d!dd"|d|d#d$d
|d|d%d$d&d'd(|d)|rdnd'|rdnd$||d||                     |          ddddd*ddd+ddd+ddd+ddd+d,d|d-           |S ).a  
        retrieves data on all markets for bitflyer
        :see: 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
        Nr   product_code_market_typeFXFuturesr#      r%   r   alias      ir&   /rh   rj   ri   g        JPY:r   rl   symbolbasequotesettlebaseIdquoteIdsettleIdtyper$   Fr'   activeTcontractlinear)amountprice)minmax)leverager   r   cost)inverserj   ri   contractSizer   expiryDatetimestrike
optionType	precisionlimitscreatedinfo)publicGetGetmarketspublicGetGetmarketsUsapublicGetGetmarketsEuarray_concatrangelenr   splitr   safe_currency_codert   yymmddappendiso8601)r{   params
jp_markets
us_markets
eu_marketsmarketsresultir   rl   
currenciesr   r%   r&   r#   r   r   r   r   r   r   
expiryDate
splitAliascurrencyIdssplitIdr   r   r   rj   ri   r   s                                  r}   fetch_marketszbitflyer.fetch_markets   s       33F;;;;;;;;
   66v>>>>>>>>
  55f========
 ##J
;;##GZ88q#g,,'' g	 g	AQZF!!&.99B#J))&-@@J$&D I-F8*F
DDFFGF  ))*a88**:q99  ))*a88**:q99  ((99=  !WF 1gG!#BCCJ!33J??FF!&S!1!1J"&"2"2:q"A"AK(2.F)"##.G hh{33G!%!1!1'1!=!=J!33J??F**622D++G44ECZ%'FIi(1EIi(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" $0$$D#2$ $(244U $ "&,,v"6"6""!   $#! !
  $# 
  $# 
  $#  $  c2 2 2 2 2 2 2f r~   c                 p   d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )Nr   r   currency_coder   total	availablefree)r   r   r   r   accountsafe_balance)r{   responser   r   balance
currencyIdcoder   s           r}   parse_balancezbitflyer.parse_balance.  s    (#q#h--(( 	# 	#AqkG))'?CCJ**:66DllnnG#//BBGG"..wDDGFO"F4LL  (((r~   c                    K   |                                   d{V  |                     |           d{V }|                     |          S )au  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: 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>`
        N)load_marketsprivateGetGetbalancer   )r{   r   r   s      r}   fetch_balancezbitflyer.fetch_balance:  sg       !!!!!!!!!226::::::::( !!(+++r~   r   limitc           	        K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     ||d         ddddd          S )	a8  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: 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
        Nr   rl   r   bidsasksr   size)r   r   publicGetGetboardextendparse_order_book)r{   r   r   r   r   request	orderbooks          r}   fetch_order_bookzbitflyer.fetch_order_bookX  s       !!!!!!!!!V$$F4L
 00Wf1M1MNNNNNNNN	$$Yx0@$PVX_aghhhr~   c                    |                      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|          S )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{   tickerr   r   r  r  s         r}   parse_tickerzbitflyer.parse_tickeri  s   !!$//NN4#3#3FK#H#HII	.. !
f!
!
 Y//!
 D	!

 4!
 4##FJ77!
 !
 4##FJ77!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **63FGG)!
 !
 !
* +  	r~   c                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: 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>`
        Nr   rl   )r   r   publicGetGettickerr  r!  )r{   r   r   r   r  r   s         r}   fetch_tickerzbitflyer.fetch_ticker  s       !!!!!!!!!V$$F4L
 00Wf1M1MNNNNNNNN  6222r~   c                 2   |                      |d          }|t          |          dk     rd }d }||dz   }||v r||         }||                     |d          }|                     |                     |d                    }|                     |d          }|                     |d          }|                     |d          }	|                     d |          }|                     |	|||                     |          |d	         |d |d ||d d d
|          S )Nsider   _child_order_acceptance_idchild_order_acceptance_id	exec_dater   r   rl   r   )rl   r   r  r
  r   orderr   r&  takerOrMakerr   r   r   fee)safe_string_lowerr   r   r   r   
safe_trader   )
r{   trader   r&  r*  idInnerr  priceStringamountStringrl   s
             r}   parse_tradezbitflyer.parse_trade  sJ   6 %%eV444yy1}}99G%g=$$U,GHHENN4#3#3E;#G#GHH	&&ug66''v66eT**!!$//"Y//X&  " 
  
   	r~   sincec                   K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     ||||          S )a'  
        get the list of most recent trades for a particular symbol
        :see: 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>`
        Nr   rl   count)r   r   publicGetGetexecutionsr  parse_tradesr{   r   r4  r   r   r   r  r   s           r}   fetch_tradeszbitflyer.fetch_trades  s       !!!!!!!!!V$$F4L
 $GG44T[[&5Q5QRRRRRRRR   65%@@@r~   c                    K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |d          }||d         ||dddS )aa  
        fetch the trading fees for a market
        :see: 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>`
        Nr   rl   commission_rater   )r   r   ri   rj   r  	tierBased)r   r   privateGetGettradingcommissionr  safe_number)r{   r   r   r   r  r   r,  s          r}   fetch_trading_feezbitflyer.fetch_trading_fee  s       !!!!!!!!!V$$F4L
 <<T[[RX=Y=YZZZZZZZZ x):;;X&
 
 	
r~   r   r&  r   r   c                 r  K   |                                   d{V  |                     |          |                                |                                ||d}|                     |                     ||                     d{V }|                     |d          }	|                     |	|d          S )a  
        create a trade order
        :see: 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 fullfilled, 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>`
        N)r   child_order_typer&  r   r   r(  )rl   r   )r   	market_idupperprivatePostSendchildorderr  r   
safe_order)
r{   r   r   r&  r   r   r   r  r   rl   s
             r}   create_orderzbitflyer.create_order  s       !!!!!!!!! NN622 $

JJLL
 
 55dkk'66R6RSSSSSSSSf&ABB 
  
   	r~   rl   c                    K   |t          | j        dz             |                                  d{V  |                     |          |d}|                     |                     ||                     d{V S )a  
        cancels an open order
        :see: 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>`
        Nz) cancelOrder() requires a symbol argument)r   r(  )r   rl   r   rC  privatePostCancelchildorderr  )r{   rl   r   r   r  s        r}   cancel_orderzbitflyer.cancel_order)  s       >#DG.Y$YZZZ!!!!!!!!! NN622)+
 
 55dkk'66R6RSSSSSSSSSr~   c                 @    dddddd}|                      |||          S )Nr  closedcanceled)ACTIVE	COMPLETEDCANCELEDEXPIREDREJECTEDr   r{   statusstatusess      r}   parse_order_statuszbitflyer.parse_order_status;  s7    !"!"
 
 &&999r~   c           	      :   |                      |                     |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|          S )Nchild_order_dater   r   executed_sizeoutstanding_sizechild_order_staterB  r&  r   total_commission)r   currencyrater(  rl   clientOrderIdr   r  r
  lastTradeTimestamprU  r   r   timeInForcepostOnly	stopPricetriggerPricer   r   )filled	remainingr,  r  trades)r   r   rW  r-  r  r?  rF  r   )r{   r*  r   r  r   r   rf  rg  rU  r   r&  r   r   r,  feeCostrl   s                   r}   parse_orderzbitflyer.parse_orderE  sT   NN4#3#3E;M#N#NOO	  00!!%00!!%99$$U,>??	(()9)9%AT)U)UVV%%e-?@@%%eV44##E>::!!(F33""5*<==  C
 e%@AA  
" 
T 
 E 
 	 

 Y// 
 !$ 
 f 
 f 
 D 
 4 
  
 D 
 U 
  
 D 
  D! 
" f# 
$ "- 
  
  
. /  	r~   d   c                 p  K   |t          | j        dz             |                                  d{V  |                     |          }|d         |d}|                     |                     ||                     d{V }|                     ||||          }||                     |d|          }|S )a3  
        fetches information on multiple orders made by the user
        :see: 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>`
        Nz) fetchOrders() requires a symbol argumentrl   )r   r6  r   )r   rl   r   r   privateGetGetchildordersr  parse_orders	filter_by)	r{   r   r4  r   r   r   r  r   orderss	            r}   fetch_orderszbitflyer.fetch_ordersr  s       >#DG.Y$YZZZ!!!!!!!!!V$$"4L
 
 66t{{7F7S7STTTTTTTT""8VUEBB^^FHf==Fr~   c           	      r   K   ddi}|                      ||||                     ||                     d{V S )a  
        fetch all unfilled currently open orders
        :see: 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\  rN  Nrq  r  r{   r   r4  r   r   r  s         r}   fetch_open_orderszbitflyer.fetch_open_orders  sQ        
 &&vueT[[RX=Y=YZZZZZZZZZr~   c           	      r   K   ddi}|                      ||||                     ||                     d{V S )a:  
        fetches information on multiple closed orders made by the user
        :see: 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\  rO  Nrs  rt  s         r}   fetch_closed_orderszbitflyer.fetch_closed_orders  sQ        
 &&vueT[[RX=Y=YZZZZZZZZZr~   c                    K   |t          | j        dz             |                     |           d{V }|                     |d          }||v r||         S t	          | j        dz   |z             )a  
        fetches information on an order made by the user
        :see: https://lightning.bitflyer.com/docs?lang=en#list-orders
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz( fetchOrder() requires a symbol argumentrl   z No order found with id )r   rl   rq  index_byr   )r{   rl   r   r   rp  
ordersByIds         r}   fetch_orderzbitflyer.fetch_order  s       >#DG.X$XYYY((00000000]]6400
b>!DG&@@2EFFFr~   c                 F  K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     ||||          S )a   
        fetch all trades made by the user
        :see: 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>`
        Nz+ fetchMyTrades() requires a symbol argumentr   rl   r6  )r   rl   r   r   privateGetGetexecutionsr  r8  r9  s           r}   fetch_my_tradeszbitflyer.fetch_my_trades  s       >#DG.[$[\\\!!!!!!!!!V$$F4L
 $GG55dkk'66R6RSSSSSSSS   65%@@@r~   symbolsc                    K   |t          | j        dz             |                                  d{V  d|                     |          i}|                     |                     ||                     d{V }|S )ay  
        fetch all open positions
        :see: 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>`
        NzO fetchPositions() requires a `symbols` argument, exactly one symbol in an arrayr   )r   rl   r   
market_idsprivateGetGetpositionsr  )r{   r  r   r  r   s        r}   fetch_positionszbitflyer.fetch_positions  s       ?#DG.$  A  A  A!!!!!!!!!DOOG44
 44T[[&5Q5QRRRRRRRR& r~   r   c                   K   |                      |           |                                  d{V  |dk    r)|dk    r#|dk    rt          | j        dz   |z   dz             |                     |          }|d         |d}|                     |                     ||                     d{V }|                     ||          S )	a  
        make a withdrawal
        :see: 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>`
        Nr   USDEURz( allows withdrawing JPY, USD, EUR only, z is not supportedrl   )r   r   )check_addressr   r   rl   r^  privatePostWithdrawr  parse_transaction)	r{   r   r   addresstagr   r^  r  r   s	            r}   r@   zbitflyer.withdraw  s       	7###!!!!!!!!!5==TU]]tu}}*T TW[ [^q qrrr==&&%d^
 

 11$++gv2N2NOOOOOOOO %%h999r~   c                   K   |                                   d{V  d}i }||                     |          }|||d<   |                     |                     ||                     d{V }|                     ||||          S )a#  
        fetch all deposits made to an account
        :see: 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>`
        Nr6  )r   r^  privateGetGetcoininsr  parse_transactionsr{   r   r4  r   r   r^  r  r   s           r}   fetch_depositszbitflyer.fetch_deposits  s       !!!!!!!!!}}T**H$GG224;;w3O3OPPPPPPPP &&x5%HHHr~   c                   K   |                                   d{V  d}i }||                     |          }|||d<   |                     |                     ||                     d{V }|                     ||||          S )a2  
        fetch all withdrawals made from an account
        :see: 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>`
        Nr6  )r   r^  privateGetGetcoinoutsr  r  r  s           r}   fetch_withdrawalszbitflyer.fetch_withdrawals>  s       !!!!!!!!!}}T**H$GG33DKK4P4PQQQQQQQQ" &&x5%HHHr~   c                 :    ddd}|                      |||          S Npendingok)PENDINGrO  rS  rT  s      r}   parse_deposit_statuszbitflyer.parse_deposit_statusb  .     
 
 &&999r~   c                 :    ddd}|                      |||          S r  rS  rT  s      r}   parse_withdrawal_statusz bitflyer.parse_withdrawal_statusi  r  r~   r^  c                 F   |                      |dd          }|                     |d          }|                     |d          }|                     ||          }|                     |                     |d                    }|                     |d          }|                     |d          }	|                     |d          }
d }d }d }d	|v rod
}|                     |
          }|                     |d	          }|                     |d          }||                     t          j        ||                    d}nd}| 	                    |
          }i d|d|d|	d|d| 
                    |          dd d|d|dd dd dd dd d|d|d|d|dd d d |dS )Nrl   
message_idr  r   
event_dater   tx_hashrU  r,  
withdrawaladditional_fee)r^  r   depositr   txidr  r
  network	addressToaddressFromr  tagTotagFromr   r^  updated)commentinternalr,  )safe_string_2r   r   r   r?  r  rz   r   
string_addr  r   )r{   transactionr^  rl   r  r   r   r  r   txId	rawStatusr   rU  r,  ri  additionalFees                   r}   r  zbitflyer.parse_transactionp  sT   H T<@@"";	::%%k?CC
&&z8<<NN4#3#3K#N#NOO	!!+x88Y77$$[(;;	KD11)<<F&&{E::G ,,[:JKKM#T->->w?QRY[h?i?i-j-jkkCCD..y99F
K
"
 D
 	

 Y//
 t
 w
 
 4
 4
 T
 t
 D
 f
 
  f!
" t#
$ )
 
 
 	
r~   rf   GETc                 |   d| j         z   dz   }|dk    r|dz  }||z  }|dk    r|r|d|                     |          z   z  }|                     | j        d         d                   }||z   }	|dk    r|                                  t          |                                           }
d                    |
||g          }|r |dk    r|                     |          }||z  }| j	        |
| 
                    |                     |          |                     | j                  t          j                  d	d
}|	|||dS )Nr   rg   zme/r  ?rC   rA    zapplication/json)z
ACCESS-KEYzACCESS-TIMESTAMPzACCESS-SIGNzContent-Type)urlmethodbodyheaders)ro   	urlencodeimplode_hostnamers   check_required_credentialsstrnoncejoinjsonapiKeyhmacencodesecrethashlibsha256)r{   pathrC   r  r   r  r  r  baseUrlr  r  auths               r}   signzbitflyer.sign  sW   $s*)uG4U?? 83!7!777''	%(8(@AA)++---

%%E77E67344D !U??99V,,DDLD"k$)#yyT):):DKK<T<TV]Vdee 2	 G fdwOOOr~   c
                    |d S | j         dz   |z   }
|                     |d          }|                     |d          }|D|                     | j        d         ||
           |                     | j        d         ||
           d S )N error_messagerU  rk   broad)rl   r   r?  throw_exactly_matched_exceptionrv   throw_broadly_matched_exception)r{   r   reasonr  r  r  r  r   requestHeadersrequestBodyfeedbackerrorMessage
statusCodes                r}   handle_errorszbitflyer.handle_errors  s    47S=4'''/BB%%h99
#001I:W_```001I<Yabbbtr~   )NNNN)N)5__name__
__module____qualname__ry   r   r   r   r	   r   r   r   r   r   r   r  r   r   r  r   r!  r$  r   r3  r:  r   r@  r   r   floatr
   rG  rJ  rW  r   rj  rq  ru  rw  r{  r~  r   r  r@   r   r  r  r  r  r   r  r  r  __classcell__)r|   s   @r}   r   r      s       j j j j jXM M M*V VC V VRU Vjm V  zI V V V V V V *, P PV P P P Pd
) 
) 
) 
) 
) *, , , , , , ,< @DB i iS i iS\ i i i i" 6 V    6 68 3 3 3F 3 3 3 3 9 9 95 9 9 9 9v <@d[] A A AS A Abfglbm A A A AB ;= 
 
c 
AT 
 
 
 
: mqy{   I Y X] fi    8 9=R T TS T# T T T T$: : :+ + +5 + + + +Z 04$UXac   C s hlmrhs    0 59tZ]fh [ [c [ [TW [mqrwmx [ [ [ [ 7;\_hj [ [ [3 [VY [ostyoz [ [ [ [ 8<B G GC G G G G G  37TX\eg "A "AC "As "ARU "A "A "A "AH 8<B ! !W ! ! ! !F EIQS : :3 : : : : :: 04$UYbd  I  I  IC  Is  Iimnyiz  I  I  I  ID 37TX\eg "I "IC "Is "IRU "Ilpq|l} "I "I "I "IH: : :: : :M
 M
x M
; M
 M
 M
 M
^ &eBSW P P P P4
 
 
 
 
 
 
r~   r   )" ccxt.async_support.base.exchanger   ccxt.abstract.bitflyerr   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r    r~   r}   <module>r     s   6 5 5 5 5 5 . . . . . .  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y       * * * * * * . . . . . . * * * * * * * * * * * * 4 4 4 4 4 4 % % % % % %P P P P Px P P P P Pr~   