> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Trade Scaling Table Context Menu

## Overview

| Plugin key                                       | BAS Setting key                      |
| ------------------------------------------------ | ------------------------------------ |
| `accelerator_plugin-menu-pivot-table-tradescale` | `bas-plugin-menu-item-trade-scaling` |

This plugin allows you to scale any number of trades in a pivot table and create a new What-If branch using the newly created trade data. The context menu action will only appear when the configured hierarchy is present in the table query.

## Availability

| Solution    | Enabled |
| ----------- | ------- |
| FRTB        | ✅       |
| Market risk | ❌       |
| SIMM        | ✅       |
| CVARC       | ✅       |
| Limits      | ❌       |
| Sign-off    | ❌       |

## Settings

For this context menu action, configure the following settings:

| Key                       | Type      | Description                                   | Example                                                                 |   |
| ------------------------- | --------- | --------------------------------------------- | ----------------------------------------------------------------------- | - |
| `asOfDateDimensionName`   | `string`  | Name of the dimension holding the as-of dates |                                                                         |   |
| `asOfDateHierarchyName`   | `string`  | Name of the hierarchy holding the as-of dates |                                                                         |   |
| `tradeDimensionName`      | `string`  | Name of the dimension holding the trades      |                                                                         |   |
| `tradeHierarchyName`      | `string`  | Name of the hierarchy holding the trades      |                                                                         |   |
| `doesSupportParentBranch` | \`boolean | undefined\`                                   | Whether the what-if endpoint supports branch chaining for trade scaling |   |

## How to modify a setting

To modify a setting, you need to modify the `basSettings` that you provide to the `activate` function. The following example shows you how to provide the activate function with the default `basSettings` while updating the settings for the Trade Scaling context menu action:

```javascript theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
import { activate, basSettings } from "@activeviam/frtb-sdk";

const frtbServerKey = "FRTB";
const customSettings = structuredClone(basSettings);

customSettings[frtbServerKey][
  "bas-plugin-menu-item-trade-scaling"
].asOfDateDimensionName = "Custom_AsOfDate_Dim_Name";

activate({
  configuration,
  basSettings: customSettings,
});
```

## How to disable it

### Disable universally

To disable this feature for all solutions, add this line at the end of your extension’s `activate` function to unregister the plugin:

```diff theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
const extension: ExtensionModule = {
  activate: async (configuration: Configuration) => {
    ...
+    delete configuration.pluginRegistry["menu-item"]["accelerator_plugin-menu-pivot-table-tradescale"];
+    Object.values(configuration.pluginRegistry["widget"]).forEach(widgetPlugin => {
+        widgetPlugin.contextMenuItems = widgetPlugin.contextMenuItems.filter( menuItem => menuItem.key !== "accelerator_plugin-menu-pivot-table-tradescale")
+    })
  }
}
```

### Disable for specific servers

To disable this feature for a given server, you must delete this feature’s settings for that server key by altering the `basSettings` parameter before calling the `activate` function.

**Example**
Disabling this feature for the `FRTB` server only:

```diff theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
+ import {produce} from "immer";
- import {activate as activateFrtb} from "@activeviam/frtb-sdk";
+ import {activate as activateFrtb, basSettings as frtbBASSettings} from "@activeviam/frtb-sdk";
 import {activate as activeMarketRisk} from "@activeviam/mr-sdk";

 const extension: ExtensionModule = {
  activate: async (configuration: Configuration) => {
    ...
+    const frtbBASSettingsWithFeatureDisabled = produce(frtbBASSettings, draft => {
+      delete draft["FRTB"]["bas-plugin-menu-item-trade-scaling"];
+    });

-   activateFrtb({configuration});
+   activateFrtb({configuration, basSetttings: frtbBASSettingsWithFeatureDisabled})
    activeMarketRisk({configuration});
  }
}
```
