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
|
|
@ -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