
    E#i                    d   S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SK J!r!  S SK J"r"  S SK J#r#  S S	K J$r$  S S
K J%r%  S SK J&r&  S SK J'r'  S SK J(r(  S SK J)r)  S SK J*r*  S SK J+r+  S SK J,r,  S SK J-r-  S SK.J/r/  S SK0J1r1   " S S\\5      r2g)    )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                   0  ^  \ rS rSrS\4U 4S jjr0 4S\4S jjr0 4S\\	   4S jjr
0 4S jrS0 4S\S	\S\4S
 jjrSSS0 4S\S\S	\S\\   4S jjrSUS\	S\4S jjrS0 4S\S\4S jjr0 4S\S\4S jjrSUS\S\	S\4S jjrSS0 4S\S\S	\S\\   4S jjrSUS\S\	S\4S jjrS0 4S\S\4S jjrSSS0 4S\S\S	\S\\   4S jjr SSS0 4S\S\S	\S\\   4S jjr!S0 4S\S\4S jjr"S0 4S\4S jjr#S0 4S\S\$S\%S \&S!\'4
S" jjr(S0 4S\S\$S\%S \&S!\'4
S# jjr)SUS$\S\	S\4S% jjr*S\S\4S& jr+S\S\4S' jr,S(\4S) jr-SSS0 4S\S\S	\4S* jjr.0 4S\\/   4S+ jjr0S, r10 4S\24S- jjr3S\24S. jr40 4S/\S\54S0 jjr60 4S/\S\\5   4S1 jjr7SUS2\8S\54S3 jjr90 4S/\S\54S4 jjr:SSS0 4S/\S\S	\S\\;   4S5 jjr<SUS6\S2\8S\;4S7 jjr=0 4S\>4S8 jjr?SSS0 4S\S\S	\4S9 jjr@SUS\	4S: jjrA0 4S\S\B4S; jjrCSUS<\S\	S\B4S= jjrDS0 4S<\ES\4S> jjrFS0 4S\S\\G   4S? jjrHSUS@\S\	4SA jjrIS0 4S/\S \&SB\SC\S\;4
SD jjrJS0 4S\S\K4SE jjrLSVSF\S\\   S\K4SG jjrMSUS\	S\\N   4SH jjrOSI\S\4SJ jrPSKSL0 SS4SM jrQS/\ESN\SO\SP\SQ\SR\4SS jrRSTrSU =rT$ )Warkham   returnc           "      	  > U R                  [        [        U ]  5       SSS/SSSS0 SS_S	S_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_SS_S S_S!S_S"S_S#S_S$S_S%S_S&S_S'S_S(S_S)S_E0 S*S_S+S_S,S_S-S_S.S_S/S_S0S_S1S_S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_S:S_ESSSSS;.ES<S=S>S?S@SASBSC.SDSSE0SFSGSHSI.SJSK/SLSM.SSN0 SOSP_SQSP_SRSP_SSSP_STSP_SUSP_SVSP_SWSP_SXSP_SYSP_SZSP_S[SP_S\SP_S]SP_S^SP_S_SP_S`SP_SaSP0E00 SbSc_SdSc_SeSc_SfSc_SgSc_ShSc_SiSc_SaSc_SjSc_SkSc_SlSc_SmSc_SnSc_SoSc_SpSc_SqSc_SrSc_0 SsSc_StSc_SuSc_SvSc_SwSc_SxSc_SySc_SzSc_S{Sc_S|Sc_S}Sc_S~Sc_SSc_SSc_SSc_SSc_SSc_E0 SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_EScScScScScScScScScS.	E0 SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_SwSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_SSc_ScScScScScScScScScScS.
EScScScScScS.ScScScScS.S.S.0SSSSSSSSSSSS.SSS.SSSSSSSSSC.S.SSSSSSS.SSSS SSSSS.SSSSSSSS.S SSS SPSS.SSSSS.SS SSSS.S SSS S S SSSS.SS0S.	SS0SS0S S.SS0S S.S.[        0 S[
        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _E0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[         _S[        _S[        _S[        _GS [        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS	[         _GS
[        _GS[        _GS["        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E[        [        [        [        [        [        [        [        [        [        [        [        [        [        [        GS.EGS[        0GS.GS.5      $ (  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)rl   rm   rn   ro   rp   rq   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  )	ri   rA   createOrdersrX   r]   rZ   fetchOrdersrK   rY   extendsdefault)linearinverse)r   r6   r8   r9   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urlsrw   optionsfeaturesprecisionMode
exceptions)deep_extendsuperr.   describer+   r)   r"   r   r#   r!   r*   r    r   r'   r$   r%   r(   r&   )self	__class__s    E/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/arkham.pyr3  arkham.describe   s   fd < >888 %8 	8
 %8 %8 $U8 '8 8 "48 t8 '8 t8  8 !%8  !8" &u#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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h (- # o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 /BDN !"   "  ## #$! &*"#$%$%%''>  %&+(,$(%)$(-
 -1)-+/6:#'#'"&#(	( #(/4$)#($)+0271$4 %)&+!$$(%&*/& ',#($)*/	# '+!%#($)*/( $(&+!$$(,0%)#($)*/	*  #y?B y
 "9  $	 "9  $	U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* 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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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T (.''''.''.0.-'.sZx 01By__
oA
 o o	    c                    U R                  U5      n0 n[        S[        U5      5       GH'  nX$   nU R                  US5      nU R	                  U5      n0 nU R                  US/ 5      n	[        S[        U	5      5       HN  n
X   nU R                  US5      nU R                  U5      nUUUU R                  US5      SSSSSSSSS.0S.
X'   MP     U R                  UUUU R                  US5      U R                  US	5      S
:H  SSU R                  US5      SSSS.U R                  US5      SS.U R                  US5      SS.S.SUS.5      X7'   GM*     U$ )z
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$  Nrk   minmax)
infor#  networktitleactivedepositrk   fee	precisionlimitsstatuslistedwithdrawalFeeminWithdrawal
minDeposit)amountrk   rB  crypto)r>  r#  coder$  rA  rB  rk   rC  rD  rE  typer   )	v1PublicGetAssetsrangelensafe_stringsafe_currency_code	safe_listnetwork_id_to_codesafe_currency_structuresafe_number)r4  paramsresponseresulticurrencyr#  rM  r   r   jchain	networkIdr?  s                 r6  fetch_currenciesarkham.fetch_currencies  s    ))&14 q#h-(A{H!!(H5B**2.DH^^Hh;F1c&k*	 ,,UH=	11)<!#&!--eV<"# $!%"#'#'%%!	 +*  77 ((6:**8X>(J ''/B!  $#
  $///J#!
  $//,G#  !$39 FL7 )l r8  c                    U R                  U5      n/ n[        S[        U5      5       GH  nX$   nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  U5      n	U R	                  U5      n
SnSnU R                  US5      nUS:H  nUS:H  nSnSnU(       a  SnU	S	-   U
-   nO-U(       a&  S
nU	R                  SS5      n	U
nUnU	S	-   U
-   S-   U-   nUR                  0 SU_SU_SU	_SU
_SU_SU_SU_SU_SU_SU_SS_S
U_SS_SS_SU R                  US5      S:H  _SU_SU(       a  SOS_U(       a  SOSU(       a  SOS SSSSU R                  US!5      U R                  US"5      S#.SSS$.U R                  US%5      U R                  US&5      S$.U R                  US'5      U R                  US(5      S$.U R                  US)5      SS$.S*.SUS+.
E5        GM     U$ ),z

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   r:  
baseSymbolquoteSymbolNpairTyper6   	perpetual/r8   z.P :r#  basequotesettlebaseIdquoteIdsettleIdrN  r7   r9   Fr:   rA  rF  rG  contractr   Tr~   minTickPrice
minLotSize)pricerK  r;  minSizemaxSizeminPricemaxPriceminNotional)r   rK  rs  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionTyperD  rE  createdr>  )v1PublicGetPairsrP  rQ  rR  rS  replaceappendrW  )r4  rX  rY  rZ  r[  marketr#  rm  rn  rj  rk  
marketTyper:  re  isSpotisPerpetualrl  ro  s                     r6  fetch_marketsarkham.fetch_markets,  s    ((0h q#h-(A[F!!&(3B%%fl;F&&v}=G**62D++G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" +$4#0$ %05T(.A"&"!--fnE"..v|D  $#!
  $//	B#//	B
  $//
C#//
C
  $//F#$  _0 0/ )P r8  c                 J    U R                  U5      nU R                  USS5      $ )a!  
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r4  rX  rY  s      r6  
fetch_timearkham.fetch_time  s+     --f5 ((<GGr8  Nr:  r   c           	      4   U R                  5         U R                  U5      nSUS   0nUb  X%S'   U R                  U R                  XS5      5      nU R	                  USS5      nU R                  US5      nU R                  X`R                  X5      USSSS	5      $ )
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
r:  r#  r   lastTimer  bidsasksrs  size)load_marketsr  v1PublicGetBookextendr  rR  parse_order_booksafe_symbol)	r4  r:  r   rX  r  requestrY  	timestampmarketIds	            r6  fetch_order_bookarkham.fetch_order_book  s     	V$fTl
 $G''G(DE< --h
EJ	##Hh7$$X/?/?/QS\^dflnuw}~~r8  rl   sincec           	         SnU R                  5         SnU R                  USSS5      u  puU(       a  U R                  SXXBXV5      $ U R                  U5      nUS   U R	                  U R
                  X"5      S.n	U R                  U5      S-  n
U R                  US5      nU R                  US/5      nUb  [        XF5      OUnUb  X9S	'   U R                  X<U
-  5      U	S
'   O'U R                  5       nUb  UOUU	S
'   U	S
   X-  -
  U	S	'   U	S	   S-  U	S	'   U	S
   S-  U	S
'   U R                  U R                  X5      5      nU R                  XX#U5      $ )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   FrY   paginater#  )r:  duration  untilstartend)r  handle_option_and_params"fetch_paginated_call_deterministicr  rR  r+  parse_timeframesafe_integeromitr<  summillisecondsv1PublicGetCandlesr  parse_ohlcvs)r4  r:  	timeframer  r   rX  maxLimitr  r  r  
durationMsr  selectedLimitnowrY  s                  r6  fetch_ohlcvarkham.fetch_ohlcv  s{    88z[`a::<X]jp{{V$Tl(()O
 )))4t;
!!&'26G9-161BE,$G!XXeZ-GHGEN##%C','8UsGEN&u~0JJGG"7+d2 $.**4;;w+GH"   9UKKr8  r  c           	          U R                  USS5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )Ntimer  openhighlowclosevolume)r  rW  )r4  ohlcvr  s      r6  parse_ohlcvarkham.parse_ohlcv4  sp     %%eVU;UF+UF+UE*UG,UH-
 	
r8  symbolsc                 F    U R                  U5      nU R                  X15      $ N)v1PublicGetTickersparse_tickersr4  r  rX  rY  s       r6  fetch_tickersarkham.fetch_tickersK  s%    **624 !!(44r8  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  XS5      $ )ah  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
r:  r#  )r  r  v1PublicGetTickerr  parse_ticker)r4  r:  rX  r  r  rY  s         r6  fetch_tickerarkham.fetch_tickerh  s\     	V$fTl
 ))$++g*FG0   22r8  r   c                 V   U R                  US5      nU R                  X25      nU R                  0 SU_SU R                  X25      _SU R	                  US5      _SU R	                  US5      _SU R	                  US5      _SU R	                  US	5      _S
U R	                  US5      _SU R	                  US5      _SU R	                  US5      _SU R	                  US5      _SU R	                  US5      _SU R	                  US5      _SU R	                  US5      _SS _SS _SS _SS _SS 0E5      $ )Nr:  r>  r  high24hr  low24hbidr   rs  r  price24hAgochangepriceChange
percentagepriceChangePercent
baseVolume	volume24hquoteVolumeusdVolume24h	markPrice
indexPricevwapaveragepreviousClose	askVolume	bidVolume)rR  safe_marketsafe_tickerr  rW  )r4  r   r  r  s       r6  r  arkham.parse_ticker  s   ##FH5!!(3 !
F!
d&&x8!
 D$$VY7!
 4##FH5	!

 4##FE2!
 D$$VW5!
 D$$V];!
 d&&v}=!
 $**63GH!
 $**6;?!
 4++FNC!
 ))&+>!
 $**6<@!
 D!
 t!
  T!!
" #!
$ %!
  	r8  c                     U R                  5         U R                  U5      nUS   nSU0nUb  X7S'   U R                  U R                  Xt5      5      nU R	                  XX#5      $ )aX  
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#  r:  r   )r  r  v1PublicGetTradesr  parse_trades)	r4  r:  r  r   rX  r  r  r  rY  s	            r6  fetch_tradesarkham.fetch_trades  sq     	V$$<h
 $G))$++g*FG   5@@r8  tradec                    U R                  US5      nU R                  X25      nU R                  USS5      nU R                  US5      nU R                  US5      nS nUb	  UUS   S.nOUb  USS.nU R	                  UU R                  US	5      UU R                  U5      US   S U R                  US
S5      S U R                  US5      U R                  US5      S UU R                  US5      S.U5      $ )Nr:  r  r  quoteFeearkmFeerk  ry  r\  ARKM
revisionIduserSide	takerSiders  r  orderId)r>  r#  r  datetimer:  rN  sidetakerOrMakerrs  rK  ry  rC  order)rR  r  r  rW  
safe_tradeiso8601safe_string_2)r4  r  r  r  r  r  r  rC  s           r6  parse_tradearkham.parse_trade  s$   : ##E84!!(3--eVUC	##E:6""5)4 "7OC  "C ""5,7"Y/X&&&uj+F %%eW5&&uf5%%eY7 
  	r8  r#  c                 ~    S[        U5      0nU R                  U R                  XC5      5      nU R                  U5      $ )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)r4  r#  r:  rX  r  rY  s         r6  fetch_orderarkham.fetch_order	  sC     #b'
 ,,T[[-IJB ))r8  c                     U R                  5         0 nSnUb  U R                  U5      nUS   US'   Ub  X5S'   U R                  U R                  XT5      5      nU R	                  XvX#5      $ )a,  
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#  r:  r   )r  r  v1PrivateGetOrdersHistoryr  parse_orders)r4  r:  r  r   rX  r  r  rY  s           r6  fetch_closed_ordersarkham.fetch_closed_orders;  sy     	[[(F &tGH$G11$++g2NOF   5@@r8  c                 R   U R                  5         SnUb  U R                  U5      nU R                  US5      nU R                  US5      nSnU(       a"  U R	                  U R                  0 U5      5      nO!U R                  U R                  0 U5      5      nU R                  XuX#5      $ )a  
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  )r4  r:  r  r   rX  r  isTriggerOrderrY  s           r6  fetch_open_ordersarkham.fetch_open_ordersu  s     	[[(F	:69-55dkk"f6MNH. ..t{{2v/FGHF   5@@r8  c                    U R                  US5      nU R                  US5      nSn0 nU R                  US5      nUb  U R                  US5      nXvS'   O$U(       a  [        U5      US'   O[        U5      US'   U(       aU  Uc  [	        U R
                  S-   5      eU R                  U5      nUS   US'   U R                  U R                  Xc5      5      nO U R                  U R                  Xc5      5      nU R                  U5      $ )	a?  
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#  r:  )r
  r  r  r  r!   r#  r   v1PrivatePostTriggerOrdersCancelr  v1PrivatePostOrdersCancelr  )	r4  r#  r:  rX  r  rY  r  r  r  s	            r6  cancel_orderarkham.cancel_order  s     	:69-))&/B$YYv7F'4O$,/G()%(W	"~'2p(pqq[[(F &tGH<<T[[=YZH55dkk'6RSH ))r8  c                     Ub  [        U R                  S-   5      eU R                  US5      nU R                  US5      nSnU(       a  U R	                  U5      nOU R                  U5      nU R                  US5      $ )a'  
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  )r4  r:  rX  r  rY  s        r6  cancel_all_ordersarkham.cancel_all_orders  s     TWW  (O  O  P  P	:69-??GH88@H   400r8  rN  r  rK  rs  c                    U R                  5         U R                  U5      nU R                  U/ SQ5      SLnU R                  XX4XV5      n	Sn
U(       a  U R	                  U	5      n
OU R                  U	5      n
U R                  X5      $ )aX  
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  )r4  r:  rN  r  rK  rs  rX  r  r  r  rY  s              r6  create_orderarkham.create_order  s    , 	V$++F4hiquu++F$V99'BH 227;H 11r8  c                    U R                  U5      nUS   nUS   UU R                  X5      S.nUS:H  n	U R                  US5      n
U R                  US5      nU R                  U/ SQ5      nUb  U R	                  X5      US'   U
b  U	(       a  S	OS
US'   OkUb  U	(       a  S
OS	US'   OYU R                  US5      nUc  [        U R                  S-   5      eUb)  US:X  a  U	(       a  S	OS
US'   OUS:X  a  U	(       a  S
OS	US'   U R                  US5      c  SUS'   US:H  nUS:H  nU R                  U/ SQ5      nU R                  USU5      nU R                  US5      nU R                  U/ SQ5      nU(       a  SUS'   U(       d  U(       a2  U R	                  X5      US'   US:X  a  SUS'   OUS:X  a  SUS'   OS US'   OU(       a  SUS'   U R                  X5      $ )!Nr:  r#  )r:  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.  rs  r   r,  rN  r   r-  r+  )r  amount_to_precisionrW  safe_string_nprice_to_precisionrR  r!   r#  in_arrayis_post_onlyr  r  )r4  r:  rN  r  rK  rs  rX  r  r  isBuyr   r   triggerPriceAnyr   isMarketOrderisLimitOrderisLimitExchangeSpecificr.  r   s                      r6  r  arkham.create_order_request;  s   V$!Tl,,V<

 ((A**63DE,,V5ij&&*&=&=f&VGN#(7<,& ,9>J&#'#3#3F<N#O #++DGG  7q  -q  r  r#/';6?D,.)\9AFJ.(:;C.4*+)"&--6Z"[$$]E6B&&v}=6  $G  H"&GJ2#66vEGGe#",%",",&GFO{{7++r8  r  c                 (   U R                  US5      nU R                  X25      nU R                  US5      nU R                  US5      nU(       a  SOU R                  U5      nU(       a  SOU R	                  U5      nU R                  US5      nU R                  US5      n	/ n
Ub$  U
R                  UU R                  US5      S	.5        U	b  U
R                  U	S
S	.5        U R                  USS5      nU R                  0 SU R                  USS5      _SU R                  US5      _SU_SU R                  U5      _SS _SU R                  USS5      _SU R                  U R                  US5      5      _SUS   _SU_SU_SS _SU R                  US5      _SU R                  US5      _SS _SU R                  US5      _SU R                  US5      _SU R                  US 5      _U R                  US!5      S S U
U R                  US"5      US#.EU5      $ )$Nr:  r.  rN  r   r   quoteFeePaidarkmFeePaidrk  r  r  r  r  r#  r  r  r  r  r  lastTradeTimeStamplastUpdateTimestampr  rF  r   r  rs  r   ry  executedNotionalr  avgPricerK  r  rh  
reduceOnly)filled	remainingr   r{   rA  r>  )rR  r  r
  parse_order_typeparse_time_in_forcer  r  
safe_orderr  r  parse_order_statusrW  safe_number_omit_zero)r4  r  r  r  
isPostOnlytypeRaw	orderTyper   r;  r<  r{   r  s               r6  r  arkham.parse_ordero  s   ` ##E84!!(3^^E:6
""5&1)Gt/D/DW/M	(dd.F.Fw.O''~>&&um<#KK$ ,,VW=  "KK#"  --eVUC	  
$$$UI7GH 
T--e_E 
  
 Y/	 

 !$ 
 "4#<#<UJPU#V 
 d--d.>.>uh.OP 
 fX& 
 I 
 ; 
  
 D$$UF3 
 T%%eW5 
 D 
 D$$U,>? 
  t11%D! 
" d&&uf5# 
$ &&ub1..=/ 
0 1 	r8  c                 4    SSSSS.nU R                  X!U5      $ )Nr   r  r+  r,  r-  r  safe_string_upperr4  rN  typess      r6  rD  arkham.parse_order_type  s*    	
 %%e488r8  c                 4    SSSSS.nU R                  X!U5      $ )NGTCr   r   rN  rO  rQ  s      r6  rE  arkham.parse_time_in_force  s*    	
 %%e488r8  rF  c                 :    SSSSSSSS.nU R                  X!U5      $ )Npendingr  closedcanceled)newstagedbookedtakermaker	cancelledrY  rR  )r4  rF  statusess      r6  rG  arkham.parse_order_status  s3    #
 &99r8  c                    U R                  5         0 nUb  X5S'   SnUb	  US-  US'   OU R                  5       U-
  S-  US'   U R                  US5      nUb  U R                  US5      nUS-  US'   OU R	                  US   US-  5      US'   U R                  SXT5      u  pTU R                  U R                  XT5      5      nU R                  USX#5      $ )a)  
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  )	r4  r:  r  r   rX  r  defaultRanger  rY  s	            r6  fetch_my_tradesarkham.fetch_my_trades  s     	$G*#dlGFO#002\ATIGFO!!&'2YYvw/F!DLGDM HHWV_lT6IJGDM227GL..t{{7/KL$   4>>r8  c                     U R                  5         0 nSnU R                  USS5      u  p1Ub  X2S'   U R                  U R                  X!5      5      nU R	                  US/ 5      nU R                  XQ5      $ )a   
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
NrB   	accountIdsubAccountIdr   )r  r  v1PrivateGetUserr  rT  parse_accounts)r4  rX  r  rm  rY  subAccountss         r6  fetch_accountsarkham.fetch_accounts>  s     		 99&/S^_	 &/N#((W)EFV nnX}bA"";77r8  c                 0    U R                  US5      S S US.$ )Nr#  )r#  rN  rM  r>  ra  )r4  accounts     r6  parse_accountarkham.parse_account{  s'     ""7D1	
 	
r8  c                 f    U R                  5         U R                  U5      nU R                  U5      $ )z
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      r6  fetch_balancearkham.fetch_balance  s3     	33F;> !!(++r8  c                 v   U R                  USS5      nUUU R                  U5      S.n[        S[        U5      5       Hh  nX   nU R	                  US5      nU R                  U5      nU R                  5       nU R	                  US5      US'   U R	                  US5      US'   XU'   Mj     U R                  U5      $ )	NlastUpdateTimer  )r>  r  r  r   r:  balancetotalfree)r  r  rP  rQ  rR  rS  ru  safe_balance)	r4  rY  r  rZ  r[  r  r:  rM  ru  s	            r6  rz  arkham.parse_balance  s    --h8H%P	"Y/

 q#h-(AkG%%gx8F**62DllnG#//CGG"..w?GFO"4L )   ((r8  rM  c                 .   U R                  5         SnU R                  U5      u  p2Uc  [        U R                  S-   5      eSU0nU R	                  U R                  XB5      5      nU R                  US5      nU R                  X`R                  U5      5      $ )aP  
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  rR  parse_deposit_addressr\  )r4  rM  rX  networkCoder  rY  addresss          r6  create_deposit_addressarkham.create_deposit_address  s     	"AA&I#DGG.b$bcc[
 ??G@\] ""8[9))'==3FGGr8  c                 \   U R                  5         SnU R                  U5      u  p2Uc  [        U R                  S-   5      eSU R	                  U5      0nU R                  U R                  XB5      5      nU R                  US5      nU R                  USSSU05      nU R                  US5      $ )al  
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^  r  Fr?  )
r  r  r!   r#  network_code_to_id#v1PrivateGetAccountDepositAddressesr  rT  parse_deposit_addressesindex_by)r4  rM  rX  r  r  rY  dataparseds           r6  "fetch_deposit_addresses_by_network)arkham.fetch_deposit_addresses_by_network  s     	"AA&I#DGG.l$lmmT,,[9
 ;;DKK<XY ~~h4--dD%)[AYZ}}VY//r8  r\  c                 2    UU R                  US5      S US S.$ )NrM  )r>  r\  r?  r  tagra  )r4  entryr\  s      r6  r  arkham.parse_deposit_address  s*    
 ((6:
 	
r8  c                    U R                  5         U R                  U5      nU R                  U5      nUS   nU R                  X5      nU R	                  US   XV5      nU R                  Xg5      nUc  [        U R                  S-   U-   5      eU$ )aG  
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   rM  z< fetchDepositAddress() could not find a deposit address for )r  r\  r  r  )select_network_code_from_unified_networks	safe_dictr&   r#  )	r4  rM  rX  r\  networkCodeAndParamsr  indexedAddressesselectedNetworkCoder  s	            r6  fetch_deposit_addressarkham.fetch_deposit_address  s     	==&#BB6J*1-BB4P"LLXV\M]_j}..!1G? +i!ilp!pqqr8  c                     U R                  5         0 nUb  X5S'   U R                  U R                  XT5      5      nSnUb  U R                  U5      nU R	                  XgX#5      $ )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  r\  parse_transactions)r4  rM  r  r   rX  r  rY  r\  s           r6  fetch_depositsarkham.fetch_deposits$  sj     	$G33DKK4PQ  }}T*H&&x5HHr8  transactionc                    U R                  US5      nU R                  USS5      nU R                  US5      nS nU(       a  SnU R                  US5      nU R                  Xr5      n0 SU_SU R                  US5      _S	U R                  US
5      _SS _SU_SU R	                  U R                  US5      5      _SU R                  US5      _SU_SU_SU R                  U5      _SU_SS _SU_SS _SS _SS _SS _S S SS.E$ )NdepositAddressr  r  	confirmedokr:  r>  r#  txidtransactionHashrN  r\  r?  r^  rK  rF  r  r  r  addressFrom	addressTor  tagFromtagToupdatedF)commentrC  internal)rR  r  r
  rS  rU  rW  r  )	r4  r  r\  r  r  confirmdrF  
currencyIdrM  s	            r6  parse_transactionarkham.parse_transactionI  s    "";0@A--k65I	>>+{;F%%k8<
&&z<
K
$"";5
 D$$[2CD
 D	

 
 t..t/?/?W/UV
 d&&{H=
 f
 
 Y/
 w
 4
 
 4
 t
  T!
" t#
$ )
 	
r8  c                 
   U R                  5         U R                  U5      n[        U R                  R	                  5       5      n0 nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n[        S[        U5      5       H[  n	X9   n
U R                  U
   nUU
S.XJ'   US   (       a  XTU
   S'   XdU
   S	'   M7  US
   (       d  US   (       d  MM  XtU
   S'   XU
   S	'   M]     U$ )aL  
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>  r:  r6   r_  r^  r8   r9   )r  v1PrivateGetAccountFeeslistmarketskeysrW  rP  rQ  )r4  rX  rY  r  rZ  	spotMaker	spotTaker	perpMaker	perpTakerr[  r:  r  s               r6  fetch_trading_feesarkham.fetch_trading_feesv  s    	//7 t||((*+$$X~>	$$X~>	$$X~>	$$X~>	q#g,'AZF\\&)F  FN f~*3vw'*3vw'6(#3#3*3vw'*3vw' ( r8  c                     U R                  5         SnUb  U R                  U5      n0 nUb  X6S'   U R                  U R                  Xd5      5      nU R	                  XuX#5      $ )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)r4  r:  r  r   rX  r  r  rY  s           r6  fetch_funding_historyarkham.fetch_funding_history  sj     	[[(F$G>>t{{7?[\  !!(EAAr8  c           
         U R                  US5      nU R                  US5      nU R                  USS5      nUU R                  X25      U R                  U5      UU R	                  U5      U R                  US5      U R                  US5      S.$ )N
pairSymbolassetSymbolr  r  r#  rK  )r>  r:  rM  r  r  r#  rK  )rR  r  r  rS  r  rW  )r4  incomer  r  r  r  s         r6  parse_incomearkham.parse_income  s     ##FL9%%fm<
--ffeD	&&x8++J7"Y/""640&&vx8
 	
r8  c                    U R                  5         U R                  U5      nU R                  US5      nSU0nU R                  U R	                  XR5      5      nU R                  US5      nU R                  Xt0 5      nU R                  X5      $ )a  
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#  r:  )r  r  rR  v1PrivateGetAccountLeverager  r  r  parse_leverage)	r4  r:  rX  r  r  r  rY  indexedr  s	            r6  fetch_leveragearkham.fetch_leverage  s     	V$##FD1h
 33DKK4PQ --(3~~g4""400r8  r   c                 x    U R                  US5      nU R                  US5      nUU R                  X25      S UUS.$ )Nr:  r   )r>  r:  r   longLeverageshortLeverage)rR  rW  r  )r4  r   r  r  leverageNums        r6  r  arkham.parse_leverage  sL     ##Hh7&&x<&&x8'(
 	
r8  c                 ,   Uc  [        U R                  S-   5      eU R                  5         U R                  U5      nU R	                  U5      nU R                  US5      nUUS.nU R                  U R                  Xs5      5      nU R                  X5      $ )a"  
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
z) setLeverage() requires a symbol argumentr#  )r:  r   )	r!   r#  r  r  number_to_stringrR  v1PrivatePostAccountLeverager  r  )	r4  r   r:  rX  r  leverageStringr  r  rY  s	            r6  set_leveragearkham.set_leverage  s     >#DGG.Y$YZZV$..x8##FD1&
 44T[[5QR ""844r8  c                     U R                  5         U R                  U5      nU R                  U5      nU R                  X15      $ )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       r6  fetch_positionsarkham.fetch_positions.  sC     	%%g.44V<6 ##H66r8  positionc                    U R                  US5      n[        R                  " U5      n[        R                  " US5      nU(       a  SOSnU R                  US5      nU R                  US5      nU R	                  0 SU_SS _SU R                  Xr5      _S	U R                  [        R                  " U5      5      _S
S _SS _SU R                  US5      _SU R                  US5      _SS _SS _SU R                  U5      _SS _SU R                  US5      _SS _SU_SS _SS _S U R                  US5      U R                  US5      S S U R                  US5      S S S S S S.E5      $ )Nrj  0longshortr:  valuer>  r#  notionalr   liquidationPrice
entryPriceaverageEntryPriceunrealizedPnlpnlrealizedPnlr  r   rz  r  	lastPricer  r   r  r~  maintenanceMargininitialMargin)r  r>  r  maintenanceMarginPercentage
collateralr  initialMarginPercentager   marginRatior   r   )	rR  r,   
string_abs	string_gesafe_positionr  parse_numberrW  r  )	r4  r  r  rj  baseAbsisLongr  r  r  s	            r6  parse_positionarkham.parse_positionX  s   2 &1$$T*""4-vW##Hh7##Hg6!! #
H#
$#
 d&&x8#
 ))'*<*<X*FG	#

 $#
 #
 $**85HI#
 T--h>#
 4#
 $#
 **73#
 D#
 ))(K@#
 #
 D#
  d!#
" ##
$ #'#4#4X?O#P!%!1!1(<O!P+/!--hH'+!#9#
  	r8  r  r  c                    U R                  XE5      u  pEU R                  5         U R                  5       nU R                  U5      nUS   U R	                  X5      U R                  USS5      S.nSn	U R                  U5      u  pU	c  [        U R                  S-   5      eU R                  US5      n
X:;  a  [        U R                  S-   5      eX   nSn[        S[        U5      5       H  nX   nUS	   U	:X  d  M  Un  O   Uc!  [        U R                  S
-   U-   S-   U	-   5      eU R                  US5      US'   U R                  U R                  X5      5      nUR                  SS5      nSU0nU R!                  UU5      $ )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#  rn  r   )r:  rK  subaccountIdNz& withdraw() requires a "network" paramr  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
rh  )handle_withdraw_tag_and_paramsr  &v1PrivateGetAccountWithdrawalAddressesr\  currency_to_precisionr  r  r!   r#  group_byr&   rP  rQ  v1PrivatePostAccountWithdrawr  r  r  )r4  rM  rK  r  r  rX  withdrawalAddressesr\  r  r  indexedListwithdrawalObjectsfoundWithdrawalObjectr[  withdrawalObjectrY  responseStringr  s                     r6  rk   arkham.withdraw  s    99#F"IIK ==&tn00> --fnaH

 "AA&I#DGG.V$VWWmm$7C&   ,I  "I  J  J'0 $q#/01A03(K7(8%	 2
 !( +i!ils!s  wG  "G  JU  "U  V  V#001FM44T[[5QR "))$3n%%%dH55r8  c                     U R                  5         Uc  [        U R                  S-   5      eU R                  U5      nU R	                  U5      nU R                  X15      $ )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
z1 fetchLeverageTiers() requires a symbols argument)r  r!   r#  r  v1PublicGetMarginSchedulesparse_leverage_tiersr  s       r6  fetch_leverage_tiersarkham.fetch_leverage_tiers  s]     	?#DGG.a$abb%%g.226:< ((;;r8  rY  c                    U R                  US5      nU R                  U5      n0 n[        S[        U5      5       H  nX&   nU R	                  U5      nU R                  US   S5      n	U	c  [        U R                  S-   U-   5      eU R                  XI0 5      n
U R                  U
S/ 5      nU R                  X5      XW'   M     U$ )Nr$  r   r>  marginSchedulez8 fetchLeverageTiers() could not find marginSchedule for bands)r  r  rP  rQ  r  rR  r#   r#  r  rT  parse_market_leverage_tiers)r4  rY  r  marketIdKeyr  tiersr[  r:  r  r  selectedDictr  s               r6  r  arkham.parse_leverage_tiers	  s    --&1%%g.q#g,'AZF[[(F!--fVn>NON%*d dgm mnn>>'2FLNN<"=E <<UKEM ( r8  c                    / nUnSn[        S[        U5      5       H  nXF   nU R                  US5      nU R                  XS S5      nU R	                  US5      n	UR                  U R                  US5      U R                  XS S5      US   (       a  US   OUS   UU	U R	                  US	5      U R                  US
5      US.5        U	nM     U$ )Nr   r  r8   positionLimitr~   r   rj  rk  
marginRateleverageRate)tierr:  r\  rx  maxNotionalmaintenanceMarginRatemaxLeverager>  )	rP  rQ  rR  r  rW  r  r  r  r  )
r4  r>  r  r   bracketsrx  r[  r'  r  r(  s
             r6  r  "arkham.parse_market_leverage_tiers	  s    q#h-(A;D''h7H%%hfEF**4AKLLA**8T6J.4X.>F6NF7O**)-)9)9$)M#00~F	 	 &K )  r8  r  c                     U R                  U R                  S0 5      n[        UR                  5       5      n[	        S[        U5      5       H!  nX4   nU R                  X%5      nXa:X  d  M  Us  $    g )Nr   r   )r  r-  r  r  rP  rQ  r  )r4  r  r+  r  r[  r  durationInMicrosecondss          r6  find_timeframe_by_duration!arkham.find_timeframe_by_duration)	  sh    ^^DLL2FK
JOO%&q#d)$AI%)%6%6z%M"%1  	 %
 r8  r   GETc                 r   U R                  US5      nU R                  US5      nUS:X  a  US-   OSn	U R                  X@R                  U5      5      n
U R                  X5      nU R                  S   U   S-   U	-   U-   nSnUS:X  a   U
(       a  U R                  U
5      nUSU-   -  nUS	:X  Ga  U R                  5         U R                  5       U R                  U R                  S
S5      -   S-  nUS:X  a  U R                  U5      nUS:w  a  US-   U-   nUb  UOSnU R                  [        U5      -   UR                  5       -   S-   U-   U-   nU R                  U R                  5      nU R!                  U R#                  U5      U[$        R&                  S5      nSSU R                  [        U5      USS.nXXeS.$ )Nr   r~   r   rg  rh  rw   r1  ?r   r   r   r  POSTbase64zapplication/json1001)zContent-TypeAcceptzArkham-Api-KeyzArkham-ExpireszArkham-SignaturezArkham-Broker-Id)rt   methodbodyheaders)rR  r  extract_paramsimplode_paramsr,  	urlencodecheck_required_credentialsr  r  r-  jsonapiKeystrupperbase64_to_binarysecrethmacencodehashlibsha256)r4  pathrw   r8  rX  r:  r9  rN  access
accessPartqueryrt   queryStringexpiresbodyStrpayloaddecodedSecret	signatures                     r6  signarkham.sign4	  s   Q'!!#q)&,&8Vc\r
		&"5"5d";<""40iit$s*Z7$>U?"nnU3s[((Y++-((*T->->t||M`bf-ggkooGyy(b czK/#/dbGkkCL06<<>ACG$NQXXG 11$++>M		$++g"6w~~W_`I 2,"&++"%g,$-$*G dOOr8  reasonrt   r8  r:  r9  c
                 f   U R                  US5      n
U
b  U R                  US5      nU R                  S-   U-   nU R                  U R                  S   X5        U R                  U R                  S   X5        U R	                  U R                  S   X5        [        U R                  S-   U-   5      eg )Nmessager#   r!  r"  )rR  r#  throw_exactly_matched_exceptionr0  throw_broadly_matched_exceptionr   )r4  rM  rU  rt   r8  r:  r9  rY  requestHeadersrequestBodyrW  	errorCodefeedbacks                r6  handle_errorsarkham.handle_errorsU	  s     ""8Y7((48Iww}t+H001I9_001I7]001I7]# 455r8   r  )NN)U__name__
__module____qualname____firstlineno__r   r3  r   r`  r   r   r  r  rA  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  rD  rE  rG  rj  r   rr  rv  r   r{  rz  r
   r  r  r	   r  r  r   r  r  r   r  r  r  r   r  r  r  r  r   r  r  rk   r   r  r  r   r  r/  rS  r_  __static_attributes____classcell__)r5  s   @r6  r.   r.      s   p# pd ') ZZ Zx $& F$v, FP !# H" :>b 2s 23 2Y 2h 26DW[df 9L# 9Lc 9LQT 9Lkoptku 9Lv
 
4 
. 04B 5W 57 5: 02 $33 $3f $3L4  6 0 6:UW $A3 $As $A# $A\`af\g $AL; ;v ; ;z 26b 0*c 0*3 0*d 154VZce 8A# 8AS 8APS 8Ajnotju 8At /3TXac OA OA3 OAc OAhlmrhs OAb 37r #*s #*C #*J /32 1 10 gksu 623 62i 62y 62RW 62`c 62p os{} 2,3 2,i 2,y 2,Z_ 2,hk 2,h| |v | ||9S 9S 99 9 9
: 
: -1tRV_a 1?c 1? 1?C 1?f %' ;84= ;8z
& $& ),( ),V) )" 8: H3 Hn H6 DF 0s 0$~J^ 0<

X 

 

 79 # ^ * *.Dt\^ #I3 #Ic #I #Icghsct #IJ+
T +
X +
Q\ +
Z )+ '{ 'R 37TX\eg $BC $Bs $BRU $BL
6 
4 24 !1S !1 !1F
t 
V 
x 
" 9=R 5S 5# 56 26b (7w (7T(^ (7T<t <V <| KOWY =6S =6% =6# =6C =6^i =6~ 7;2 ,<G ,<- ,<\S 49 bo   $|J\ ,	3 	3 	 &eBSW PB# s  c TX `c  r8  r.   )3ccxt.base.exchanger   ccxt.abstract.arkhamr   rG  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.   ra  r8  r6  <module>rq     sz    ( ,  D  D  D  D  D  D  D  * 0 - . ' & . . + ) * , . 4 %K%X{ K%r8  