AlchemyAPI

Modified on 2013/05/11 09:14 by Eugene — Categorized as: Community Components

Syntax


public TextSentiment AlchemyAPIClient.GetRank(string text, string yourAlchemyAPIKey)

int TextSentiment.Type: -1 (negative), 1 (positive) double TextSentiment.Score: sentiment rank expressed as a value of type double

Parameter Description

textSome text to apply AlchemyAPI's sentiment analysis on
yourAlchemyAPIKeyYour AlchemyAPI key sequence

Description

Image

The AlchemyAPIClient is powered by AlchemyAPI. AlchemyAPI provides natural language processing ability.

To use the AlchemyAPIClient, you need to register for your own AlchemyAPI key here:

Example

The following example illustrates sentiment analysis (powered by AlchemyAPI) on a list of twits for current symbol obtained from StockTwits:


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using Community.Components; /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { const string key = ""; // GET A FREE API KEY FROM alchemyapi.com AND INSERT YOUR KEY HERE protected override void Execute() { if( key.Length == 0 ) { System.Windows.Forms.MessageBox.Show( "Get an API key before using" ); Abort(); } List<string> lst = StockTwitsClient.GetStockTwits( Bars.Symbol ); if( lst.Count < 1 ) return; foreach( string s in lst ) { TextSentiment ts = AlchemyAPIClient.GetRank( s, key ); PrintDebug( s + Environment.NewLine + ts.Type.ToString() + "\t" + ts.Score.ToString() ); FlushDebug(); } } } }