# NEGATIVE_RESIDUE

> Shows the inputs provided to the Negative Residue Constraints in the Dispatch horizon

## Column Schema

### DIRECTIONAL_INTERCONNECTORID

> Negative residue related direction interconnector id

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

This column is mandatory, and a primary key.

Examples:

- `NSW1_QLD1`
- `NSW1_VIC1`
- `QLD1_NSW1`
- `SA1_VIC1`
- `TAS1_VIC1`
- `VIC1_NSW1`
- `VIC1_SA1`
- `VIC1_TAS1`

### NRM_DATETIME

> The time that residue information is processed

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

This column is mandatory, and a primary key.

Example: `2026/08/31 23:55:24`

### SETTLEMENTDATE

> Dispatch Interval

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

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

This column is mandatory, and a primary key.

Example: `2026/09/01 00:05:00`

### CUMUL_NEGRESIDUE_AMOUNT

> Negative residue triggering amount

SQL Type: `NUMBER(15,5)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`-0.14`, `0`, `-33525.75`

### CUMUL_NEGRESIDUE_PREV_TI

> Previous trading interval cumulative negative residue amount

SQL Type: `NUMBER(15,5)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`-0.17`, `0`, `-26187.44`

### DI_NOTBINDING_COUNT

> Count of the number of DIs not binding by this constraint

SQL Type: `NUMBER(2,0)`
Polars Type: `pl.Int8`

This column is not mandatory.

Example: `3`

### DI_VIOLATED_COUNT

> Count of the number of DIs violated by this constraint

SQL Type: `NUMBER(2,0)`
Polars Type: `pl.Int8`

This column is not mandatory.

Example: `0`

### EVENT_ACTIVATED_DI

> The starting DI when NRM event is active

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

This column is not mandatory.

Example: `2026/01/20 00:05:00`

### EVENT_DEACTIVATED_DI

> The finishing DI when NRM event stops being active.

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

This column is not mandatory.

Example: `2026/01/20 00:05:00`

### NEGRESIDUE_CURRENT_TI

> Current trading interval negative residue amount

SQL Type: `NUMBER(15,5)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`-0.14`, `0`, `-14329`, `-20116.1`

### NEGRESIDUE_PD_NEXT_TI

> The cumulative negative residue for the next trading interval (PD)

SQL Type: `NUMBER(15,5)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`-0.33`, `0`, `-4610`, `-5856.66`

### NRM_ACTIVATED_FLAG

> Is 1 if negative residue process is on, else is 0

SQL Type: `NUMBER(1,0)`
Polars Type: `pl.Int8`

This column is not mandatory.

Example: `0`

### NRM_LOOP_FLAG

> NRM Loop Flag controls monitoring behaviour:
0 = Individual NRM monitoring suppressed (loop operational with aggregate IRSR >= 0)
1 = Individual NRM monitoring active (applies to: loop not operational, aggregate loop IRSR < 0, or non-loop interconnection)
This flag is evaluated and set for ALL interconnections in each dispatch interval

SQL Type: `NUMBER(1,0)`
Polars Type: `pl.Boolean`

This column is not mandatory.

### NRMCONSTRAINT_BLOCKED_FLAG

> 1 if constraint is blocked, else 0

SQL Type: `NUMBER(1,0)`
Polars Type: `pl.Int8`

This column is not mandatory.

### PREDISPATCHSEQNO

> Predispatch sequence number

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

This column is not mandatory.

Examples:

- `2026083140`
- `2026090112`

### PRICE_REVISION

> SubjectToReview, Indeterminate, Accepted or Rejected

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

This column is not mandatory.

## 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"

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(
            "NRM_DATETIME",
            "SETTLEMENTDATE",
            "EVENT_ACTIVATED_DI",
            "EVENT_DEACTIVATED_DI",
        ).str.strptime(pl.Datetime, dt_s_fmt),
    )
    # Polars can't cast string straight to bool. Need to go via something else.
    .cast({"NRM_LOOP_FLAG": pl.UInt8})
    .cast(
        {
            "DIRECTIONAL_INTERCONNECTORID": str,
            "CUMUL_NEGRESIDUE_AMOUNT": pl.Float64,
            "CUMUL_NEGRESIDUE_PREV_TI": pl.Float64,
            "DI_NOTBINDING_COUNT": int,  # or pl.Int8
            "DI_VIOLATED_COUNT": int,  # or pl.Int8
            "NEGRESIDUE_CURRENT_TI": pl.Float64,
            "NEGRESIDUE_PD_NEXT_TI": pl.Float64,
            "NRM_ACTIVATED_FLAG": int,  # or pl.Int8
            "NRM_LOOP_FLAG": pl.Boolean,
            "NRMCONSTRAINT_BLOCKED_FLAG": int,  # or pl.Int8
            "PREDISPATCHSEQNO": str,
            "PRICE_REVISION": str,
        }
    )
    # Deduplicate
    # We want one row per ['DIRECTIONAL_INTERCONNECTORID', 'NRM_DATETIME', 'SETTLEMENTDATE']
    # Tie-breaker: greatest value of ['SETTLEMENTDATE', 'NRM_DATETIME', 'DIRECTIONAL_INTERCONNECTORID']
    .sort(
        ["SETTLEMENTDATE", "NRM_DATETIME", "DIRECTIONAL_INTERCONNECTORID"],
        descending=False,
    )
    .unique(
        subset=["DIRECTIONAL_INTERCONNECTORID", "NRM_DATETIME", "SETTLEMENTDATE"],
        keep="last",
    )
)

