Validate market tick sizes and encode precise limit order amounts
This commit is contained in:
@@ -47,6 +47,12 @@ flowchart LR
|
||||
estimate -->|同步并读取常驻盘口| cache
|
||||
estimate -->|成交金额| book
|
||||
market -->|上架时保存起订份额| minimum["src/minimum_size.rs"]
|
||||
market -->|保存价格步长与选取开盘网格| tick["src/tick_size.rs"]
|
||||
queries -->|编码限价买卖金额| tick
|
||||
book -->|委托价及保护价校验| tick
|
||||
estimate -->|复用保护价网格| tick
|
||||
assets -->|读取市场步长| tick
|
||||
tick -->|舍入后的最小份额| minimum
|
||||
book -->|检查提交量| minimum
|
||||
estimate -->|检查提交量与预算| minimum
|
||||
queries -->|展示盘口起订份额| minimum
|
||||
@@ -647,3 +653,25 @@ sequenceDiagram
|
||||
E->>D: 同一快照读取可用金额及有效买单的预留金额
|
||||
E-->>C: available_micros、reserved_micros、total_cash_micros
|
||||
```
|
||||
|
||||
## 上架步长与金额预览
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant O as 操作员
|
||||
participant E as Exchange
|
||||
participant D as SQLite
|
||||
participant C as 客户端
|
||||
participant B as 常驻订单簿
|
||||
O->>E: list 指定 tick_size
|
||||
E->>D: 同事务写市场和步长
|
||||
C->>E: limit_amounts 提交方向、微单位价格与份额
|
||||
E->>D: 按市场查步长和最小份额
|
||||
E->>E: 校验价格、向下取百分之一份、计算抵押金额
|
||||
E-->>C: 返回 makerAmount、takerAmount 和本地精度支持标记
|
||||
C->>E: order 提交整分价格与整份数量
|
||||
E->>D: 检查价格符合市场步长
|
||||
E->>B: 盘前挂单或连续撮合
|
||||
O->>E: open
|
||||
E->>B: 在本地可执行网格选取统一成交价
|
||||
```
|
||||
|
||||
@@ -44,6 +44,8 @@ pub(crate) fn market_assets(db: &Connection, market: &str) -> Result<Value> {
|
||||
Ok(detail)
|
||||
},
|
||||
)?;
|
||||
detail["tick_size"] =
|
||||
json!(crate::tick_size::TickSize::load(db, market)?.map(|tick| tick.text()));
|
||||
detail["min_order_size"] =
|
||||
json!(crate::minimum_size::MinimumSize::load(db, market)?.map(|size| size.text()));
|
||||
detail["taker_fee_rate_ppm"] = json!(crate::fees::rate(db, market)?);
|
||||
@@ -66,6 +68,7 @@ pub(crate) fn resolve(db: &Connection, request: &mut Value) -> Result<()> {
|
||||
| "trades"
|
||||
| "market_sell"
|
||||
| "estimate"
|
||||
| "limit_amounts"
|
||||
| "market_buy"
|
||||
| "cancel_market_orders"
|
||||
)
|
||||
|
||||
@@ -74,6 +74,9 @@ pub(crate) fn submit(tx: &Transaction, books: &Books, order: NewOrder) -> Result
|
||||
if let Some(minimum) = crate::minimum_size::MinimumSize::load(tx, &market)? {
|
||||
minimum.check_shares(qty)?;
|
||||
}
|
||||
if let Some(tick) = crate::tick_size::TickSize::load(tx, &market)? {
|
||||
tick.check(price * 10000)?;
|
||||
}
|
||||
let deadline = match tif {
|
||||
TimeInForce::Gtd => {
|
||||
let expiration =
|
||||
@@ -190,6 +193,9 @@ pub(crate) fn market_buy(tx: &Transaction, books: &Books, order: BudgetBuy) -> R
|
||||
if let Some(minimum) = crate::minimum_size::MinimumSize::load(tx, &market)? {
|
||||
minimum.check_budget(amount_cents, max_price, rate)?;
|
||||
}
|
||||
if let Some(tick) = crate::tick_size::TickSize::load(tx, &market)? {
|
||||
tick.check(max_price * 10000)?;
|
||||
}
|
||||
ledger::cash(tx, &account, -amount_cents)?;
|
||||
tx.execute(
|
||||
"INSERT INTO orders(account,market,outcome,side,price,quantity,remaining,status)
|
||||
|
||||
@@ -235,6 +235,7 @@ impl Listing {
|
||||
#[serde(tag = "op", rename_all = "snake_case", deny_unknown_fields)]
|
||||
pub(crate) enum Query {
|
||||
Estimate(crate::estimate::Request),
|
||||
LimitAmounts(crate::tick_size::LimitAmounts),
|
||||
PricesHistory(crate::prices_history::Request),
|
||||
QuoteHistory(crate::quotes::Filter),
|
||||
Price(crate::quotes::PriceRequest),
|
||||
@@ -304,6 +305,7 @@ impl Query {
|
||||
Self::Prices { requests } => crate::quotes::prices(db, &requests),
|
||||
Self::QuoteHistory(request) => request.read(db),
|
||||
Self::PricesHistory(request) => request.read(db),
|
||||
Self::LimitAmounts(request) => request.read(db),
|
||||
Self::Estimate(request) => request.read(db, books),
|
||||
Self::Resolution { market } => crate::resolution::read(db, &market),
|
||||
Self::Assets { market } => assets::market_assets(db, &market),
|
||||
@@ -335,7 +337,8 @@ impl Query {
|
||||
let minimum =
|
||||
crate::minimum_size::MinimumSize::load(db, &market)?.map(|size| size.text());
|
||||
Ok(
|
||||
json!({"asset_id":assets::id(&market,&outcome),"market":market,"outcome":outcome,"phase":phase,"bids":bids,"asks":asks,"min_order_size":minimum}),
|
||||
json!({"asset_id":assets::id(&market,&outcome),"market":market,"outcome":outcome,"phase":phase,"bids":bids,"asks":asks,"min_order_size":minimum,
|
||||
"tick_size":crate::tick_size::TickSize::load(db,&market)?.map(|tick|tick.text())}),
|
||||
)
|
||||
}
|
||||
Self::Quote { market, outcome } => {
|
||||
@@ -398,10 +401,11 @@ impl Query {
|
||||
let mut stmt = db.prepare(
|
||||
"SELECT s.market,COALESCE(a.question,s.question),yes_label,no_label,terms,source,resolver,rules_version,
|
||||
m.rules,m.phase,COALESCE(a.name,group_title),group_order,n.group_id,n.ordinal,
|
||||
a.role,a.clarification,a.named_at,minimum.microshares
|
||||
a.role,a.clarification,a.named_at,minimum.microshares,tick.step_micros
|
||||
FROM listed_markets s JOIN markets m ON m.id=s.market
|
||||
LEFT JOIN neg_risk_members n ON n.market=s.market
|
||||
LEFT JOIN augmented_outcomes a ON a.market=s.market
|
||||
LEFT JOIN market_tick_sizes tick ON tick.market=s.market
|
||||
LEFT JOIN market_minimum_sizes minimum ON minimum.market=s.market
|
||||
WHERE event=? AND (a.role IS NULL OR a.role<>'placeholder') ORDER BY group_order,s.market"
|
||||
)?;
|
||||
@@ -426,6 +430,7 @@ impl Query {
|
||||
"augmented_role":r.get::<_,Option<String>>(14)?,
|
||||
"clarification":r.get::<_,Option<String>>(15)?,
|
||||
"named_at":r.get::<_,Option<i64>>(16)?,
|
||||
"tick_size":r.get::<_,Option<i64>>(18)?.map(|v|crate::tick_size::TickSize(v).text()),
|
||||
"min_order_size":r.get::<_,Option<i64>>(17)?.map(crate::minimum_size::MinimumSize::format_microshares),
|
||||
"source":r.get::<_,String>(5)?,
|
||||
"resolver":r.get::<_,String>(6)?,
|
||||
|
||||
@@ -14,6 +14,7 @@ pub(crate) enum Command {
|
||||
rules: String,
|
||||
taker_fee_rate_ppm: Option<i64>,
|
||||
min_order_size: Option<String>,
|
||||
tick_size: Option<String>,
|
||||
#[serde(default)]
|
||||
listing: Option<crate::catalog::Listing>,
|
||||
resolution: Option<crate::resolution::Policy>,
|
||||
|
||||
@@ -39,29 +39,18 @@ impl Request {
|
||||
amount_cents,
|
||||
max_price,
|
||||
tif,
|
||||
} => (
|
||||
market,
|
||||
outcome,
|
||||
Side::Buy,
|
||||
amount_cents,
|
||||
max_price.unwrap_or(100),
|
||||
tif,
|
||||
),
|
||||
} => (market, outcome, Side::Buy, amount_cents, max_price, tif),
|
||||
Self::Sell {
|
||||
market,
|
||||
outcome,
|
||||
qty,
|
||||
min_price,
|
||||
tif,
|
||||
} => (
|
||||
market,
|
||||
outcome,
|
||||
Side::Sell,
|
||||
qty,
|
||||
min_price.unwrap_or(0),
|
||||
tif,
|
||||
),
|
||||
} => (market, outcome, Side::Sell, qty, min_price, tif),
|
||||
};
|
||||
let tick = crate::tick_size::TickSize::load(tx, &market)?;
|
||||
let edge = tick.as_ref().map_or(0, |t| i64::from(t.local_step().get()));
|
||||
let limit = limit.unwrap_or(if side == Side::Buy { 100 - edge } else { edge });
|
||||
let tif = tif.unwrap_or(TimeInForce::Fak);
|
||||
amount(requested)?;
|
||||
ensure!(
|
||||
@@ -72,6 +61,9 @@ impl Request {
|
||||
matches!(outcome.as_str(), "YES" | "NO") && (0..=100).contains(&limit),
|
||||
"invalid outcome or price"
|
||||
);
|
||||
if let Some(tick) = tick {
|
||||
tick.check(limit * 10000)?;
|
||||
}
|
||||
phase(tx, &market, &["continuous"])?;
|
||||
let rate = crate::fees::rate(tx, &market)?;
|
||||
if let Some(minimum) = crate::minimum_size::MinimumSize::load(tx, &market)? {
|
||||
|
||||
@@ -27,6 +27,7 @@ mod public_trades;
|
||||
mod quotes;
|
||||
mod resident;
|
||||
mod resolution;
|
||||
mod tick_size;
|
||||
use resident::Books;
|
||||
|
||||
use anyhow::{ensure, Context, Result};
|
||||
@@ -98,6 +99,7 @@ impl Exchange {
|
||||
Some(
|
||||
"assets"
|
||||
| "estimate"
|
||||
| "limit_amounts"
|
||||
| "catalog"
|
||||
| "events"
|
||||
| "history"
|
||||
|
||||
@@ -51,6 +51,7 @@ pub(crate) fn apply(
|
||||
resolution,
|
||||
taker_fee_rate_ppm,
|
||||
min_order_size,
|
||||
tick_size,
|
||||
} => {
|
||||
identifier(&market)?;
|
||||
ensure!(!rules.trim().is_empty(), "rules required");
|
||||
@@ -58,6 +59,9 @@ pub(crate) fn apply(
|
||||
"INSERT INTO markets(id,rules,phase) VALUES(?,?,'preopen')",
|
||||
params![market, rules],
|
||||
)?;
|
||||
if let Some(tick) = tick_size {
|
||||
crate::tick_size::TickSize::configure(tx, &market, &tick)?;
|
||||
}
|
||||
if let Some(size) = min_order_size {
|
||||
crate::minimum_size::MinimumSize::configure(tx, &market, &size)?;
|
||||
}
|
||||
@@ -261,7 +265,9 @@ pub(crate) fn apply(
|
||||
let book = books
|
||||
.get(&market, &outcome)
|
||||
.ok_or_else(|| anyhow::anyhow!("missing auction book"))?;
|
||||
book::settle(tx, &market, &outcome, book.opening(), None)?;
|
||||
let step = crate::tick_size::TickSize::load(tx, &market)?
|
||||
.map_or(std::num::NonZeroU32::MIN, |tick| tick.local_step());
|
||||
book::settle(tx, &market, &outcome, book.opening_with_step(step), None)?;
|
||||
}
|
||||
tx.execute("UPDATE markets SET phase='continuous' WHERE id=?", [market])?;
|
||||
Ok(json!({"phase":"continuous"}))
|
||||
|
||||
@@ -58,8 +58,12 @@ impl MinimumSize {
|
||||
}
|
||||
|
||||
pub fn check_shares(&self, qty: i64) -> Result<()> {
|
||||
self.check_microshares(qty * SCALE)
|
||||
}
|
||||
|
||||
pub fn check_microshares(&self, shares: i64) -> Result<()> {
|
||||
ensure!(
|
||||
qty * SCALE >= self.0,
|
||||
shares >= self.0,
|
||||
"order is below min_order_size of {} shares",
|
||||
self.text()
|
||||
);
|
||||
|
||||
@@ -260,3 +260,8 @@ CREATE TABLE IF NOT EXISTS market_minimum_sizes (
|
||||
market TEXT PRIMARY KEY REFERENCES markets(id),
|
||||
microshares INTEGER NOT NULL CHECK(microshares BETWEEN 1 AND 1000000000000000)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS market_tick_sizes (
|
||||
market TEXT PRIMARY KEY REFERENCES markets(id),
|
||||
step_micros INTEGER NOT NULL CHECK(step_micros IN (100000,10000,5000,2500,1000,100))
|
||||
);
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
use crate::{assets, minimum_size::MinimumSize};
|
||||
use anyhow::{ensure, Result};
|
||||
use rusqlite::{params, Connection, OptionalExtension, Transaction};
|
||||
use serde::Deserialize;
|
||||
use serde_json::{json, Value};
|
||||
use std::num::NonZeroU32;
|
||||
|
||||
pub(crate) struct TickSize(pub i64);
|
||||
|
||||
impl TickSize {
|
||||
pub fn configure(tx: &Transaction, market: &str, value: &str) -> Result<()> {
|
||||
let micros = match value.trim_end_matches('0') {
|
||||
"0.1" => 100_000,
|
||||
"0.01" => 10_000,
|
||||
"0.005" => 5_000,
|
||||
"0.0025" => 2_500,
|
||||
"0.001" => 1_000,
|
||||
"0.0001" => 100,
|
||||
_ => anyhow::bail!("unsupported tick_size"),
|
||||
};
|
||||
tx.execute(
|
||||
"INSERT INTO market_tick_sizes(market,step_micros) VALUES(?,?)",
|
||||
params![market, micros],
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn load(db: &Connection, market: &str) -> Result<Option<Self>> {
|
||||
Ok(db
|
||||
.prepare_cached("SELECT step_micros FROM market_tick_sizes WHERE market=?")?
|
||||
.query_row([market], |r| Ok(Self(r.get(0)?)))
|
||||
.optional()?)
|
||||
}
|
||||
|
||||
pub fn text(&self) -> String {
|
||||
format!("0.{:06}", self.0).trim_end_matches('0').to_owned()
|
||||
}
|
||||
|
||||
pub fn check(&self, price: i64) -> Result<()> {
|
||||
ensure!(
|
||||
(self.0..=1_000_000 - self.0).contains(&price) && price % self.0 == 0,
|
||||
"price outside trading range or off tick_size {}",
|
||||
self.text()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn local_step(&self) -> NonZeroU32 {
|
||||
// Each supported sub-cent step divides one cent exactly.
|
||||
NonZeroU32::new((self.0 / 10_000).max(1) as u32).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
enum Side {
|
||||
Buy,
|
||||
Sell,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub(crate) struct LimitAmounts {
|
||||
market: String,
|
||||
outcome: String,
|
||||
side: Side,
|
||||
price_micros: i64,
|
||||
size_micros: i64,
|
||||
}
|
||||
|
||||
impl LimitAmounts {
|
||||
pub fn read(self, db: &Connection) -> Result<Value> {
|
||||
ensure!(
|
||||
matches!(self.outcome.as_str(), "YES" | "NO"),
|
||||
"invalid outcome"
|
||||
);
|
||||
let tick = TickSize::load(db, &self.market)?
|
||||
.ok_or_else(|| anyhow::anyhow!("listed market with configured tick_size required"))?;
|
||||
tick.check(self.price_micros)?;
|
||||
ensure!(
|
||||
(10_000..=1_000_000_000_000_000).contains(&self.size_micros),
|
||||
"invalid share size"
|
||||
);
|
||||
let shares = self.size_micros / 10_000 * 10_000;
|
||||
if let Some(minimum) = MinimumSize::load(db, &self.market)? {
|
||||
minimum.check_microshares(shares)?;
|
||||
}
|
||||
// Every supported step times 0.01 shares is an integer number of micros.
|
||||
let collateral = i128::from(self.price_micros) * i128::from(shares) / 1_000_000;
|
||||
let (maker, taker) = match self.side {
|
||||
Side::Buy => (collateral, i128::from(shares)),
|
||||
Side::Sell => (i128::from(shares), collateral),
|
||||
};
|
||||
Ok(
|
||||
json!({"asset_id":assets::id(&self.market,&self.outcome),"tick_size":tick.text(),
|
||||
"price_micros":self.price_micros,"size_micros":shares,"collateral_micros":collateral,
|
||||
"makerAmount":maker.to_string(),"takerAmount":taker.to_string(),
|
||||
"local_precision_supported":self.price_micros%10000==0 && shares%1_000_000==0}),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -2184,3 +2184,55 @@ fn collateral_query_reconciles_subcent_funding_reservations_and_trade() {
|
||||
.execute(json!({"op":"balance","account":"invalid"}))
|
||||
.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn configured_ticks_bind_order_amounts_execution_and_opening_price() {
|
||||
let dir = tempdir().unwrap();
|
||||
let path = dir.path().join("ticks.db");
|
||||
let mut exchange = Exchange::open(&path).unwrap();
|
||||
for line in include_str!("../../../docs/examples/tick-size.jsonl").lines() {
|
||||
let request: Value = serde_json::from_str(line).unwrap();
|
||||
let result = exchange.execute(request.clone()).unwrap();
|
||||
if request["op"] == "limit_amounts" {
|
||||
assert_eq!(result["size_micros"], 5120000);
|
||||
assert_eq!(result["collateral_micros"], 66560);
|
||||
assert_eq!(result["local_precision_supported"], false);
|
||||
let (maker, taker) = if request["side"] == "buy" {
|
||||
("66560", "5120000")
|
||||
} else {
|
||||
("5120000", "66560")
|
||||
};
|
||||
assert_eq!(result["makerAmount"], maker);
|
||||
assert_eq!(result["takerAmount"], taker);
|
||||
}
|
||||
if request["op"] == "book" {
|
||||
assert_eq!(result["tick_size"], "0.001");
|
||||
}
|
||||
if request["op"] == "state" {
|
||||
assert_eq!(result["fills"][0]["price"], 60);
|
||||
}
|
||||
}
|
||||
drop(exchange);
|
||||
let mut e = Exchange::open(path).unwrap();
|
||||
let before = state(&mut e);
|
||||
for bad in [
|
||||
json!({"op":"order","id":"bad","market":"coarse","outcome":"NO","account":"bob","price":51,"qty":1,"side":"buy"}),
|
||||
json!({"op":"market_sell","id":"bad","market":"coarse","outcome":"YES","account":"bob","min_price":51,"qty":1}),
|
||||
json!({"op":"market_buy","id":"bad","market":"coarse","outcome":"YES","account":"bob","max_price":51,"amount_cents":90}),
|
||||
json!({"op":"estimate","market":"coarse","outcome":"YES","side":"buy","max_price":51,"amount_cents":90}),
|
||||
json!({"op":"limit_amounts","asset_id":"eb:YES:sample-559651","side":"buy","price_micros":13100,"size_micros":5000000}),
|
||||
json!({"op":"limit_amounts","asset_id":"eb:YES:sample-559651","side":"buy","price_micros":13000,"size_micros":4999999}),
|
||||
json!({"op":"list","id":"invalid","market":"legacy","rules":"r","tick_size":"0.03"}),
|
||||
] {
|
||||
assert!(e.execute(bad).is_err());
|
||||
}
|
||||
assert_eq!(state(&mut e), before);
|
||||
assert_eq!(
|
||||
e.execute(json!({"op":"assets","market":"coarse"})).unwrap()["tick_size"],
|
||||
"0.1"
|
||||
);
|
||||
e.execute(json!({"op":"list","id":"invalid","market":"legacy","rules":"r"}))
|
||||
.unwrap();
|
||||
assert!(e.execute(json!({"op":"assets","market":"legacy"})).unwrap()["tick_size"].is_null());
|
||||
e.execute(json!({"op":"order","id":"old","market":"legacy","outcome":"YES","account":"bob","side":"buy","price":0,"qty":1})).unwrap();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
{"op":"list","id":"fine","market":"sample-559651","rules":"Simulated sample","tick_size":"0.001","min_order_size":"5"}
|
||||
{"op":"book","asset_id":"eb:YES:sample-559651"}
|
||||
{"op":"limit_amounts","asset_id":"eb:YES:sample-559651","side":"buy","price_micros":13000,"size_micros":5129999}
|
||||
{"op":"limit_amounts","asset_id":"eb:YES:sample-559651","side":"sell","price_micros":13000,"size_micros":5129999}
|
||||
{"op":"list","id":"coarse","market":"coarse","rules":"Simulated auction","tick_size":"0.1"}
|
||||
{"op":"fund","id":"maker","account":"alice","cents":2000}
|
||||
{"op":"fund","id":"taker","account":"bob","cents":2000}
|
||||
{"op":"split","id":"s","market":"coarse","account":"alice","qty":2}
|
||||
{"op":"order","id":"ask","market":"coarse","account":"alice","side":"sell","outcome":"YES","price":50,"qty":2}
|
||||
{"op":"order","id":"b1","market":"coarse","account":"bob","side":"buy","outcome":"YES","price":50,"qty":3}
|
||||
{"op":"order","id":"b2","market":"coarse","account":"bob","side":"buy","outcome":"YES","price":70,"qty":2}
|
||||
{"op":"open","id":"o","market":"coarse"}
|
||||
{"op":"state"}
|
||||
@@ -230,3 +230,11 @@ list 接受十进制份额字符串,最多六位小数;book、assets 和事
|
||||
[现金与费用样例](examples/cash-balance.jsonl)中,买家以 512500 微单位开户,先挂 49 分买单,仍有 22500 微单位可用。撤单后以 50 分买入一份,费率 0.05,对应费用 12500 微单位,买方余额恰为零。若初始现金少一个微单位,交易整体回滚。
|
||||
|
||||
费用函数使用六位小数的价格计算本金两侧的价格因子。例如 5 份、单价 0.013、费率 0.05,按目前的逐笔五位小数舍入约定收取 3210 微单位。正常下单入口的价格和预算仍以分输入;该价格算例覆盖费用运算,细价格限价单的提交与交割仍待接入。官方 SDK 对限价单按市场步长和数量精度推导抵押金额。这里的 fund 和 balance 是本地模拟账本接口,外场的授权额度及链上钱包余额需要分别对照。[官方 SDK 的订单金额计算](https://github.com/Polymarket/py-clob-client-v2/blob/main/py_clob_client_v2/order_builder/builder.py) · [官方费用公式](https://docs.polymarket.com/trading/fees.md)
|
||||
|
||||
## 价格步长与限价单编码
|
||||
|
||||
list 可传 tick_size 字符串。资产、盘口与赛事目录返回配置的步长。当前支持 0.1、0.01、0.005、0.0025、0.001、0.0001 美元。配置市场的委托价及市价单保护价必须在 [tick, 1−tick] 且为步长的整数倍。官方对 0.0025 的应用限定于指定世界杯盘型;模拟市场允许操作员配置六种网格,未按赛事资格过滤。步长在本次上架时固定,生产市场推送的 tick_size_change 尚待接入。未配置的旧盘返回 null,延续原有整分交易范围。[官方交易约束](https://docs.polymarket.com/market-data/market-details.md#trading-constraints)
|
||||
|
||||
[限价金额重放样例](examples/tick-size.jsonl)使用 Gamma 市场 559651 曾公开的 0.001 步长和 0.013 报价。limit_amounts 接收整数 price_micros 和 size_micros,后者向下取到百分之一份后检查最小份额。5.129999 份得到 5.12 份,抵押金额为 0.06656 模拟美元。买单的 makerAmount 为字符串 66560,takerAmount 为 5120000,卖单反向。回执的 local_precision_supported 仅描述价格和舍入后数量能否经现有整分、整份订单入口表示。预览不预留资金,不签名、不发送外场订单。官方六档的价格小数位数加两位份额精度均不超过六位,网格上的上述整数乘法可精确编码。[官方限价金额映射](https://docs.polymarket.com/trading/place-orders.md#limit-orders)
|
||||
|
||||
样例还包含一个步长 0.1 的本地集合竞价。50 分卖 2 份,对手分别以 50 分买 3 份、70 分买 2 份,开盘以 60 分成交 2 份。同一组订单若步长为 1 分,开盘价是 51 分。细于一分的市场目前只接受其与整分网格重合的本地委托价格。
|
||||
|
||||
Reference in New Issue
Block a user