fix(web): preserve historical backtests with null configuration (CL25)
This commit is contained in:
parent
731acc41db
commit
ed7429cfbc
10 changed files with 41 additions and 23 deletions
|
|
@ -208,7 +208,7 @@ export function BacktestDetailPageV2() {
|
|||
dataSource: (backtest.config?.dataSource ?? 'auto') as BacktestConfig['dataSource'],
|
||||
datasetHash:
|
||||
typeof backtest.config?.datasetHash === 'string'
|
||||
? backtest.config.datasetHash
|
||||
? backtest.config?.datasetHash
|
||||
: undefined,
|
||||
commission: Number(backtest.config?.commission ?? 0.001),
|
||||
slippage: Number(backtest.config?.slippage ?? 0.0001),
|
||||
|
|
@ -226,13 +226,13 @@ export function BacktestDetailPageV2() {
|
|||
|
||||
const renderSettings = () => (
|
||||
<div className="max-w-4xl mx-auto space-y-4">
|
||||
{catalog && backtest && (showCanonicalSetup || backtest.config.canonical) ? (
|
||||
{catalog && backtest && (showCanonicalSetup || backtest.config?.canonical) ? (
|
||||
<CanonicalSetup
|
||||
key={backtest.id}
|
||||
backtest={backtest}
|
||||
disabled={archived || isLoading}
|
||||
onSave={request => updateBacktest(backtest.id, request)}
|
||||
onClose={!backtest.config.canonical ? () => setShowCanonicalSetup(false) : undefined}
|
||||
onClose={!backtest.config?.canonical ? () => setShowCanonicalSetup(false) : undefined}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ function defaults(capital: number): CanonicalResearchSettings {
|
|||
};
|
||||
}
|
||||
function initialPolicy(backtest: Backtest): RawPolicy {
|
||||
const input = backtest.config.canonical;
|
||||
const input = backtest.config?.canonical;
|
||||
const source = input && typeof input === 'object' ? input : defaults(backtest.initialCapital);
|
||||
return Object.fromEntries(
|
||||
policyFields.map(({ key }) => {
|
||||
|
|
@ -259,8 +259,9 @@ export function CanonicalSetup({
|
|||
const [capital, setCapital] = useState(String(backtest.initialCapital));
|
||||
const [raw, setRaw] = useState(() => initialPolicy(backtest));
|
||||
const [hash, setHash] = useState(
|
||||
typeof backtest.config.canonical === 'object' && typeof backtest.config.datasetHash === 'string'
|
||||
? backtest.config.datasetHash
|
||||
typeof backtest.config?.canonical === 'object' &&
|
||||
typeof backtest.config?.datasetHash === 'string'
|
||||
? backtest.config?.datasetHash
|
||||
: ''
|
||||
);
|
||||
const [selection, setSelection] = useState<CatalogSelection>({
|
||||
|
|
@ -322,15 +323,15 @@ export function CanonicalSetup({
|
|||
setCapital(String(backtest.initialCapital));
|
||||
setRaw(initialPolicy(backtest));
|
||||
setHash(
|
||||
typeof backtest.config.canonical === 'object' &&
|
||||
typeof backtest.config.datasetHash === 'string'
|
||||
? backtest.config.datasetHash
|
||||
typeof backtest.config?.canonical === 'object' &&
|
||||
typeof backtest.config?.datasetHash === 'string'
|
||||
? backtest.config?.datasetHash
|
||||
: ''
|
||||
);
|
||||
selectedHash.current =
|
||||
typeof backtest.config.canonical === 'object' &&
|
||||
typeof backtest.config.datasetHash === 'string'
|
||||
? backtest.config.datasetHash
|
||||
typeof backtest.config?.canonical === 'object' &&
|
||||
typeof backtest.config?.datasetHash === 'string'
|
||||
? backtest.config?.datasetHash
|
||||
: '';
|
||||
setKnownHash('');
|
||||
setKnownHashError(null);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue