Indian stock market • Open source
GTT Trigger Price Calculator
Enter a stock's current price to prepare candidate buy and sell trigger prices before placing a GTT order with your broker.
This page answers:How do you turn error-prone order preparation into a transparent calculation without crossing into trade execution?
Problem
Preparing a Good Till Triggered order requires consistent trigger-distance, rounding, amount, and share calculations before values are entered with a broker.
Challenge
The rules must remain understandable and reviewable, yet broker policies can change. The tool also has to coordinate related inputs without implying that a calculated value is current market data or an executable order.
My Contribution
I built the calculation logic and Streamlit interaction that validate price input, apply visible distance and rounding rules, and synchronize investment amount with share count while keeping brokerage access outside the system.
Architecture
- Visitor inputCurrent price, rounding multiple, amount, or share count
- Streamlit applicationValidation, calculation, rounding, and synchronized fields
- Broker remains separateNo credentials, live prices, account access, or trade execution
Prepare candidate GTT values
Inputs become reviewable values without crossing into a brokerage account.
- InputCurrent pricePositive numeric value
- RuleDistance bufferThreshold-based adjustment
- RulePrice roundingSelected multiple
- StateAmount or sharesSynchronized calculation
- ReviewCandidate valuesVisitor verifies before use
Execution boundaryThe calculator prepares values only; it does not place orders or confirm current broker rules.
Current implementation
- Accepts a positive current stock price and a configurable rounding multiple.
- For prices at or above ₹50, the code applies a 0.256% distance buffer; below ₹50, it applies ₹0.09.
- Rounds candidate buy and sell triggers to the selected multiple, with ₹0.05 as the interface default.
- Uses Streamlit session state and callbacks to calculate share count from amount, or amount from share count.
- Rejects non-numeric and non-positive price input with visible feedback.
Engineering Decisions
Keep the pricing rule visible
I kept thresholds, distance calculations, and rounding in a short inspectable function rather than hiding them behind a service. A user can review how candidate values are produced before relying on them. The trade-off is that hard-coded rules can become stale and require explicit verification.
Separate calculation from trading
I chose not to connect the utility to a brokerage account, live market feed, or order-placement API. This avoids credentials and keeps the tool within the narrower responsibility of preparing values for human review. It sacrifices convenience, but materially reduces security, compliance, and execution risk.
Synchronize amount and share inputs conservatively
I allowed either amount or share count to drive the other value because both are natural starting points for the user. The interface tracks the latest input and uses floor operations so the derived value does not imply unavailable precision. This state coordination adds complexity, but prevents two editable fields from silently disagreeing.
Outcome
Trigger distance, rounding, amount, and share calculations were separate manual preparation steps.
One reviewable workflow prepares candidate buy and sell values without accessing an account or placing a trade.
Trade-offs and limits
- Broker rules and allowed tick sizes can change; the repository contains hard-coded assumptions rather than a versioned authoritative rules source.
- The public repository contains no automated tests, so boundary values and rounding behavior are not protected against regression.
requirements.txtnames Streamlit without pinning a version, which weakens reproducibility.- The hosted Streamlit app currently redirects through Streamlit authentication, so some visitors may be asked to sign in before using it.
- This utility is not financial advice and does not guarantee that a broker will accept a calculated value.
Evidence
No claims are made about trading outcomes, usage, current broker-policy accuracy, or production scale.
Review the repositoryWhat This Project Demonstrates
Rule Modeling
Translated trigger-distance, rounding, and synchronization rules into a small inspectable calculation path.
Transparent Computation
Kept assumptions visible so a user can review the logic instead of trusting an opaque result.
Boundary Design
Separated value preparation from brokerage access, credentials, order placement, and financial advice.
Risk-Aware Engineering
Documented stale-rule, dependency, testing, and deployment limitations rather than implying unsupported reliability.
This project demonstrates my ability to turn a narrow, error-prone calculation into a reviewable tool with explicit operating boundaries.
Reflection
I would keep the visible calculation and the boundary between preparation and trade execution. I would not treat the current implementation as complete today without automated boundary tests, pinned dependencies, and a versioned authoritative source for broker rules; those controls matter more than adding another convenience feature.
Have a workflow that needs clearer rules and fewer manual calculations?