+
    i\                        ^ RI Ht ^ RIHt ^ RIHt ^RIHt ^RIH	t	H
t
HtHtHtHtHt ^RIHt ^RIHtHt ^RIHtHtHtHtHtHtHtHtHtHt ]'       d   ^R	I H!t! ^R
I"H#t#  ! R R4      t$R# )    )annotations)TYPE_CHECKING)	urlencode)Order)ActionSide	OrderTypeOrderStatusTimeInForceSelfTradePreventionPositionCountFilter)DataFrameList)normalize_tickernormalize_tickers)

OrderModelBalanceModelPositionModel	FillModelSettlementModelQueuePositionModelOrderGroupModelSubaccountModelSubaccountBalanceModelSubaccountTransferModel)KalshiClient)Marketc                  \   ] tR t^tRtR R ltR R lt]P                  3RRRRR	RR
RRRRRRRRRRRRRRRRR/R R lllt	RR/R R llt
RRRRRRRRRRRRRR/R R lltR R ltR RRRR!RR"RR#RR$^dR%RR&R/R' R( lltR) R* ltRRR!RR+RR$^dR%RR&R/R, R- lltRRR.RR"RR#RR$^dR%RR&R/R/ R0 lltR1 R2 ltR3 R4 ltR5 R6 ltR7RR!R/R8 R9 lltRRR!RR$^dR%RR&R/R: R; lltR< R= ltR> R? ltR@ RA ltRB RC ltRD RE ltRF RG ltRH RI ltRJ RK ltRL RM ltRN RO ltR$^dR%RR&R/RP RQ llt RRt!R# )S	Portfolioz6Authenticated user's portfolio and trading operations.c                    V ^8  d   QhRRRR/# )   clientr   returnNone )formats   "Y/home/wkmabra/.openclaw/workspace/venv/lib/python3.14/site-packages/pykalshi/portfolio.py__annotate__Portfolio.__annotate__   s      |      c                	    Wn         R # N_client)selfr!   s   &&r&   __init__Portfolio.__init__   s    r)   c                   V ^8  d   QhRR/# )r    r"   r   r$   )r%   s   "r&   r'   r(      s     1 1\ 1r)   c                d    V P                   P                  R4      p\        P                  ! V4      # )z+Get portfolio balance. Values are in cents.z/portfolio/balance)r-   getr   model_validate)r.   datas   & r&   get_balancePortfolio.get_balance   s(    || 45**400r)   	yes_priceNno_priceclient_order_idtime_in_force	post_onlyFreduce_onlyexpiration_tsbuy_max_costself_trade_preventionorder_group_id
subaccountcancel_order_on_pausec          $     `    V ^8  d   QhRRRRRRRRR	R
RRRRRRRRRRRRRRRRRRRRRRRRRR/# )r    tickerzstr | Marketactionr   sider   countint
order_typer	   r8   
int | Noner9   r:   
str | Noner;   zTimeInForce | Noner<   boolr=   r>   r?   r@   zSelfTradePrevention | NonerA   rB   rC   zbool | Noner"   r   r$   )r%   s   "r&   r'   r(      s     U* U*U* U* 	U*
 U* U* U* U* $U* *U* U* U* "U* !U*   :!U*" ##U*$ %U*&  +'U*( 
)U*r)   c          
        Ve   Ve   \        R4      hVf%   Vf!   V\        P                  8X  d   \        R4      hVe
   ^dV,
          p\        V\        4      '       d   VP                  4       MVP                  pRVRVP                  RVP                  RVRVP                  /pVe   VVR&   Ve   VVR	&   V	e   V	P                  VR
&   V
'       d   RVR&   V'       d   RVR&   Ve   VVR&   Ve   VVR&   Ve   VP                  VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   V P                  P                  RV4      p\        P                  ! VR,          4      p\        V P                  V4      # )at  Place an order on a market.

Args:
    ticker: Market ticker string or Market object.
    action: BUY or SELL.
    side: YES or NO.
    count: Number of contracts.
    order_type: LIMIT or MARKET.
    yes_price: Price in cents (1-99) for the YES side.
    no_price: Price in cents (1-99) for the NO side.
              Converted to yes_price internally (yes_price = 100 - no_price).
    client_order_id: Idempotency key. Resubmitting returns existing order.
    time_in_force: GTC (default), IOC (immediate-or-cancel), FOK (fill-or-kill).
    post_only: If True, reject order if it would take liquidity. Essential for market makers.
    reduce_only: If True, only reduce existing position, never increase.
    expiration_ts: Unix timestamp when order auto-cancels.
    buy_max_cost: Maximum total cost in cents. Protects against slippage.
    self_trade_prevention: Behavior on self-cross (CANCEL_RESTING or CANCEL_INCOMING).
    order_group_id: Link to an order group for OCO/bracket strategies.
    subaccount: Subaccount number (0 for primary, 1-32 for subaccounts).
    cancel_order_on_pause: If True, cancel order if market is paused.
'Specify yes_price or no_price, not both*Limit orders require yes_price or no_pricerE   rF   rG   rH   typer8   r:   r;   Tr<   r=   r>   r?   self_trade_prevention_typerA   rB   rC   /portfolio/ordersorder)
ValueErrorr	   LIMIT
isinstancestrupperrE   valuer-   postr   r4   r   )r.   rE   rF   rG   rH   rJ   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   
ticker_str
order_dataresponsemodels   &&&&&&$$$$$$$$$$$$    r&   place_orderPortfolio.place_order   s   V  X%9FGG!1jIOO6SIJJhI'1&#'>'>V\\^FMM
 jfllDJJUJ$$

  &/J{#&,;J()$*7*=*=J'&*J{#(,J}%$*7J'#)5J~& ,7L7R7RJ34%+9J'(!'1J|$ ,2GJ./<<$$%8*E))(7*;<T\\5))r)   c               $    V ^8  d   QhRRRRRR/# )r    order_idrX   rB   rK   r"   r   r$   )r%   s   "r&   r'   r(   u   s!     * *S * *u *r)   c                   RV 2pVe   VRV 2,          pV P                   P                  V4      p\        P                  ! VR,          4      p\	        V P                   V4      # )zCancel a resting order.

Args:
    order_id: ID of the order to cancel.
    subaccount: Subaccount number (0 for primary, 1-32 for subaccounts).

Returns:
    The canceled Order with updated status.
/portfolio/orders/z?subaccount=rT   )r-   deleter   r4   r   )r.   rc   rB   endpointr^   r_   s   &&$   r&   cancel_orderPortfolio.cancel_orderu   sa     (z2!,zl33H<<&&x0))(7*;<T\\5))r)   rH   rE   rF   rG   c               <    V ^8  d   QhRRRRRRRRRRRR	R
RRRRR/	# )r    rc   rX   rH   rK   r8   r9   rB   rE   rL   rF   zAction | NonerG   zSide | Noner"   r   r$   )r%   s   "r&   r'   r(      sd     :* :*:* 	:*
 :* :* :* :* :* :* 
:*r)   c          	        Ve   Ve   \        R4      hVe
   ^dV,
          p\        V4      pVe   Ve	   Ve   Vfd   V P                  V4      p	T;'       g    V	P                  pT;'       g    V	P                  pT;'       g    V	P
                  pVf   V	P                  pRTR\        V\        4      '       d   VP                  MTR\        V\        4      '       d   VP                  MTRV/p
Ve   W:R&   Ve   WZR&   RV
9  d   RV
9  d   \        R4      hV P                  P                  R	V R
2V
4      p\        P                  ! VR,          4      p\        V P                  V4      # )a  Amend a resting order's price or count.

Args:
    order_id: ID of the order to amend.
    count: New total contract count.
    yes_price: New YES price in cents.
    no_price: New NO price in cents. Converted to yes_price internally.
    subaccount: Subaccount number (0 for primary, 1-32 for subaccounts).
    ticker: Market ticker (fetched from order if not provided).
    action: Order action (fetched from order if not provided).
    side: Order side (fetched from order if not provided).
rO   rE   rF   rG   rH   r8   rB   z:Must specify at least one of count, yes_price, or no_pricere   z/amendrT   )rU   r   	get_orderrE   rF   rG   remaining_countrW   r   rZ   r   r-   r[   r   r4   r   )r.   rc   rH   r8   r9   rB   rE   rF   rG   originalbodyr^   r_   s   &&$$$$$$$    r&   amend_orderPortfolio.amend_order   sX   2  X%9FGGhI!&) >V^t|u}~~h/H..xF..xF((8==D} 00 fj&@&@fllf*T4"8"8DJJdU	
   )!!+$;d#:YZZ<<$$'9(6%JDQ))(7*;<T\\5))r)   c               $    V ^8  d   QhRRRRRR/# )r    rc   rX   	reduce_byrI   r"   r   r$   )r%   s   "r&   r'   r(      s!     * *s *s *u *r)   c                    V P                   P                  RV R2RV/4      p\        P                  ! VR,          4      p\	        V P                   V4      # )zDecrease the remaining count of a resting order.

Args:
    order_id: ID of the order to decrease.
    reduce_by: Number of contracts to reduce by.
re   z	/decreasers   rT   )r-   r[   r   r4   r   )r.   rc   rs   r^   r_   s   &&&  r&   decrease_orderPortfolio.decrease_order   sS     <<$$ 
)4{I6N
 ))(7*;<T\\5))r)   statusevent_tickermin_tsmax_tslimitcursor	fetch_allc               <    V ^8  d   QhRRRRRRRRRRR	R
RRRRRR/	# )r    rw   zOrderStatus | NonerE   rL   rx   ry   rK   rz   r{   rI   r|   r}   rM   r"   DataFrameList[Order]r$   )r%   s   "r&   r'   r(      sq     &^ &^ #&^ 	&^
 !&^ &^ &^ &^ &^ &^ 
&^r)   c                  a  RTRVe   VP                   MRR\        V4      R\        V4      RVRVRV/V	Cp
S P                  P                  R	R
W4      p\	        V 3R lV 4       4      # )at  Get list of orders.

Args:
    status: Filter by order status (resting, canceled, executed).
    ticker: Filter by market ticker.
    event_ticker: Filter by event ticker (supports comma-separated, max 10).
    min_ts: Filter orders after this Unix timestamp.
    max_ts: Filter orders before this Unix timestamp.
    limit: Maximum results per page (default 100, max 200).
    cursor: Pagination cursor for fetching next page.
    fetch_all: If True, automatically fetch all pages.
    **extra_params: Additional API parameters (e.g., subaccount).
                   See https://docs.kalshi.com/api-reference/orders/get-orders
r{   rw   NrE   rx   ry   rz   r|   rS   ordersc              3  x   <"   T F/  p\        SP                  \        P                  ! V4      4      x  K1  	  R # 5ir+   )r   r-   r   r4   ).0dr.   s   & r&   	<genexpr>'Portfolio.get_orders.<locals>.<genexpr>   s-     ]X\STU4<<1J1J11MNNX\s   7:)rZ   r   r-   paginated_getr   )r.   rw   rE   rx   ry   rz   r{   r|   r}   extra_paramsparamsr5   s   f$$$$$$$$,  r&   
get_ordersPortfolio.get_orders   s}    8 Uf&8flld&v.,\:fff	
 	
 ||))*=x[]X\]]]r)   c                    V ^8  d   QhRRRR/# )r    rc   rX   r"   r   r$   )r%   s   "r&   r'   r(      s     * *# *% *r)   c                    V P                   P                  RV 24      p\        P                  ! VR,          4      p\	        V P                   V4      # )zGet a single order by ID.re   rT   )r-   r3   r   r4   r   )r.   rc   r^   r_   s   &&  r&   rl   Portfolio.get_order   sD    <<##&8
$CD))(7*;<T\\5))r)   count_filterc               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# )r    rE   rL   rx   r   zPositionCountFilter | Noner{   rI   r|   r}   rM   r"   zDataFrameList[PositionModel]r$   )r%   s   "r&   r'   r(      s[     L L L !	L
 1L L L L 
&Lr)   c          
         RTR\        V4      R\        V4      RVe   VP                  MRRV/VCpV P                  P                  RRW4      p	\	        R	 V	 4       4      # )
a  Get portfolio positions.

Args:
    ticker: Filter by specific market ticker.
    event_ticker: Filter by event ticker (supports comma-separated, max 10).
    count_filter: Filter positions with non-zero values (POSITION or TOTAL_TRADED).
    limit: Maximum positions per page (default 100, max 1000).
    cursor: Pagination cursor for fetching next page.
    fetch_all: If True, automatically fetch all pages.
    **extra_params: Additional API parameters (e.g., subaccount).
r{   rE   rx   r   Nr|   z/portfolio/positionsmarket_positionsc              3  N   "   T F  p\         P                  ! V4      x  K  	  R # 5ir+   )r   r4   )r   ps   & r&   r   *Portfolio.get_positions.<locals>.<genexpr>  s     Kd]99!<<d   #%)r   rZ   r-   r   r   )
r.   rE   rx   r   r{   r|   r}   r   r   r5   s
   &$$$$$$,  r&   get_positionsPortfolio.get_positions   sv    . U&v.,\:,2JL..PTf
 
 ||))*@BTV\hKdKKKr)   rc   c               8    V ^8  d   QhRRRRRRRRRRR	RR
RRR/# )r    rE   rL   rc   ry   rK   rz   r{   rI   r|   r}   rM   r"   zDataFrameList[FillModel]r$   )r%   s   "r&   r'   r(     sf     "H "H "H 	"H
 "H "H "H "H "H 
""Hr)   c                   RVR\        V4      RVRVRVRV/VCp	V P                  P                  RRW4      p
\        R	 V
 4       4      # )
a  Get trade fills (executed trades).

Args:
    ticker: Filter by market ticker.
    order_id: Filter by specific order ID.
    min_ts: Minimum timestamp (Unix seconds).
    max_ts: Maximum timestamp (Unix seconds).
    limit: Maximum fills per page (default 100, max 200).
    cursor: Pagination cursor for fetching next page.
    fetch_all: If True, automatically fetch all pages.
    **extra_params: Additional API parameters (e.g., subaccount).
r{   rE   rc   ry   rz   r|   z/portfolio/fillsfillsc              3  N   "   T F  p\         P                  ! V4      x  K  	  R # 5ir+   )r   r4   )r   fs   & r&   r   &Portfolio.get_fills.<locals>.<genexpr>@  s     G$QY55a88$r   r   r-   r   r   )r.   rE   rc   ry   rz   r{   r|   r}   r   r   r5   s   &$$$$$$$,  r&   	get_fillsPortfolio.get_fills  se    2 U&v.fff
 
 ||))*<gvYG$GGGr)   c                    V ^8  d   QhRRRR/# )r    r   z
list[dict]r"   r   r$   )r%   s   "r&   r'   r(   D  s      %  %  %8L  %r)   c           	     N   . pV F  p\        V4      pRV9   d   RV9   d   \        R4      hVP                  RR4      R8X  d   RV9  d   RV9  d   \        R4      hRV9   d   ^dVP                  R4      ,
          VR&   VP	                  V4       K  	  V P
                  P                  RRV/4      p. pVP                  R. 4       FS  pVP                  R	4      pVf   K  VP	                  \        V P
                  \        P                  ! V4      4      4       KU  	  \        V4      # )
a  Place multiple orders atomically.

Args:
    orders: List of order dicts with keys: ticker, action, side, count,
            type, yes_price/no_price, and optional advanced params.

Example:
    orders = [
        {"ticker": "KXBTC", "action": "buy", "side": "yes", "count": 10, "type": "limit", "yes_price": 45},
        {"ticker": "KXBTC", "action": "buy", "side": "no", "count": 10, "type": "limit", "no_price": 45},
    ]
    results = portfolio.batch_place_orders(orders)
r8   r9   rO   rQ   r{   rP   /portfolio/orders/batchedr   rT   )dictrU   r3   popappendr-   r[   r   r   r4   r   )	r.   r   preparedrT   or^   resultitemr]   s	   &&       r&   batch_place_ordersPortfolio.batch_place_ordersD  s    EUAaJ!O !JKKuuVW%0[5Ij`aNa !MNNQ!$quuZ'8!8+OOA  <<$$%@8XBVWLL2.D'*J!MM%j.G.G
.STU	 /
 V$$r)   c                    V ^8  d   QhRRRR/# )r    	order_idsz	list[str]r"   r   r$   )r%   s   "r&   r'   r(   f  s     % %Y %;O %r)   c           	     Z   V Uu. uF  pRV/NK	  	  ppV P                   P                  RRV/4      p. pVP                  R. 4       FS  pVP                  R4      pVf   K  VP                  \	        V P                   \
        P                  ! V4      4      4       KU  	  \        V4      # u upi )zCancel multiple orders atomically.

