
    ei                    l   d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dl m!Z! d dl m"Z" d dl m#Z# d d	l m$Z$ d d
l m%Z% d dl m&Z& d dl m'Z' d dl m(Z( d dl m)Z) d dl m*Z* d dl m+Z+ d dl m,Z, d dl m-Z- d dl.m/Z/ d dl0m1Z1  G d dee          Z2dS )    )Exchange)ImplicitAPIN)AccountAnyBalances
CurrenciesCurrencyDepositAddressIntLeverageLeverageTierLeverageTiersMarketNumOrder	OrderBook	OrderSide	OrderTypePositionStrStringsTickerTickersTradeTradingFeesTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)	BadSymbol)OperationRejected)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)OperationFailed)RateLimitExceeded)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdefdZi fdee         fdZ	i fdZ
di fdededefd	Zd
ddi fdedededee         fdZdSdedefdZdi fdedefdZi fdedefdZdSdededefdZddi fdedededee         fdZdSdede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i fdedefdZ!di f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#de$de%d e&f
d"Z(dSd#ededefd$Z)dedefd%Z*dedefd&Z+d'efd(Z,dddi fdededefd)Z-i fdee.         fd*Z/d+ Z0i fde1fd,Z2de1fd-Z3i fd.ede4fd/Z5i fd.edee4         fd0Z6dSd1e7de4fd2Z8i fd.ede4fd3Z9dddi fd.edededee:         fd4Z;dSd5ed1e7de:fd6Z<i fde=fd7Z>dddi fdededefd8Z?dSdefd9Z@i fdedeAfd:ZBdSd;ededeAfd<ZCdi fd;eDdefd=ZEdi fdedeeF         fd>ZGdSd?edefd@ZHdi fd.ede%dAedBede:f
dCZIdi fdedeJfdDZKdTdEedee         deJfdFZLdSdedeeM         fdGZNdHedefdIZOdJdKi ddfdLZPd.eDdMedNedOedPedQefdRZQ xZRS )Uarkhamreturnc           "      
   |                      t          t          |                                           dddgddddi ddd	dd
dddddddddddddddddddddddddddddi ddddddddddddddd dd!dd"dd#dd$dd%dd&dd'dd(dd)di d*dd+dd,dd-dd.dd/dd0dd1dd2dd3dd4dd5dd6dd7dd8dd9dd:dddddd;d<d=d>d?d@dAdBdCdDddEidFdGdHdIdJdKgdLdMddNi dOdPdQdPdRdPdSdPdTdPdUdPdVdPdWdPdXdPdYdPdZdPd[dPd\dPd]dPd^dPd_dPd`dPdadPiii dbdcdddcdedcdfdcdgdcdhdcdidcdadcdjdcdkdcdldcdmdcdndcdodcdpdcdqdcdrdci dsdcdtdcdudcdvdcdwdcdxdcdydcdzdcd{dcd|dcd}dcd~dcddcddcddcddcddci ddcddcddcddcddcddcddcddcddcddcddcddcddcddcddcddcddcdcdcdcdcdcdcdcdcdcd	i ddcddcddcddcddcddcddcddcdwdcddcddcddcddcddcddcddcddcdcdcdcdcdcdcdcdcdcdcd
dcdcdcdcdcddcdcdcdcdddiddddddddddddddddddddddddC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dd dPddĜdddddŜdd ddddƜd ddd d d ddddǜddidʜ	ddiddid d͜ddid d͜dΜt          i dt
          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt           dt          dt          dt          d t          dt          i dt          dt          dt          dt          dt          dt          dt          d	t           d
