fix biome kvetches

This commit is contained in:
2024-08-02 17:00:35 -04:00
parent 39bb6c85f8
commit eba5344b15
3 changed files with 279 additions and 279 deletions
+7 -7
View File
@@ -48,7 +48,7 @@ export async function backtest({
...calendar,
},
date,
}),
})
);
}
// for each minute of that day for which we have a stock candlestick:
@@ -57,12 +57,12 @@ export async function backtest({
// filter-out calendars that are far-from-the-money (10%)
const calendarsNearTheMoney = calendars.filter(
({ strike }) =>
Math.abs((stockAggregate.open - strike) / stockAggregate.open) < 0.1,
Math.abs((stockAggregate.open - strike) / stockAggregate.open) < 0.1
);
// for each relevant calendar on that day:
for (const calendar of calendarsNearTheMoney) {
const strikePercentageFromTheMoney = Math.abs(
(stockAggregate.open - calendar.strike) / stockAggregate.open,
(stockAggregate.open - calendar.strike) / stockAggregate.open
);
/** In days. */
const calendarSpan =
@@ -78,14 +78,14 @@ export async function backtest({
});
const calendarAggregates = calendarsAggregates.get(calendar);
const calendarAggregateAtCurrentTime = calendarAggregates.find(
({ tsStart }) => tsStart === stockAggregate.tsStart,
({ tsStart }) => tsStart === stockAggregate.tsStart
);
// if there exists a matching calendar candlestick for the current minute:
if (calendarAggregateAtCurrentTime) {
// if the current candlestick is a good price (i.e. less than the target price):
const minCalendarPriceInCandlestick = Math.min(
calendarAggregateAtCurrentTime.open,
calendarAggregateAtCurrentTime.close,
calendarAggregateAtCurrentTime.close
);
if (
minCalendarPriceInCandlestick < targetCalendarPrice &&
@@ -104,7 +104,7 @@ export async function backtest({
minCalendarPriceInCandlestick * 100,
"...$",
buyingPower,
"left",
"left"
);
didBuyCalendar = true;
}
@@ -136,7 +136,7 @@ export async function backtest({
calendarClosingPrice,
"...$",
buyingPower,
"left",
"left"
);
}
}
+1 -1
View File
@@ -57,7 +57,7 @@ function makeCalendarDatabase(): CalendarDatabase {
close:
backOptionContractAggregates[j].close -
frontOptionContractAggregates[i].close,
// the high and low are not exactly correct since we don't know if each contract's high and low happened ata the same moment as the other:
// the high and low are not exactly correct since we don't know if each contract's high and low happened at the same moment as the other:
high:
backOptionContractAggregates[j].high -
frontOptionContractAggregates[i].high,
+1 -1
View File
@@ -17,7 +17,7 @@ async function syncAggregates<T>({
date: string;
}) {
const aggregatesFrom = (await fromDatabase.getAggregates({ key, date })).map(
(aggregateWithoutKey) => ({ ...aggregateWithoutKey, key }),
(aggregateWithoutKey) => ({ ...aggregateWithoutKey, key })
);
await toDatabase.insertAggregates(aggregatesFrom);
}