# MNSP_OFFERTRK

> MNSP_OFFERTRK records all valid MNSPOFFERS loaded into the MMS system. The authorised date reflects the date and time of the load. MNSP_OFFERTRK is key for tracking MNSP bid submission.

!!! tip "Deprecation Warning"
    This table is in the [HISTORICAL TABLES](../packages/HISTORICAL TABLES.md) package,
    so is likely deprecated.

> MNSP_OFFERTRK shows own (confidential) data updates as bids are
> processed. All bids are available as part of next day market data.
> 
> Volume
> 
> 4000 per year

## Column Schema

### FILENAME

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

This column is mandatory, and a primary key.

Examples:

- `BASSLINK_OFFER_20210201_001.TXT`
- `BASSLINK_OFFER_20210201_002.TXT`
- `BASSLINK_OFFER_20210201_003.TXT`
- `BASSLINK_OFFER_20210201_004.TXT`
- `BASSLINK_OFFER_20210201_005.TXT`
- `BASSLINK_OFFER_20210201_006.TXT`
- `BASSLINK_OFFER_20210201_007.TXT`
- `BASSLINK_OFFER_20210201_008.TXT`
- `BASSLINK_OFFER_20210201_009.TXT`
- `BASSLINK_OFFER_20210202_001.TXT`

### OFFERDATE

!!! 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: `2021/01/20 13:01:55`

### PARTICIPANTID

For more information, see the [dedicated documentation page](../../guide/querying.md#duid-genset-id-etc).

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

This column is mandatory, and a primary key.

Example: `BASSLINK`

### SETTLEMENTDATE

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

This column is mandatory, and a primary key.

Example: `2021/02/01 00:00:00`

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

### VERSIONNO

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

This column is mandatory, and a primary key.

Examples:
`1`, `21`

### AUTHORISEDBY

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

This column is not mandatory.

Example: `MARK BOSTE`

### AUTHORISEDDATE

!!! 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: `2021/01/20 13:01:55`

### LASTCHANGED

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: `2021/01/20 13:01:56`

## New Data Timing

> As bids are processed

## 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("OFFERDATE", "AUTHORISEDDATE", "LASTCHANGED").str.strptime(
            pl.Datetime, dt_s_fmt
        ),
        pl.col("SETTLEMENTDATE").str.strptime(pl.Date, d_fmt),
    )
    .cast(
        {
            "FILENAME": str,
            "PARTICIPANTID": pl.Categorical,
            "SETTLEMENTDATE": pl.Date(),
            "VERSIONNO": int,  # or pl.UInt16
            "AUTHORISEDBY": str,
        }
    )
    # Deduplicate
    # We want one row per ['FILENAME', 'OFFERDATE', 'PARTICIPANTID', 'SETTLEMENTDATE', 'VERSIONNO']
    # Tie-breaker: greatest value of ['LASTCHANGED']
    .sort(["LASTCHANGED"], descending=False)
    .unique(
        subset=[
            "FILENAME",
            "OFFERDATE",
            "PARTICIPANTID",
            "SETTLEMENTDATE",
            "VERSIONNO",
        ],
        keep="last",
    )
)