t          dt          dt"          dt          dt          dt          dt          dt          dt          t          t          t          t          t          t          t          t          t          t          t          t          t          t          t          ddt          idd          S (  Nr.   ARKHAMUSv1g@FTCORSspotmarginswapfutureoptionborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercreateDepositAddresscreateOrderfetchAccountsfetchAllGreeksfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesByNetworkfetchDepositsfetchFundingHistoryfetchGreeksfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchMyTrades
fetchOHLCVfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchPositionsfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeesfetchVolatilityHistoryfetchWithdrawalsrepayCrossMargin)repayIsolatedMarginsandboxsetLeveragewithdraw1m5m15m30m1h6h24h)rk   rl   rm   rn   ro   rp   1dzOhttps://github.com/user-attachments/assets/5cefdcfb-2c10-445b-835c-fa21317bf5aczhttps://arkm.com/apizhttps://arkm.com/z"https://arkm.com/register?ref=ccxtr   )urldiscountzhttps://arkm.com/limits-apiz"https://info.arkm.com/api-platformzhttps://arkm.com/fees)logoapiwwwreferraldocfeesgetalerts   announcementsassetsbookcandleschains	contractszindex-pricezindex-priceszmargin-schedulesmarketcapchart
marketcapspairpairszserver-timetickertickerstradesuserg      @orderszorders/by-client-order-idzorders/historyz!orders/history/by-client-order-idzorders/history_offsetzorders/{id}ztrades/historyztrades/timeztrigger-orderszaccount/airdropszaccount/balance-updateszaccount/balanceszaccount/balances/llzaccount/balances/historyzaccount/balances/commissionszaccount/deposit/addresseszaccount/depositszaccount/feeszaccount/funding-rate-paymentszaccount/leveragezaccount/lsp-assignmentszaccount/marginzaccount/margin/allzaccount/notificationszaccount/position-updateszaccount/positionszaccount/realized-pnlzaccount/rebateszaccount/referral-linkszaccount/sessionszaccount/settingsaccount/settings/price-alertzaccount/transferszaccount/unsubscribezaccount/watchlistzaccount/withdrawal/addresses!account/withdrawal/addresses/{id}zaccount/withdrawalssubaccountsairdropzairdrop/claimz%affiliate-dashboard/commission-earnedz%affiliate-dashboard/min-arkm-last-30dzaffiliate-dashboard/pointsz#affiliate-dashboard/points-season-1z#affiliate-dashboard/points-season-2z affiliate-dashboard/realized-pnlz"affiliate-dashboard/rebate-balancez"affiliate-dashboard/referral-count)	z&affiliate-dashboard/referrals-season-1z&affiliate-dashboard/referrals-season-2z(affiliate-dashboard/trading-volume-statsz#affiliate-dashboard/volume-season-1z#affiliate-dashboard/volume-season-2zaffiliate-dashboard/api-keyzcompetitions/opt-in-statuszrewards/infozrewards/vouchersz
orders/newztrigger-orders/newzorders/cancelztrigger-orders/cancelzorders/cancel/allztrigger-orders/cancel/allzorders/new/simplezaccount/deposit/addresses/newzaccount/notifications/readzaccount/sessions/deletezaccount/sessions/terminate-allzaccount/settings/updatezaccount/watchlist/addzaccount/watchlist/removezaccount/withdraw)
z$account/withdrawal/addresses/confirmr   zsubaccounts/transferzsubaccounts/perp-transferzsubaccounts/update-settingsr   zapi-key/createauthenticatezcompetitions/opt-inzrewards/vouchers/claim)z account/referral-links/{id}/slugr   r   r   zapi-key/update/{id})r   r   zsubaccounts/{subaccountId}zapi-key/{id})r{   postputdelete)publicprivateETHBTCSOLTONDOGESUIXRPOPAVAXARB)r   ERC20r   r   r   r   r   r   r   AVAXCARBONEr   )r   r     i i i 5i Ikl    $'- l    X l    `;P )networksnetworksByIdrequestExpirationtimeframeDurations)markindexlast)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedselfTradePreventiontrailingicebergleveragemarketBuyByCostmarketBuyRequiresPriced   )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )r   r   r   daysBackCanceledr   r   r   r   r   m  )	rh   r@   createOrdersrW   r\   rY   fetchOrdersrJ   rX   extendsdefault)linearinverse)r   r5   r7   r8   1000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025200012000220003200042000530001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028400014000240003400044000540006400074000840009)400104001140012400139000190002900039000490005900069000790008900099001090011zless than min withdrawal )exactbroad)idname	countriesversion	rateLimit	certifiedprohas
timeframesurlsrv   optionsfeaturesprecisionMode
exceptions)deep_extendsuperr.   describer+   r)   r"   r   r#   r!   r*   r    r   r'   r$   r%   r(   r&   )self	__class__s    I/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/arkham.pyr2  zarkham.describe   s   fd 3 3 < < > >888 %8 	8
 %8 %8 $U8 '8 8 "48 t8 '8 t8  8 !%8  !8" &u#8 8$ "5%8& +E'8( )%)8* #E+8, ,U-8. $T/80 '182 (384 "4586 &u788 1$98:  ;8< &t=8> u?8@ *5A8B +EC8D  E8 8 8F %dG8H  I8J dK8L "4M8N uO8P #EQ8R dS8T !$U8V !$W8X tY8Z [8\ T]8^ t_8` #Da8b )%c8d #De8f #Eg8 8h (- # o8 8 8v 	 	 j0 +? ! 
 28 0 "   $a +Q  %a  #A	 
 &q  %a  (  *1  +A  /  -a  )!  #A  $Q  *1   %a! " &q# $ %a%   0= "C= $c=  8=  -c	= 
 @=  4S=  *3=  %c=  -c=  *3=  -c=  /=  6s=  /=  23=   7!= " ;C#=  = $ 8%= & /'= ( +C)= * <S+= , /-= . 6s/= 0 -c1= 2 1#3= 4 4S5= 6 77= 8 09= : 3C;= < .s== > 5c?= @ /A= B /C= D ;CE=  =  = F 0G= H 23I= J 0K= L ;CM= N @O= P 23Q= R *3S= T &sU= V ,SW= X DSY= Z DS[= \ 9#]= ^ B3_= ` B3a= b ?c= d A#e= f A#g=  = h GJFIHKCFCF;>:=,/03y=  =  = |!(#!0#! ,S! 4S	!
 0! 8! 0! <S! /! 9#! 5c! 6s! =c! 6s! 4S!  7!!" /#!$ EH+.479<;>'*.1,/36697! ! !< AD<?AD+.36    =@AD:=,/	# #Ij  j /B BDN !"   "  ##  #$! ! &*"#$%$%%' '' >  %&+(,$(%)$(- -
 -1)-+/6:#'#'"&#(	( ( #(/4$)#($)+0271$ $4 %)&+!$$(%&*/& & ',#($)*/	# # '+!%#($)*/( ( $(&+!$$(,0%)#($)*/	* 	*  #y? ?B y
 "9  $	  "9  $	 UP Pb 'Z _Z Z	Z
 0Z YZ .Z .Z -Z -Z .Z -Z -Z 0Z -Z  -!Z" 0#Z$ -%Z& -'Z Z( -)Z* 0+Z, 0-Z. -/Z0 -1Z2 ]3Z4 Z5Z6 ]7Z8 Z9Z< Z=Z> .?Z@ ZAZB .CZD ZEZH \IZJ \KZL \MZ Z ZN \OZP \QZR \SZT YUZV .WZX .YZZ .[Z\ Y]Z^ ._Z` .aZb \cZd ]eZf \gZh \iZj \kZl .mZn \oZ Z Zp \qZr \sZt \uZv \wZx ZyZz -{Z| -}Z~ ]ZB .CZD ZEZF ^GZH .IZJ ZKZL -MZN .OZP .QZR .SZ ZT (.''''.''.0.-'.sZ Z Zx 01By_ __
oA
 oA
 o o o	    c                 <   |                      |          }i }t          dt          |                    D ]e}||         }|                     |d          }|                     |          }i }|                     |dg           }	t          dt          |	                    D ]^}
|	|
         }|                     |d          }|                     |          }||||                     |d          dddddddddid
||<   _|                     ||||                     |d          |                     |d	          d
k    dd|                     |d          dddd|                     |d          dd|                     |d          dddd|d          ||<   g|S )a  
        fetches all available currencies on an exchange

        https://arkm.com/docs#get/public/assets

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        r   symbolr   r#  Nrj   minmax)
infor"  networktitleactivedepositrj   fee	precisionlimitsstatuslistedwithdrawalFeeminWithdrawal
minDeposit)amountrj   r@  crypto)r<  r"  coder#  r?  r@  rj   rA  rB  rC  typer   )	v1PublicGetAssetsrangelensafe_stringsafe_currency_code	safe_listnetwork_id_to_codesafe_currency_structuresafe_number)r3  paramsresponseresulticurrencyr"  rK  r   r   jchain	networkIdr=  s                 r5  fetch_currencieszarkham.fetch_currencies  s    ))&114 q#h--(( 5	 5	A{H!!(H55B**2..DH^^Hh;;F1c&kk**  q	 ,,UH==	11)<<!#&!--eV<<"# $!%"#'#'% %% %!!"  77 ((6::**8X>>(J ''/BB!  $# 
  $///JJ#! !
  $//,GG#     !$39 9  F4LL6 r6  c                 X   |                      |          }g }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |d          }|                     |          }	|                     |          }