```

### Nemosis

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

## Example File

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

=== "Raw Text with Metadata"
    ```csv
    C,SETP.WORLD,DVD_NEGATIVE_RESIDUE,AEMO,PUBLIC,2026/10/09,15:56:01,001791525361499,MONTHLY_ARCHIVE,001791525361499
    I,DISPATCH,NEGATIVE_RESIDUE,2,SETTLEMENTDATE,NRM_DATETIME,DIRECTIONAL_INTERCONNECTORID,NRM_ACTIVATED_FLAG,CUMUL_NEGRESIDUE_AMOUNT,CUMUL_NEGRESIDUE_PREV_TI,NEGRESIDUE_CURRENT_TI,NEGRESIDUE_PD_NEXT_TI,PRICE_REVISION,PREDISPATCHSEQNO,EVENT_ACTIVATED_DI,EVENT_DEACTIVATED_DI,DI_NOTBINDING_COUNT,DI_VIOLATED_COUNT,NRMCONSTRAINT_BLOCKED_FLAG,NRM_LOOP_FLAG
    D,DISPATCH,NEGATIVE_RESIDUE,2,"2026/09/01 00:05:00","2026/08/31 23:55:24",NSW1_QLD1,0,0,0,0,0,,2026083140,,,3,0,,
    D,DISPATCH,NEGATIVE_RESIDUE,2,"2026/09/01 00:05:00","2026/08/31 23:55:24",NSW1_VIC1,0,0,0,0,0,,2026083140,,,3,0,,
    D,DISPATCH,NEGATIVE_RESIDUE,2,"2026/09/01 00:05:00","2026/08/31 23:55:24",QLD1_NSW1,0,0,0,0,0,,2026083140,,,3,0,,
    D,DISPATCH,NEGATIVE_RESIDUE,2,"2026/09/01 00:05:00","2026/08/31 23:55:24",SA1_VIC1,0,-895.74,0,-895.74,-1034.61,,2026083140,,,3,0,,
    D,DISPATCH,NEGATIVE_RESIDUE,2,"2026/09/01 00:05:00","2026/08/31 23:55:24",TAS1_VIC1,0,-1778.28,0,-1778.28,-1984.23,,2026083140,,,3,0,,
    D,DISPATCH,NEGATIVE_RESIDUE,2,"2026/09/01 00:05:00","2026/08/31 23:55:24",VIC1_NSW1,0,0,0,0,0,,2026083140,,,3,0,,
    D,DISPATCH,NEGATIVE_RESIDUE,2,"2026/09/01 00:05:00","2026/08/31 23:55:24",VIC1_SA1,0,0,-2656.21,0,0,,2026083140,,,3,0,,
    D,DISPATCH,NEGATIVE_RESIDUE,2,"2026/09/01 00:05:00","2026/08/31 23:55:24",VIC1_TAS1,0,0,0,0,0,,2026083140,,,3,0,,
    D,DISPATCH,NEGATIVE_RESIDUE,2,"2026/09/01 00:10:00","2026/09/01 00:00:17",NSW1_QLD1,0,0,0,0,0,,,,,3,0,,
    D,DISPATCH,NEGATIVE_RESIDUE,2,"2026/09/01 00:10:00","2026/09/01 00:00:17",NSW1_VIC1,0,0,0,0,0,,,,,3,0,,
    D,DISPATCH,NEGATIVE_RESIDUE,2,"2026/09/01 00:10:00","2026/09/01 00:00:17",QLD1_NSW1,0,0,0,0,0,,,,,3,0,,
    ...
    C,"END OF REPORT",1003
    ```

## 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/NEGATIVE_RESIDUE.csv). (Columns `year`, `month`, `url`, `compressed_size` in bytes).

The earliest available data is month 8 of 2024.
The most recent available data is month 9 of 2026.

 Every month in between has a file. (No gaps.)

## Data Size

Each year of data is approximately
5 MB when zipped,
48 MB as unzipped CSV.

## Deduplication and PDR Loader Configuration

The primary keys are:

- [`DIRECTIONAL_INTERCONNECTORID`](#directional_interconnectorid)

- [`NRM_DATETIME`](#nrm_datetime)

- [`SETTLEMENTDATE`](#settlementdate)

The transaction type is ["insert"](https://di-help.docs.public.aemo.com.au/Content/pdrLoader/How_it_works.htm?TocPath=pdrLoader%7CAbout+pdrLoader%7C_____5#INSERT), which means that you will usually not see duplicate data.
If you do, you can deduplicate based on the primary keys, without sorting first.
Rows from different files with the same primary keys should have the same values.

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

| Report Name | Report Subtype | Version |
|---------------|-------------------|-----------|
| DISPATCH | NEGATIVE_RESIDUE  | 1 |
| DISPATCH | NEGATIVE_RESIDUE  | 2 |

This means that the CSV files start with metadata columns:

```csv
I,DISPATCH,NEGATIVE_RESIDUE,1,...
D,DISPATCH,NEGATIVE_RESIDUE,1,...
```

or

```csv
I,DISPATCH,NEGATIVE_RESIDUE,2,...
D,DISPATCH,NEGATIVE_RESIDUE,2,...
```

## Indexes

- [`SETTLEMENTDATE`](#settlementdate)

- [`NRM_DATETIME`](#nrm_datetime)

- [`DIRECTIONAL_INTERCONNECTORID`](#directional_interconnectorid)

## Links

[This page as JSON](../json/tables/NEGATIVE_RESIDUE/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/NEGATIVE_RESIDUE/json-schema.json) specification for this table.

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

## Other Information

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