fix biome kvetches
This commit is contained in:
@@ -48,7 +48,7 @@ export async function backtest({
|
|||||||
...calendar,
|
...calendar,
|
||||||
},
|
},
|
||||||
date,
|
date,
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// for each minute of that day for which we have a stock candlestick:
|
// 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%)
|
// filter-out calendars that are far-from-the-money (10%)
|
||||||
const calendarsNearTheMoney = calendars.filter(
|
const calendarsNearTheMoney = calendars.filter(
|
||||||
({ strike }) =>
|
({ 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 each relevant calendar on that day:
|
||||||
for (const calendar of calendarsNearTheMoney) {
|
for (const calendar of calendarsNearTheMoney) {
|
||||||
const strikePercentageFromTheMoney = Math.abs(
|
const strikePercentageFromTheMoney = Math.abs(
|
||||||
(stockAggregate.open - calendar.strike) / stockAggregate.open,
|
(stockAggregate.open - calendar.strike) / stockAggregate.open
|
||||||
);
|
);
|
||||||
/** In days. */
|
/** In days. */
|
||||||
const calendarSpan =
|
const calendarSpan =
|
||||||
@@ -78,14 +78,14 @@ export async function backtest({
|
|||||||
});
|
});
|
||||||
const calendarAggregates = calendarsAggregates.get(calendar);
|
const calendarAggregates = calendarsAggregates.get(calendar);
|
||||||
const calendarAggregateAtCurrentTime = calendarAggregates.find(
|
const calendarAggregateAtCurrentTime = calendarAggregates.find(
|
||||||
({ tsStart }) => tsStart === stockAggregate.tsStart,
|
({ tsStart }) => tsStart === stockAggregate.tsStart
|
||||||
);
|
);
|
||||||
// if there exists a matching calendar candlestick for the current minute:
|
// if there exists a matching calendar candlestick for the current minute:
|
||||||
if (calendarAggregateAtCurrentTime) {
|
if (calendarAggregateAtCurrentTime) {
|
||||||
// if the current candlestick is a good price (i.e. less than the target price):
|
// if the current candlestick is a good price (i.e. less than the target price):
|
||||||
const minCalendarPriceInCandlestick = Math.min(
|
const minCalendarPriceInCandlestick = Math.min(
|
||||||
calendarAggregateAtCurrentTime.open,
|
calendarAggregateAtCurrentTime.open,
|
||||||
calendarAggregateAtCurrentTime.close,
|
calendarAggregateAtCurrentTime.close
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
minCalendarPriceInCandlestick < targetCalendarPrice &&
|
minCalendarPriceInCandlestick < targetCalendarPrice &&
|
||||||
@@ -104,7 +104,7 @@ export async function backtest({
|
|||||||
minCalendarPriceInCandlestick * 100,
|
minCalendarPriceInCandlestick * 100,
|
||||||
"...$",
|
"...$",
|
||||||
buyingPower,
|
buyingPower,
|
||||||
"left",
|
"left"
|
||||||
);
|
);
|
||||||
didBuyCalendar = true;
|
didBuyCalendar = true;
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ export async function backtest({
|
|||||||
calendarClosingPrice,
|
calendarClosingPrice,
|
||||||
"...$",
|
"...$",
|
||||||
buyingPower,
|
buyingPower,
|
||||||
"left",
|
"left"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function makeCalendarDatabase(): CalendarDatabase {
|
|||||||
close:
|
close:
|
||||||
backOptionContractAggregates[j].close -
|
backOptionContractAggregates[j].close -
|
||||||
frontOptionContractAggregates[i].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:
|
high:
|
||||||
backOptionContractAggregates[j].high -
|
backOptionContractAggregates[j].high -
|
||||||
frontOptionContractAggregates[i].high,
|
frontOptionContractAggregates[i].high,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ async function syncAggregates<T>({
|
|||||||
date: string;
|
date: string;
|
||||||
}) {
|
}) {
|
||||||
const aggregatesFrom = (await fromDatabase.getAggregates({ key, date })).map(
|
const aggregatesFrom = (await fromDatabase.getAggregates({ key, date })).map(
|
||||||
(aggregateWithoutKey) => ({ ...aggregateWithoutKey, key }),
|
(aggregateWithoutKey) => ({ ...aggregateWithoutKey, key })
|
||||||
);
|
);
|
||||||
await toDatabase.insertAggregates(aggregatesFrom);
|
await toDatabase.insertAggregates(aggregatesFrom);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user