Args:
    order_ids: List of order IDs to cancel (max 20).

Returns:
    The canceled Orders with updated status.
rc   r   r   rT   )r-   rf   r3   r   r   r   r4   r   )r.   r   oidr   r^   r   r   r]   s   &&      r&   batch_cancel_ordersPortfolio.batch_cancel_ordersf  s     099y:s#y9<<&&'BXvDVWLL2.D'*J!MM%j.G.G
.STU	 /
 V$$ :s   B(c                    V ^8  d   QhRRRR/# )r    rc   rX   r"   r   r$   )r%   s   "r&   r'   r(   {  s     

 

3 

3E 

r)   c                z    V P                   P                  RV R24      p\        VVP                  R^ 4      R7      # )zGet queue position for a single resting order.

Returns 0-indexed position in the queue at the order's price level.
Position 0 means you're first in line to be filled.
re   z/queue_positionqueue_position)rc   r   )r-   r3   r   )r.   rc   r^   s   && r&   get_queue_positionPortfolio.get_queue_position{  sA     <<##&8
/$RS!#<<(8!<
 	
r)   market_tickersc               $    V ^8  d   QhRRRRRR/# )r    r   zlist[str] | Nonerx   rL   r"   z!DataFrameList[QueuePositionModel]r$   )r%   s   "r&   r'   r(     s*     
 
 )
 !	

 
+
r)   c               *   / pV'       d   RP                  \        V4      4      VR&   V'       d   \        V4      VR&   RpV'       d   V R\        V4       2pV P                  P                  V4      p\        R VP                  R. 4       4       4      # )a  Get queue positions for all resting orders.

Queue position represents the number of contracts that need to be
matched before an order receives a partial or full match.

Args:
    market_tickers: Filter by market tickers (optional).
    event_ticker: Filter by event ticker (optional).
,r   rx   z!/portfolio/orders/queue_positions?c              3  N   "   T F  p\         P                  ! V4      x  K  	  R # 5ir+   )r   r4   )r   qps   & r&   r   0Portfolio.get_queue_positions.<locals>.<genexpr>  s%      
9 --b119r   queue_positions)joinr   r   r   r-   r3   r   )r.   r   rx   r   rg   r^   s   &$$   r&   get_queue_positionsPortfolio.get_queue_positions  s     '*xx0A.0Q'RF#$%5l%CF>"6"1Yv%6$78H<<##H- 
ll#4b9
 
 	
r)   c               0    V ^8  d   QhRRRRRRRRRRR	R
/# )r    rE   rL   rx   r{   rI   r|   r}   rM   r"   zDataFrameList[SettlementModel]r$   )r%   s   "r&   r'   r(     sP     N N N !	N
 N N N 