d}d}|                     |d          }|dk    }|dk    }d}d}|rd}|	d	z   |
z   }n,|r*d
}|	                    dd          }	|
}|}|	d	z   |
z   dz   |z   }|                    i d|d|d|	d|
d|d|d|d|d|d|ddd
|ddddd|                     |d          dk    d|d|rdn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|d+
           |S ),a  

        https://arkm.com/docs#get/public/pairs

        retrieves data on all markets for arkm
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r   r8  
baseSymbolquoteSymbolNpairTyper5   	perpetual/r7   z.P :r"  basequotesettlebaseIdquoteIdsettleIdrL  r6   r8   Fr9   r?  rD  rE  contractr   Tr}   minTickPrice
minLotSize)pricerI  r9  minSizemaxSizeminPricemaxPriceminNotional)r   rI  rp  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionTyperB  rC  createdr<  )v1PublicGetPairsrN  rO  rP  rQ  replaceappendrU  )r3  rV  rW  rX  rY  marketr"  rj  rk  rg  rh  
marketTyper8  rb  isSpotisPerpetualri  rl  s                     r5  fetch_marketszarkham.fetch_markets,  sh    ((00h q#h--(( G	 G	Aa[F!!&(33B%%fl;;F&&v}==G**622D++G44E"JF''
;;H'F"k1KFH ;#
e+ ;#
||D"--"e+c1F:MM 0b0&0 0 	0
 &0 &0 70 H0 
0 0 $0 0 %0 %0 $**68<<H0  K!0" +7$$4#0$ %0955T(. 5A"&"!--fnEE"..v|DD   $#! !
  $//	BB#//	BB 
  $//
CC#//
CC 
  $//FF#  $  _0 0 0 0 0 0 0b r6  c                 Z    |                      |          }|                     |dd          S )aI  
        fetches the current integer timestamp in milliseconds from the exchange server

        https://arkm.com/docs#get/public/server-time

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        
serverTimeMbP?)v1PublicGetServerTimesafe_integer_productr3  rV  rW  s      r5  
fetch_timezarkham.fetch_time  s1     --f55 ((<GGGr6  Nr8  r   c           	         |                                   |                     |          }d|d         i}|||d<   |                     |                     ||                    }|                     |dd          }|                     |d          }|                     ||                     ||          |ddd	d
          S )a!  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://arkm.com/docs#get/public/book

        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the number of order book entries to return, max 50
        :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
        r8  r"  Nr   lastTimer  bidsasksrp  size)load_marketsr  v1PublicGetBookextendr  rP  parse_order_booksafe_symbol)	r3  r8  r   rV  r  requestrW  	timestampmarketIds	            r5  fetch_order_bookzarkham.fetch_order_book  s     	V$$fTl
 $GG''GV(D(DEE< --h
EJJ	##Hh77$$Xt/?/?&/Q/QS\^dflnuw}~~~r6  rk   sincec           	      (   d}|                                   d}|                     |ddd          \  }}|r|                     d||||||          S |                     |          }|d         |                     | j        ||          d}	|                     |          dz  }
|                     |d          }|                     |dg          }|t          ||          n|}|"||	d
<   | 
                    |||
z            |	d<   n.|                                 }||n||	d<   |	d         ||
z  z
  |	d
<   |	d
         dz  |	d
