just print if the first minute is up or down
This commit is contained in:
36
src/index.ts
36
src/index.ts
@@ -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() {
|
||||||
|
while(true) {
|
||||||
await runDay();
|
await runDay();
|
||||||
|
await wait(1000 * 60 * 60);//wait an hour before going and getting the next open
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user