(Nr)   c                   RVR\        V4      R\        V4      RV/VCpV P                  P                  RRWu4      p\        R V 4       4      # )aA  Get settlement records for resolved positions.

Args:
    ticker: Filter by market ticker.
    event_ticker: Filter by event ticker.
    limit: Maximum settlements per page (default 100).
    cursor: Pagination cursor.
    fetch_all: If True, automatically fetch all pages.
    **extra_params: Additional API parameters.
r{   rE   rx   r|   z/portfolio/settlementssettlementsc              3  N   "   T F  p\         P                  ! V4      x  K  	  R # 5ir+   )r   r4   )r   ss   & r&   r   ,Portfolio.get_settlements.<locals>.<genexpr>  s     M1_;;A>>r   r   )	r.   rE   rx   r{   r|   r}   r   r   r5   s	   &$$$$$,  r&   get_settlementsPortfolio.get_settlements  sb    * U&v.,\:f	

 
 ||))*BMSYeMMMMr)   c                   V ^8  d   QhRR/# )r    r"   rI   r$   )r%   s   "r&   r'   r(     s     < < <r)   c                \    V P                   P                  R4      pVP                  R^ 4      # )zGet total value of all resting orders in cents.

NOTE: This endpoint is FCM-only (institutional accounts).
Regular users will get a 403 Forbidden error.
z,/portfolio/summary/total_resting_order_valuetotal_resting_order_value)r-   r3   r.   r^   s   & r&   get_resting_order_value!Portfolio.get_resting_order_value  s+     <<##$RS||7;;r)   c                    V ^8  d   QhRRRR/# )r    contracts_limitrI   r"   r   r$   )r%   s   "r&   r'   r(     s     8 88 
8r)   c                n    RV/pV P                   P                  RV4      p\        P                  ! V4      # )a  Create an order group for rate-limiting contract matches.

