Beispiel #1
0
def main():
    # Create credentials for use with an secured channel
    creds = grpc.ssl_channel_credentials(open(PATH_TO_CERT_FILE, 'rb').read())

    # Initialize GRPC channel
    channel = grpc.secure_channel(SERVER_ADDRESS, creds)

    # create stub
    stub = types_pb2_grpc.HistoricDataStub(channel)

    # create timeframe
    now = time.time()
    seconds = int(now)
    to_time = timestamp_pb2.Timestamp(seconds=seconds)
    from_time = timestamp_pb2.Timestamp(seconds=to_time.seconds -
                                        int(86400 / 4))  # last 6 hours

    # in our case we have to use kwarg because `from` is
    # is recognized as python keyword so there would syntax be error
    # if you want get value you have to use getattr()
    historic_request_kwargs = {
        'from': from_time,
        'to': to_time,
        'filter': types_pb2.AssetsFilter(assets=['BTC', 'ETH'],
                                         all_assets=False)
    }
    req = types_pb2.HistoricRequest(**historic_request_kwargs)

    article_stream = stub.HistoricArticles(req)
    for article in article_stream:
        print(article.base.id, article.base.title)
Beispiel #2
0
def main():
    assert TOKEN != '', 'You need to set TOKEN. To obtain your token visit https://cryptomood.com/business/products/sentiment-analysis-api/.'
    # Create credentials for use with an secured channel
    credentials = grpc.ssl_channel_credentials(open(PATH_TO_CERT_FILE, 'rb').read())

    call_credentials = grpc.access_token_call_credentials(TOKEN)
    credentials = grpc.composite_channel_credentials(credentials, call_credentials)

    channel = grpc.secure_channel(SERVER_ADDRESS, credentials)

    # create stub
    stub = types_pb2_grpc.HistoricDataStub(channel)

    # create timeframe 
    now = time.time()
    seconds = int(now)
    to_time = timestamp_pb2.Timestamp(seconds=seconds)
    from_time = timestamp_pb2.Timestamp(seconds=to_time.seconds - int(86400 / 4)) # last 6 hours

    # in our case we have to use kwarg because `from` is
    # is recognized as python keyword so there would syntax be error
    # if you want get value you have to use getattr()
    historic_request_kwargs = { 'from': from_time, 'to': to_time, 
                                'filter': types_pb2.AssetsFilter(assets=['BTC', 'ETH'], all_assets=False)}
    req = types_pb2.HistoricRequest(**historic_request_kwargs)
    
    article_stream = stub.HistoricArticles(req)
    for article in article_stream:
        print(article.base.id, article.base.title)
Beispiel #3
0
def main():
    # Create credentials for use with an secured channel
    credentials = grpc.ssl_channel_credentials(
        open(PATH_TO_CERT_FILE, 'rb').read())

    # uncomment commands below if token auth is required
    # call_credentials = grpc.access_token_call_credentials('YOUR_TOKEN')
    # credentials = grpc.composite_channel_credentials(credentials, call_credentials)

    channel = grpc.secure_channel(SERVER_ADDRESS, credentials)

    # create stub
    stub = types_pb2_grpc.HistoricDataStub(channel)

    # create timeframe
    now = time.time()
    seconds = int(now)
    to_time = timestamp_pb2.Timestamp(seconds=seconds)
    from_time = timestamp_pb2.Timestamp(seconds=to_time.seconds -
                                        int(86400 / 4))  # last 6 hours

    # in our case we have to use kwarg because `from` is
    # is recognized as python keyword so there would syntax be error
    # if you want get value you have to use getattr()
    historic_request_kwargs = {
        'from': from_time,
        'to': to_time,
        'filter': types_pb2.AssetsFilter(assets=['BTC', 'ETH'],
                                         all_assets=False)
    }
    req = types_pb2.HistoricRequest(**historic_request_kwargs)
    reddit_stream = stub.HistoricRedditPosts(req)

    for reddit in reddit_stream:
        print(reddit.base.id, reddit.base.content)
Beispiel #4
0
def main():
    assert TOKEN != '', 'You need to set TOKEN. To obtain your token visit https://cryptomood.com/business/products/sentiment-analysis-api/.'
    # Create credentials for use with an secured channel
    credentials = grpc.ssl_channel_credentials(
        open(PATH_TO_CERT_FILE, 'rb').read())

    call_credentials = grpc.access_token_call_credentials(TOKEN)
    credentials = grpc.composite_channel_credentials(credentials,
                                                     call_credentials)

    channel = grpc.secure_channel(SERVER_ADDRESS, credentials)

    # create stub
    stub = types_pb2_grpc.SentimentsStub(channel)

    # create request
    req = types_pb2.AggregationCandleFilter(
        resolution='M1',
        assets_filter=types_pb2.AssetsFilter(assets=['BTC'], all_assets=False))

    # Response-streaming RPC
    candle_stream = stub.SubscribeSocialSentiment(req)
    for candle in candle_stream:
        # attributes are same as defined in proto messages
        print(candle.id, candle.a)
