docs: sync Polymarket documentation (2026-05-04)
This commit is contained in:
@@ -63,12 +63,16 @@ Before making authenticated requests, you need to obtain API credentials using L
|
|||||||
<Tab title="TypeScript">
|
<Tab title="TypeScript">
|
||||||
```typescript theme={null}
|
```typescript theme={null}
|
||||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||||
import { Wallet } from "ethers"; // v5.8.0
|
import { createWalletClient, http } from "viem";
|
||||||
|
import { privateKeyToAccount } from "viem/accounts";
|
||||||
|
|
||||||
|
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
||||||
|
const signer = createWalletClient({ account, transport: http() });
|
||||||
|
|
||||||
const client = new ClobClient({
|
const client = new ClobClient({
|
||||||
host: "https://clob.polymarket.com",
|
host: "https://clob.polymarket.com",
|
||||||
chain: 137, // Polygon mainnet
|
chain: 137, // Polygon mainnet
|
||||||
signer: new Wallet(process.env.PRIVATE_KEY),
|
signer,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Creates new credentials or derives existing ones
|
// Creates new credentials or derives existing ones
|
||||||
@@ -76,7 +80,7 @@ Before making authenticated requests, you need to obtain API credentials using L
|
|||||||
|
|
||||||
console.log(credentials);
|
console.log(credentials);
|
||||||
// {
|
// {
|
||||||
// apiKey: "550e8400-e29b-41d4-a716-446655440000",
|
// key: "550e8400-e29b-41d4-a716-446655440000",
|
||||||
// secret: "base64EncodedSecretString",
|
// secret: "base64EncodedSecretString",
|
||||||
// passphrase: "randomPassphraseString"
|
// passphrase: "randomPassphraseString"
|
||||||
// }
|
// }
|
||||||
@@ -85,17 +89,17 @@ Before making authenticated requests, you need to obtain API credentials using L
|
|||||||
|
|
||||||
<Tab title="Python">
|
<Tab title="Python">
|
||||||
```python theme={null}
|
```python theme={null}
|
||||||
from py_clob_client.client import ClobClient
|
from py_clob_client_v2 import ClobClient
|
||||||
import os
|
import os
|
||||||
|
|
||||||
client = ClobClient(
|
client = ClobClient(
|
||||||
host="https://clob.polymarket.com",
|
host="https://clob.polymarket.com",
|
||||||
chain=137, # Polygon mainnet
|
chain_id=137, # Polygon mainnet
|
||||||
key=os.getenv("PRIVATE_KEY")
|
key=os.getenv("PRIVATE_KEY")
|
||||||
)
|
)
|
||||||
|
|
||||||
# Creates new credentials or derives existing ones
|
# Creates new credentials or derives existing ones
|
||||||
credentials = client.create_or_derive_api_creds()
|
credentials = client.create_or_derive_api_key()
|
||||||
|
|
||||||
print(credentials)
|
print(credentials)
|
||||||
# {
|
# {
|
||||||
@@ -109,9 +113,9 @@ Before making authenticated requests, you need to obtain API credentials using L
|
|||||||
<Tab title="Rust">
|
<Tab title="Rust">
|
||||||
```rust theme={null}
|
```rust theme={null}
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use polymarket_client_sdk::POLYGON;
|
use polymarket_client_sdk_v2::POLYGON;
|
||||||
use polymarket_client_sdk::auth::{LocalSigner, Signer};
|
use polymarket_client_sdk_v2::auth::{LocalSigner, Signer};
|
||||||
use polymarket_client_sdk::clob::{Client, Config};
|
use polymarket_client_sdk_v2::clob::{Client, Config};
|
||||||
|
|
||||||
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
||||||
let signer = LocalSigner::from_str(&private_key)?
|
let signer = LocalSigner::from_str(&private_key)?
|
||||||
@@ -221,7 +225,7 @@ The `POLY_SIGNATURE` is generated by signing the following EIP-712 struct:
|
|||||||
Reference implementations:
|
Reference implementations:
|
||||||
|
|
||||||
* [TypeScript](https://github.com/Polymarket/clob-client-v2/blob/main/src/signing/eip712.ts)
|
* [TypeScript](https://github.com/Polymarket/clob-client-v2/blob/main/src/signing/eip712.ts)
|
||||||
* [Python](https://github.com/Polymarket/py-clob-client-v2/blob/main/py_clob_client/signing/eip712.py)
|
* [Python](https://github.com/Polymarket/py-clob-client-v2/blob/main/py_clob_client_v2/signing/eip712.py)
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
||||||
@@ -249,20 +253,24 @@ All trading endpoints require these 5 headers:
|
|||||||
| `POLY_API_KEY` | User's API `apiKey` value |
|
| `POLY_API_KEY` | User's API `apiKey` value |
|
||||||
| `POLY_PASSPHRASE` | User's API `passphrase` value |
|
| `POLY_PASSPHRASE` | User's API `passphrase` value |
|
||||||
|
|
||||||
The `POLY_SIGNATURE` for L2 is an HMAC-SHA256 signature created using the user's API credentials `secret` value. Reference implementations can be found in the [TypeScript](https://github.com/Polymarket/clob-client-v2/blob/main/src/signing/hmac.ts) and [Python](https://github.com/Polymarket/py-clob-client-v2/blob/main/py_clob_client/signing/hmac.py) clients.
|
The `POLY_SIGNATURE` for L2 is an HMAC-SHA256 signature created using the user's API credentials `secret` value. Reference implementations can be found in the [TypeScript](https://github.com/Polymarket/clob-client-v2/blob/main/src/signing/hmac.ts) and [Python](https://github.com/Polymarket/py-clob-client-v2/blob/main/py_clob_client_v2/signing/hmac.py) clients.
|
||||||
|
|
||||||
### CLOB Client
|
### CLOB Client
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<Tab title="TypeScript">
|
<Tab title="TypeScript">
|
||||||
```typescript theme={null}
|
```typescript theme={null}
|
||||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
import { ClobClient, Side } from "@polymarket/clob-client-v2";
|
||||||
import { Wallet } from "ethers"; // v5.8.0
|
import { createWalletClient, http } from "viem";
|
||||||
|
import { privateKeyToAccount } from "viem/accounts";
|
||||||
|
|
||||||
|
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
||||||
|
const signer = createWalletClient({ account, transport: http() });
|
||||||
|
|
||||||
const client = new ClobClient({
|
const client = new ClobClient({
|
||||||
host: "https://clob.polymarket.com",
|
host: "https://clob.polymarket.com",
|
||||||
chain: 137,
|
chain: 137,
|
||||||
signer: new Wallet(process.env.PRIVATE_KEY),
|
signer,
|
||||||
creds: apiCreds, // Generated from L1 auth, API credentials enable L2 methods
|
creds: apiCreds, // Generated from L1 auth, API credentials enable L2 methods
|
||||||
signatureType: 1, // signatureType explained below
|
signatureType: 1, // signatureType explained below
|
||||||
funderAddress, // funder explained below
|
funderAddress, // funder explained below
|
||||||
@@ -270,7 +278,7 @@ The `POLY_SIGNATURE` for L2 is an HMAC-SHA256 signature created using the user's
|
|||||||
|
|
||||||
// Now you can trade!
|
// Now you can trade!
|
||||||
const order = await client.createAndPostOrder(
|
const order = await client.createAndPostOrder(
|
||||||
{ tokenID: "123456", price: 0.65, size: 100, side: "BUY" },
|
{ tokenID: "123456", price: 0.65, size: 100, side: Side.BUY },
|
||||||
{ tickSize: "0.01", negRisk: false }
|
{ tickSize: "0.01", negRisk: false }
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -278,12 +286,13 @@ The `POLY_SIGNATURE` for L2 is an HMAC-SHA256 signature created using the user's
|
|||||||
|
|
||||||
<Tab title="Python">
|
<Tab title="Python">
|
||||||
```python theme={null}
|
```python theme={null}
|
||||||
from py_clob_client.client import ClobClient
|
from py_clob_client_v2 import ClobClient, OrderArgs, PartialCreateOrderOptions
|
||||||
|
from py_clob_client_v2.order_builder.constants import BUY
|
||||||
import os
|
import os
|
||||||
|
|
||||||
client = ClobClient(
|
client = ClobClient(
|
||||||
host="https://clob.polymarket.com",
|
host="https://clob.polymarket.com",
|
||||||
chain=137,
|
chain_id=137,
|
||||||
key=os.getenv("PRIVATE_KEY"),
|
key=os.getenv("PRIVATE_KEY"),
|
||||||
creds=api_creds, # Generated from L1 auth, API credentials enable L2 methods
|
creds=api_creds, # Generated from L1 auth, API credentials enable L2 methods
|
||||||
signature_type=1, # signatureType explained below
|
signature_type=1, # signatureType explained below
|
||||||
@@ -292,16 +301,16 @@ The `POLY_SIGNATURE` for L2 is an HMAC-SHA256 signature created using the user's
|
|||||||
|
|
||||||
# Now you can trade!
|
# Now you can trade!
|
||||||
order = client.create_and_post_order(
|
order = client.create_and_post_order(
|
||||||
{"token_id": "123456", "price": 0.65, "size": 100, "side": "BUY"},
|
OrderArgs(token_id="123456", price=0.65, size=100, side=BUY),
|
||||||
{"tick_size": "0.01", "neg_risk": False}
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
</Tab>
|
</Tab>
|
||||||
|
|
||||||
<Tab title="Rust">
|
<Tab title="Rust">
|
||||||
```rust theme={null}
|
```rust theme={null}
|
||||||
use polymarket_client_sdk::clob::types::{Side, SignatureType};
|
use polymarket_client_sdk_v2::clob::types::{Side, SignatureType};
|
||||||
use polymarket_client_sdk::types::dec;
|
use polymarket_client_sdk_v2::types::dec;
|
||||||
|
|
||||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||||
.authentication_builder(&signer)
|
.authentication_builder(&signer)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Polymarket provides official open-source clients in TypeScript, Python, and Rust
|
|||||||
|
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```bash TypeScript theme={null}
|
```bash TypeScript theme={null}
|
||||||
npm install @polymarket/clob-client-v2 ethers@5
|
npm install @polymarket/clob-client-v2 viem
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash Python theme={null}
|
```bash Python theme={null}
|
||||||
@@ -20,7 +20,7 @@ Polymarket provides official open-source clients in TypeScript, Python, and Rust
|
|||||||
```
|
```
|
||||||
|
|
||||||
```bash Rust theme={null}
|
```bash Rust theme={null}
|
||||||
cargo add polymarket-client-sdk
|
cargo add polymarket_client_sdk_v2 --features clob
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|
||||||
@@ -41,12 +41,12 @@ Polymarket provides official open-source clients in TypeScript, Python, and Rust
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python Python theme={null}
|
```python Python theme={null}
|
||||||
from py_clob_client.client import ClobClient
|
from py_clob_client_v2 import ClobClient
|
||||||
|
|
||||||
client = ClobClient(
|
client = ClobClient(
|
||||||
"https://clob.polymarket.com",
|
"https://clob.polymarket.com",
|
||||||
key=private_key,
|
key=private_key,
|
||||||
chain=137,
|
chain_id=137,
|
||||||
creds=api_creds,
|
creds=api_creds,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ Polymarket provides official open-source clients in TypeScript, Python, and Rust
|
|||||||
```
|
```
|
||||||
|
|
||||||
```rust Rust theme={null}
|
```rust Rust theme={null}
|
||||||
use polymarket_client_sdk::clob::{Client, Config};
|
use polymarket_client_sdk_v2::clob::{Client, Config};
|
||||||
|
|
||||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||||
.authentication_builder(&signer)
|
.authentication_builder(&signer)
|
||||||
@@ -71,7 +71,7 @@ Polymarket provides official open-source clients in TypeScript, Python, and Rust
|
|||||||
| ---------- | ---------------------------- | ------------------------------------------------------------------------------------------ |
|
| ---------- | ---------------------------- | ------------------------------------------------------------------------------------------ |
|
||||||
| TypeScript | `@polymarket/clob-client-v2` | [github.com/Polymarket/clob-client-v2](https://github.com/Polymarket/clob-client-v2) |
|
| TypeScript | `@polymarket/clob-client-v2` | [github.com/Polymarket/clob-client-v2](https://github.com/Polymarket/clob-client-v2) |
|
||||||
| Python | `py-clob-client-v2` | [github.com/Polymarket/py-clob-client-v2](https://github.com/Polymarket/py-clob-client-v2) |
|
| Python | `py-clob-client-v2` | [github.com/Polymarket/py-clob-client-v2](https://github.com/Polymarket/py-clob-client-v2) |
|
||||||
| Rust | `polymarket-client-sdk` | [github.com/Polymarket/rs-clob-client-v2](https://github.com/Polymarket/rs-clob-client-v2) |
|
| Rust | `polymarket_client_sdk_v2` | [github.com/Polymarket/rs-clob-client-v2](https://github.com/Polymarket/rs-clob-client-v2) |
|
||||||
|
|
||||||
Each repository includes working examples in the `/examples` directory.
|
Each repository includes working examples in the `/examples` directory.
|
||||||
|
|
||||||
|
|||||||
@@ -166,7 +166,7 @@
|
|||||||
</Update>
|
</Update>
|
||||||
|
|
||||||
<Update label="July 23, 2025" description="Get Book(s) update">
|
<Update label="July 23, 2025" description="Get Book(s) update">
|
||||||
* We're adding new fields to the `get-book` and `get-books` CLOB endpoints to include key market metadata that previously required separate queries.
|
* We’re adding new fields to the `get-book` and `get-books` CLOB endpoints to include key market metadata that previously required separate queries.
|
||||||
* `min_order_size`
|
* `min_order_size`
|
||||||
* type: string
|
* type: string
|
||||||
* description: Minimum price increment.
|
* description: Minimum price increment.
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
</Update>
|
</Update>
|
||||||
|
|
||||||
<Update label="June 3, 2025" description="New Batch Orders Endpoint">
|
<Update label="June 3, 2025" description="New Batch Orders Endpoint">
|
||||||
* We're excited to roll out a highly requested feature: **order batching**. With this new endpoint, users can now submit up to five trades in a single request. To help you get started, we've included sample code demonstrating how to use it. Please see [Create Orders](/trading/orders/create) for more details.
|
* We’re excited to roll out a highly requested feature: **order batching**. With this new endpoint, users can now submit up to five trades in a single request. To help you get started, we’ve included sample code demonstrating how to use it. Please see [Create Orders](/trading/orders/create) for more details.
|
||||||
</Update>
|
</Update>
|
||||||
|
|
||||||
<Update label="June 3, 2025" description="Change to /data/trades">
|
<Update label="June 3, 2025" description="Change to /data/trades">
|
||||||
@@ -194,7 +194,7 @@
|
|||||||
</Update>
|
</Update>
|
||||||
|
|
||||||
<Update label="May 28, 2025" description="New FAK Order Type">
|
<Update label="May 28, 2025" description="New FAK Order Type">
|
||||||
We're excited to introduce a new order type soon to be available to all users: Fill and Kill (FAK). FAK orders behave similarly to the well-known Fill or Kill (FOK) orders, but with a key difference:
|
We’re excited to introduce a new order type soon to be available to all users: Fill and Kill (FAK). FAK orders behave similarly to the well-known Fill or Kill (FOK) orders, but with a key difference:
|
||||||
|
|
||||||
* FAK will fill as many shares as possible immediately at your specified price, and any remaining unfilled portion will be canceled.
|
* FAK will fill as many shares as possible immediately at your specified price, and any remaining unfilled portion will be canceled.
|
||||||
* Unlike FOK, which requires the entire order to fill instantly or be canceled, FAK is more flexible and aims to capture partial fills if possible.
|
* Unlike FOK, which requires the entire order to fill instantly or be canceled, FAK is more flexible and aims to capture partial fills if possible.
|
||||||
@@ -208,7 +208,7 @@
|
|||||||
* CLOB - /price (100req - 10s / Throttle requests over the maximum configured rate)
|
* CLOB - /price (100req - 10s / Throttle requests over the maximum configured rate)
|
||||||
* CLOB markets/0x (50req / 10s - Throttle requests over the maximum configured rate)
|
* CLOB markets/0x (50req / 10s - Throttle requests over the maximum configured rate)
|
||||||
* CLOB POST /order - 500 every 10s (50/s) - (BURST) - Throttle requests over the maximum configured rate
|
* CLOB POST /order - 500 every 10s (50/s) - (BURST) - Throttle requests over the maximum configured rate
|
||||||
* CLOB POST /order - 3000 every 10 minutes (5/s) - Throttle requests over the maximum configured rate)
|
* CLOB POST /order - 3000 every 10 minutes (5/s) - Throttle requests over the maximum configured rate
|
||||||
* CLOB DELETE /order - 500 every 10s (50/s) - (BURST) - Throttle requests over the maximum configured rate
|
* CLOB DELETE /order - 500 every 10s (50/s) - (BURST) - Throttle requests over the maximum configured rate
|
||||||
* DELETE /order - 3000 every 10 minutes (5/s) - Throttle requests over the maximum configured rate)
|
* DELETE /order - 3000 every 10 minutes (5/s) - Throttle requests over the maximum configured rate
|
||||||
</Update>
|
</Update>
|
||||||
+7
-7
@@ -78,20 +78,20 @@ export const IconCard = ({ icon, title, description, href, color }) => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python Python theme={null}
|
```python Python theme={null}
|
||||||
from py_clob_client.client import ClobClient
|
from py_clob_client_v2 import ClobClient, OrderArgs, PartialCreateOrderOptions
|
||||||
from py_clob_client.order_builder.constants import BUY
|
from py_clob_client_v2.order_builder.constants import BUY
|
||||||
|
|
||||||
client = ClobClient(host, key=key, chain=chain, creds=creds)
|
client = ClobClient(host, key=key, chain_id=chain, creds=creds)
|
||||||
order = client.create_and_post_order(
|
order = client.create_and_post_order(
|
||||||
OrderArgs(token_id=token_id, price=0.50, size=10, side=BUY),
|
OrderArgs(token_id=token_id, price=0.50, size=10, side=BUY),
|
||||||
options={"tick_size": "0.01", "neg_risk": False}
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
```rust Rust theme={null}
|
```rust Rust theme={null}
|
||||||
use polymarket_client_sdk::clob::{Client, Config};
|
use polymarket_client_sdk_v2::clob::{Client, Config};
|
||||||
use polymarket_client_sdk::clob::types::Side;
|
use polymarket_client_sdk_v2::clob::types::Side;
|
||||||
use polymarket_client_sdk::types::dec;
|
use polymarket_client_sdk_v2::types::dec;
|
||||||
|
|
||||||
let client = Client::new(host, Config::default())?.authentication_builder(&signer).authenticate().await?;
|
let client = Client::new(host, Config::default())?.authentication_builder(&signer).authenticate().await?;
|
||||||
let order = client.limit_order().token_id(token_id).price(dec!(0.50)).size(dec!(10)).side(Side::Buy).build().await?;
|
let order = client.limit_order().token_id(token_id).price(dec!(0.50)).size(dec!(10)).side(Side::Buy).build().await?;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -167,9 +167,9 @@ The geoblocking system includes:
|
|||||||
|
|
||||||
<Tab title="Rust">
|
<Tab title="Rust">
|
||||||
```rust theme={null}
|
```rust theme={null}
|
||||||
use polymarket_client_sdk::clob::Client;
|
use polymarket_client_sdk_v2::clob::{Client, Config};
|
||||||
|
|
||||||
let client = Client::default();
|
let client = Client::new("https://clob.polymarket.com", Config::default())?;
|
||||||
let geo = client.check_geoblock().await?;
|
let geo = client.check_geoblock().await?;
|
||||||
|
|
||||||
if geo.blocked {
|
if geo.blocked {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -60,8 +60,8 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python Python theme={null}
|
```python Python theme={null}
|
||||||
from py_clob_client.clob_types import OrderArgs, OrderType
|
from py_clob_client_v2 import OrderArgs, OrderType, PartialCreateOrderOptions
|
||||||
from py_clob_client.order_builder.constants import BUY
|
from py_clob_client_v2.order_builder.constants import BUY
|
||||||
|
|
||||||
response = client.create_and_post_order(
|
response = client.create_and_post_order(
|
||||||
OrderArgs(
|
OrderArgs(
|
||||||
@@ -70,10 +70,7 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
|||||||
size=10,
|
size=10,
|
||||||
side=BUY,
|
side=BUY,
|
||||||
),
|
),
|
||||||
options={
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||||
"tick_size": "0.01",
|
|
||||||
"neg_risk": False,
|
|
||||||
},
|
|
||||||
order_type=OrderType.GTC
|
order_type=OrderType.GTC
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -82,8 +79,8 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
|||||||
```
|
```
|
||||||
|
|
||||||
```rust Rust theme={null}
|
```rust Rust theme={null}
|
||||||
use polymarket_client_sdk::clob::types::Side;
|
use polymarket_client_sdk_v2::clob::types::Side;
|
||||||
use polymarket_client_sdk::types::dec;
|
use polymarket_client_sdk_v2::types::dec;
|
||||||
|
|
||||||
let token_id = "TOKEN_ID".parse()?;
|
let token_id = "TOKEN_ID".parse()?;
|
||||||
let order = client
|
let order = client
|
||||||
@@ -132,10 +129,7 @@ For more control, you can separate signing from submission. This is useful for b
|
|||||||
size=10,
|
size=10,
|
||||||
side=BUY,
|
side=BUY,
|
||||||
),
|
),
|
||||||
options={
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)
|
||||||
"tick_size": "0.01",
|
|
||||||
"neg_risk": False,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Step 2: Submit to the CLOB
|
# Step 2: Submit to the CLOB
|
||||||
@@ -197,17 +191,14 @@ GTD orders auto-expire at a specified time. Useful for quoting around known even
|
|||||||
side=BUY,
|
side=BUY,
|
||||||
expiration=expiration,
|
expiration=expiration,
|
||||||
),
|
),
|
||||||
options={
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||||
"tick_size": "0.01",
|
|
||||||
"neg_risk": False,
|
|
||||||
},
|
|
||||||
order_type=OrderType.GTD
|
order_type=OrderType.GTD
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
```rust Rust theme={null}
|
```rust Rust theme={null}
|
||||||
use chrono::{TimeDelta, Utc};
|
use chrono::{TimeDelta, Utc};
|
||||||
use polymarket_client_sdk::clob::types::OrderType;
|
use polymarket_client_sdk_v2::clob::types::OrderType;
|
||||||
|
|
||||||
let order = client
|
let order = client
|
||||||
.limit_order()
|
.limit_order()
|
||||||
@@ -266,32 +257,36 @@ Market orders execute immediately against resting liquidity using FOK or FAK typ
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python Python theme={null}
|
```python Python theme={null}
|
||||||
from py_clob_client.order_builder.constants import BUY, SELL
|
from py_clob_client_v2.order_builder.constants import BUY, SELL
|
||||||
from py_clob_client.clob_types import OrderType
|
from py_clob_client_v2 import MarketOrderArgs, OrderType, PartialCreateOrderOptions
|
||||||
|
|
||||||
# FOK BUY: spend exactly $100 or cancel entirely
|
# FOK BUY: spend exactly $100 or cancel entirely
|
||||||
buy_order = client.create_market_order(
|
buy_order = client.create_market_order(
|
||||||
token_id="TOKEN_ID",
|
order_args=MarketOrderArgs(
|
||||||
side=BUY,
|
token_id="TOKEN_ID",
|
||||||
amount=100, # dollar amount
|
side=BUY,
|
||||||
price=0.50, # worst-price limit (slippage protection)
|
amount=100, # dollar amount
|
||||||
options={"tick_size": "0.01", "neg_risk": False},
|
price=0.50, # worst-price limit (slippage protection)
|
||||||
|
),
|
||||||
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||||
)
|
)
|
||||||
client.post_order(buy_order, OrderType.FOK)
|
client.post_order(buy_order, OrderType.FOK)
|
||||||
|
|
||||||
# FOK SELL: sell exactly 200 shares or cancel entirely
|
# FOK SELL: sell exactly 200 shares or cancel entirely
|
||||||
sell_order = client.create_market_order(
|
sell_order = client.create_market_order(
|
||||||
token_id="TOKEN_ID",
|
order_args=MarketOrderArgs(
|
||||||
side=SELL,
|
token_id="TOKEN_ID",
|
||||||
amount=200, # number of shares
|
side=SELL,
|
||||||
price=0.45, # worst-price limit (slippage protection)
|
amount=200, # number of shares
|
||||||
options={"tick_size": "0.01", "neg_risk": False},
|
price=0.45, # worst-price limit (slippage protection)
|
||||||
|
),
|
||||||
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||||
)
|
)
|
||||||
client.post_order(sell_order, OrderType.FOK)
|
client.post_order(sell_order, OrderType.FOK)
|
||||||
```
|
```
|
||||||
|
|
||||||
```rust Rust theme={null}
|
```rust Rust theme={null}
|
||||||
use polymarket_client_sdk::clob::types::{Amount, OrderType, Side};
|
use polymarket_client_sdk_v2::clob::types::{Amount, OrderType, Side};
|
||||||
|
|
||||||
let token_id = "TOKEN_ID".parse()?;
|
let token_id = "TOKEN_ID".parse()?;
|
||||||
|
|
||||||
@@ -347,12 +342,17 @@ For convenience, `createAndPostMarketOrder` handles creation, signing, and submi
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python Python theme={null}
|
```python Python theme={null}
|
||||||
|
from py_clob_client_v2 import MarketOrderArgs, OrderType, PartialCreateOrderOptions
|
||||||
|
from py_clob_client_v2.order_builder.constants import BUY
|
||||||
|
|
||||||
response = client.create_and_post_market_order(
|
response = client.create_and_post_market_order(
|
||||||
token_id="TOKEN_ID",
|
order_args=MarketOrderArgs(
|
||||||
side=BUY,
|
token_id="TOKEN_ID",
|
||||||
amount=100,
|
side=BUY,
|
||||||
price=0.50,
|
amount=100,
|
||||||
options={"tick_size": "0.01", "neg_risk": False},
|
price=0.50,
|
||||||
|
),
|
||||||
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||||
order_type=OrderType.FOK,
|
order_type=OrderType.FOK,
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
@@ -446,26 +446,26 @@ Place up to **15 orders** in a single request:
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python Python theme={null}
|
```python Python theme={null}
|
||||||
from py_clob_client.clob_types import OrderArgs, OrderType, PostOrdersArgs
|
from py_clob_client_v2 import OrderArgs, OrderType, PostOrdersV2Args, PartialCreateOrderOptions
|
||||||
from py_clob_client.order_builder.constants import BUY, SELL
|
from py_clob_client_v2.order_builder.constants import BUY, SELL
|
||||||
|
|
||||||
response = client.post_orders([
|
response = client.post_orders([
|
||||||
PostOrdersArgs(
|
PostOrdersV2Args(
|
||||||
order=client.create_order(OrderArgs(
|
order=client.create_order(OrderArgs(
|
||||||
price=0.48,
|
price=0.48,
|
||||||
size=500,
|
size=500,
|
||||||
side=BUY,
|
side=BUY,
|
||||||
token_id="TOKEN_ID",
|
token_id="TOKEN_ID",
|
||||||
), options={"tick_size": "0.01", "neg_risk": False}),
|
), options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)),
|
||||||
orderType=OrderType.GTC,
|
orderType=OrderType.GTC,
|
||||||
),
|
),
|
||||||
PostOrdersArgs(
|
PostOrdersV2Args(
|
||||||
order=client.create_order(OrderArgs(
|
order=client.create_order(OrderArgs(
|
||||||
price=0.52,
|
price=0.52,
|
||||||
size=500,
|
size=500,
|
||||||
side=SELL,
|
side=SELL,
|
||||||
token_id="TOKEN_ID",
|
token_id="TOKEN_ID",
|
||||||
), options={"tick_size": "0.01", "neg_risk": False}),
|
), options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)),
|
||||||
orderType=OrderType.GTC,
|
orderType=OrderType.GTC,
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -60,8 +60,8 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python Python theme={null}
|
```python Python theme={null}
|
||||||
from py_clob_client.clob_types import OrderArgs, OrderType
|
from py_clob_client_v2 import OrderArgs, OrderType, PartialCreateOrderOptions
|
||||||
from py_clob_client.order_builder.constants import BUY
|
from py_clob_client_v2.order_builder.constants import BUY
|
||||||
|
|
||||||
response = client.create_and_post_order(
|
response = client.create_and_post_order(
|
||||||
OrderArgs(
|
OrderArgs(
|
||||||
@@ -70,10 +70,7 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
|||||||
size=10,
|
size=10,
|
||||||
side=BUY,
|
side=BUY,
|
||||||
),
|
),
|
||||||
options={
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||||
"tick_size": "0.01",
|
|
||||||
"neg_risk": False,
|
|
||||||
},
|
|
||||||
order_type=OrderType.GTC
|
order_type=OrderType.GTC
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -82,8 +79,8 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
|||||||
```
|
```
|
||||||
|
|
||||||
```rust Rust theme={null}
|
```rust Rust theme={null}
|
||||||
use polymarket_client_sdk::clob::types::Side;
|
use polymarket_client_sdk_v2::clob::types::Side;
|
||||||
use polymarket_client_sdk::types::dec;
|
use polymarket_client_sdk_v2::types::dec;
|
||||||
|
|
||||||
let token_id = "TOKEN_ID".parse()?;
|
let token_id = "TOKEN_ID".parse()?;
|
||||||
let order = client
|
let order = client
|
||||||
@@ -132,10 +129,7 @@ For more control, you can separate signing from submission. This is useful for b
|
|||||||
size=10,
|
size=10,
|
||||||
side=BUY,
|
side=BUY,
|
||||||
),
|
),
|
||||||
options={
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)
|
||||||
"tick_size": "0.01",
|
|
||||||
"neg_risk": False,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Step 2: Submit to the CLOB
|
# Step 2: Submit to the CLOB
|
||||||
@@ -197,17 +191,14 @@ GTD orders auto-expire at a specified time. Useful for quoting around known even
|
|||||||
side=BUY,
|
side=BUY,
|
||||||
expiration=expiration,
|
expiration=expiration,
|
||||||
),
|
),
|
||||||
options={
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||||
"tick_size": "0.01",
|
|
||||||
"neg_risk": False,
|
|
||||||
},
|
|
||||||
order_type=OrderType.GTD
|
order_type=OrderType.GTD
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
```rust Rust theme={null}
|
```rust Rust theme={null}
|
||||||
use chrono::{TimeDelta, Utc};
|
use chrono::{TimeDelta, Utc};
|
||||||
use polymarket_client_sdk::clob::types::OrderType;
|
use polymarket_client_sdk_v2::clob::types::OrderType;
|
||||||
|
|
||||||
let order = client
|
let order = client
|
||||||
.limit_order()
|
.limit_order()
|
||||||
@@ -266,32 +257,36 @@ Market orders execute immediately against resting liquidity using FOK or FAK typ
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python Python theme={null}
|
```python Python theme={null}
|
||||||
from py_clob_client.order_builder.constants import BUY, SELL
|
from py_clob_client_v2.order_builder.constants import BUY, SELL
|
||||||
from py_clob_client.clob_types import OrderType
|
from py_clob_client_v2 import MarketOrderArgs, OrderType, PartialCreateOrderOptions
|
||||||
|
|
||||||
# FOK BUY: spend exactly $100 or cancel entirely
|
# FOK BUY: spend exactly $100 or cancel entirely
|
||||||
buy_order = client.create_market_order(
|
buy_order = client.create_market_order(
|
||||||
token_id="TOKEN_ID",
|
order_args=MarketOrderArgs(
|
||||||
side=BUY,
|
token_id="TOKEN_ID",
|
||||||
amount=100, # dollar amount
|
side=BUY,
|
||||||
price=0.50, # worst-price limit (slippage protection)
|
amount=100, # dollar amount
|
||||||
options={"tick_size": "0.01", "neg_risk": False},
|
price=0.50, # worst-price limit (slippage protection)
|
||||||
|
),
|
||||||
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||||
)
|
)
|
||||||
client.post_order(buy_order, OrderType.FOK)
|
client.post_order(buy_order, OrderType.FOK)
|
||||||
|
|
||||||
# FOK SELL: sell exactly 200 shares or cancel entirely
|
# FOK SELL: sell exactly 200 shares or cancel entirely
|
||||||
sell_order = client.create_market_order(
|
sell_order = client.create_market_order(
|
||||||
token_id="TOKEN_ID",
|
order_args=MarketOrderArgs(
|
||||||
side=SELL,
|
token_id="TOKEN_ID",
|
||||||
amount=200, # number of shares
|
side=SELL,
|
||||||
price=0.45, # worst-price limit (slippage protection)
|
amount=200, # number of shares
|
||||||
options={"tick_size": "0.01", "neg_risk": False},
|
price=0.45, # worst-price limit (slippage protection)
|
||||||
|
),
|
||||||
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||||
)
|
)
|
||||||
client.post_order(sell_order, OrderType.FOK)
|
client.post_order(sell_order, OrderType.FOK)
|
||||||
```
|
```
|
||||||
|
|
||||||
```rust Rust theme={null}
|
```rust Rust theme={null}
|
||||||
use polymarket_client_sdk::clob::types::{Amount, OrderType, Side};
|
use polymarket_client_sdk_v2::clob::types::{Amount, OrderType, Side};
|
||||||
|
|
||||||
let token_id = "TOKEN_ID".parse()?;
|
let token_id = "TOKEN_ID".parse()?;
|
||||||
|
|
||||||
@@ -347,12 +342,17 @@ For convenience, `createAndPostMarketOrder` handles creation, signing, and submi
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python Python theme={null}
|
```python Python theme={null}
|
||||||
|
from py_clob_client_v2 import MarketOrderArgs, OrderType, PartialCreateOrderOptions
|
||||||
|
from py_clob_client_v2.order_builder.constants import BUY
|
||||||
|
|
||||||
response = client.create_and_post_market_order(
|
response = client.create_and_post_market_order(
|
||||||
token_id="TOKEN_ID",
|
order_args=MarketOrderArgs(
|
||||||
side=BUY,
|
token_id="TOKEN_ID",
|
||||||
amount=100,
|
side=BUY,
|
||||||
price=0.50,
|
amount=100,
|
||||||
options={"tick_size": "0.01", "neg_risk": False},
|
price=0.50,
|
||||||
|
),
|
||||||
|
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||||
order_type=OrderType.FOK,
|
order_type=OrderType.FOK,
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
@@ -446,26 +446,26 @@ Place up to **15 orders** in a single request:
|
|||||||
```
|
```
|
||||||
|
|
||||||
```python Python theme={null}
|
```python Python theme={null}
|
||||||
from py_clob_client.clob_types import OrderArgs, OrderType, PostOrdersArgs
|
from py_clob_client_v2 import OrderArgs, OrderType, PostOrdersV2Args, PartialCreateOrderOptions
|
||||||
from py_clob_client.order_builder.constants import BUY, SELL
|
from py_clob_client_v2.order_builder.constants import BUY, SELL
|
||||||
|
|
||||||
response = client.post_orders([
|
response = client.post_orders([
|
||||||
PostOrdersArgs(
|
PostOrdersV2Args(
|
||||||
order=client.create_order(OrderArgs(
|
order=client.create_order(OrderArgs(
|
||||||
price=0.48,
|
price=0.48,
|
||||||
size=500,
|
size=500,
|
||||||
side=BUY,
|
side=BUY,
|
||||||
token_id="TOKEN_ID",
|
token_id="TOKEN_ID",
|
||||||
), options={"tick_size": "0.01", "neg_risk": False}),
|
), options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)),
|
||||||
orderType=OrderType.GTC,
|
orderType=OrderType.GTC,
|
||||||
),
|
),
|
||||||
PostOrdersArgs(
|
PostOrdersV2Args(
|
||||||
order=client.create_order(OrderArgs(
|
order=client.create_order(OrderArgs(
|
||||||
price=0.52,
|
price=0.52,
|
||||||
size=500,
|
size=500,
|
||||||
side=SELL,
|
side=SELL,
|
||||||
token_id="TOKEN_ID",
|
token_id="TOKEN_ID",
|
||||||
), options={"tick_size": "0.01", "neg_risk": False}),
|
), options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)),
|
||||||
orderType=OrderType.GTC,
|
orderType=OrderType.GTC,
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user