feat: strategy builder
This commit is contained in:
@@ -57,12 +57,17 @@ function PayoffChart({ priced, spot, scenarioSpot }: { priced: PriceCombo; spot:
|
|||||||
expiry: p.pnl,
|
expiry: p.pnl,
|
||||||
scenario: priced.at_scenario[i]?.pnl,
|
scenario: priced.at_scenario[i]?.pnl,
|
||||||
}))
|
}))
|
||||||
|
// Decimals scale with the underlying's own magnitude — an equity at ~740 reads fine
|
||||||
|
// rounded to the unit, but an FX rate at ~1.15 needs several decimals or every tick
|
||||||
|
// collapses to the same rounded label.
|
||||||
|
const decimals = spot < 5 ? 4 : spot < 50 ? 2 : 0
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer width="100%" height={280}>
|
<ResponsiveContainer width="100%" height={280}>
|
||||||
<LineChart data={data} margin={{ top: 8, right: 16, left: 0, bottom: 0 }}>
|
<LineChart data={data} margin={{ top: 8, right: 16, left: 0, bottom: 0 }}>
|
||||||
<CartesianGrid strokeDasharray="3 3" stroke="#1e2d4d" />
|
<CartesianGrid strokeDasharray="3 3" stroke="#1e2d4d" />
|
||||||
<XAxis dataKey="underlying" tick={{ fill: '#475569', fontSize: 10 }} tickLine={false}
|
<XAxis dataKey="underlying" type="number" domain={['dataMin', 'dataMax']}
|
||||||
tickFormatter={(v) => v.toFixed(0)} />
|
tick={{ fill: '#475569', fontSize: 10 }} tickLine={false}
|
||||||
|
tickFormatter={(v) => v.toFixed(decimals)} />
|
||||||
<YAxis tick={{ fill: '#475569', fontSize: 10 }} tickLine={false} axisLine={false}
|
<YAxis tick={{ fill: '#475569', fontSize: 10 }} tickLine={false} axisLine={false}
|
||||||
tickFormatter={(v) => `${v}`} />
|
tickFormatter={(v) => `${v}`} />
|
||||||
<Tooltip
|
<Tooltip
|
||||||
|
|||||||
Reference in New Issue
Block a user