Giter Club home page Giter Club logo

ibm / watson-stock-advisor Goto Github PK

View Code? Open in Web Editor NEW
95.0 21.0 55.0 2.8 MB

Create a web app for monitoring sentiment, price, and news for individual listed stocks, using IBM Watson Discovery and CloudantDB as well as Nodejs and Alpha Vantage.

Home Page: https://developer.ibm.com/patterns/create-a-web-app-to-get-stock-information-prices-and-sentiment/

License: Apache License 2.0

JavaScript 85.01% CSS 3.45% HTML 11.54%
ibmcode watson-discovery stock-prices discovery-news artificial-intelligence alphavantage nodejs

watson-stock-advisor's Introduction

Build Status

Read this in other languages: 日本語.

WARNING: This repository is no longer maintained ⚠️

This repository will not be updated. The repository will be kept available in read-only mode.

Watson Stock Advisor

In this Code Pattern, we will create a web app for monitoring sentiment, price, and news for individual listed stocks, using IBM Watson Discovery and CloudantDB as well as Nodejs and Alpha Vantage. The web page is adapted from a template from Start Bootstrap by Blackrock Digital. You can find the repository for the template here, including its License.

When the reader has completed this Code Pattern, they will understand how to:

  • Create and use Watson Discovery and Cloudant NoSQL Database
  • Gather news from the Watson Discovery News service
  • Obtain stock price information from Alpha Vantage
  • Deploy a Nodejs application to input stock choices and display information

Flow

  1. The user adds and remove stocks they are interested in using the Web UI.
  2. User input is processed and routed to the backend server.
  3. The backend server stores stock information in a Cloudant NoSQL database for easy retrieval.
  4. The backend server uses Watson Discovery to find information about a specific company.
  5. The Watson Discovery Service queries the Watson News collection for articles related to the company.
  6. The Alpha Vantage APIs are queried to find market price for a given company.
  7. News, sentiment, and stock price are all returned and rendered in the web app to the user.

Included Components

  • Watson Discovery: A cognitive search and content analytics engine for applications to identify patterns, trends, and actionable insights.
  • Cloudant NoSQL DB: A fully managed data layer designed for modern web and mobile applications that leverages a flexible JSON schema.

Featured Technologies

  • NodeJS: Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Watch the Video

Prerequisites

Create an Alpha Vantage account and get API key

  • Create an account on Alpha Vantage by clicking Get Your Free API Key Today.
  • Copy the Alpha Vantage API key for later use

Steps

Use the Deploy to IBM Cloud button OR create the services and run locally.

Deploy to IBM Cloud

Deploy to IBM Cloud

  1. Press the above Deploy to IBM Cloud button and then click on Deploy.
  1. In Toolchains, click on Delivery Pipeline to watch while the app is deployed. (Note, if you get an error on the first time you deploy such as Server error, status code: 409, error code: 60016, message: An operation for service instance wsa-discovery is in progress., just click on the re-deploy button again, and it should work). Once deployed, the app can be viewed by clicking View app.

  1. To see the app and services created and configured for this Code Pattern, use the IBM Cloud dashboard. The app is named watsonstockadvisor with a unique suffix. The following services are created and easily identified by the wsa- prefix:
    • wsa-discovery
    • wsa-cloudant

You can Deploy the application simply by clicking the Deploy to IBM Cloud button above to automatically create a toolchain to provision and run the application.

If you do not have an IBM Cloud account yet, you will need to create one.

Update the Environment of your deployed app

  1. Navigate to https://cloud.ibm.com/dashboard/apps/
  2. Located and click on your newly created application (not the 'Route' link)
  3. Select 'Runtime' in the left menu
  4. Select the 'Environment Variables' tab in the middle of the page
  5. Scroll down to the User defined variables section
  6. Paste your API key from Alpha Vantage

Run locally

  1. Clone the repo
  2. Create IBM Cloud services
  3. Configure Watson Discovery and Get Credentials
  4. Provision Cloudant NoSQL DB and Get Credentials
  5. Web Portal
  6. Add IBM Cloud Services Credentials to .env file
  7. Run the application

1. Clone the repo

Clone the watson-stock-advisor locally. In a terminal, run:

$ git clone https://github.com/ibm/watson-stock-advisor

2. Create IBM Cloud services

Create the following services:

3. Configure Watson Discovery and get credentials

  • Launch the Watson Discovery tool. The first time you do this, you will see "Before working with private data, we will need to set up your storage". Click Continue and wait for the storage to be set up.

  • Choose Watson Discovery News from the Manage Data tab.

  • Under Collection Info section, click Use this collection in API and copy the Environment ID into your .env file as DISCOVERY_ENV_ID. This should be system for the Watson Discovery News collection.

  • From the top-level Discovery page, click Service Credentials. If there is no credential under View Credentials click New Credential and then View Credentials.

  • Use the username and password in the .env file, as instructed below.

4. Provision Cloudant NoSQL DB and Get Credentials

  • Navigate to cloud.ibm.com

  • Click Create Resource

  • Search for cloudant nosql

  • Select the only search result under Data & Analytics called Cloudant NoSQL DB

  • Specify the settings you want

  • Click Create in the bottom right

  • From the top-level Cloudant page, click Service Credentials. If there is no credential under View Credentials click New Credential and then View Credentials.

