# Cookbook

Twelve complete programs in all seven languages, from listing your accounts to a webhook receiver: copy one and run it.

Twelve complete programs, each in all seven languages, every one compiled against its SDK before a release. Each runs as it is against the sandbox.

| Recipe | What it does |
|---|---|
| [Your key and accounts](/cookbook/accounts) | Who you are (the key, its access and limits) and your accounts. |
| [Markets and a quote](/cookbook/markets) | The markets and their rules, then a quote (bid, ask, last) from the market stream. |
| [Live market data](/cookbook/market-stream) | Live market data: prices for two markets and the trades of one, until 20 frames came. |
| [Place and cancel a limit order](/cookbook/place-cancel-limit) | A limit order far from the market, found again by your own id, then canceled. |
| [A market order with exits](/cookbook/market-with-brackets) | A market order with its exits: a take profit 1% away and a stop loss 0.5% away, placed by the API the moment it fills and kept on its servers. |
| [Trailing stop and break-even](/cookbook/trailing-breakeven) | A position whose stop loss trails the price by 0.5% and moves to break-even once the price has gone 0.5% your way, all on the API's servers. |
| [What an order would do](/cookbook/what-if) | What an order would do now, without placing it: fill or rest, the price, the fee, the margin, the position after. |
| [A live copy of your accounts](/cookbook/account-stream-mirror) | A live copy of your accounts' positions and working orders: the snapshot first, then every event applied once. |
| [Account history](/cookbook/history) | An account's history: the equity curve by day, the result of each trading day, closed positions and fills. |
| [Candles to a CSV file](/cookbook/candles-to-csv) | The last 100 closed one-minute candles of a market and the one forming (final false), written to candles.csv. |
| [A webhook receiver](/cookbook/webhook-receiver) | Receive webhooks: every delivery is checked (its signature and its time) before it is trusted. |
| [Handling errors](/cookbook/error-handling) | What failures look like: each has a class by family, the API's code, the request id to quote to support, and details. |

## Running one

| Language | What it needs |
|---|---|
| TypeScript | Node 22 or later: `npm install https://github.com/phoenixperps/sdk/releases/download/v1.0.0/phoenixperps-sdk-1.0.0.tgz`, then `node accounts.mts` |
| Python | Python 3.10 or later: `pip install https://github.com/phoenixperps/sdk/releases/download/v1.0.0/phoenixperps-1.0.0-py3-none-any.whl`, then `python accounts.py` |
| Go | Go 1.23 or later: `go mod init bot && go get github.com/phoenixperps/sdk/go`, the program as `main.go`, then `go run .` |
| C# | .NET 10: once, `dotnet nuget add source https://phoenixperps.github.io/sdk/nuget/index.json --name phoenixperps`; each program is a file-based app whose `#:package` line brings the SDK: `dotnet run accounts.cs` |
| Java | Java 17 or later, with `maven("https://phoenixperps.github.io/sdk/maven")` in your repositories and `com.phoenixperpsfunding:phoenixperps-sdk:1.0.0` in your dependencies |
| Rust | Rust 1.85 or later: `cargo add phoenixperps --git https://github.com/phoenixperps/sdk --tag v1.0.0`, `cargo add futures-util serde_json`, `cargo add uuid --features v4`, `cargo add tokio --features macros,rt-multi-thread,time`, the program as `src/main.rs`, then `cargo run` |
| PHP | PHP 8.2 or later: `composer config repositories.phoenixperps composer https://phoenixperps.github.io/sdk/composer`, `composer require phoenixperps/sdk`, then `php accounts.php` |