<   |	d         dz  |	d<   |                     |                     |	|                    }|                     |||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://arkm.com/docs#get/public/candles

        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms for the ending date filter, default is the current time
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r   FrX   paginater"  )r8  duration  untilNstartend)r  handle_option_and_params"fetch_paginated_call_deterministicr  rP  r*  parse_timeframesafe_integeromitr:  summillisecondsv1PublicGetCandlesr  parse_ohlcvs)r3  r8  	timeframer  r   rV  maxLimitr  r  r  
durationMsr  selectedLimitnowrW  s                  r5  fetch_ohlcvzarkham.fetch_ohlcv  s    88z[`aa& 	|::<QVX]_hjprz{{{V$$Tl(()YOO
 
 )))44t;
!!&'226G9--161BE8,,,$GG!XXe]Z-GHHGENN##%%C','8UUsGEN&u~
0JJGG"7+d2 $.**4;;w+G+GHH"   69eUKKKr6  r  c           	         |                      |dd          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Ntimer  openhighlowclosevolume)r  rU  )r3  ohlcvr  s      r5  parse_ohlcvzarkham.parse_ohlcv4  s     %%eVU;;UF++UF++UE**UG,,UH--
 	
r6  symbolsc                 X    |                      |          }|                     ||          S N)v1PublicGetTickersparse_tickersr3  r  rV  rW  s       r5  fetch_tickerszarkham.fetch_tickersK  s-    **6224 !!(G444r6  c                     |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
        r8  r"  )r  r  v1PublicGetTickerr  parse_ticker)r3  r8  rV  r  r  rW  s         r5  fetch_tickerzarkham.fetch_tickerh  sr     	V$$fTl
 ))$++gv*F*FGG0   6222r6  r   c                    |                      |d          }|                     ||          }|                     i d|d|                     ||          d|                     |d          d|                     |d          d|                     |d          d|                     |d	          d
|                     |d          d|                     |d          d|                     |d          d|                     |d          d|                     |d          d|                     |d          d|                     |d          dd dd dd dd dd i          S )Nr8  r<  r  high24hr  low24hbidr   rp  r  price24hAgochangepriceChange
percentagepriceChangePercent
baseVolume	volume24hquoteVolumeusdVolume24h	markPrice
indexPricevwapaveragepreviousClose	askVolume	bidVolume)rP  safe_marketsafe_tickerr  rU  )r3  r   r  r  s       r5  r  zarkham.parse_ticker  s   ##FH55!!(F33 !
F!
d&&x88!
 D$$VY77!
 4##FH55	!

 4##FE22!
 D$$VW55!
 D$$V];;!
 d&&v}==!
 $**63GHH!
 $**6;??!
 4++FNCC!
 ))&+>>!
 $**6<@@!
 D!
 t!
  T!!
" #!
$ %!
 !
   	r6  c                     |                                   |                     |          }|d         }d|i}|||d<   |                     |                     ||                    }|                     ||||          S )a  
        get the list of most recent trades for a particular symbol

        https://arkm.com/docs#get/public/trades

        :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
        :param str [params.loc]: crypto location, default: us
        :param str [params.method]: method, default: marketPublicGetV1beta3CryptoLocTrades
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        r"  r8  Nr   )r  r  v1PublicGetTradesr  parse_trades)	r3  r8  r  r   rV  r  r  r  rW  s	            r5  fetch_tradeszarkham.fetch_trades  s     	V$$$<h
 $GG))$++gv*F*FGG   65%@@@r6  tradec                 R   |                      |d          }|                     ||          }|                     |dd          }|                     |d          }|                     |d          }d }|||d         d}n||dd}|                     ||                      |d	          ||                     |          |d         d |                     |d
d          d |                      |d          |                      |d          d ||                      |d          d|          S )Nr8  r  r  quoteFeearkmFeerh  rv  rZ  ARKM
revisionIduserSide	takerSiderp  r  orderId)r<  r"  r  datetimer8  rL  sidetakerOrMakerrp  rI  rv  rA  order)rP  r  r  rU  
safe_tradeiso8601safe_string_2)r3  r  r  r  r  r  r  rA  s           r5  parse_tradezarkham.parse_trade  s]   : ##E844!!(F33--eVUCC	##E:66""5)44 "7O CC  " C ""5,77"Y//X&&&uj+FF %%eW55&&uf55%%eY77 
  
   	r6  r"  c                     dt          |          i}|                     |                     ||                    }|                     |          S )a  
        fetches information on an order made by the user

        https://arkm.com/docs#get/orders/by-client-order-id

        :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
        :param str [params.clientOrderId]: a unique id for the order
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        r"  )intv1PrivateGetOrdersIdr  parse_order)r3  r"  r8  rV  r  rW  s         r5  fetch_orderzarkham.fetch_order	  sP     #b''
 ,,T[[&-I-IJJB )))r6  c                    |                                   i }d}| |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     ||||          S )ar  
        fetches information on multiple closed orders made by the user

        https://arkm.com/docs#get/orders/history

        :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
        :param int [params.until]: the latest time in ms to fetch orders for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr"  r8  r   )r  r  v1PrivateGetOrdersHistoryr  parse_orders)r3  r8  r  r   rV  r  r  rW  s           r5  fetch_closed_orderszarkham.fetch_closed_orders;  s     	[[((F &tGH$GG11$++gv2N2NOOF   65%@@@r6  c                    |                                   d}||                     |          }|                     |d          }|                     |d          }d}|r*|                     |                     i |                    }n)|                     |                     i |                    }|                     ||||          S )aT  
        fetch all unfilled currently open orders

        https://arkm.com/docs#get/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
        :param int [params.until]: the latest time in ms to fetch orders for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr   )r  r  	safe_boolr  v1PrivateGetTriggerOrdersr  v1PrivateGetOrdersr  )r3  r8  r  r   rV  r  isTriggerOrderrW  s           r5  fetch_open_orderszarkham.fetch_open_ordersu  s     	[[((F	::69-- 	H55dkk"f6M6MNNHH. ..t{{2v/F/FGGHF   65%@@@r6  c                 ^   |                      |d          }|                     |d          }d}i }|                     |d          }||                     |d          }||d<   n'|rt          |          |d<   nt          |          |d<   |rc|t	          | j        dz             |                     |          }|d         |d<   |                     |                     ||                    }n)| 	                    |                     ||                    }| 
                    |          S )	au  
        cancels an open order

        https://arkm.com/docs#post/orders/cancel

        :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>`
        r   NclientOrderIdtriggerOrderIdr  z< cancelOrder() requires a symbol argument for trigger ordersr"  r8  )r  r  r  r  r!   r"  r   v1PrivatePostTriggerOrdersCancelr  v1PrivatePostOrdersCancelr  )	r3  r"  r8  rV  r  rW  r  r  r  s	            r5  cancel_orderzarkham.cancel_order  s9    	::69--))&/BB$YYv77F'4GO$$ -,/GG())%(WW	" 	T~'2p(pqqq[[((F &tGH<<T[[RX=Y=YZZHH55dkk'66R6RSSH )))r6  c                    |t          | j        dz             |                     |d          }|                     |d          }d}|r|                     |          }n|                     |          }|                     |d          S )aU  
        cancel all open orders in a market

        https://arkm.com/docs#post/orders/cancel/all

        :param str symbol: cancel alls open orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nze cancelAllOrders() does not support a symbol argument, use cancelOrder() or fetchOpenOrders() insteadr   )r"   r"  r  r  #v1PrivatePostTriggerOrdersCancelAllv1PrivatePostOrdersCancelAllr  )r3  r8  rV  r  rW  s        r5  cancel_all_orderszarkham.cancel_all_orders  s     TW  (O  O  P  P  P	::69-- 	A??GGHH88@@H   4000r6  rL  r  rI  rp  c                 F   |                                   |                     |          }|                     |g d          du}|                     ||||||          }	d}
|r|                     |	          }
n|                     |	          }
|                     |
|          S )a  
        create a trade order on the exchange

        https://arkm.com/docs#post/orders/new

        :param str symbol: unified CCXT market symbol
        :param str type: "limit" or "market"
        :param str side: "buy" or "sell"
        :param float amount: the amount of currency to trade
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
        :param float [params.triggerPrice]: price for a trigger(conditional) order
        :param float [params.stopLossPrice]: price for a stoploss order
        :param float [params.takeProfitPrice]: price for a takeprofit order
        :param str [params.triggerDirection]: the direction for trigger orders, 'ascending' or 'descending'
        :param str [params.triggerPriceType]: mark, index or last
        :param bool [params.postOnly]: True or False whether the order is post-only
        :param bool [params.reduceOnly]: True or False whether the order is reduce-only
        :returns: `An order structure <https://docs.ccxt.com/?id=order-structure>`
        r   r   r   N)r  r  safe_number_ncreate_order_requestv1PrivatePostTriggerOrdersNewv1PrivatePostOrdersNewr  )r3  r8  rL  r  rI  rp  rV  r  r  r  rW  s              r5  create_orderzarkham.create_order  s    , 	V$$++F4h4h4hiiquu++FD$vVV 	<99'BBHH 227;;H &111r6  c                    |                      |          }|d         }|d         ||                     ||          d}|dk    }	|                     |d          }
|                     |d          }|                     |g d          }||                     ||          |d<   |

|	rd	nd
|d<   n\|
|	rd
nd	|d<   nP|                     |d          }|t          | j        dz             ||dk    r
|	rd	nd
|d<   n|dk    r	|	rd
nd	|d<   |                     |d          d|d<   |dk    }|dk    }|                     |g d          }| 	                    |d|          }|                     |d          }| 
                    |g d          }|rd|d<   |s|r7|                     ||          |d<   |dk    rd|d<   n|dk    rd|d<   nd |d<   n|rd|d<   |                     ||          S )!Nr8  r"  )r8  r  r  buyr   r   r  r   stopLoss
