> For the complete documentation index, see [llms.txt](https://sway-technologies.gitbook.io/sway-charts-api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sway-technologies.gitbook.io/sway-charts-api-documentation/rest-api-specification/cash-transaction/order-leg.md).

# Order Leg

| Field                 | Value                                                                                                  | Type                                                                                                                    |
| --------------------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
| **instrument**        | Symbol of the order’s instrument                                                                       | String, **required**                                                                                                    |
| **positionEffect**    | The effect of this order on a position                                                                 | String, *optional*                                                                                                      |
| **positionCode**      | ID of a position that should be modified by this order                                                 | String, *optional*                                                                                                      |
| **price**             | Price of the order                                                                                     | [Number](/sway-charts-api-documentation/rest-api-specification/getting-started/data-types-and-formats.md), **required** |
| **legRatio**          | Always 1.0                                                                                             | [Number](/sway-charts-api-documentation/rest-api-specification/getting-started/data-types-and-formats.md), **required** |
| **quantity**          | Initial quantity of the order in units (not in lots)                                                   | [Number](/sway-charts-api-documentation/rest-api-specification/getting-started/data-types-and-formats.md), **required** |
| **filledQuantity**    | Quantity filled so far in units (not in lots). If no fills took place, this field equals to `0.0`.     | [Number](/sway-charts-api-documentation/rest-api-specification/getting-started/data-types-and-formats.md), **required** |
| **remainingQuantity** | Quantity available for further execution (in units).                                                   | [Number](/sway-charts-api-documentation/rest-api-specification/getting-started/data-types-and-formats.md), **required** |
| **averagePrice**      | Volume-weighted average price of all fills for this leg. The value is `0.0` if there are no fills yet. | [Number](/sway-charts-api-documentation/rest-api-specification/getting-started/data-types-and-formats.md), **required** |

## *<mark style="color:blue;">**string**</mark>***&#x20;Position Effect**

Indicates whether the resulting position after a trade should be a new position or the trade should close an existing position. Required for position-based trading. If the value is `Close`, the *positionCode* field is also present.

Possible values:

* `OPEN`
* `CLOSE`

## *<mark style="color:blue;">**string**</mark>***&#x20;Position Code**

ID of a position that should be modified by this order. Used for position based trading. Present when *positionEffect* is `Close` and omitted otherwise.

## *<mark style="color:blue;">**number**</mark>***&#x20;Quantity**

Initial quantity of the order in units (not in lots) as specified in a "Place" request.

This value is not present if this is an **attached Limit or Stop** "closing" order linked to a position. In this case the `positionCode` field is present and `positionEffect` is "Close". It means initial quantity of the order equals to the quantity of the position.

If this is a **Market** order closing the position, it may have quantity set to be able to partially close the position. If quantity is omitted for Market order with the **"Closing"** position effect, then whole position will be closed.

## **Order Link**

| Field                   | Value                                                                                                                                                                                        | Type                 |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
| **linkType**            | Type of the link                                                                                                                                                                             | String, **required** |
| **linkedOrder**         | Internal unique string code of the linked order. Corresponds to the `orderCode` field in the [Order](/sway-charts-api-documentation/rest-api-specification/cash-transaction/order.md) object | String, **required** |
| **linkedClientOrderId** | Unique order id of the linked order. Corresponds to the `clientOrderId` field in the [Order](/sway-charts-api-documentation/rest-api-specification/cash-transaction/order.md) object         | String, **required** |

## *<mark style="color:blue;">**string**</mark>***&#x20;Link Type**

One of the following values:

* `PARENT` – this order is a parent of the linked one
* `CHILD` – this order is a child of the linked one
* `OCO` – this order is a member of an OCO group with the linked one.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sway-technologies.gitbook.io/sway-charts-api-documentation/rest-api-specification/cash-transaction/order-leg.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
