FennEdge Learn · Programming

DAS Trader Advanced Hotkey Script Course

Understand the code. Inspect the state. Verify the outcome. A detailed path through Advanced Script: language, data structures, order objects, event workflows and complete practice projects.

Plan about 1046 minutes including reading, worked examples, and each lesson exercise; actual time varies.

36Lessons≈1046Est. minutes—Sign in to save progress
36
Lesson 36 of 36 · About 45 min

Project: A DAS Order Audit and Reconciliation Worksheet

Keep draft intent, observed order identity and reconciliation records separate.

Project specification

Prerequisites: order objects, filters and lifecycle. Build an audit record for a known simulator order. It combines an intended quantity, an observed order identifier and manually reconciled fill quantities. It does not infer fills from an undocumented property or treat a local success flag as an execution report. The project is useful because disagreements stay visible.

Read the known platform record

Replace TR_PRACTICE and RefNum=17 with a verified existing simulated record. Use a build supporting combined filters. A no-match result requires stopping and checking Orders; no portable missing-object branch is assumed.

Lookup and inspection

$feAuditOrder = GetOrderObj("Acc=TR_PRACTICE,Symb=MSFT,RefNum=17");
$feAuditOrder.ShowObject();
MsgBox($feAuditOrder.Account, $feAuditOrder.Symbol, $feAuditOrder.RefNum, $feAuditOrder.Status);

A self-contained quantity reconciliation

The next block uses invented values for one order. It can be run without an order connection. requested, filled and remaining are supplied observations, not DAS API property names.

Reconciliation implementation

$feAudit = NewUserObj();
$feAudit.requested = 120;
$feAudit.filled = 45;
$feAudit.remaining = 75;
$feAudit.balanced = 0;
$feAudit.modelRemaining = 0;
$feAudit.error = "Inconsistent quantities";
if ($feAudit.requested >= 0) {
    if ($feAudit.filled >= 0) {
        if ($feAudit.filled <= $feAudit.requested) {
            $feAudit.modelRemaining = $feAudit.requested - $feAudit.filled;
            if ($feAudit.remaining == $feAudit.modelRemaining) {
                $feAudit.balanced = 1;
                $feAudit.error = "";
            }
        }
    }
}
$feAudit.ShowObject();

What the result proves

For 120/45/75, balanced=1 only proves the supplied numbers satisfy the simple equation. After a cancellation, requested-filled may include cancelled quantity rather than open quantity, so the model needs an additional cancelled category. Replacements and order revisions may also change the accounting basis. Account position is separate from this one order’s fills. A Trigger using QTY:POS can therefore differ from the entry order’s requested shares.

Acceptance and extension

Test filled=121, remaining=74 and a valid partial fill. Answer: the first two fail, 120/45/75 passes. Extend the model to requested=filled+open+cancelled for a single non-replaced order with nonnegative categories; test 120=45+0+75 after cancellation. Preserve observed status text, identifiers and timestamps beside the arithmetic. Do not automatically resubmit an order when the equation fails: reconcile the record source first.