takeProfittriggerTyper   zx createOrder() requires a triggerDirection parameter when triggerPrice is specified, must be "ascending" or "descending"	ascending
descendingr   r   r  r   )limitGtclimitIoclimitFokFr   )postOnlyr   r   r   r   r   Tr  rp  r   r  rL  r   r  r  )r  amount_to_precisionrU  safe_string_nprice_to_precisionrP  r!   r"  in_arrayis_post_onlyr  r  )r3  r8  rL  r  rI  rp  rV  r  r  isBuyr   r   triggerPriceAnyr   isMarketOrderisLimitOrderisLimitExchangeSpecificr  r   s                      r5  r  zarkham.create_order_request;  s   V$$!Tl,,VV<<
 

 ((AA**63DEE,,V5i5i5ijj&&*&=&=fo&V&VGN#(7<)N,&& ,9>)NJ&&#'#3#3F<N#O#O #++DG  7q  -q  r  r  r#/';66?D1V,..)\99AF1VJ.(:;;C.4*+)"&--6Z6Z6Z"["[$$]E6BB&&v}==6  $G  $G  $G  H  H 	'"&GJ 
	'2 
	'#66vuEEGGe##",%%",", 	'&GFO{{7F+++r6  r  c                    |                      |d          }|                     ||          }|                     |d          }|                      |d          }|rdn|                     |          }|rdn|                     |          }|                      |d          }|                      |d          }	g }
|,|
                    ||                      |d          d	           |	|
                    |	d
d	           |                     |dd          }|                     i d|                     |dd          d|                      |d          d|d| 	                    |          dd d|                     |dd          d| 
                    |                      |d                    d|d         d|d|dd d|                      |d          d|                     |d          dd d|                     |d          d|                     |d          d|                     |d           |                     |d!          d d |
|                     |d"          |d#|          S )$Nr8  r  rL  r   r   quoteFeePaidarkmFeePaidrh  r  r  r  r  r"  r  r  r  r  r  lastTradeTimeStamplastUpdateTimestampr  rD  r   r  rp  r   rv  executedNotionalr  avgPricerI  r  re  
reduceOnly)filled	remainingr   rz   r-  r<  )rP  r  r  parse_order_typeparse_time_in_forcer  r  
safe_orderr  r  parse_order_statusrU  safe_number_omit_zero)r3  r  r  r  
isPostOnlytypeRaw	orderTyper   r'  r(  rz   r  s               r5  r  zarkham.parse_ordero  s    ` ##E844!!(F33^^E:66
""5&11)MGGt/D/DW/M/M	(Oddd.F.Fw.O.O''~>>&&um<<#KK$ ,,VW==     "KK#"     --eVUCC	  
$$$UI7GHH 
T--e_EE 
  
 Y//	 

 !$ 
 "4#<#<UJPU#V#V 
 d--d.>.>uh.O.OPP 
 fX& 
 I 
 ; 
  
 D$$UF33 
 T%%eW55 
 D 
 D$$U,>?? 
  t11%DD! 
" d&&uf55# 
$ &&ub11..==/ 
  
  
0 1  	r6  c                 >    ddddd}|                      |||          S )Nr   r  r  r  r  r  safe_string_upperr3  rL  typess      r5  r0  zarkham.parse_order_type  s4    	
 
 %%eT4888r6  c                 >    ddddd}|                      |||          S )NGTCr   r   r9  r:  r<  s      r5  r1  zarkham.parse_time_in_force  s4    	
 
 %%eT4888r6  rD  c                 D    dddddddd}|                      |||          S )Npendingr  closedcanceled)newstagedbookedtakermaker	cancelledrB  rP  )r3  rD  statusess      r5  r3  zarkham.parse_order_status  s=    #
 
 &&999r6  c                    |                                   i }|||d<   d}|	|dz  |d<   n|                                 |z
  dz  |d<   |                     |d          }||                     |d          }|dz  |d<   n"|                     |d         |dz            |d<   |                     d||          \  }}|                     |                     ||                    }|                     |d||          S )aw  
        fetch all trades made by the user

        https://arkm.com/docs#get/trades/time

        :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 trade structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch trades for
        :param str [params.page_token]: page_token - used for paging
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
        Nr   i \&r  fromr  to)	r  r  r  r  r  handle_until_optionv1PrivateGetTradesTimer  r  )	r3  r8  r  r   rV  r  defaultRanger  rW  s	            r5  fetch_my_tradeszarkham.fetch_my_trades  s    	$GG*#dlGFOO#0022\ATIGFO!!&'22YYvw//F!DLGDMM HHWV_lT6IJJGDM227GVLL..t{{7F/K/KLL$   4>>>r6  c                     |                                   i }d}|                     |dd          \  }}|||d<   |                     |                     ||                    }|                     |dg           }|                     ||          S )aF  
        fetch all the accounts associated with a profile

        https://arkm.com/docs#get/user

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `account structures <https://docs.ccxt.com/?id=account-structure>` indexed by the account type
        NrA   	accountIdsubAccountIdr   )r  r  v1PrivateGetUserr  rR  parse_accounts)r3  rV  r  rT  rW  subAccountss         r5  fetch_accountszarkham.fetch_accounts>  s     		 99&/S^__	6 &/GN#((Wf)E)EFFV nnX}bAA"";777r6  c                 8    |                      |d          d d |dS )Nr"  )r"  rL  rK  r<  rJ  )r3  accounts     r5  parse_accountzarkham.parse_account{  s/     ""7D11	
 
 	
r6  c                 ~    |                                   |                     |          }|                     |          S )a  
        query for account info

        https://arkm.com/docs#get/account/balances

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        )r  v1PrivateGetAccountBalancesparse_balancer  s      r5  fetch_balancezarkham.fetch_balance  s?     	33F;;> !!(+++r6  c                    |                      |dd          }|||                     |          d}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )	NlastUpdateTimer  )r<  r  r  r   r8  balancetotalfree)r  r  rN  rO  rP  rQ  r[  safe_balance)	r3  rW  r  rX  rY  rc  r8  rK  r[  s	            r5  r_  zarkham.parse_balance  s    --h8H%PP	"Y//
 

 q#h--(( 	# 	#AqkG%%gx88F**622DllnnG#//CCGG"..w??GFO"F4LL  (((r6  rK  c                 h   |                                   d}|                     |          \  }}|t          | j        dz             d|i}|                     |                     ||                    }|                     |d          }|                     ||                     |                    S )a~  
        create a currency deposit address

        https://arkm.com/docs#post/account/deposit/addresses/new

        :param str code: unified currency code of the currency for the deposit address
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/?id=address-structure>`
        Nz2 createDepositAddress() requires a "network" paramr\  	addresses)	r  handle_network_code_and_paramsr!   r"  'v1PrivatePostAccountDepositAddressesNewr  rP  parse_deposit_addressrZ  )r3  rK  rV  networkCoder  rW  addresss          r5  create_deposit_addresszarkham.create_deposit_address  s     	"AA&IIV#DG.b$bccc[
 ??GU[@\@\]] ""8[99))'4==3F3FGGGr6  c                    |                                   d}|                     |          \  }}|t          | j        dz             d|                     |          i}|                     |                     ||                    }|                     |d          }|                     |ddd|i          }| 	                    |d          S )a  
        fetch the deposit addresses for a currency associated with self account

        https://arkm.com/docs#get/account/deposit/addresses

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary `address structures <https://docs.ccxt.com/?id=address-structure>`, indexed by the network
        Nz< fetchDepositAddressesByNetwork() requires a "network" paramr\  rh  Fr=  )
