Register the trend data providers in the init function of your signal:
Copy
// register a trend data provider for Elon Musk's X/Twitter account$this->_elonMuskX = $this->addTrendDataProvider("elonMuskX", new XTrendDataProvider("elonmusk"));// register a trend data provider for Telegram channel CatfishcallsbyPoe$this->_catfishcallsByPoeTelegram = $this->addTrendDataProvider("catfishcallsByPoeTelegram", new TelegramTrendDataProvider("CatfishcallsbyPoe"));
Use the trend data in the getSignalInfo function of your signal:
Copy
function getSignalInfo(TradeContext $tradeContext):?TradeSignalInfo{ if ($this->_elonMuskX->hasNewData()) { $xPost = $this->_elonMuskX->getLatestContent(); if (str_contains($xPost, "DOGE")) { // do something } } if ($this->_catfishcallsByPoeTelegram->hasNewData()) { $telegramMessage = $this->_catfishcallsByPoeTelegram->getLatestContent(); if (str_contains($telegramMessage, "BAI")) { // do something } } ...}
We currently support the following trend data providers:
Copy
new XTrendDataProvider(twitterUsername); // hasNewData() triggers on new tweetsnew YouTubeTrendDataProvider(channelName); // hasNewData() triggers on new video uploadsnew TelegramTrendDataProvider(channelName); // hasNewData() triggers on new messagesnew RedditTrendDataProvider(subredditName); // hasNewData() triggers on new postsnew WebsiteTrendDataProvider(websiteUrl); // hasNewData() is not supported. Call getLatestContent() to crawl the website's contentnew RSSTrendDataProvider(feedUrl); // hasNewData() triggers on new feed itemsnew TradingViewTrendDataProvider(alertName); // hasNewData() triggers on new alertsnew WebhookTrendDataProvider(webhookUrl); // hasNewData() triggers on new webhook calls
interface ITrendDataProvider{ // returns true if new data is available function hasNewData():bool; // returns the latest content // NOTE: there could be multiple new contents available since the last call to hasNewData(). // Use getPreviousContentId() to get the content id of the last fetched content and getContent(x) to iterate over all new contents if needed. function getLatestContent():string; // returns the content id of the getLatestContent() content function getLatestContentId():int // returns the content id of the last call to hasNewData() function getPreviousContentId():string; // returns the content of the specified id function getContent(int $id):int;}
Missing a data provider you would like to use? Feel free to contact us. Adding a new trend data provider is easy due to our plugin based technology.