DAS Locate Cost Models and Response Reconciliation
Model quotes, allocations and retries without inventing broker-independent APIs.
Extend the workflow, not just the command string
Prerequisite: the Locate basics lesson and custom objects. InquiryShare and Inquire prepare an inquiry; LocateLowest can commit a locate. The reviewed public guide does not define a structured response object or a universal maximum-fee parameter. Advanced handling therefore has two layers: portable calculation/state logic and an adapter verified against the actual ShortLocate command list and broker.
Model one observed response
Advanced Script · hypothetical arithmetic only. These values are manually supplied test data, not properties returned by a DAS Locate API. Price is assumed to be dollars per share; minimum charges and other fees are outside this simple model.
Cost worksheet
$feLocateReview = NewUserObj();
$feLocateReview.requested = 200;
$feLocateReview.available = 150;
$feLocateReview.pricePerShare = 0.025;
$feLocateReview.feeCap = 4.00;
$feLocateReview.candidate = $feLocateReview.requested;
if ($feLocateReview.candidate > $feLocateReview.available) {
$feLocateReview.candidate = $feLocateReview.available;
}
$feLocateReview.estimatedFee = $feLocateReview.candidate * $feLocateReview.pricePerShare;
$feLocateReview.withinCap = 0;
if ($feLocateReview.candidate > 0) {
if ($feLocateReview.pricePerShare >= 0) {
if ($feLocateReview.estimatedFee <= $feLocateReview.feeCap) {
$feLocateReview.withinCap = 1;
}
}
}
MsgBox($feLocateReview.candidate, $feLocateReview.estimatedFee, $feLocateReview.withinCap);
Interpret the output correctly
Expected candidate quantity 150 and modeled fee 3.75, within the 4-dollar cap under the stated assumptions. This is insufficient to authorize a locate: quantity is below the requested 200, a quote may expire, extra fees may exist and LocateLowest may use a different final price. Choose whether partial availability is acceptable as an explicit workflow policy; do not silently redefine requested quantity. A zero price may be legitimate or missing data and must be classified by the response adapter.
A reconciliation record
Record account, symbol, provider, requested quantity, quote time, quoted quantity, quoted unit, selected amount, actual allocation, charged fee and status. Keep status as requested/waiting/observed/unknown/failed, not merely a success boolean. A lost response means unknown, not failed. Before retrying, inspect the original request and allocation records. Never equate cancellation of a trading order with reversal of a locate charge.
How to extend broker-specific commands
For InquireAll, automatic locate or a price ceiling found in your client, record its exact signature and unit from Script Builder before writing an adapter. Test inquiry separately from commitment and document whether the broker offers a non-billing test environment. This chapter deliberately provides no invented polling field, LocateStatus() function or callback name. Put unverified operations behind a manual reconciliation step rather than disguising them as working code.
Exercise and worked answer
Change availability to 200 and unit price to 0.03. Answer: candidate 200, modeled fee 6, withinCap=0. Change availability to zero: candidate zero and withinCap=0 even though estimatedFee is zero. Add a stale-quote flag to the model and require it to be false before declaring a response reviewable. The flag itself must come from a verified observation source.