r  ri  r!   r"  network_code_to_id#v1PrivateGetAccountDepositAddressesr  rR  parse_deposit_addressesindex_by)r3  rK  rV  rl  r  rW  dataparseds           r5  "fetch_deposit_addresses_by_networkz)arkham.fetch_deposit_addresses_by_network  s     	"AA&IIV#DG.l$lmmmT,,[99
 ;;DKKQW<X<XYY ~~h44--dD%)[AYZZ}}VY///r6  rZ  c                 :    ||                      |d          d |d dS )NrK  )r<  rZ  r=  rm  tagrJ  )r3  entryrZ  s      r5  rk  zarkham.parse_deposit_address  s2    
 ((6::
 
 	
r6  c                 \   |                                   |                     |          }|                     |          }|d         }|                     ||          }|                     |d         ||          }|                     ||          }|t          | j        dz   |z             |S )au  
        fetch the deposit address for a currency associated with self account

        https://arkm.com/docs#get/account/deposit/addresses

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/?id=address-structure>`
        r   rK  Nz< fetchDepositAddress() could not find a deposit address for )r  rZ  ri  rv  )select_network_code_from_unified_networks	safe_dictr&   r"  )	r3  rK  rV  rZ  networkCodeAndParamsrl  indexedAddressesselectedNetworkCoderm  s	            r5  fetch_deposit_addresszarkham.fetch_deposit_address  s     	==&&#BB6JJ*1-BB4PP"LLXV\M]_jl|}}..!13FGG? +i!ilp!pqqqr6  c                     |                                   i }|||d<   |                     |                     ||                    }d}||                     |          }|                     ||||          S )a  
        fetch all deposits made to an account

        https://arkm.com/docs#get/account/deposits

        :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>`
        Nr   )r  v1PrivateGetAccountDepositsr  rZ  parse_transactions)r3  rK  r  r   rV  r  rW  rZ  s           r5  fetch_depositszarkham.fetch_deposits$  s     	$GG33DKK4P4PQQ  }}T**H&&x5%HHHr6  transactionc                 N   |                      |d          }|                     |dd          }|                     |d          }d }|r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S )NdepositAddressr  r  	confirmedokr8  r<  r"  txidtransactionHashrL  rZ  r=  r\  rI  rD  r  r  rm  addressFrom	addressTorx  tagFromtagToupdatedF)commentrA  internal)rP  r  r  rQ  rS  rU  r  )	r3  r  rZ  rm  r  confirmdrD  
currencyIdrK  s	            r5  parse_transactionzarkham.parse_transactionI  s    "";0@AA--k65II	>>+{;; 	F%%k8<<
&&z8<<
K
$"";55
 D$$[2CDD
 D	

 
 t..t/?/?W/U/UVV
 d&&{H==
 f
 
 Y//
 w
 4
 
 4
 t
  T!
" t#
$ )
 
 
 	
r6  c                 \   |                                   |                     |          }t          | j                                                  }i }|                     |d          }|                     |d          }|                     |d          }|                     |d          }t          dt          |                    D ]d}	||	         }
| j        |
         }||
d||
<   |d         r|||
         d<   |||
         d	<   >|d
         s|d         r|||
         d<   |||
         d	<   e|S )az  
        fetch the trading fees for multiple markets

        https://arkm.com/docs#get/account/fees

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.subType]: "linear" or "inverse"
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/?id=fee-structure>` indexed by market symbols
        spotMakerFeespotTakerFeeperpMakerFeeperpTakerFeer   )r<  r8  r5   rH  rG  r7   r8   )r  v1PrivateGetAccountFeeslistmarketskeysrU  rN  rO  )r3  rV  rW  r  rX  	spotMaker	spotTaker	perpMaker	perpTakerrY  r8  r  s               r5  fetch_trading_feeszarkham.fetch_trading_feesv  sP    	//77 t|((**++$$X~>>	$$X~>>	$$X~>>	$$X~>>	q#g,,'' 	4 	4AQZF\&)F   F6N f~ 4*3vw'*3vw'' 46(#3 4*3vw'*3vw'r6  c                     |                                   d}||                     |          }i }|||d<   |                     |                     ||                    }|                     ||||          S )a+  
        fetch the history of funding payments paid and received on self account

        https://arkm.com/docs#get/account/funding-rate-payments

        :param str [symbol]: unified market symbol
        :param int [since]: the earliest time in ms to fetch funding history for
        :param int [limit]: the maximum number of funding history structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns dict: a `funding history structure <https://docs.ccxt.com/?id=funding-history-structure>`
        Nr   )r  r  &v1PrivateGetAccountFundingRatePaymentsr  parse_incomes)r3  r8  r  r   rV  r  r  rW  s           r5  fetch_funding_historyzarkham.fetch_funding_history  s     	[[((F$GG>>t{{7TZ?[?[\\  !!(FE5AAAr6  c           
      `   |                      |d          }|                      |d          }|                     |dd          }||                     ||          |                     |          ||                     |          |                      |d          |                     |d          dS )N
pairSymbolassetSymbolr  r  r"  rI  )r<  r8  rK  r  r  r"  rI  )rP  r  r  rQ  r  rU  )r3  incomer  r  r  r  s         r5  parse_incomezarkham.parse_income  s     ##FL99%%fm<<
--ffeDD	&&x88++J77"Y//""6400&&vx88
 
 	
r6  c                 `   |                                   |                     |          }|                     |d          }d|i}|                     |                     ||                    }|                     |d          }|                     ||i           }|                     ||          S )aM  
        fetch the set leverage for a market

        https://arkm.com/docs#get/account/leverage

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `leverage structure <https://docs.ccxt.com/?id=leverage-structure>`
        r"  r8  )r  r  rP  v1PrivateGetAccountLeverager  rs  r|  parse_leverage)	r3  r8  rV  r  r  r  rW  indexedrt  s	            r5  fetch_leveragezarkham.fetch_leverage  s     	V$$##FD11h
 33DKK4P4PQQ --(33~~gx44""4000r6  r   c                     |                      |d          }|                     |d          }||                     ||          d ||dS )Nr8  r   )r<  r8  r   longLeverageshortLeverage)rP  rU  r  )r3  r   r  r  leverageNums        r5  r  zarkham.parse_leverage  s\     ##Hh77&&x<<&&x88'(
 
 	