Beispiel #5
0
def main():
    # Create credentials for use with an secured channel
    creds = grpc.ssl_channel_credentials(open(PATH_TO_CERT_FILE, 'rb').read())

    # Initialize GRPC channel
    channel = grpc.secure_channel(SERVER_ADDRESS, creds)
    
    # create stub
    stub = types_pb2_grpc.MessagesProxyStub(channel)

    # create request
    assets_filter = types_pb2.AssetsFilter(assets = ['BTC'], all_assets = False)

    # Response-streaming RPC
    telegram_stream = stub.SubscribeTelegram(assets_filter)
    for telegram in telegram_stream:
        # attributes are same as defined in proto messages
        print(telegram.user_message.base.id, telegram.user_message.message)
Beispiel #6
0
def main():
    # Create credentials for use with an secured channel
    creds = grpc.ssl_channel_credentials(open(PATH_TO_CERT_FILE, 'rb').read())

    # Initialize GRPC channel
    channel = grpc.secure_channel(SERVER_ADDRESS, creds)

    # create stub
    stub = types_pb2_grpc.SentimentsStub(channel)

    # create request
    req = types_pb2.AggregationCandleFilter(
        resolution='M1',
        assets_filter=types_pb2.AssetsFilter(assets=['BTC'], all_assets=False))

    # Response-streaming RPC
    candle_stream = stub.SubscribeNewsSentiment(req)
    for candle in candle_stream:
        # attributes are same as defined in proto messages
        print(candle.id, candle.a)
Beispiel #7
0
def main():
    # Create credentials for use with an secured channel
    credentials = grpc.ssl_channel_credentials(open(PATH_TO_CERT_FILE, 'rb').read())

    # uncomment commands below if token auth is required
    # call_credentials = grpc.access_token_call_credentials('YOUR_TOKEN')
    # credentials = grpc.composite_channel_credentials(credentials, call_credentials)

    channel = grpc.secure_channel(SERVER_ADDRESS, credentials))

    # create stub
    stub = types_pb2_grpc.MessagesProxyStub(channel)

    # create request
    assets_filter = types_pb2.AssetsFilter(assets = ['BTC'], all_assets = False)

    # Response-streaming RPC
    tweet_stream = stub.SubscribeTweet(assets_filter)
    for tweet in tweet_stream:
        # attributes are same as defined in proto messages
        print(tweet.id, tweet.content)
Beispiel #8
0
def main():
    # Create credentials for use with an secured channel
    credentials = grpc.ssl_channel_credentials(open(PATH_TO_CERT_FILE, 'rb').read())

    # uncomment commands below if token auth is required
    # call_credentials = grpc.access_token_call_credentials('YOUR_TOKEN')
    # credentials = grpc.composite_channel_credentials(credentials, call_credentials)

    channel = grpc.secure_channel(SERVER_ADDRESS, credentials)
    
    # create stub
    stub = types_pb2_grpc.SentimentsStub(channel)

    # create request
    req = types_pb2.AggregationCandleFilter(resolution='M1', assets_filter=types_pb2.AssetsFilter(assets = ['BTC'], all_assets = False))
   
    # Response-streaming RPC
    candle_stream = stub.SubscribeNewsSentiment(req)
    for candle in candle_stream:
        # attributes are same as defined in proto messages
        print(candle.id, candle.a)
Beispiel #9
0
def main():
    assert TOKEN != '', 'You need to set TOKEN. To obtain your token visit https://cryptomood.com/business/products/sentiment-analysis-api/.'
    # Create credentials for use with an secured channel
    credentials = grpc.ssl_channel_credentials(open(PATH_TO_CERT_FILE, 'rb').read())

    call_credentials = grpc.access_token_call_credentials(TOKEN)
    credentials = grpc.composite_channel_credentials(credentials, call_credentials)

    channel = grpc.secure_channel(SERVER_ADDRESS, credentials)
    
    # create stub
    stub = types_pb2_grpc.MessagesProxyStub(channel)

    # create request
    assets_filter = types_pb2.AssetsFilter(assets = ['BTC'], all_assets = False)
    
    # Response-streaming RPC
    article_stream = stub.SubscribeArticle(assets_filter)
    for article in article_stream:
        # attributes are same as defined in proto messages
        print(article.base.id, article.base.content)