> For the complete documentation index, see [llms.txt](https://quandora.gitbook.io/quandora-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://quandora.gitbook.io/quandora-docs/understanding-quandora/plugin.py.md).

# plugin.py

`plugin.py` is created during the factor-mining stage.

```
task card
-> agent generates plugin.py and formula
-> Quandora evaluates the factor
-> result card returns
```

The task card tells the agent what kind of factor to build. `plugin.py` is the factor implementation the agent produces.

***

#### A factor usually starts as a formula.

Example:

```
signal = ts_delta(open_interest, 4) / ts_std(open_interest, 20) * sign(return_1h)
```

This says:

```
Look for unusual open-interest change,
scale it by recent open-interest volatility,
then align it with the direction of recent return.
```

Broken down:

| Part                         | Meaning                                                       |
| ---------------------------- | ------------------------------------------------------------- |
| `open_interest`              | How many positions are open in the market.                    |
| `ts_delta(open_interest, 4)` | How much open interest changed over 4 periods.                |
| `ts_std(open_interest, 20)`  | How unusual that change is compared with the last 20 periods. |
| `sign(return_1h)`            | Whether recent price movement was positive or negative.       |
| `signal`                     | The final factor score Quandora can test.                     |

***

### Why plugin.py Exists <a href="#why-pluginpy-exists" id="why-pluginpy-exists"></a>

The formula is easy for humans to read.

`plugin.py` makes the same formula executable, so Quandora can run it against market data.

```
task card
-> agent writes formula
-> agent turns formula into plugin.py
-> Quandora evaluates plugin.py
-> result card returns
```

### What plugin.py Is Not <a href="#what-pluginpy-is-not" id="what-pluginpy-is-not"></a>

`plugin.py` is not a trading bot.

It is not:

* a buy or sell instruction
* a complete strategy
* a guarantee of profit
* a live trading system

It is just the testable formula.


---

# 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://quandora.gitbook.io/quandora-docs/understanding-quandora/plugin.py.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.
