<jupyter_start><jupyter_text>[🥭 Mango Markets](https://mango.markets/) support is available at: [Docs](https://docs.mango.markets/) | [Discord](https://discord.gg/67jySBhxrg) | [Twitter](https://twitter.com/mangomarkets) | [Github](https://github.com/blockworks-foundation) | [Email](mailto:<EMAIL>)[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/blockworks-foundation/mango-explorer-examples/HEAD?labpath=ShowPerpEventFillsPolling.ipynb) [Run this code](https://mybinder.org/v2/gh/blockworks-foundation/mango-explorer-examples/HEAD?labpath=ShowPerpEventFillsPolling.ipynb) on Binder._🏃‍♀️ To run this notebook press the ⏩ icon in the toolbar above._  🥭 Show Perp Event Fill PollingThis notebook shows how to fetch poll the event queue for a perp market, and list all the new fills for a given account.You may be best using the same account in another window to trade so that there are some fills to show.<jupyter_code>import mango
import time

# Use our hard-coded devnet wallet for DeekipCw5jz7UgQbtUbHQckTYGKXWaPQV4xY93DaiM6h.
# For real-world use you'd load the bytes from the environment or a file.
wallet = mango.Wallet(bytes([67,218,68,118,140,171,228,222,8,29,48,61,255,114,49,226,239,89,151,110,29,136,149,118,97,189,163,8,23,88,246,35,187,241,107,226,47,155,40,162,3,222,98,203,176,230,34,49,45,8,253,77,136,241,34,4,80,227,234,174,103,11,124,146]))

# Create a 'devnet' Context
with mango.ContextBuilder.build(cluster_name="devnet") as context:
    # Mango accounts are per-Group, so we need to load the Group first.
    group = mango.Group.load(context)

    # Get all the Wallet's accounts for that Group
    accounts = mango.Account.load_all_for_owner(context, wallet.address, group)

    # Just pick the first account even if there are multiple accounts
    account = accounts[0]

    # Load the market
    market = mango.market(context, "BTC-PERP")

    # Pick out the event queue address
    event_queue_address = market.event_queue_address

    # Load and parse the initial event queue
    initial = mango.PerpEventQueue.load(context, event_queue_address, market.lot_size_converter)

    # Create the tracker and initialise it with the current state of the event queue.
    tracker = mango.UnseenAccountFillEventTracker(initial, account.address)

    # Now loop - sleep then poll for new fills
    for counter in range(5):
        time.sleep(5)
        updated = mango.PerpEventQueue.load(context, event_queue_address, market.lot_size_converter)
        unseen = tracker.unseen(updated)
        print("New fills:", unseen)

print("Example complete.")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.115003808073115, 'fraction_numerical': 0.06587966488956588, 'mean_word_length': 5.052995391705069, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '409840', 'license': 'MIT', 'n_tokens_mistral': 1013, 'n_tokens_neox': 886, 'n_words': 216, 'path': 'ShowPerpEventFillsPolling.ipynb', 'repo_name': 'blockworks-foundation/mango-explorer-examples', 'size': '2646'}