a
    ›»�jÇ  ã                   @   sD  d Z ddlZej dd¡ ddlZddlZg Zd5dd„Z	ddd	d
ifddi fddi ffD �]ˆ\ZZ
Ze dd¡d Zede› d�ƒ e ee
eedd�¡Zee
 Zes¸ede› d�ƒ qXdd„ Zdd„ eD ƒZe ee
eedd�¡Zee
 Zdd„ eD ƒZeeƒdk�redeeƒ› d�ƒ qXe	e› d �ed! dked! › d"eeƒ› d#�ƒ e	e› d$�eeƒeeƒkeeƒeeƒ › d%e d&d¡› d'�ƒ eee@ ƒZedeeeƒeeƒƒƒZe	e› d(�eed) ke› de› d*eeeA ƒ› d+�ƒ qXed,ƒ ed-ej› d.�ƒ e	d/ejd0k d1ƒ ed2e�sd3nd4e› � ƒ e e�r:dnd¡ dS )6aE  The portfolio listing must return EVERYTHING, not the first page.

On 2026-08-15 the live maker posted 81 then 111 duplicate orders. Root cause:
/portfolio/orders is cursor-paginated and get_open_orders() made a single call,
so with 111 orders resting it reported 55. The duplicate guard compared against
that halved number and could not fire; neither could the "too many resting"
abort, because the count it checked was also half.

Two things fixed it: following the cursor, and asking for 200 per page. The
second one MASKS the first at current caps -- MAX_CONCURRENT_ORDERS is 60, so a
real run never exceeds one page and the cursor code is never exercised. This
test forces a tiny page size so the cursor path actually runs, and checks the
paginated result against the single-page truth.

Read-only. Places nothing, cancels nothing.
é    NzE:\soccer\mainÚ c                 C   s>   t d|rdnd› d| › |r"d| nd› �ƒ |s:t | ¡ d S )Nz  [ÚpassZFAILz] z  r   )ÚprintÚfailsÚappend)ZlabelZcondZextra© r   ú!E:\soccer\main\test_pagination.pyÚcheck   s    ,r	   z/portfolio/ordersZordersZstatusZrestingz/portfolio/positionsZmarket_positionsz/portfolio/fillsZfillsú/é   éÿÿÿÿz=== z ===iô  )Úlimitz  (nothing to page through -- z is empty, skipped)c                 C   s0   dD ]}|   |¡r| |   S qtt|  ¡ ƒƒS )N)Zorder_idZfill_idZticker)ÚgetÚreprÚsortedÚitems)ÚoÚkr   r   r   Úident+   s    
r   c                 C   s   h | ]}t |ƒ’qS r   ©r   ©Ú.0r   r   r   r   Ú	<setcomp>1   ó    r   é   c                 C   s   h | ]}t |ƒ’qS r   r   r   r   r   r   r   4   r   z  (only z> items -- cannot force a second page, boundary checks skipped)z: cursor path actually ranZpagesz pages at limit=7 for z itemsz$: no item returned twice in one walkz raw dupes, Zdedupedz removed by _get_allz+: paginated walk covers the same populationgffffffî?z	 shared (z differ -- live churn)z.
=== the cap that currently hides all this ===z  MAX_CONCURRENT_ORDERS = z, per-page limit = 200zBorder cap stays below the page size, so a real run cannot truncateéÈ   z@raise the cap above 200 and the cursor path becomes load-bearingÚ
z
ALL PASSEDz
FAILURES: )r   ) Ú__doc__ÚsysÚpathÚinsertZkalshi_traderZktZkalshi_makerZkmr   r	   ÚkeyÚparamsÚrsplitÚnamer   Z_get_allÚdictÚtruthZt_itemsr   Zt_idsZpagedZp_itemsZp_idsÚlenr   ZoverlapÚmaxÚminÚrefZMAX_CONCURRENT_ORDERSÚexitr   r   r   r   Ú<module>   s\   
ýÿ
"þ

þþ