Order groups limit total contracts matched across all orders in the group
over a rolling 15-second window. When the limit is hit, all orders in the
group are cancelled.

To add orders to a group, pass `order_group_id` when calling `place_order`.

Args:
    contracts_limit: Maximum contracts that can be matched in a rolling
        15-second window. When hit, all orders in the group are cancelled.

Returns:
    Created OrderGroupModel.
r   z/portfolio/order_groups/create)r-   r[   r   r4   )r.   r   ro   r^   s   &&  r&   create_order_groupPortfolio.create_order_group  s6    & (9<<$$%EtL--h77r)   c                    V ^8  d   QhRRRR/# )r    rA   rX   r"   r   r$   )r%   s   "r&   r'   r(     s     8 8c 8o 8r)   c                r    V P                   P                  RV 24      pWR&   \        P                  ! V4      # )zaGet an order group by ID.

Returns order group details including list of order IDs in the group.
/portfolio/order_groups/id)r-   r3   r   r4   )r.   rA   r^   s   && r&   get_order_groupPortfolio.get_order_group  s9    
 <<##&>~>N$OP'--h77r)   c                    V ^8  d   QhRRRR/# r    rA   rX   r"   r#   r$   )r%   s   "r&   r'   r(     s     R R# R$ Rr)   c                F    V P                   P                  RV R2/ 4       R# )z=Manually trigger an order group, cancelling all orders in it.r   z/triggerNr-   putr.   rA   s   &&r&   trigger_order_groupPortfolio.trigger_order_group  s!    3N3C8LbQr)   c                   V ^8  d   QhRR/# )r    r"   zDataFrameList[OrderGroupModel]r$   )r%   s   "r&   r'   r(     s     
 
