Cashtags and Hashtags with FilteredStream

Oct 28, 2014 at 9:17 PM
I'm using the latest Nuget package of Tweetinvi. I'm having trouble creating filtered streams for both hashtags (#) and cahstags ($). Cashtags are used in tweets when users are referencing market securities such as stocks ($FB).
            int tweets = 0;
            var stream = Stream.CreateFilteredStream();
            stream.AddTrack("$FB");

            stream.MatchingTweetReceived += (o, args) =>
            {
                logger.Debug(String.Format("{0}\t{1}", args.Tweet, ++tweets));
            };

            stream.StartStreamMatchingAllConditions();
For example, $FB is a very popular cashtag on Twitter. However, my filtered stream is not picking up tweets. The same goes for hastags. If I remove # or $ from my tracks, I get flooded with tweets, however, the $/# tagging is important to filter out garbage that I am not interested in.

Is there a workaround to this? Is there something on the roadmap to better deal with hashtags and cashtags?

Chris
Oct 28, 2014 at 9:24 PM
This is my current solution, but is not ideal. It does work however.
            int tweets = 0;
            var stream = Stream.CreateFilteredStream();
            stream.AddTrack("FB");

            stream.MatchingTweetReceived += (o, args) =>
            {
                string tweet = args.Tweet.Text;
                if (tweet.IndexOf("$FB") != -1)
                {
                    logger.Debug(String.Format("{0}\t{1}", args.Tweet, ++tweets));
                }
            };

            stream.StartStreamMatchingAllConditions();
Nov 2, 2014 at 11:00 AM
Edited Nov 2, 2014 at 11:01 AM
I just checked and hashtags seem to be working fine with stream.

However, there's a problem with cashtag. You can check that JsonObjectReceived event is fired on cashtags but not the MatchingTweetReceived.

I'm sure linvi would fix this whenever he has time.

Meanwhile you can use this:
stream.JsonObjectReceived += (o, arg) => 
    Console.WriteLine(Tweet.TweetFactory.GenerateTweetFromJson(arg.Json).Text);
Marked as answer by ChrisBB on 11/2/2014 at 6:31 AM
Nov 2, 2014 at 2:31 PM
Thank for your help. This workaround is performing well. CPU usage dropped by about 20% as well as resolved the original issue. Should I open a bug on this, or did you already handle that?
Nov 2, 2014 at 7:46 PM
Edited Nov 2, 2014 at 7:47 PM
I've created an issue about this problem.

https://tweetinvi.codeplex.com/workitem/2453
Nov 3, 2014 at 5:17 PM
Edited Nov 3, 2014 at 6:16 PM
I never heard about cashtags before :p

I will try to have a look into it but I don't know if it will be released with 0.9.4.1 or 0.9.5.0.

Concerning the Execution Time, the FilteredStream is quite CPU hungry because each times it receives a tweet it matches the criteria so that you can get additional information on how the Tweet has been matched.

I have worked around 2 weeks to make it the more efficient I could. If you find any improvement you would think of, please let me know, there might be some algorithms that I did not find when doing my researches.

Kind Regards,
Linvi
Nov 3, 2014 at 5:56 PM
Here's more on Cashtags. It's actually a real thing :-)

http://thenextweb.com/twitter/2012/07/31/twitter-rolls-out-clickable-stock-symbols-so-you-can-keep-up-with-your-investments/

I'll let you know more about my observations concerning the API.
Nov 10, 2014 at 4:15 PM
Hi there,

If you download the latest version of the Source Code, you will be able to get cashtags working with the FilteredStream.
This will be available in the next release 0.9.4.1.

Linvi
Marked as answer by linvi on 11/10/2014 at 8:15 AM