Skip to main content
Glama
VaishnaviK23

Trading MCP Server

by VaishnaviK23

simulate_sell

Estimate profit or loss by simulating stock sales with FIFO matching. Enter a stock symbol and share quantity to calculate potential returns.

Instructions

Simulate selling a number of shares of a stock and estimate the profit or loss.

Args: symbol: The stock ticker symbol to simulate the sale for (e.g., TSLA) shares: The number of shares to simulate selling.

Returns: The estimated profit/loss from the simulated sale using FIFO matching, in dollars.

Example: simulate_sell("AAPL", 50) -> 123.45

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
sharesYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'simulate_sell' tool is registered using @mcp.tool() and implements logic to calculate the estimated profit/loss of a stock sale using FIFO matching, based on current holdings derived from a CSV and the live market price.
    @mcp.tool()
    def simulate_sell(symbol: str, shares: int) -> float:
        """Simulate selling a number of shares of a stock and estimate the profit or loss.
    
        Args:
            symbol: The stock ticker symbol to simulate the sale for (e.g., TSLA)
            shares: The number of shares to simulate selling.
    
        Returns:
            The estimated profit/loss from the simulated sale using FIFO matching, in dollars.
    
        Example:
            simulate_sell("AAPL", 50) -> 123.45
        """
        # Build current holdings for this symbol
        holdings = []
        for _, row in df.iterrows():
            if row['symbol'] != symbol:
                continue
            if row['type'] == 'Buy':
                holdings.append((row['shares'], row['price_per_share']))
            else:
                to_sell = row['shares']
                while to_sell > 0 and holdings:
                    qty, price = holdings[0]
                    matched = min(qty, to_sell)
                    if matched == qty:
                        holdings.pop(0)
                    else:
                        holdings[0] = (qty - matched, price)
                    to_sell -= matched
    
        proceeds = 0.0
        sell_price = get_live_price(symbol)
        to_sell = shares
    
        while to_sell > 0 and holdings:
            qty, buy_price = holdings[0]
            matched = min(qty, to_sell)
            proceeds += matched * (sell_price - buy_price)
            if matched == qty:
                holdings.pop(0)
            else:
                holdings[0] = (qty - matched, buy_price)
            to_sell -= matched
    
        return round(proceeds, 2)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It successfully discloses the use of 'FIFO matching' for cost basis calculation and clarifies the return format (dollars). However, it omits operational details like data source (current market price vs. historical), error conditions (insufficient shares), or explicit confirmation that no portfolio modification occurs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Uses a clean docstring format (Args/Returns/Example) with zero wasted words. The example invocation is concrete and illustrative. Information is front-loaded with the core purpose in the first sentence.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 2-parameter tool with simple types and no nested objects, the description is nearly complete. It covers methodology (FIFO), parameters, return values, and provides an example. Minor gap: does not clarify whether the simulation uses real-time market prices or specify handling of fractional shares.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite 0% schema description coverage, the description fully compensates via the Args section. It provides clear semantics for both 'symbol' (with TSLA example) and 'shares', including data types and purpose. This is exemplary compensation for a bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the specific action ('simulate selling'), resource ('shares of a stock'), and outcome ('estimate the profit or loss'). The term 'simulate' effectively distinguishes this from sibling tools like 'realized_gains' (actual historical data) and 'validate_trades' (trade validation).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

While the term 'simulate' implies hypothetical usage, the description lacks explicit guidance on when to use this versus alternatives like 'validate_trades' or 'current_price'. It does not state prerequisites (e.g., needing existing positions) or suggest this is for pre-trade financial impact assessment.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/VaishnaviK23/Trading-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server