# RESIDUE_TRK

> RESIDUE_TRK supports the Settlement Residue Auction, by showing the tracking records for different residue auction runs. RESIDUE_TRK joins to [`RESIDUE_PUBLIC_DATA`](./RESIDUE_PUBLIC_DATA.md) and [`RESIDUE_CON_DATA`](./RESIDUE_CON_DATA.md).

> Source
> 
> RESIDUE_TRK updates whenever Settlement Residue Auctions are run and the
> results published (i.e. quarterly).
> 
> The RESIDUE_TRK data is available to all participants post the
> associated auction date.
> 
> Volume
> 
> Assuming quarterly contracts, RESIDUE_TRK shows a maximum of 50 records
> per year.

## Column Schema

### AUCTIONID

> Unique id for each auction date. (new in March 2003 to support SRA Inter-Temporal Linking)

SQL Type: `VARCHAR2(30)`
Polars Type: `str`

This column is mandatory, and a primary key.

Example: `A202609`

### VERSIONNO

> Contract run version

SQL Type: `NUMBER(3,0)`
Polars Type: `pl.UInt16`

This column is mandatory, and a primary key.

Example: `1`

### AUTHORISEDBY

> Authorising officer or process

SQL Type: `VARCHAR2(15)`
Polars Type: `str`

This column is not mandatory.

Example: `YCHEN`

### AUTHORISEDDATE

> Date results published

SQL Type: `DATE`
Polars Type: `pl.Date()`

This column is not mandatory.

Example: `2026/09/15 00:00:00`

Note that AEMO represents dates as datetimes with a midnight time component.

### CONTRACTID

> SRA Contract identifier

SQL Type: `VARCHAR2(30)`
Polars Type: `pl.Categorical`

This column is not mandatory.

### LASTCHANGED

> Last date and time record changed