"@ 
r)   c                |    V P                   P                  R4      p\        R VP                  R. 4       4       4      # )zList all order groups.z/portfolio/order_groupsc              3  N   "   T F  p\         P                  ! V4      x  K  	  R # 5ir+   )r   r4   )r   ogs   & r&   r   -Portfolio.get_order_groups.<locals>.<genexpr>  s%      
6 **2..6r   order_groupsr-   r3   r   r   s   & r&   get_order_groupsPortfolio.get_order_groups  s<    <<##$=> 
ll>26
 
 	
r)   c                    V ^8  d   QhRRRR/# r   r$   )r%   s   "r&   r'   r(     s     P P P Pr)   c                F    V P                   P                  RV R2/ 4       R# )zReset matched contract counter for an order group.

Use this to re-enable the group after it has been triggered,
allowing orders to continue matching up to the contracts_limit again.
r   z/resetNr   r   s   &&r&   reset_order_groupPortfolio.reset_order_group  s#     	3N3C6JBOr)   c               $    V ^8  d   QhRRRRRR/# )r    rA   rX   r   rI   r"   r#   r$   )r%   s   "r&   r'   r(     s-     R RR R 
	Rr)   c                N    RV/pV P                   P                  RV R2V4       R# )aD  Update the contracts limit for an order group.

If the new limit would immediately trigger the group (because current
matched contracts exceed it), all orders are cancelled and the group
is triggered.

Args:
    order_group_id: ID of the order group.
    contracts_limit: New maximum contracts for 15-second rolling window.
r   r   z/limitNr   )r.   rA   r   ro   s   &&& r&   update_order_group_limit"Portfolio.update_order_group_limit  s-     (93N3C6JDQr)   c                   V ^8  d   QhRR/# )r    r"   r   r$   )r%   s   "r&   r'   r(     s     
T 
T? 
Tr)   c                    V P                   P                  R/ 4      p\        P                  ! VP	                  RV4      4      # )zCreate a new numbered subaccount.

Subaccounts allow strategy isolation - run multiple bots
with separate capital pools under one API key.

