# Charts & Market History

PaperMarket uses Polymarket as the only source of historical price information.\
The app does not backfill its own prices or simulate fake history. Every point on the chart is derived from data returned by Polymarket APIs.

This page explains how historical data is fetched, how it is shaped into a time series and how that series is used inside the app.

### Source of historical prices

For each loaded market PaperMarket queries Polymarket history endpoints for the relevant YES and NO tokens.

The backend requests a series of time stamped price points that Polymarket exposes for a given market or token.\
These values are already normalized in the Polymarket convention

* prices are in the `[0, 1]` range
* each point is linked to a specific time

PaperMarket does not recalculate these prices.\
It treats them as the canonical history for that market.

### Building the time series

When the backend receives the raw history it converts it into an internal time series that is easier to render and reuse.

Typical steps include

* sorting all points by timestamp
* removing clearly duplicated timestamps when they appear
* optionally downsampling very dense sequences so the chart remains readable

The result is a list of points of the form

* `time` a timestamp from Polymarket data
* `price` a value between zero and one representing the token price at that time

This list is stored or cached per market so that repeated visits to the same market do not require repeated full history downloads during a short period.

### What the chart represents

The chart in PaperMarket is a visual view of that time series for the selected market.

By design

* it reflects only what comes back from Polymarket history APIs
* it uses the same normalized price scale between zero and one
* it focuses on the evolution of the YES token price over time for the current market

The chart is an analytical aid.\
It does not drive execution and is not used directly in PnL calculations.\
Execution uses the live order book and valuation uses mid prices derived from the current book.

### Time windows and granularity

The amount of history requested from Polymarket and the density of points can vary by market and by configuration.

In general the backend

* requests a recent window that is sufficient to show the current context of the market
* keeps the number of points to a level that can be drawn smoothly in a browser
* prefers regular spacing when downsampling so that the visual story remains clear

If Polymarket returns only a short history for a new market the chart will show a shorter line.\
PaperMarket does not extrapolate missing history into the past.

### Handling gaps and missing history

External historical data is not guaranteed to be perfect.\
PaperMarket handles gaps conservatively.

Typical cases include

* if the history endpoint is temporarily unavailable the chart for that market is left empty or marked as unavailable instead of fabricated
* if there are gaps in the timestamps the line on the chart simply spans those gaps without interpolating intermediate synthetic points
* if the history contains clearly inconsistent values the backend can reject that response and avoid displaying it

In all cases the intention is to make it obvious that history comes from Polymarket and to avoid hiding gaps behind artificial smoothing.

### Relation to positions and PnL

Historical data and live data play different roles.

* historical prices are used to draw charts and to give context for past movement
* live order books are used to simulate fills and to compute current mid prices
* positions and PnL are derived from trades and current mid prices, not from chart lines

This separation keeps the simulation logic tied to live Polymarket liquidity while still giving traders a clear visual view of how a market has evolved over time.


---

# 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://papermarket.gitbook.io/papermarket/market-data-and-charts/charts-and-market-history.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.
