Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ exports.getRichQuick = functions
const stocksToBuy = gptCompletion.data.choices[0].text.match(/\b[A-Z]+\b/g);
console.log(`Thanks for the tips Jim! ${stocksToBuy}`);

if (!stocksToBuy) {
const holdingStonk = await alpaca.getPositions().at(0).symbol; // assuming there's only 1 open position
const shouldTradeToday = !(stocksToBuy.includes(holdingStonk));

if (!stocksToBuy || !shouldTradeToday) {
console.log('sitting this one out');
return null;
}
Expand Down