[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HYYTQQR4EERNX7BA5ABTSY":3,"skill-same:01M6HYYTQQR4EERNX7BA5ABTSY":79},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":40,"linkOnly":41,"markdownContent":42,"markdownBody":43,"frontMatter":44,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":55,"repositoryHtmlUrl":50,"repositoryHomepageUrl":56,"ownerHtmlUrl":57,"ownerBlogUrl":58,"ownerDescription":6,"updatedAt":59,"install":60,"resources":72},"01M6HYYTQQR4EERNX7BA5ABTSY","price-handling",null,"Load when comparing, rounding, formatting, or parsing prices, or designing price types.","vanillagreencom\u002Fkendex","vanillagreencom","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F960140?v=4","01M6HYKK40E293HJHZHAXBHRP3","vanillagreen","01M6HYKK8C03G1JWBP1S14HHFN",93,"MIT","https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fblob\u002Fmain\u002Fskills\u002Fprice-handling\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39],"price handling","price","when","github","for","prices","display","load","broker","true","size","types","systems","patterns","trading","Market","parsing","feeds","data","https","issues","2026-11-10 10:12:30",false,"---\nname: price-handling\ndescription: \"Load when comparing, rounding, formatting, or parsing prices, or designing price types.\"\nsummary: \"f64 price patterns for trading systems: comparing prices, rounding to tick size, formatting for display and broker APIs, parsing market feeds, designing price types.\"\nlicense: MIT\nuser-invocable: true\nmetadata:\n  author: vanillagreen\n  source: kendex\n  repository: \"https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\"\n  bugs: \"https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fissues\"\ntags: [data]\n---\n\n# Price Handling Patterns\n\n## The price type is `f64`\n\nIEEE 754 double precision. No fixed-point, no decimal types.\n\nUse `i64` fixed-point **only** for a matching engine (bit-exact required), a regulatory audit trail mandating reproducibility, or a settlement system with legal precision requirements. Hybrid: `i64` on the execution hot path, `f64` for display and analytics.\n\n## Never `==` on prices\n\n```rust\nuse float_cmp::{approx_eq, F64Margin};\n\npub const PRICE_EPSILON: f64 = 1e-10;  \u002F\u002F sub-pipette tolerance\n\npub fn prices_equal(a: f64, b: f64) -> bool {\n    approx_eq!(f64, a, b, epsilon = PRICE_EPSILON, ulps = 4)\n}\n\npub fn price_gte(a: f64, b: f64) -> bool { a > b || prices_equal(a, b) }\npub fn price_lte(a: f64, b: f64) -> bool { a \u003C b || prices_equal(a, b) }\n```\n\n## Round only at the boundaries\n\n| Boundary | Rounding |\n|---|---|\n| Order submission (OrderRequest → broker API) | Round to tick, then validate alignment |\n| Display formatting | Round to the symbol's `display_decimals` |\n| Market data ingestion (ticks, bars, quotes) | **Never**. Preserve full feed precision |\n| P&L calculation | **Never**. Use raw values |\n\n```rust\npub fn round_to_tick(price: f64, tick_size: f64) -> f64 {\n    (price \u002F tick_size).round() * tick_size\n}\n\npub fn validate_tick_alignment(price: f64, tick_size: f64) -> bool {\n    prices_equal(price, round_to_tick(price, tick_size))\n}\n```\n\nOrder submission order: round to tick, validate alignment (on failure return an error, never re-round), then format for the broker API if it takes a string.\n\nFormat with the symbol's precision, never hardcoded decimals (EURUSD 5, AAPL 2, BTC 8):\n\n```rust\nformat!(\"{:.1$}\", price, symbol.display_decimals as usize)\n```\n\n## Symbol metadata owns precision\n\nTick size and display precision belong to the symbol, not to the price value. A `Price { value, decimals }` struct is the wrong shape.\n\n```rust\n#[derive(Clone, Copy)]\npub struct SymbolSpec {\n    pub symbol_id: u32,\n    pub tick_size: f64,         \u002F\u002F minimum price increment\n    pub display_decimals: u8,   \u002F\u002F decimal places for UI\n    pub lot_size: f64,          \u002F\u002F minimum quantity\n}\n\nimpl SymbolSpec {\n    pub fn round_price(&self, price: f64) -> f64 {\n        round_to_tick(price, self.tick_size)\n    }\n\n    pub fn format_price(&self, price: f64) -> String {\n        format!(\"{:.1$}\", price, self.display_decimals as usize)\n    }\n}\n```\n\nThe symbol table loads at subscription setup (cold path), is keyed by symbol ID, and re-syncs on reconnect or symbol list change.\n\n## Price newtype\n\nOptional: wrap `f64` in a `#[repr(transparent)]` newtype with `PartialOrd` but **no `PartialEq`**; equality goes through `prices_equal`. Constructor `debug_assert!`s `is_finite()`. Use for order types; skip on the market-data hot path.\n\n## Normalize feeds to `f64` at ingest\n\nConvert at the entry boundary; downstream code sees plain `f64` regardless of feed source.\n\n```rust\n\u002F\u002F doubles (IB, dxFeed, Rithmic): pass through\nfn ingest_double(value: f64) -> f64 { value }\n\n\u002F\u002F strings (Binance, Coinbase): parse\nfn ingest_string(s: &str) -> Result\u003Cf64, ParseFloatError> { s.parse() }\n\n\u002F\u002F scaled integers (CME MDP): unscale\nfn ingest_scaled(mantissa: i64, exponent: i8) -> f64 {\n    mantissa as f64 * 10f64.powi(exponent as i32)\n}\n```\n","# Price Handling Patterns\n\n## The price type is `f64`\n\nIEEE 754 double precision. No fixed-point, no decimal types.\n\nUse `i64` fixed-point **only** for a matching engine (bit-exact required), a regulatory audit trail mandating reproducibility, or a settlement system with legal precision requirements. Hybrid: `i64` on the execution hot path, `f64` for display and analytics.\n\n## Never `==` on prices\n\n```rust\nuse float_cmp::{approx_eq, F64Margin};\n\npub const PRICE_EPSILON: f64 = 1e-10;  \u002F\u002F sub-pipette tolerance\n\npub fn prices_equal(a: f64, b: f64) -> bool {\n    approx_eq!(f64, a, b, epsilon = PRICE_EPSILON, ulps = 4)\n}\n\npub fn price_gte(a: f64, b: f64) -> bool { a > b || prices_equal(a, b) }\npub fn price_lte(a: f64, b: f64) -> bool { a \u003C b || prices_equal(a, b) }\n```\n\n## Round only at the boundaries\n\n| Boundary | Rounding |\n|---|---|\n| Order submission (OrderRequest → broker API) | Round to tick, then validate alignment |\n| Display formatting | Round to the symbol's `display_decimals` |\n| Market data ingestion (ticks, bars, quotes) | **Never**. Preserve full feed precision |\n| P&L calculation | **Never**. Use raw values |\n\n```rust\npub fn round_to_tick(price: f64, tick_size: f64) -> f64 {\n    (price \u002F tick_size).round() * tick_size\n}\n\npub fn validate_tick_alignment(price: f64, tick_size: f64) -> bool {\n    prices_equal(price, round_to_tick(price, tick_size))\n}\n```\n\nOrder submission order: round to tick, validate alignment (on failure return an error, never re-round), then format for the broker API if it takes a string.\n\nFormat with the symbol's precision, never hardcoded decimals (EURUSD 5, AAPL 2, BTC 8):\n\n```rust\nformat!(\"{:.1$}\", price, symbol.display_decimals as usize)\n```\n\n## Symbol metadata owns precision\n\nTick size and display precision belong to the symbol, not to the price value. A `Price { value, decimals }` struct is the wrong shape.\n\n```rust\n#[derive(Clone, Copy)]\npub struct SymbolSpec {\n    pub symbol_id: u32,\n    pub tick_size: f64,         \u002F\u002F minimum price increment\n    pub display_decimals: u8,   \u002F\u002F decimal places for UI\n    pub lot_size: f64,          \u002F\u002F minimum quantity\n}\n\nimpl SymbolSpec {\n    pub fn round_price(&self, price: f64) -> f64 {\n        round_to_tick(price, self.tick_size)\n    }\n\n    pub fn format_price(&self, price: f64) -> String {\n        format!(\"{:.1$}\", price, self.display_decimals as usize)\n    }\n}\n```\n\nThe symbol table loads at subscription setup (cold path), is keyed by symbol ID, and re-syncs on reconnect or symbol list change.\n\n## Price newtype\n\nOptional: wrap `f64` in a `#[repr(transparent)]` newtype with `PartialOrd` but **no `PartialEq`**; equality goes through `prices_equal`. Constructor `debug_assert!`s `is_finite()`. Use for order types; skip on the market-data hot path.\n\n## Normalize feeds to `f64` at ingest\n\nConvert at the entry boundary; downstream code sees plain `f64` regardless of feed source.\n\n```rust\n\u002F\u002F doubles (IB, dxFeed, Rithmic): pass through\nfn ingest_double(value: f64) -> f64 { value }\n\n\u002F\u002F strings (Binance, Coinbase): parse\nfn ingest_string(s: &str) -> Result\u003Cf64, ParseFloatError> { s.parse() }\n\n\u002F\u002F scaled integers (CME MDP): unscale\nfn ingest_scaled(mantissa: i64, exponent: i8) -> f64 {\n    mantissa as f64 * 10f64.powi(exponent as i32)\n}\n```\n",{"name":5,"tags":45,"license":15,"summary":46,"metadata":47,"description":7,"user-invocable":51},[37],"f64 price patterns for trading systems: comparing prices, rounding to tick size, formatting for display and broker APIs, parsing market feeds, designing price types.",{"bugs":48,"author":12,"source":49,"repository":50},"https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fissues","kendex","https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex",true,"main","0ed06e4c0bac91ac09d898349d1c5a34c98aa996","skills\u002Fprice-handling",37,"https:\u002F\u002Fkendex.ai","https:\u002F\u002Fgithub.com\u002Fvanillagreencom","http:\u002F\u002Fvanillagreen.com","2026-11-13 03:56:19",{"source":8,"skillName":5,"commands":61,"prompt":71,"zipAvailable":51},[62,65,68],{"tool":63,"command":64},"npx","npx skills add vanillagreencom\u002Fkendex --skill price-handling",{"tool":66,"command":67},"bunx","bunx skills add vanillagreencom\u002Fkendex --skill price-handling",{"tool":69,"command":70},"pnpm","pnpm dlx skills add vanillagreencom\u002Fkendex --skill price-handling","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fblob\u002Fmain\u002Fskills\u002Fprice-handling\u002FSKILL.md",[73],{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},"README.md","REFERENCE","参考文档",793,"https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fblob\u002Fmain\u002Fskills\u002Fprice-handling\u002FREADME.md",[80,102,133,156,195,223],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":40},"01M6HZ0GYHMRX8JCH9RPPAY59N","youtube-publish","Load to draft a YouTube upload, comment or reply, or send a draft after the user's recorded approval.","https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-publish\u002FSKILL.md",[],[87,88,89,90,39,28,91,26,92,93,94,95,96,97,22,98,38,37,99,100,101],"youtube publish","publish","youtube","youtube upload","publishing","upload","api","synthetic","check","draft","with","integration","youtube data","content","send",{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":113,"publishedAt":40},"01M6HZ0CT05TA9746ZG5Q4K1E0","xcode-run","Load to install or dispatch a macOS GitHub Actions build, test or simulator screenshot run for an Xcode project.","https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fblob\u002Fmain\u002Fskills\u002Fxcode-run\u002FSKILL.md",[108],{"categoryNo":109,"categoryName":110,"taxonomyType":111,"taxonomyTypeDesc":112},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[114,115,116,117,118,119,120,39,121,122,123,124,125,126,127,128,129,130,131,132],"xcode","run","xcode run","SET","project","actions","testing","github actions","workflows","workflow","logs","delete","artifact","scripts","repository","install","screenshot","macos","screenshots",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":40},"01M6HZ060RP0FKH75JKN214909","worktree","Load to create, list, remove, push, or repair a git worktree.","https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fblob\u002Fmain\u002Fskills\u002Fworktree\u002FSKILL.md",[],[135,140,141,39,142,143,144,145,146,147,148,149,150,151,152,28,153,154,26,155],"branch","remove","create","git worktree","config","git","list","path","push","repair","conflict","pr","continue","reuse","replay","keep",{"skillNo":157,"name":158,"nameZh":6,"description":159,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":160,"sourceHtmlUrl":161,"categories":162,"keywords":177,"publishedAt":40},"01M6HZ01AB8P28NTWWMHDMTM0A","social-media-content-calendar","Load to plan a social media campaign, build a content calendar, or adapt existing material into post drafts.","https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fblob\u002Fmain\u002Fskills\u002Fsocial-media-content-calendar\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fblob\u002Fmain\u002Fskills\u002Fsocial-media-content-calendar\u002FSKILL.md",[163,166,169,174],{"categoryNo":164,"categoryName":165,"taxonomyType":111,"taxonomyTypeDesc":112},"01JBSEEDCAT000000000000019","营销推广",{"categoryNo":167,"categoryName":168,"taxonomyType":111,"taxonomyTypeDesc":112},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":170,"categoryName":171,"taxonomyType":172,"taxonomyTypeDesc":173},"01JBSEEDCAT000000000000035","市场营销","PROFESSION","适用职业",{"categoryNo":175,"categoryName":176,"taxonomyType":172,"taxonomyTypeDesc":173},"01JBSEEDCAT000000000000036","内容创作者",[178,179,180,181,182,183,100,184,39,185,186,187,188,189,190,191,23,192,28,193,194],"Media","social","calendar","content calendar","social media content calendar","social media","adaptation","campaign","plan","drafts","asset","briefs","platform","planning","adapt","material","approval gate",{"skillNo":196,"name":197,"nameZh":6,"description":198,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":199,"categories":200,"keywords":204,"publishedAt":40},"01M6HYZS25D7RJK8CZ93MCZ3V8","slack","Load to bind an overseer's mailbox to a private Slack channel, run or check the relay, or post an alert or a file to Slack.","https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fblob\u002Fmain\u002Fskills\u002Fslack\u002FSKILL.md",[201],{"categoryNo":202,"categoryName":203,"taxonomyType":111,"taxonomyTypeDesc":112},"01JBSEEDCAT000000000000005","邮件与沟通",[197,205,206,207,208,209,210,211,212,39,28,26,213,214,215,216,217,115,129,218,219,220,95,221,222],"bind","back","checkout","lane","relay","messages","socket","mode","compact","alert","orchestration","mail","communication","linear","receiver","file","store","post",{"skillNo":224,"name":225,"nameZh":6,"description":226,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":227,"categories":228,"keywords":229,"publishedAt":40},"01M6HYZHPANA68C9WQQ11A1B5Z","second-opinion","Load for a cross-model review, challenge, audit, or quick consult.","https:\u002F\u002Fgithub.com\u002Fvanillagreencom\u002Fkendex\u002Fblob\u002Fmain\u002Fskills\u002Fsecond-opinion\u002FSKILL.md",[],[230,231,232,233,234,235,23,236,39,237,238,28,239,26,240,241,242,243,22,244,38],"second opinion","second","quick","ai cli","scope","model","pi","copilot","challenge","question","consult","review","codex","cli","audit"]