惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cisco Blogs
罗磊的独立博客
D
Docker
Microsoft Azure Blog
Microsoft Azure Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
V
V2EX
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cisco Talos Blog
Cisco Talos Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
I
InfoQ
S
Securelist
K
Kaspersky official blog
博客园 - 司徒正美
爱范儿
爱范儿
Scott Helme
Scott Helme
B
Blog RSS Feed
H
Help Net Security
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
Stack Overflow Blog
Stack Overflow Blog
AI
AI
Blog — PlanetScale
Blog — PlanetScale
Webroot Blog
Webroot Blog
P
Proofpoint News Feed
V
Visual Studio Blog
Cyberwarzone
Cyberwarzone
P
Privacy International News Feed
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
IT之家
IT之家
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
S
Security Affairs
T
Threat Research - Cisco Blogs
S
Security @ Cisco Blogs
The Register - Security
The Register - Security
F
Full Disclosure
A
Arctic Wolf
C
Check Point Blog
Recent Announcements
Recent Announcements
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
T
Tor Project blog
Latest news
Latest news
Schneier on Security
Schneier on Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Scarab Diagnostic Field Test #032 — QuantConnect Lean Option Target Quote-Side Pricing Boundary
Scarab Systems · 2026-06-18 · via DEV Community

Target: QuantConnect/Lean

Issue: QuantConnect/Lean#6360

PR: QuantConnect/Lean#9539

Field Lab: https://github.com/scarab-systems/scarab-field-lab

This field test targeted an option portfolio target sizing bug in QuantConnect Lean.

The issue concerned PortfolioTarget.Percent, which is used to calculate target quantities from a requested portfolio percentage.

The visible failure was serious for option strategies:

  • a user requested a target percentage for an option position
  • Lean calculated a target quantity
  • the final filled position could exceed the requested target weight
  • the discrepancy was tied to the option bid/ask spread
  • long option targets could be sized from a mid/last price even though the executable buy side was the ask

That is not just a small math mismatch.

For portfolio construction, target sizing is part of the risk contract.

If a user asks for a 10% option target, but the final filled position can land materially above that target because the sizing path used the wrong side of the quote, the engine has crossed a real boundary.

The diagnostic question was not:

How do we make all security target sizing use bid and ask?

The better question was:

Where does Lean price option premium/margin for target quantity calculation, and which quote side should that option-specific path use when quotes are available?

Field Lab record

The public case record for this field test is available in the Scarab Field Lab:

https://github.com/scarab-systems/scarab-field-lab

SDS result

This field test was recorded as a diagnostic-proof-and-repair case against QuantConnect Lean.

The useful result was a bounded pricing boundary.

The failure touched several tempting surfaces:

  • portfolio construction
  • PortfolioTarget.Percent
  • buying power calculation
  • option margin pricing
  • quote data
  • bid/ask spread
  • order fill behavior
  • final portfolio weight

That is exactly the kind of bug where a repair can drift.

A patch could try to change portfolio construction broadly.

A patch could try to change generic buying power behavior for every security type.

A patch could try to compensate after fill.

A patch could try to adjust target quantities in the execution layer.

But the owned repair surface was narrower.

For options, target sizing depends on the buying power model’s initial margin requirement. That option-specific margin path was using security.Price, which may reflect a last, mark, or mid-like value instead of the executable side of the quote.

For a long option target, the executable buy side is the ask when an ask is available.

For a short option target, the executable sell side is the bid when a bid is available.

That is the repair boundary.

Failure shape

The failure shape was a quote-side mismatch.

The user requested a target percentage.

Lean calculated a quantity using an option margin pricing path.

That path used security.Price.

But for options, the last or mark price can differ materially from the ask or bid.

So a long option target could be sized as if the option cost less than the price actually required to buy it.

Then, when the order filled closer to the ask, the final holdings cost could exceed the requested target weight.

In plain English:

the target calculation used a price that was not the executable buy-side price

That is why the error scaled with the bid/ask spread.

The wider the spread, the larger the possible gap between the sizing price and the actual fill-side price.

That makes this a finance-engine correctness issue, not a cosmetic pricing issue.

Boundary

The boundary here is:

option target margin pricing versus generic security price behavior

Lean should not need to rewrite PortfolioTarget.Percent for every security type to handle this case.

It should not need to change generic buying power behavior for all assets.

It should not need to force all target sizing to use quote-side logic universally.

But options have a specific pricing reality.

When an option quantity is positive, the target is increasing long exposure or buying premium. If an ask is available, the ask is the relevant executable side.

When an option quantity is negative, the target is selling or reducing from the opposite side. If a bid is available, the bid is the relevant executable side.

When quotes are not available, Lean should preserve the existing fallback behavior.

That is the clean boundary:

  • positive option quantity: use ask when available
  • negative option quantity: use bid when available
  • no quote available: fall back to existing last/mark behavior
  • keep the change local to option margin pricing

That is the repair lane.

What changed

The PR updates option margin pricing so target option quantities use available executable quote prices.

The change is intentionally local:

  • positive option quantities use the ask price when available
  • negative option quantities use the bid price when available
  • existing last/mark price behavior remains the fallback when quotes are unavailable

