def test_get_most_recent_sentiment_by_symbol_id(self):

        data = PyStockTwitData()

        recent_sentiment = data.get_most_recent_sentiment_by_symbol_id('AAPL')

        # Since the recent msg always changes, just testing if a dict
        # is returned
        self.assertEqual(type({}), type(recent_sentiment))
    def test_get_all_msgs_with_sentiment_by_symbol_id(self):

        data = PyStockTwitData()

        msgs, sentiment = data.get_all_msgs_with_sentiment_by_symbol_id(
                            'AAPL', limit=3)

        # Check if the length equals the limit
        self.assertEqual(3, len(msgs))
        self.assertEqual(3, len(sentiment))
    def test_get_most_recent_msg_by_symbol_id(self):

        data = PyStockTwitData()

        recent_msg = data.get_most_recent_msg_by_symbol_id('AAPL')

        # Since the recent msg always changes, just testing if a string
        # is returned

        self.assertEqual(type('test'), type(recent_msg))
    def test_extract_sentiment_statements_basic(self):

        data = PyStockTwitData()

        # Use an example json that this statement parses
        example = [{'sentiment': {'basic': 'Bullish'}}, {'sentiment': None}]
        parsed_sentiment = data.extract_sentiment_statements_basic(example)

        # Check if the parser gets Bullish and None
        self.assertEqual('Bullish', parsed_sentiment[0])
        self.assertEqual("None", parsed_sentiment[1])
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pystocktwits_data_utils import PyStockTwitData

import panda as pd

data = PyStockTwitData()

# Get all msgs from this company that is specified
list_of_msgs, list_of_sentiment_json = (
    data.get_all_msgs_with_sentiment_by_symbol_id("VEEV"))

# Parse out the Bullish, Bearish, or None Sentiment
list_of_sentiment = (
    data.extract_sentiment_statements_basic(list_of_sentiment_json))

# Create a Dataframe
dataframe = pd.DataFrame({'msg': list_of_msgs, 'sentiment': list_of_sentiment})

# Print to see dataframe and save
print(dataframe)
dataframe.to_csv('../sample_csv_output/pystockdataset.csv')
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pystocktwits_data_utils import PyStockTwitData

data = PyStockTwitData()

recent_msg = data.get_most_recent_msg_by_symbol_id('AAPL')

print(recent_msg)

# Sample Output
# $AAPL i'd love to have a 1,000 shares of this at $150 average.
Ejemplo n.º 7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pystocktwits_data_utils import PyStockTwitData

data = PyStockTwitData()

example = [{'sentiment': {'basic': 'Bullish'}}, {'sentiment': None}]
parsed_sentiment = data.extract_sentiment_statements_basic(example)

print(parsed_sentiment)

# Sample Output
# ['Bullish', 'None']
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pystocktwits_data_utils import PyStockTwitData

data = PyStockTwitData()

company_list = ['AAPL', 'VEEV', 'DECK', 'MSFT', 'AMZN']

data.stock_csv_list_create(
    "../sample_csv_output/"
    "stocktwit_csv__list_create_multi.csv",
    company_list,
    30,
    5,
    limit=30)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pystocktwits_data_utils import PyStockTwitData

data = PyStockTwitData()

recent_msg = data.get_most_recent_msg_by_user('170')

print(recent_msg)

# Sample Output
# @howardlindzon Thanks man. How did you get so good at this?
Ejemplo n.º 10
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pystocktwits_data_utils import PyStockTwitData

data = PyStockTwitData()

data.stocktwit_csv_create("../sample_csv_output/stocktwit_csv_create_VEEV.csv",
                          "VEEV",
                          30,
                          5,
                          limit=30)