{"record":{"id":"4c52caf1c489cde4","repo":"nautechsystems/nautilus_trader","slug":"invalid-peg-price-type-s","errorCode":null,"errorMessage":"Invalid peg_price_type: {s}","messagePattern":"Invalid peg_price_type: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/common/parse.rs","lineNumber":506,"sourceCode":"        is_reported,\n        event_id,\n        ts_event,\n        ts_init,\n        None,\n    ))\n}\n\n/// Extracts the peg price type from order command parameters.\n///\n/// # Errors\n///\n/// Returns an error if the value is present but not a valid `BitmexPegPriceType`.\npub fn parse_peg_price_type(params: Option<&Params>) -> anyhow::Result<Option<BitmexPegPriceType>> {\n    let value = params.and_then(|p| p.get_str(\"peg_price_type\"));\n    match value {\n        Some(s) => BitmexPegPriceType::from_str(s)\n            .map(Some)\n            .map_err(|_| anyhow::anyhow!(\"Invalid peg_price_type: {s}\")),\n        None => Ok(None),\n    }\n}\n\n/// Extracts the peg offset value from order command parameters.\n///\n/// # Errors\n///\n/// Returns an error if the value is present but not a valid `f64`.\npub fn parse_peg_offset_value(params: Option<&Params>) -> anyhow::Result<Option<f64>> {\n    let value = params.and_then(|p| p.get_str(\"peg_offset_value\"));\n    match value {\n        Some(s) => s\n            .parse::<f64>()\n            .map(Some)\n            .map_err(|_| anyhow::anyhow!(\"Invalid peg_offset_value: {s}\")),\n        None => Ok(None),\n    }","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/common/parse.rs#L488-L524","documentation":"parse_peg_price_type reads the optional peg_price_type string from order command Params and converts it to a BitmexPegPriceType. If the parameter is present but is not a recognized peg price type enum value, it returns this error instead of silently dropping the peg instruction.","triggerScenarios":"Submitting an order (submit_order or submit_order_list) with Params containing peg_price_type set to a string BitMEX adapter does not map (typo, wrong casing, unsupported peg type).","commonSituations":"Typos like 'MARKET' vs 'Market', passing Nautilus-native peg values not mapped to BitMEX's PegPriceType vocabulary, stale strategy code after adapter enum changes.","solutions":["Use an exact valid BitMEX peg price type string (e.g. 'ParticipateDoNotInitiate', 'MarketPeg') in peg_price_type","Check BitmexPegPriceType::from_str for the accepted values and match casing exactly","Remove peg_price_type from Params if pegging is not intended"],"exampleFix":"// before\nparams.insert(\"peg_price_type\", \"MARKET_PEG\");\n// after\nparams.insert(\"peg_price_type\", \"MarketPeg\");","handlingStrategy":"validation","validationCode":"const VALID_PEG_TYPES: [&str; 6] = [\"ParticipateDoNotInitiate\", \"MarketPeg\", \"PrimaryPeg\", \"MarkPrice\", \"LastPrice\", \"LastMidPrice\"];\nfn peg_type_ok(s: &str) -> bool { VALID_PEG_TYPES.contains(&s) }","typeGuard":"fn is_valid_peg(s: &str) -> bool { BitmexPegPriceType::from_str(s).is_ok() }","tryCatchPattern":"match client.submit_order(order) {\n    Err(e) if e.to_string().starts_with(\"Invalid peg_price_type\") => {\n        log::error!(\"fix peg_price_type param: {e}\");\n        // correct the param and resubmit\n    }\n    r => r?,\n}","preventionTips":["Use BitmexPegPriceType enum values, never hand-typed strings","Match BitMEX's exact casing for peg types","Add a unit test covering every peg_price_type your strategies emit"],"tags":["order-submission","enum-parsing","parameters"],"backgroundTag":"invalid-enum-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}