r6  c                 d   |t          | j        dz             |                                  |                     |          }|                     |          }|                     |d          }||d}|                     |                     ||                    }|                     ||          S )aZ  
        set the level of leverage for a market

        https://arkm.com/docs#post/account/leverage

        :param float leverage: the rate of leverage
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        Nz) setLeverage() requires a symbol argumentr"  )r8  r   )	r!   r"  r  r  number_to_stringrP  v1PrivatePostAccountLeverager  r  )	r3  r   r8  rV  r  leverageStringr  r  rW  s	            r5  set_leveragezarkham.set_leverage  s     >#DG.Y$YZZZV$$..x88##FD11&
 
 44T[[&5Q5QRR ""8V444r6  c                     |                                   |                     |          }|                     |          }|                     ||          S )a  
        fetch all open positions

        https://arkm.com/docs#get/account/positions

        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.standard]: whether to fetch standard contract positions
        :returns dict[]: a list of `position structures <https://docs.ccxt.com/?id=position-structure>`
        )r  market_symbolsv1PrivateGetAccountPositionsparse_positionsr  s       r5  fetch_positionszarkham.fetch_positions.  sT     	%%g..44V<<6 ##Hg666r6  positionc                    |                      |d          }t          j        |          }t          j        |d          }|rdnd}|                      |d          }|                      |d          }|                     i d|dd d|                     ||          d	|                     t          j        |                    d
d dd d|                     |d          d|                     |d          dd dd d|                     |          dd d|                     |d          dd d|dd dd d |                     |d          |                     |d          d d |                     |d          d d d d d d          S )Nrg  0longshortr8  valuer<  r"  notionalr   liquidationPrice
entryPriceaverageEntryPriceunrealizedPnlpnlrealizedPnlr  r   rw  r  	lastPricer  r   r  rb  maintenanceMargininitialMargin)r  r*  r  maintenanceMarginPercentage
collateralr  initialMarginPercentager   marginRatior   r   )	rP  r,   
string_abs	string_gesafe_positionr  parse_numberrU  r  )	r3  r  r  rg  baseAbsisLongr  r  r  s	            r5  parse_positionzarkham.parse_positionX  s$   2 &11$T**"4--,vvW##Hh77##Hg66!! #
H#
$#
 d&&x88#
 ))'*<X*F*FGG	#

 $#
 #
 $**85HII#
 T--h>>#
 4#
 $#
 **733#
 D#
 ))(K@@#
 #
 D#
  d!#
" ##
$ #'#4#4X?O#P#P!%!1!1(<O!P!P+/!--hHH'+!#9#
 #
 #
   	r6  rm  rx  c                    |                      ||          \  }}|                                  |                                 }|                     |          }|d         |                     ||          |                     |dd          d}d}	|                     |          \  }	}|	t          | j        dz             | 	                    |d          }
||
vrt          | j        dz             |
|         }d}t          dt          |                    D ]}||         }|d	         |	k    r|} n| t          | j        d
z   |z   dz   |	z             |                     |d          |d<   |                     |                     ||                    }|                    dd          }d|i}|                     ||          S )a  
        make a withdrawal

        https://arkm.com/docs#post/account/withdraw
        https://arkm.com/docs#get/account/withdrawal/addresses

        :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"  rU  r   )r8  rI  subaccountIdNz& withdraw() requires a "network" paramrm  z[ withdraw() requires an address that has been previously added to the whitelisted addressesr\  z< withdraw() can not find whitelisted withdrawal address for z with network 	addressId
