just print if the first minute is up or down

This commit is contained in:
Jon
2025-02-11 00:00:04 -07:00
parent 04d1202acb
commit fe60f014aa

View File

@@ -20,30 +20,36 @@ async function waitForNextOpen() {
} }
function wait(ms :number) { function wait(ms :number) {
return new Promise((resolve) => { return new Promise((resolve) => {
console.log('would wait: ' + ms + 'ms'); //console.log('would wait: ' + ms + 'ms');
resolve('') //resolve('')
//setTimeout(resolve, ms); setTimeout(resolve, ms);
}); });
} }
async function runDay() { async function runDay() {
await waitForNextOpen(); await waitForNextOpen();
console.log('run the day');
await printAsset('AAPL');
await printAsset('TQQQ');
await printAsset('SQQQ');
console.log(await accountBalance()); await wait(1000); //wait a miniute
let stocks = [
'AAPL', const q = await alpaca.getLatestQuote('TQQQ');
'TQQQ', await wait(1000);
'SQQQ'
] const q2 = await alpaca.getLatestQuote('TQQQ');
console.log(await alpaca.getLatestTrades(stocks))
//console.log(await alpaca.getLatestQuote('AAPL')); if (q2.ap - q.ap > 0) {
//up day
console.log('up day: ', new Date())
}
else {
//down day
console.log('down day', new Date());
}
} }
async function main() { async function main() {
await runDay(); while(true) {
await runDay();
await wait(1000 * 60 * 60);//wait an hour before going and getting the next open
}
} }