For more information, see the [dedicated documentation page](../../guide/querying.md#deduplication).

SQL Type: `DATE`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Example: `2026/09/15 14:16:03`

### POSTDATE

> Date the run is authorised

!!! danger "Warning"
    Despite what the name suggests, this is a datetime, not a date.

SQL Type: `DATE`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Example: `2026/09/15 14:16:03`

### POSTEDBY

> Name of authorising officer or process

SQL Type: `VARCHAR2(15)`
Polars Type: `str`

This column is not mandatory.

Example: `SYSTEM`

### RUNDATE

> Date auction results determined

!!! danger "Warning"
    Despite what the name suggests, this is a datetime, not a date.

SQL Type: `DATE`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Example: `2026/09/15 14:00:08`

### STATUS

> Load status [SUCCESSFUL/CORRUPT]

The SQL type is `VARCHAR2(15)`.
This is actually a factor/enum, with values:

- `SUCCESSFUL`

- `CORRUPT`

This column is not mandatory.

## New Data Timing

> Updated  after an auction

## Code Examples

### Polars

Explicitly listing every column, casting to enums, categoricals etc is not essential, but may speed up parsing.
Swapping `int` for `pl.UInt16`, `pl.Int32` would also speed up parsing. However some of the datatypes are inferred, so they may be wrong.

This code deduplicates for you.
Deduplication is normally only required across multiple months.

This code assumes that all columns are present, which may not be true for older files.

```python
import polars as pl
import polars.selectors as cs

# e.g. "2029/03/15 00:05:00"
dt_s_fmt = "%Y/%m/%d %H:%M:%S"

# Dates are represented as datetimes at midnight

d_fmt = "%Y/%m/%d 00:00:00"

csv_paths = ["SOMEFILE.CSV", "OTHERFILE.CSV"]

lf = (
    pl.concat(
        [
            pl.scan_csv(
                csv_path,  # must be unzipped beforehand
                skip_rows=1,  # skip the header
                infer_schema=False,  # much faster
            )
            .filter(cs.by_index(0) == "D")  # drop the footer
            .select(~cs.by_index(range(4)))  # drop metadata columns
            for csv_path in csv_paths
        ],
        how="diagonal_relaxed",
    )
    .with_columns(
        pl.col("LASTCHANGED", "POSTDATE", "RUNDATE").str.strptime(
            pl.Datetime, dt_s_fmt
        ),
        pl.col("AUTHORISEDDATE").str.strptime(pl.Date, d_fmt),
    )
    .cast(
        {
            "AUCTIONID": str,
            "VERSIONNO": int,  # or pl.UInt16
            "AUTHORISEDBY": str,
            "AUTHORISEDDATE": pl.Date(),
            "CONTRACTID": pl.Categorical,
            "POSTEDBY": str,
            "STATUS": pl.Enum(["SUCCESSFUL", "CORRUPT"]),
        }
    )
    # Deduplicate
    # We want one row per ['AUCTIONID', 'VERSIONNO']
    # Tie-breaker: greatest value of ['LASTCHANGED']
    .sort(["LASTCHANGED"], descending=False)
    .unique(subset=["AUCTIONID", "VERSIONNO"], keep="last")
)

```

### Nemosis

This table is not yet available in [Nemosis](https://github.com/UNSW-CEEM/NEMOSIS/#static_table).

## Example File

From [PUBLIC_ARCHIVE_RESIDUE_TRK_FILE01_202609010000.zip](https://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/2026/MMSDM_2026_09/MMSDM_Historical_Data_SQLLoader/DATA/PUBLIC_ARCHIVE%23RESIDUE_TRK%23FILE01%23202609010000.zip)

=== "Raw Text with Metadata"
    ```csv
    C,SETP.WORLD,DVD_RESIDUE_TRK,AEMO,PUBLIC,2026/10/09,16:28:08,001791527288737,MONTHLY_ARCHIVE,001791527288737
    I,IRAUCTION,RESIDUE_TRK,1,CONTRACTID,VERSIONNO,RUNDATE,AUTHORISEDDATE,AUTHORISEDBY,POSTDATE,POSTEDBY,LASTCHANGED,STATUS,AUCTIONID
    D,IRAUCTION,RESIDUE_TRK,1,,1,"2026/09/15 14:00:08","2026/09/15 00:00:00",YCHEN,"2026/09/15 14:16:03",SYSTEM,"2026/09/15 14:16:03",,A202609
    C,"END OF REPORT",4
    ```

## Availability

Visibility: Public

This table is in the public monthly [MMSDM archive](https://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/).

I have collated the list of all those files into one place, in [this CSV metadata file](../../manifests/per_table/csv/RESIDUE_TRK.csv). (Columns `year`, `month`, `url`, `compressed_size` in bytes).

The earliest available data is month 3 of 2015.
The most recent available data is month 9 of 2026.

!!! warning Warning
    There are some months with no files.

## Data Size

Each year of data is approximately
5 KB when zipped,
53 KB as unzipped CSV.

## Deduplication and PDR Loader Configuration

The primary keys are:

- [`AUCTIONID`](#auctionid)

- [`VERSIONNO`](#versionno)

The transaction type is ["INSERT-UPDATE"](https://di-help.docs.public.aemo.com.au/Content/pdrLoader/How_it_works.htm?TocPath=pdrLoader%7CAbout+pdrLoader%7C_____5#UPDATEINSERT), which means that you will likely see duplicate data with different values.

You should deduplicate by sorting based on `LASTCHANGED`, within each group of primary keys.

[PDR Loader configuration](https://nemweb.com.au/Reports/Current/MMSDataModelReport/PDRCONFIG/PROD_PUBLIC_PDR_CONFIG_FULL.zip) is:

| Report Name | Report Subtype | Version |
|---------------|-------------------|-----------|
| IRAUCTION | RESIDUE_TRK  | 1 |

This means that the CSV files start with metadata columns:

```csv
I,IRAUCTION,RESIDUE_TRK,1,...
D,IRAUCTION,RESIDUE_TRK,1,...
```

`ROW_FILTER_TYPE` is LASTCHANGED

## Indexes

- [`LASTCHANGED`](#lastchanged)

## Links

[This page as JSON](../json/tables/RESIDUE_TRK/bespoke.json) (schema documented [here](https://gitlab.com/MatthewDavis/mms-schema/-/blob/master/schema.py?ref_type=heads), but may change)

Download a [JSON Schema](../json/tables/RESIDUE_TRK/json-schema.json) specification for this table.

[Official AEMO schema documentation](https://nemweb.com.au/Reports/Current/MMSDataModelReport/Electricity/ElectricityDataModelReport_files/Elec31.htm#145)

## Other Information

Package: [IRAUCTION](../packages/IRAUCTION.md)