re  )handle_withdraw_tag_and_paramsr  &v1PrivateGetAccountWithdrawalAddressesrZ  currency_to_precisionr  ri  r!   r"  group_byr&   rN  rO  v1PrivatePostAccountWithdrawr  r~  r  )r3  rK  rI  rm  rx  rV  withdrawalAddressesrZ  r  rl  indexedListwithdrawalObjectsfoundWithdrawalObjectrY  withdrawalObjectrW  responseStringrt  s                     r5  rj   zarkham.withdraw  s&    99#vFFV"IIKK ==&&tn00v>> --fnaHH
 

 "AA&IIV#DG.V$VWWWmm$7CC;&&   ,I  "I  J  J  J'0 $q#/0011 	 	A03(K77(8% 8 !( +i!ils!s  wG  "G  JU  "U  V  V  V#001FMM44T[[&5Q5QRR "))$33n%%%dH555r6  c                     |                                   |t          | j        dz             |                     |          }|                     |          }|                     ||          S )a  
        retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes

        https://arkm.com/docs#get/public/margin-schedules

        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/?id=leverage-tiers-structure>`, indexed by market symbols
        Nz1 fetchLeverageTiers() requires a symbols argument)r  r!   r"  r  v1PublicGetMarginSchedulesparse_leverage_tiersr  s       r5  fetch_leverage_tierszarkham.fetch_leverage_tiers  so     	?#DG.a$abbb%%g..226::< ((7;;;r6  rW  c                    |                      |d          }|                     |          }i }t          dt          |                    D ]}||         }|                     |          }|                     |d         d          }	|	t          | j        dz   |z             |                     ||	i           }
| 	                    |
dg           }| 
                    ||          ||<   |S )Nr#  r   r<  marginSchedulez8 fetchLeverageTiers() could not find marginSchedule for bands)rs  r  rN  rO  r  rP  r#   r"  r|  rR  parse_market_leverage_tiers)r3  rW  r  marketIdKeyr  tiersrY  r8  r  r  selectedDictr  s               r5  r  zarkham.parse_leverage_tiers	  s    --&11%%g..q#g,,'' 	L 	LAQZF[[((F!--fVn>NOON%*d dgm mnnn>>'>2FFLNN<"==E <<UFKKE&MMr6  c                    g }|}d}t          dt          |                    D ]}||         }|                     |d          }|                     ||d d          }|                     |d          }	|                    |                     |d          |                     ||d d          |d         r|d         n|d         ||	|                     |d	          |                     |d
          |d           |	}|S )Nr   r  r7   positionLimitr}   r   rg  rh  
marginRateleverageRate)tierr8  rZ  ru  maxNotionalmaintenanceMarginRatemaxLeverager<  )	rN  rO  rP  r  rU  r  r  r  r  )
r3  r<  r  r  bracketsru  rY  r  r  r  s
             r5  r  z"arkham.parse_market_leverage_tiers	  s   q#h--(( 	& 	&AA;D''h77H%%hfEEF**4AAKLLA**8VT6JJ.4X.>SF6NNF7O**)-)9)9$)M)M#00~FF	 	 	 	 	 &KKr6  r  c                    |                      | j        di           }t          |                                          }t	          dt          |                    D ]*}||         }|                     ||          }||k    r|c S +d S )Nr   r   )r|  r,  r  r  rN  rO  r  )r3  r  r*  r  rY  r  durationInMicrosecondss          r5  find_timeframe_by_durationz!arkham.find_timeframe_by_duration)	  s    ^^DL2FKK
JOO%%&&q#d))$$ 	! 	!AQI%)%6%6z9%M%M"%11     2tr6  r   GETc                    |                      |d          }|                      |d          }|dk    r|dz   nd}	|                     ||                     |                    }
|                     ||          }| j        d         |         dz   |	z   |z   }d}|dk    r|
r|                     |
          }|d|z   z  }|d	k    r|                                  |                                 |                     | j	        d
d          z   dz  }|dk    r| 
                    |          }|dk    r|dz   |z   }||nd}| j        t          |          z   |                                z   dz   |z   |z   }|                     | j                  }|                     |                     |          |t$          j        d          }dd| j        t          |          |dd}||||dS )Nr   r}   r   rd  re  rv   r  ?r   r   r   r  POSTbase64zapplication/json1001)zContent-TypeAcceptzArkham-Api-KeyzArkham-ExpireszArkham-SignaturezArkham-Broker-Id)rs   methodbodyheaders)rP  r  extract_paramsimplode_paramsr+  	urlencodecheck_required_credentialsr  r  r,  jsonapiKeystrupperbase64_to_binarysecrethmacencodehashlibsha256)r3  pathrv   r  rV  r
  r	  rL  access
accessPartqueryrs   queryStringexpiresbodyStrpayloaddecodedSecret	signatures                     r5  signzarkham.sign4	  s   Q''!!#q))&,&8&8Vc\\r
		&$"5"5d";";<<""400it$s*Z7$>U?? )"nnU33s[((Y++---((**T->->t|M`bf-g-ggkooGyy((b  czK/#/ddbGkCLL06<<>>ACG$NQXXG 11$+>>M		$++g"6"6w~W_``I 2,"&+"%g,,$-$* G fdwOOOr6  reasonrs   r  r
  r	  c
                 |   |                      |d          }
|
|                      |d          }| j        dz   |z   }|                     | j        d         ||           |                     | j        d         |
|           |                     | j        d         |
|           t          | j        dz   |z             d S )Nmessager"   r   r!  )rP  r"  throw_exactly_matched_exceptionr/  throw_broadly_matched_exceptionr   )r3  rK  r$  rs   r  r
  r	  rW  requestHeadersrequestBodyr&  	errorCodefeedbacks                r5  handle_errorszarkham.handle_errorsU	  s     ""8Y77((488Iw}t+H001I9V^___001I7T\]]]001I7T\]]]# 4555tr6  r  )NN)S__name__
__module____qualname__r   r2  r   r^  r   r   r  r  r  r   r   r  r  r  r  r   r   r  r   r  dictr  r   r  r  r   r  r   r  r  r  r	  r   r   floatr   r  r  r  r0  r1  r3  rR  r   rY  r\  r   r`  r_  r
   rn  rv  r	   rk  r  r   r  r  r   r  r  r  r   r  r  r  r  r   r  r  rj   r   r  r  r   r  r   r#  r.  __classcell__)r4  s   @r5  r.   r.      s	       p# p p p p p pd ') Z ZZ Z Z Z Zx $& F F$v, F F F FP !# H H H H" :>b 2 2s 23 2Y 2 2 2 2h 26DW[df 9L 9L# 9Lc 9LQT 9Lkoptku 9L 9L 9L 9Lv
 
 
4 
 
 
 
. 04B 5 5W 57 5 5 5 5: 02 $3 $33 $3f $3 $3 $3 $3L 4  6    0 6:UW $A $A3 $As $A# $A\`af\g $A $A $A $AL; ; ;v ; ; ; ; ;z 26b 0* 0*c 0*3 0* 0* 0* 0*d 154VZce 8A 8A# 8AS 8APS 8Ajnotju 8A 8A 8A 8At /3TXac OA OA OA3 OAc OAhlmrhs OA OA OA OAb 37r #* #*s #*C #* #* #* #*J /32 1 1 1 1 1 10 gksu 62 623 62i 62y 62RW 62`c 62 62 62 62p os{} 2, 2,3 2,i 2,y 2,Z_ 2,hk 2, 2, 2, 2,h| | |v | | | | ||9S 9S 9 9 9 99 9 9 9 9 9
: 
: 
: 
: 
: -1tRV_a 1? 1?c 1? 1?C 1? 1? 1? 1?f %' ;8 ;84= ;8 ;8 ;8 ;8z
 
 
& $& ), ),( ), ), ), ),V) ) ) ) )" 8: H H3 Hn H H H H6 DF 0 0s 0$~J^ 0 0 0 0<

 

X 

 

 

 

 

 79  # ^    * *.Dt\^ #I #I3 #Ic #I #Icghsct #I #I #I #IJ+
 +
T +
X +
Q\ +
 +
 +
 +
Z )+ ' '{ ' ' ' 'R 37TX\eg $B $BC $Bs $BRU $B $B $B $BL
 
6 
 
 
 
4 24 !1 !1S !1 !1 !1 !1 !1F
 
t 
V 
x 
 
 
 
" 9=R 5 5S 5# 5 5 5 56 26b (7 (7w (7T(^ (7 (7 (7 (7T< <t <V < < < <| KOWY =6 =6S =6% =6# =6C =6^i =6 =6 =6 =6~ 7;2 ,< ,<G ,<- ,< ,< ,< ,<\ S 49 bo       $|J\    ,	3 	3 	 	 	 	 &eBSW P P P PB# s  c TX `c        r6  r.   )3ccxt.base.exchanger   ccxt.abstract.arkhamr   r  ccxt.base.typesr   r   r   r   r	   r
   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!   r"   r#   r$   r%   r&   r'   r(   r)   r*   ccxt.base.decimal_to_precisionr+   ccxt.base.preciser,   r.    r6  r5  <module>r=     s   ( ' ' ' ' ' , , , , , ,  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  D       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . . . . . . . + + + + + + ) ) ) ) ) ) * * * * * * , , , , , , . . . . . . 4 4 4 4 4 4 % % % % % %K% K% K% K% K%X{ K% K% K% K% K%r6  