5. Web Portal

The web page is adapted from a template from Start Bootstrap by Blackrock Digital. You can find the repository for the template here, including its License.

6. Add IBM Cloud Services Credentials to .env file

As you create the Bluemix Services, you'll need to create service credentials and get the username and password:

Move the watson-stock-advisor/web/env.sample file to watson-stock-advisor/web/.env and populate the service credentials (and Cloudant URL) as you create the credentials:

The credentials for IBM Cloud services (Discovery), can be found in the Services menu in IBM Cloud, by selecting the Service Credentials option for each service.

The other settings for Discovery were collected during the earlier setup steps (ENV_ID).

Navigate to the web directory and Copy the env.sample to .env.

$ cp env.sample .env

Edit the .env file with the necessary settings.

env.sample:

# Copy this file to .env and replace the credentials with 
# your own before starting the app.

# Watson Discovery
DISCOVERY_VERSION_DATE="2018-03-05"
DISCOVERY_ENV_ID="system"
DISCOVERY_URL=<add_discovery_url>
## Un-comment and use either username+password or IAM apikey.
# DISCOVERY_USERNAME=<add_discovery_username>
# DISCOVERY_PASSWORD=<add_discovery_password>
# DISCOVERY_IAM_APIKEY=<add_discovery_iam_apikey>

# Cloudant
CLOUDANT_USERNAME=<add_cloudant_username>
CLOUDANT_PASSWORD=<add_cloudant_password>
CLOUDANT_HOST=<add_cloudant_host>
DB_NAME="stock-data"

# App Config
MAX_COMPANIES=20
MAX_ARTICLES_PER_COMPANY=100

# AlphaVantage
ALPHAVANTAGE_API_KEY="demo"

7. Run the application

If you decided to run the app locally...

In the root directory, run:

$ npm install
$ npm start

The portal should now be accessible on port 8080 (or another port specified by PORT in .env)

Sample Output

Links

Learn more

  • Artificial Intelligence Code Patterns: Enjoyed this Code Pattern? Check out our other AI Code Patterns.
  • AI and Data Code Pattern Playlist: Bookmark our playlist with all of our Code Pattern videos
  • With Watson: Want to take your Watson app to the next level? Looking to utilize Watson Brand assets? Join the With Watson program to leverage exclusive brand, marketing, and tech resources to amplify and accelerate your Watson embedded commercial solution.

License

This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.

Apache Software License (ASL) FAQ

watson-stock-advisor's People

Contributors

asanzi avatar creitz avatar dolph avatar gjena avatar horeaporutiu avatar imgbot[bot] avatar jamaya2001 avatar jayakrishna-duvvuri avatar kant avatar kyokonishito avatar ljbennett62 avatar rhagarty avatar scottdangelo avatar smahale18 avatar stevemar avatar stevemart avatar tqtran7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

watson-stock-advisor's Issues

Cloudant Connectivity Parameter Change

Hi

I was trying to run the stock-advisor. Following issues I faced.

  1. If I want to run locally, Cloudant connectivity parameters has changed. No User/password available. Now its all API key.
  2. I got int into error while running the pipeline which I think is due to change in connectivity parameter.

It will be great if u take care the issue.

Suggestions to Help Improve "Deploy to IBM Cloud" Instructions Section

  1. Deploy to IBM Cloud
    Suggestions:
  • I've had previous experience with IBM Cloud before, so I was familiar with navigating the website and even if I wasn't, the instructions explaining how to deploy the code to IBM Cloud were very straightforward.

  • It was especially nice to have that screen shot showing what the stock advisor app should look like in Step 2, which I would also recommend to incorporate in the following Step 3 and Steps 1-7 in "Update the Environment of your deployed app."

  • It probably would be better for the user to know they have to create an IBM Cloud account in the initial Prerequisites rather than at the end of the "Deploy to IBM Cloud instructions" since both options of deploying to the IBM Cloud and running locally utilize a Cloud account.

Suggestions to Help Improve "Update the Environment of your Deployed App"

  1. Update the Environment of your Deployed App
    Suggestions:
  • Updating the Environment of your deployed app should be made into Step 4 because it is a necessary component of the stock advisor.

  • As stated before, Steps 1-7 would be more clear if a screen shot accompanied the instructions to show the user exactly what they should be seeing and doing.