That means the repair does not change generic buying power behavior for other security types.

It does not rewrite portfolio target construction.

It does not alter execution models.

It corrects the option-specific pricing path used when calculating premium/margin value for a target option quantity.

The patch also adds regression coverage for both sides of the option quote boundary:

  • long-option ask pricing
  • short-option bid pricing

That matters because the bug was not simply “use ask.”

The correct side depends on the sign of the target quantity.

A long-side target and a short-side target should not be priced the same way.

Why this was not a generic portfolio construction fix

The visible symptom appeared through PortfolioTarget.Percent.

That makes it tempting to repair the portfolio construction layer.

But PortfolioTarget.Percent was not the true ownership surface.

The target helper depends on the security buying power model to calculate the quantity needed to reach a portfolio percentage.

For options, the buying power model’s initial margin path is where the premium/margin value is priced.

That is where the quote-side mismatch lived.

So the repair stayed there.

That is important.

Portfolio construction should not need to know every option bid/ask pricing detail.

Execution should not be responsible for repairing a quantity that was undersized or oversized before the order was placed.

The option margin model already owns option-specific premium/margin pricing.

That is where the patch belongs.

Why the fallback mattered

The fallback behavior is important.

The repair does not assume that bid and ask are always populated.

Market data can be incomplete.

Backtests can have different data shapes.

Some option securities may not have fresh quotes at the exact moment target sizing runs.

So the patch uses executable quote prices when available, but preserves the existing last/mark behavior when quotes are unavailable.

That keeps the repair narrow and compatible.

It improves the case where quote data is present without breaking the existing behavior for cases where quote data has not been populated.

That is the right kind of platform patch:

use better truth when the engine has it, preserve the old path when it does not

Why the diagnostic result mattered

This case is useful because it sits inside a high-stakes financial calculation.

A target percentage is not just a display value.

It is part of the algorithm’s risk expression.

If the engine calculates the wrong quantity from that target, the algorithm can take more exposure than requested.

That matters especially for options because spreads can be wide, prices can move quickly, and executable quote-side pricing can differ meaningfully from last or mark values.

The diagnostic posture helped keep the repair framed around the actual contract:

  • the user expresses a target weight
  • Lean calculates a target quantity
  • the option margin path prices the quantity
  • available quote data should align that price with the executable side
  • the final position should not exceed the requested target because sizing used a stale or non-executable price

That framing kept the patch small.

It avoided a broad portfolio construction rewrite.

It avoided execution-layer compensation.

It avoided changing generic security behavior.

It repaired the option-specific margin pricing boundary.

Validation

Validation was completed in QuantConnect’s foundation container.

The release build passed.

Focused option-margin tests passed:

41/41

The new regression coverage includes:

  • long-option ask pricing
  • short-option bid pricing

A full local arm64 suite run had two unrelated failures.

Both failures reproduced on unchanged upstream master in the same foundation-container environment, so they were documented in the PR rather than claimed as branch failures.

That is the correct validation posture.

The focused option-margin coverage passed, the release build passed, and the unrelated local full-suite failures were not hidden or misrepresented.

At the time of this report, the PR is reopened and marked ready for review.

Field test result

This was a bounded option margin pricing repair candidate for QuantConnect Lean.

The issue reduced to:

  • PortfolioTarget.Percent calculates target quantities from a requested portfolio percentage
  • for options, that calculation depends on initial margin pricing
  • the existing option margin path used security.Price
  • security.Price could reflect a last, mark, or mid-like price
  • long option targets could therefore be sized below the actual ask-side cost
  • the final filled position weight could exceed the requested target
  • the repair uses ask for positive option quantities when available
  • the repair uses bid for negative option quantities when available
  • the existing last/mark behavior remains the fallback when quotes are unavailable
  • focused tests cover long ask pricing and short bid pricing
  • release build and focused option-margin validation passed

That is the repair lane.

This patch does not claim to redesign portfolio construction.

It does not claim to change generic buying power behavior for all security types.

It does not claim to alter execution models.

It does not claim to guarantee exact final weights under every fill condition.

It fixes the option-specific margin pricing boundary where target quantity calculation should use the executable side of the quote when that quote is available.

Public claim

The correct claim for this field test is:

Scarab/SDS helped drive a bounded repair candidate for QuantConnect/Lean#6360, where PortfolioTarget.Percent could size option targets using security.Price instead of the executable side of the quote. For long option targets, that could understate cost when the ask was higher and allow the final position weight to exceed the requested target. The upstream PR updates option margin pricing so positive option quantities use the ask price when available, negative option quantities use the bid price when available, and existing last/mark behavior remains the fallback when quotes are unavailable. Release build validation passed, focused option-margin tests passed 41/41, and new regression tests cover long-option ask pricing and short-option bid pricing. This does not claim to redesign portfolio construction or generic buying power behavior; it fixes the option margin pricing boundary used during target quantity calculation.

Disclosure: This field report was prepared with AI-assisted editing from my own field-test notes, public issue and PR records, validation summary, and Field Lab record. The technical claims and final wording were reviewed before publication.