Auto-fetch live marks on strategy page open
On opening the Strategy page, automatically pull the current spot, each leg's live mid (Mark column) and IV — without touching entry prices. The Reload button still re-prices unlocked legs to the current mark. Clarified the legs table hint. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -118,7 +118,7 @@
|
||||
<!-- Legs table (at the bottom) -->
|
||||
<div class="card mb-4" x-show="legs.length > 0 || showManual" x-cloak>
|
||||
<div class="card-header d-flex align-items-center justify-content-between">
|
||||
<h3 class="card-title mb-0">Legs <span class="text-secondary small fw-normal">— uncheck a leg to drop it from the chart</span></h3>
|
||||
<h3 class="card-title mb-0">Legs <span class="text-secondary small fw-normal">— Mark = live mid · 🔒 locks entry price · uncheck to drop from chart</span></h3>
|
||||
<div>
|
||||
<span class="me-3" :class="netCost >= 0 ? 'text-danger' : 'text-success'">
|
||||
Net <strong x-text="netCost >= 0 ? 'debit' : 'credit'"></strong>:
|
||||
@@ -299,6 +299,8 @@
|
||||
|
||||
init() {
|
||||
this.reload();
|
||||
// pull live spot / marks / IVs on open (does NOT touch entry prices)
|
||||
if (this.legs.length > 0 && this.symbol) this.reloadMarket(false);
|
||||
// re-sync if another tab changed the basket
|
||||
window.addEventListener('storage', (e) => { if (e.key === StrategyStore.KEY) this.reload(); });
|
||||
},
|
||||
@@ -438,9 +440,10 @@
|
||||
this.reload();
|
||||
this.flash('Leg added');
|
||||
},
|
||||
// Re-fetch spot + each leg's current mark & IV. Unlocked legs also get
|
||||
// their entry price reset to the current mark; locked legs keep their entry.
|
||||
async reloadMarket() {
|
||||
// Re-fetch spot + each leg's current mark & IV.
|
||||
// When repriceUnlocked (default — the Reload button), unlocked legs also
|
||||
// get their entry price reset to the current mark; locked legs always keep it.
|
||||
async reloadMarket(repriceUnlocked = true) {
|
||||
if (!this.symbol || this.legs.length === 0) return;
|
||||
this.refreshing = true;
|
||||
try {
|
||||
@@ -471,7 +474,7 @@
|
||||
const mark = Math.round((o.midPrice ?? o.mid ?? o.bsPrice ?? 0) * 100) / 100;
|
||||
leg.currentMark = mark;
|
||||
if (o.iv > 0) leg.iv = o.iv;
|
||||
if (!leg.locked && mark > 0) { leg.entryPrice = mark; relinked++; }
|
||||
if (!leg.locked && repriceUnlocked && mark > 0) { leg.entryPrice = mark; relinked++; }
|
||||
updated++;
|
||||
}
|
||||
if (spot > 0) st.spotSnapshot = spot;
|
||||
@@ -480,11 +483,13 @@
|
||||
if (spot > 0) this.spot = spot;
|
||||
if (this.dteOffset > this.maxDTE) this.dteOffset = this.maxDTE;
|
||||
this.$nextTick(() => this.renderChart());
|
||||
this.flash(updated > 0
|
||||
? `Reloaded ${updated} leg${updated===1?'':'s'}${relinked?` (${relinked} re-priced)`:''} · spot $${(spot||this.spot).toFixed(2)}`
|
||||
: 'Reloaded — no matching contracts found in the current chain');
|
||||
if (repriceUnlocked) {
|
||||
this.flash(updated > 0
|
||||
? `Reloaded ${updated} leg${updated===1?'':'s'}${relinked?` (${relinked} re-priced)`:''} · spot $${(spot||this.spot).toFixed(2)}`
|
||||
: 'Reloaded — no matching contracts found in the current chain');
|
||||
}
|
||||
} catch (e) {
|
||||
this.flash('Reload failed: ' + e.message);
|
||||
if (repriceUnlocked) this.flash('Reload failed: ' + e.message);
|
||||
} finally {
|
||||
this.refreshing = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user