|
|
@ -148,12 +148,21 @@ export async function pullOptionContractAggregates(
|
|
|
|
...optionContract,
|
|
|
|
...optionContract,
|
|
|
|
firstDate,
|
|
|
|
firstDate,
|
|
|
|
})) {
|
|
|
|
})) {
|
|
|
|
console.log(batch.length);
|
|
|
|
if (batch.length > 0) {
|
|
|
|
await clickhouse.insert({
|
|
|
|
console.log(
|
|
|
|
table: "option_contract_aggregates",
|
|
|
|
optionContract.symbol,
|
|
|
|
values: batch,
|
|
|
|
optionContract.expirationDate,
|
|
|
|
format: "JSONEachRow",
|
|
|
|
optionContract.strike,
|
|
|
|
});
|
|
|
|
optionContract.type,
|
|
|
|
|
|
|
|
new Date(batch[0].tsStart * 1000),
|
|
|
|
|
|
|
|
new Date(batch[batch.length - 1].tsStart * 1000)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
await clickhouse.insert({
|
|
|
|
|
|
|
|
table: "option_contract_aggregates",
|
|
|
|
|
|
|
|
values: batch,
|
|
|
|
|
|
|
|
format: "JSONEachRow",
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await setPullOptionContractAggregatesState(ticker, {
|
|
|
|
await setPullOptionContractAggregatesState(ticker, {
|
|
|
|
status: OptionContractAggregatesSyncStatus.COMPLETED,
|
|
|
|
status: OptionContractAggregatesSyncStatus.COMPLETED,
|
|
|
@ -210,13 +219,15 @@ export async function pullOptionContractAggregatesSince(
|
|
|
|
yesterdayAsDateObject.setUTCDate(yesterdayAsDateObject.getUTCDate() - 1);
|
|
|
|
yesterdayAsDateObject.setUTCDate(yesterdayAsDateObject.getUTCDate() - 1);
|
|
|
|
while (currentDateAsDateObject <= yesterdayAsDateObject) {
|
|
|
|
while (currentDateAsDateObject <= yesterdayAsDateObject) {
|
|
|
|
const currentDate = currentDateAsDateObject.toISOString().substring(0, 10);
|
|
|
|
const currentDate = currentDateAsDateObject.toISOString().substring(0, 10);
|
|
|
|
|
|
|
|
console.log(`Date: ${currentDate}`);
|
|
|
|
for await (const optionContracts of makeGetOptionContractsIterator(
|
|
|
|
for await (const optionContracts of makeGetOptionContractsIterator(
|
|
|
|
symbol,
|
|
|
|
symbol,
|
|
|
|
currentDate
|
|
|
|
currentDate
|
|
|
|
)) {
|
|
|
|
)) {
|
|
|
|
await pullOptionContractAggregates(optionContracts);
|
|
|
|
for (const optionContract of optionContracts) {
|
|
|
|
|
|
|
|
await pullOptionContractAggregates(optionContract);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(`Date: ${currentDate}`);
|
|
|
|
|
|
|
|
currentDateAsDateObject.setUTCDate(
|
|
|
|
currentDateAsDateObject.setUTCDate(
|
|
|
|
currentDateAsDateObject.getUTCDate() + 1
|
|
|
|
currentDateAsDateObject.getUTCDate() + 1
|
|
|
|
);
|
|
|
|
);
|
|
|
|