From fe60f014aaf389a505e65d20a64dc3416a91483b Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 11 Feb 2025 00:00:04 -0700 Subject: [PATCH] just print if the first minute is up or down --- src/index.ts | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/index.ts b/src/index.ts index dc16c06..31a9ec7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,30 +20,36 @@ async function waitForNextOpen() { } function wait(ms :number) { return new Promise((resolve) => { - console.log('would wait: ' + ms + 'ms'); - resolve('') - //setTimeout(resolve, ms); + //console.log('would wait: ' + ms + 'ms'); + //resolve('') + setTimeout(resolve, ms); }); } async function runDay() { await waitForNextOpen(); - console.log('run the day'); - await printAsset('AAPL'); - await printAsset('TQQQ'); - await printAsset('SQQQ'); - console.log(await accountBalance()); - let stocks = [ - 'AAPL', - 'TQQQ', - 'SQQQ' - ] - console.log(await alpaca.getLatestTrades(stocks)) - //console.log(await alpaca.getLatestQuote('AAPL')); + await wait(1000); //wait a miniute + + const q = await alpaca.getLatestQuote('TQQQ'); + await wait(1000); + + const q2 = await alpaca.getLatestQuote('TQQQ'); + + 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() { - await runDay(); + while(true) { + await runDay(); + await wait(1000 * 60 * 60);//wait an hour before going and getting the next open + } }