> For the complete documentation index, see [llms.txt](https://docs.outpoll.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.outpoll.com/api/futures-api/python-examples/futures-examples.md).

# Futures Examples

End-to-end Python scripts for perpetual futures: REST trading plus the market data and account streams.

Use these scripts to automate common futures workflows.

## Start Here

Use [Setup & Helpers](broken://pages/e380e76256ed05ef72de8d8e710c3fe3bec1115b) first.

That page covers:

* Python version and package install
* The signed REST client for the futures API
* The private WebSocket `AUTH` helper
* Pair lookup, rounding to tick and lot size, and market data helpers

## Trading Workflows

* [Open a Position with TP/SL](broken://pages/9531550c5d378859fc3bbfb93b810361a392bc89) — market order sized by spend, with take-profit and stop-loss attached
* [Limit Entry with Timeout](broken://pages/224c4a882ace8a3cfba080dbaac2952a1a60bb78) — rest a post-only limit below the bid, wait for the fill on the account stream, cancel if it does not fill
* [Protect Open Positions](broken://pages/ab964b607a34db8e25cd2bcfc3060690e55c66ef) — put a stop-loss and take-profit on every open position that has none

## Monitoring and Risk

* [Live PnL Monitor](broken://pages/7ed1a5eab224b6ff285f42b693a2e379365d0fad) — unrealized PnL of every position, updated from the account stream and best bid/ask
* [Margin Call Guard](broken://pages/5404a55180026e6d95cae8ef7307e6eb5b5a8e4a) — reduce cross positions automatically when a margin call arrives

## Related Pages

* [Futures API](broken://pages/5af105514c769e54cdcc5c7c16de2848aa3aa267)
* [Futures Market Data](broken://pages/03869a2c7095ebee30a177ae823d7a4420086e38)
* [Futures Account streams](broken://pages/faa2c076dfe2f95047048724a161c66cc460d6ec)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.outpoll.com/api/futures-api/python-examples/futures-examples.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
