# Working with Price Oracles

**`initialize_oracle<CURRENCY>(...)`**, **`update_oracle(...)`**, and **`get_twap(...)`**\
**Purpose**: Integrate a price oracle to record price samples and compute a time-weighted average price (TWAP).\
**Process**:

1. Store historical prices during trades.
2. Update `price_cumulative` and `price_samples` periodically.
3. Compute TWAP for stable pricing signals and detect anomalies.

**Use Cases**:

* Avoiding price manipulation by referencing TWAP rather than spot prices.
* Informing traders and liquidity providers with more reliable pricing.

**Best Practices**:

* Configure appropriate `sample_period` to reflect market conditions.
* Use TWAP checks in large trades to prevent large deviations from fair value.


---

# Agent Instructions: 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:

```
GET https://docs.artinals.com/artinals-protocol/working-with-price-oracles.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