Suggestions to Improve Run Locally Instructions

  1. Clone the repo
    -Cloning the repository is straightforward, instructions tell you exactly what to do
    -But what if the person doesn't know what a terminal is? What if they are just starting out with coding, maybe should offer an explanation or recommendation on where to go for more information?

  2. Create IBM Cloud services
    -Watson Discovery: Process is clear, but free IBM Cloud account only lets you create so many services, so that could be an issue.
    -Cloudant NoSQL DB: See later suggestions

  3. Configure Watson Discovery and get credentials
    -Launching and choosing Watson Discovery News from the Manage Data tab is clear.
    -Found Environment ID ok as well, but maybe explain what a .env file?
    -Looked at youtube video tutorial for help, followed along to get to the credentials on terminal.
    -No clear written instructions on how to get .env file and how to edit it - maybe add something to further clarify?

  4. Provision Cloudant NoSQL DB and Get Credentials
    -Navigated to console.bluemix.net and searched for cloudant nosql, but 3 results came up, not 1.
    -Not listed under data & analytics section.

  5. Web Portal
    -Not quite why these instructions are here, why is it important to have the repository of the template of the website?

  6. Add IBM Cloud Services Credentials to .env file
    -Clear on how to get the credentials, but to replace the credentials to the .env file, need to know how to use the vi text editor
    -Where do you exactly save the file on the computer?

  7. Run the application
    -Need to have downloaded Node.js and npm, steps just tell you to run "npm install" and "npm start" in root directory
    -^Should be a part of the prerequisites or add more instructions to step 7

Alpha Vantage Acknowledgement

Hello Team IBM,

We are the support team of Alpha Vantage. Huge fan of the Watson Stock Advisor - we are honored to be part of the journey!

The title of the project home page reads "Use Watson Discovery, Cloudant NoSQL DB, and Node.js to create a web app to monitor sentiment, price, and news for individually listed stocks."

Would it be possible to include Alpha Vantage in the title as well? If you see fit, please feel free to drop us a note at [email protected] anytime.

Sincerely,

Team Alpha Vantage

Code pattern text edits

All mentions of "Watson News Explorer" on the developerWorks code pattern page should be replaced with "Watson Discovery News"

sentiment, trend, news not loading

I deployed the app using the Deploy to IBM Cloud button. I was able to add stocks but no sentiment, news or trend graph was created.

Screenshot:

screen shot 2018-03-11 at 12 24 13 am

Snippet from chrome's web console:

angular.js:14800 TypeError: Cannot read property 'data' of undefined
    at $scope.$apply (MainCtrl.js:66)
    at b.$eval (angular.js:18542)
    at b.$apply (angular.js:18641)
    at success (MainCtrl.js:57)
    at StockService.add.then (MainCtrl.js:84)
    at <anonymous>
(anonymous) @ angular.js:14800
angular.js:14800 TypeError: Cannot read property 'data' of undefined
    at $scope.$apply (MainCtrl.js:66)
    at m.$eval (angular.js:18542)
    at m.$apply (angular.js:18641)
    at success (MainCtrl.js:57)
    at StockService.add.then (MainCtrl.js:84)
    at <anonymous>
(anonymous) @ angular.js:14800
angular.js:14800 TypeError: Cannot read property 'data' of undefined
    at b.$scope.selectCompany (MainCtrl.js:165)
    at fn (eval at compile (angular.js:15651), <anonymous>:4:307)
    at e (angular.js:27475)
    at b.$eval (angular.js:18542)
    at b.$apply (angular.js:18641)
    at HTMLTableRowElement.<anonymous> (angular.js:27480)
    at jg (angular.js:3791)
    at HTMLTableRowElement.d (angular.js:3779)
(anonymous) @ angular.js:14800

Looking at the CF logs, no errors are reported. I can see the services properly linked as the VCAP environment variables are set:

screen shot 2018-03-11 at 12 26 57 am

Make the repo code-pattern compliant

Looking good so far team! We need to do a few other things to make this a "code pattern":

  1. Create a thorough README.md
  2. Create a wiki to draft IBMCode content
  3. Add an architectural diagram
  4. Add Deploy to IBM Cloud support
  5. Create a video
  6. Create a blog
  7. Add unit tests
  8. Add linting tests

Feature Change Convo Recap

  1. 3-4 stats (e.g. P/E, div yield, mkt cap) added to chart at top left of page
  2. Remove ticker column from chart (or add ticker as a parenthetical next to company name)
  3. Consider replacing red delete buttons with one small edit icon inside the Company cell
  4. Change neutral sentiment pie chart color from yellow to light grey
  5. Re news articles: either segment according to meaningful categories/concepts and arrange articles according to these buckets, or, otherwise, add 1-5 keyword tags below article icon describing article content
    —> this step is crucial to highlight Discovery enrichments
  6. Optional: add a second graph similar to the co-mentions graph in the Discovery News demo
  7. Display high/low and open/close in app header

@ddevara @creitz

Suggestions to help improve README.md

Hello! My name is Madison and I'm one of the IBM Digital Business Group San Francisco interns this summer. I'm currently going through some IBM code patterns and documenting my experiences to hopefully provide some useful suggestions to help improve the code patterns' user instructions. As a beginner coder, I hope I'll be able to bring a fresh pair of eyes to these patterns and provide some feedback on how to perhaps clarify some steps to make them more clear to other beginner developers who are new to code patterns and the topics these code patterns cover in general.

Steps
Suggestions:

  • I went through both the "Deploy to IBM Cloud" button and creating the services & run locally options, but when I was first starting this code pattern, I was confused about the difference between them and which one I should personally do. It may be helpful for users to be able to read an explanation of each option so they can better decide which one to do or to start out with.

  • Providing definitions for these two options can also be applied to all code patterns containing deploy to IBM cloud and running locally instructions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.