```

### Nemosis

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

## Example File

From [PUBLIC_DVD_MNSP_OFFERTRK_202102010000.zip](https://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/2021/MMSDM_2021_02/MMSDM_Historical_Data_SQLLoader/DATA/PUBLIC_DVD_MNSP_OFFERTRK_202102010000.zip)

=== "Raw Text with Metadata"
    ```csv
    C,SETP.WORLD,DVD_MNSP_OFFERTRK,AEMO,PUBLIC,2021/03/06,15:45:08,0000000337773402,,0000000337773314
    I,OFFER,MNSP_OFFERTRK,1,SETTLEMENTDATE,OFFERDATE,VERSIONNO,PARTICIPANTID,FILENAME,AUTHORISEDDATE,AUTHORISEDBY,LASTCHANGED
    D,OFFER,MNSP_OFFERTRK,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BASSLINK_OFFER_20210201_001.TXT,"2021/01/20 13:01:55","MARK BOSTE","2021/01/20 13:01:56"
    D,OFFER,MNSP_OFFERTRK,1,"2021/02/01 00:00:00","2021/01/24 08:04:23",2,BASSLINK,BASSLINK_OFFER_20210201_002.TXT,"2021/01/24 08:04:23","MARK BOSTE","2021/01/24 08:04:23"
    D,OFFER,MNSP_OFFERTRK,1,"2021/02/01 00:00:00","2021/01/25 05:55:04",3,BASSLINK,BASSLINK_OFFER_20210201_003.TXT,"2021/01/25 05:55:04","MARK BOSTE","2021/01/25 05:55:05"
    D,OFFER,MNSP_OFFERTRK,1,"2021/02/01 00:00:00","2021/01/26 06:13:09",4,BASSLINK,BASSLINK_OFFER_20210201_004.TXT,"2021/01/26 06:13:09","MARK BOSTE","2021/01/26 06:13:10"
    D,OFFER,MNSP_OFFERTRK,1,"2021/02/01 00:00:00","2021/01/27 05:19:40",5,BASSLINK,BASSLINK_OFFER_20210201_005.TXT,"2021/01/27 05:19:40","MARK BOSTE","2021/01/27 05:19:41"
    D,OFFER,MNSP_OFFERTRK,1,"2021/02/01 00:00:00","2021/01/28 05:38:46",6,BASSLINK,BASSLINK_OFFER_20210201_006.TXT,"2021/01/28 05:38:46","MARK BOSTE","2021/01/28 05:38:47"
    D,OFFER,MNSP_OFFERTRK,1,"2021/02/01 00:00:00","2021/01/29 05:26:25",7,BASSLINK,BASSLINK_OFFER_20210201_007.TXT,"2021/01/29 05:26:25","MARK BOSTE","2021/01/29 05:26:26"
    D,OFFER,MNSP_OFFERTRK,1,"2021/02/01 00:00:00","2021/01/30 05:37:25",8,BASSLINK,BASSLINK_OFFER_20210201_008.TXT,"2021/01/30 05:37:25","MARK BOSTE","2021/01/30 05:37:26"
    D,OFFER,MNSP_OFFERTRK,1,"2021/02/01 00:00:00","2021/01/31 05:25:16",9,BASSLINK,BASSLINK_OFFER_20210201_009.TXT,"2021/01/31 05:25:16","MARK BOSTE","2021/01/31 05:25:17"
    D,OFFER,MNSP_OFFERTRK,1,"2021/02/02 00:00:00","2021/01/21 13:10:08",1,BASSLINK,BASSLINK_OFFER_20210202_001.TXT,"2021/01/21 13:10:08","MARK BOSTE","2021/01/21 13:10:08"
    D,OFFER,MNSP_OFFERTRK,1,"2021/02/02 00:00:00","2021/01/25 05:55:16",2,BASSLINK,BASSLINK_OFFER_20210202_002.TXT,"2021/01/25 05:55:16","MARK BOSTE","2021/01/25 05:55:17"
    ...
    C,"END OF REPORT",281
    ```

## Availability

Visibility: Private & Public Next-Day

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

The earliest available data is month 1 of 2015.
The most recent available data is month 2 of 2021.

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

## Data Size

Each year of data is approximately
63 KB when zipped,
635 KB as unzipped CSV.

## Deduplication and PDR Loader Configuration

The primary keys are:

- [`FILENAME`](#filename)

- [`OFFERDATE`](#offerdate)

- [`PARTICIPANTID`](#participantid)

- [`SETTLEMENTDATE`](#settlementdate)

- [`VERSIONNO`](#versionno)

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 | Undisclosed |
|---------------|-------------------|-----------|-------------|
| BID | MNSP_OFFERTRK  | 1 |
| OFFER | MNSP_OFFERTRK  | 1 | ⚠️ |

!!! danger "Warning"
    Some of these file mappings are not in the
    [published PDR Loader configuration file](https://nemweb.com.au/Reports/Current/MMSDataModelReport/PDRCONFIG/PROD_PUBLIC_PDR_CONFIG_FULL.zip),
    even though files for this table exist with those metadata values.
    Mappings marked with ⚠️ have been added by me after manually inspecting those files.

This means that the CSV files start with metadata columns:

```csv
I,BID,MNSP_OFFERTRK,1,...
D,BID,MNSP_OFFERTRK,1,...
```

or

```csv
I,OFFER,MNSP_OFFERTRK,1,...
D,OFFER,MNSP_OFFERTRK,1,...
```

## Indexes

- [`LASTCHANGED`](#lastchanged)

## Links

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

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

## Other Information

Package: [HISTORICAL TABLES](../packages/HISTORICAL TABLES.md)
