Skip to content

Instantly share code, notes, and snippets.

@chrispeterson3
Created May 11, 2022 03:10
Show Gist options
  • Save chrispeterson3/a82a7d211f34820ab72ff38ee661ad02 to your computer and use it in GitHub Desktop.
Save chrispeterson3/a82a7d211f34820ab72ff38ee661ad02 to your computer and use it in GitHub Desktop.
const signals = gainers.reduce(
(
acc: Array<{
ticker: string;
news: Array<NewsResult>;
bias: string;
}>,
curr
) => {
const openingBar = curr.bars.find((bar) => bar.t === openingBarTime);
const isSignal =
openingBar &&
openingBar.ema9 &&
openingBar.c > openingBar.ema9 &&
openingBar.v > 500000;
return isSignal
? [
...acc,
{
ticker: curr.ticker,
news: curr.news,
bias: openingBar.c >= openingBar.o ? "long" : "short",
},
]
: acc;
},
[]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment