Checking Available Funds Before Converting a Locked Order
Summary
The forum question asks how to add an available-funds check when a trading framework converts an order request under lock logic. The proposed approach is to obtain account information through the main engine, read the account’s available balance, compare it with the funds required for the intended opening order, and only then create an order request marked as an open.
The answer is a short implementation sketch rather than a complete margin calculation or tested solution. It assumes that the first account returned is the relevant one and that a value for required funds is already available. It does not explain how to calculate that requirement for a particular contract, account currency, leverage, fees, or exchange rules, nor how to handle missing or stale account data. Those details must be resolved before the check can reliably prevent an underfunded order.
Key ideas
- Account data can be queried from the trading engine to inspect available funds.
- An opening order can be gated on whether available funds meet the required amount.
- The example assumes the first returned account is the correct account to check.
- The required-funds calculation and contract-specific margin rules are not provided.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.