Returns:
    Created SubaccountModel with ID and number.
z/portfolio/subaccountsrB   )r-   r[   r   r4   r3   r   s   & r&   create_subaccountPortfolio.create_subaccount  s7     <<$$%=rB--hll<.RSSr)   c               (    V ^8  d   QhRRRRRRRR/# )r    from_subaccount_idrX   to_subaccount_idamountrI   r"   r   r$   )r%   s   "r&   r'   r(   %  s8     Z ZZ Z 	Z
 
!Zr)   c                    RVRVRV/pV P                   P                  RV4      p\        P                  ! VP	                  RV4      4      # )zTransfer funds between subaccounts.

Args:
    from_subaccount_id: Source subaccount ID.
    to_subaccount_id: Destination subaccount ID.
    amount: Amount to transfer in cents.

Returns:
    Transfer record.
r   r   r   z/portfolio/subaccounts/transfertransfer)r-   r[   r   r4   r3   )r.   r   r   r   ro   r^   s   &&&&  r&   transfer_between_subaccounts&Portfolio.transfer_between_subaccounts%  sQ    " !"4 0f

 <<$$%FM&55hll:x6XYYr)   c                   V ^8  d   QhRR/# )r    r"   z%DataFrameList[SubaccountBalanceModel]r$   )r%   s   "r&   r'   r(   =  s     
 
)N 
r)   c                |    V P                   P                  R4      p\        R VP                  R. 4       4       4      # )z!Get balances for all subaccounts.z/portfolio/subaccounts/balancesc              3  N   "   T F  p\         P                  ! V4      x  K  	  R # 5ir+   )r   r4   )r   bs   & r&   r   4Portfolio.get_subaccount_balances.<locals>.<genexpr>@  s%      
1 #11!441r   balancesr   r   s   & r&   get_subaccount_balances!Portfolio.get_subaccount_balances=  s<    <<##$EF 
\\*b1
 
 	
r)   c               (    V ^8  d   QhRRRRRRRR/# )	r    r{   rI   r|   rL   r}   rM   r"   z&DataFrameList[SubaccountTransferModel]r$   )r%   s   "r&   r'   r(   E  s:     V V V 	V
 V 
0Vr)   c               p    RVRV/VCpV P                   P                  RRWS4      p\        R V 4       4      # )a   Get transfer history between subaccounts.

Args:
    limit: Maximum results per page (default 100).
    cursor: Pagination cursor for fetching next page.
    fetch_all: If True, automatically fetch all pages.
    **extra_params: Additional API parameters.
r{   r|   z /portfolio/subaccounts/transfers	transfersc              3  N   "   T F  p\         P                  ! V4      x  K  	  R # 5ir+   )r   r4   )r   ts   & r&   r   5Portfolio.get_subaccount_transfers.<locals>.<genexpr>Y  s!     UPT14CCAFFPTr   )r-   r   r   )r.   r{   r|   r}   r   r   r5   s   &$$$,  r&   get_subaccount_transfers"Portfolio.get_subaccount_transfersE  sF      5(FClC||)).V
 UPTUUUr)   r,   )"__name__
__module____qualname____firstlineno____doc__r/   r6   r	   rV   r`   rh   rp   ru   r   rl   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  __static_attributes__r$   r)   r&   r   r      s   @1 !*U* !%U*  $U* '+U* -1U*  U* "U* %)U* $(U*  =A!U*" &*#U*$ "&%U*& .2'U* U*n*d *":* !	:*
 !%:*  $:* "&:* ":* !%:* !:*x*&^ &*&^ "	&^
 $(&^ "&^ "&^ &^ "&^  &^P*L "L $(	L
 48L L "L  LB"H ""H  $	"H
 ""H ""H "H ""H  "HL %D%*


 ,0
 $(	
BN "N $(	N
 N "N  N<<8.8R
PR(
TZ0
V V "	V
  V Vr)   r   N)%
__future__r   typingr   urllib.parser   r   r   enumsr   r   r	   r
   r   r   r   	dataframer   _utilsr   r   modelsr   r   r   r   r   r   r   r   r   r   r!   r   marketsr   r   r$   r)   r&   <module>r!     sH    "   "  n n n $ 7   $F	V F	Vr)   