Simple stock market analysis

3,180
-1

Published on

Implement a simple stock market analysis program with Google App Engine and Google Web Toolkit,

Published in: Education, Technology, Business
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,180
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
47
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Simple stock market analysis

  1. 1. Simple Stock Market Analysis<br />Cloud Computing<br />LinaQu<br />Independent Study instructed by Dr. Yacobellis<br />2011.05.10<br />
  2. 2. Outline<br />Introduction<br />Cloud Computing<br />Google App Engine™ platform<br />Google Web Toolkit<br />Simple Stock Market Analysis<br />References<br />
  3. 3. 1. Introduction<br />Using the cloud computing platform, Google App Engine™ platform in this case, together with Google Web Toolkit to develop and deploy a simple program ---- Simple Stock Market Analysis. <br />Through this project, we can learn briefly:<br /><ul><li>Cloud Computing and its service models;
  4. 4. Google App Engine(GAE) as develop platform;
  5. 5. Google Web Toolkit(GWT) as a development toolkit;
  6. 6. Big Table as a distributed storage system;
  7. 7. An example project actually runs on GAE.</li></li></ul><li>2. Cloud Computing<br />2.1 What is Cloud Computing?<br />A large-scale distributed computing paradigm that is driven by economies of scale, in which a pool of abstracted, virtualized, dynamically-scalable, managed computing power, storage, platforms, and services are delivered on demand to external customers over the Internet[1].<br />Cloud computing refers to the provision of computational resources on demand via a computer network, such as applications, databases, file services, email, etc.  <br />(----Wikipedia)<br />
  8. 8. 2. Cloud Computing<br />2.2 Key characters of Cloud Computing<br /><ul><li> On-demand self-service
  9. 9. Broad network access
  10. 10. Resource pooling
  11. 11. Rapid elasticity
  12. 12. Measured Service</li></li></ul><li>2. Cloud Computing<br />2.3 Service models of Cloud Computing<br />Software as a Service (SaaS)<br />Platform as a Service (PaaS)<br />Infrastructure as a Service (IaaS)<br />Access computer infrastructure via Web.<br />Google Pack, Salesforce.com, NetSuite.<br />Do the development in the cloud.<br />Google App Engine, Windows® Azure, Force.com.<br />Applications are hosted by a provider, or could be accessed via the Web.<br />Amazon EC2 (Elastic Cloud Computing) Service, S3 (Simple Storage Service), IBM® Cloud.<br />
  13. 13. 2. Cloud Computing<br />2.3 Service models of Cloud Computing<br />
  14. 14. 3. Google App Engine™ platform<br />3.1 What is Google App Engine?<br />It lets you run your web applications on Google’s infrastructure.<br />Visit here for more information.<br />Google App Engine FAQ.<br />Sample Apps Code is here.<br />
  15. 15. 3. Google App Engine™ platform<br />3.2 Why Google App Engine?<br /><ul><li> Easy to build
  16. 16. Easy to get Started[17]
  17. 17. Simple app configuration
  18. 18. Easy to maintain
  19. 19. Cost efficient hosting
  20. 20. Risk free trial period
  21. 21. The reliability, performance and security of Google's infrastructure
  22. 22. Easy to scale
  23. 23. Automatic scalability
  24. 24. APIs</li></li></ul><li>3. Google App Engine™ platform<br />3.3 Google App Engine Architecture<br />req/resp<br />stateless APIs<br />R/O FS<br />Python<br />VM<br />process<br />urlfech<br />stdlib<br />mail<br />app<br />images<br />datastore<br />stateful<br />APIs<br />memcache<br />Source: [15] <br />
  25. 25. 3. Google App Engine™ platform<br />3.3 Google App Engine Architecture<br />The App Engine request handling architecture[13].<br />
  26. 26. 3. Google App Engine™ platform<br />3.4 Key Concepts in Google App Engine<br /><ul><li>Sandbox: </li></ul>-Security; It isolates your application in its own secure, reliable environment ; the hardware, operating system and physical location of the web server.<br />
  27. 27. 3. Google App Engine™ platform<br />3.4 Key Concepts in Google App Engine<br /><ul><li>Bigtable: A Distributed Storage System for Structured Data[8].</li></ul>-It uses the distributed Google File System(GFS[25]) to store log and data files.<br />-It uses Google SSTable file format to store data. (persistent, ordered immutable map from keys to values)<br />-It relies on a highly-available and persistent distributed lock service called Chubby.<br />-It is designed to scale to a very large size.<br />-It does not support a full relational data model.<br />
  28. 28. 3. Google App Engine™ platform<br />3.4 Key Concepts in Google App Engine<br /><ul><li>Datastore: A distributed data storage service grows with your data.</li></ul>-Abstraction on top of Bigtable; It provides a scalable, transactional storage system for creating, storing, and querying data objects.<br />-Two data storage options[18, 19]: The Master/Slave Datastore and the High Replication Datastore.<br />- APIs For Java: Java Data Objects(JDO) 2.3 and Java Persistence API (JPA) 1.0<br />
  29. 29. 3. Google App Engine™ platform<br />3.4 Key Concepts in Google App Engine<br /><ul><li>HierarchicalDatastore</li></li></ul><li>3. Google App Engine™ platform<br />3.4 Key Concepts in Google App Engine<br /><ul><li> Indexes
  30. 30. index.yaml;  the development server automatically determines the index configuration for you[22].
  31. 31. Properties are automatically indexed by type+value[15, 21].
  32. 32. Queries</li></ul>-JDOQL:  is similar to SQL, but is more appropriate for object-oriented databases like the App Engine datastore.<br />-GQL[24]: is a SQL-like language for retrieving entities or keys from the App Engine scalable datastore.<br />
  33. 33. 3. Google App Engine™ platform<br />3.5 Develop Web app with Google App Engine<br />GAE Application Development Cycle[10]<br />
  34. 34. 3. Google App Engine™ platform<br />3.6 Managing Your App<br />
  35. 35. 3. Google App Engine™ platform<br />3.6 Managing Your App<br /><ul><li> Quotas</li></ul>-5M pageviews/month<br />-Channel API Calls: 657K calls<br />-Stored Data: 1GB<br />-Datastore API Calls: 141M calss<br />-Number of Indexes: 200<br />-Requests(includes HTTPS): 43.2M requests<br />-CPU Time: 6.5 CPU-hours/day<br />-Task Queue API Calls: 100K<br />-UrlFetch API Calls: 657K calls<br />-XMPP API Calls: 46M calls<br />
  36. 36. 3. Google App Engine™ platform<br />3.6 Managing Your App<br />
  37. 37. 3. Google App Engine™ platform<br />3.7 Support<br /><ul><li> Java[7]
  38. 38. Java 6
  39. 39. Common Java web technology standards
  40. 40. Plugin for the Eclipse IDE
  41. 41. Other languages: JRuby, JavaScript(Thino), Scala.
  42. 42. Spring, Struts 1&2, Apache Commons FileUpload, etc.
  43. 43. Python[27]</li></ul>-Complete Python standard library<br />-Django<br />-CGI or WSGI<br />
  44. 44. 3. Google App Engine™ platform<br />3.8 Summary in Google App Engine<br />Strengths <br />- Python, Java support. (with SDK)<br />- Collections of APIs.<br />- Dashboard.<br />- Generous Quotas lead to low entry cost.<br />- GFS, Bigtable<br />
  45. 45. 3. Google App Engine™ platform<br />3.8 Summary in Google App Engine<br />Weaknesses <br />- Non-relational database lead to many constraints.<br />- Quotas' limit often cause substantial headaches for developers.<br />- Impose on the basis of security, HTTPS/HTTP.<br />- Not very stable version in 2011.<br />- Being blocked in China<br />
  46. 46. 4. Google Web Toolkit<br />4.1 What is Google Web Toolkit?<br />Google Web Toolkit (GWT) is a development toolkit for building and optimizing complex browser-based applications. <br />It is Java Web development and let you develop and debug AJAX applications in the Java Language[40]. <br />Visit here for more information.<br />Google Web Toolkit showcase : here.<br />Google Web Toolkit Widget Gallery.<br />
  47. 47. 4. Google Web Toolkit<br />4.2 Why is Google Web Toolkit? [38]<br />Its goal is to enable productive development of high-performance web applications without the developer having to be an expert in browser quirks, HMLHttpRequest, and JavaScript. <br /><ul><li> Open Source, completely free.
  48. 48. Code stable, efficient and cross-browser apps (include mobile), offline compatible.
  49. 49. Developer friendly, IDE support etc.</li></li></ul><li>4. Google Web Toolkit<br />4.3 Google Web Toolkit Architecture.<br />Source: [40]<br />
  50. 50. 5. Simple Stock Market Analysis<br />5.1 Functions<br /><ul><li>Sign in with users' account
  51. 51. Display the users' stock list
  52. 52. Search stock quote and save the quote for users
  53. 53. Remove specific stock from users’ stock list
  54. 54. Log out</li></li></ul><li>5. Simple Stock Market Analysis<br />5.2 Features<br /><ul><li>Relative real-time Stock Information[33]
  55. 55. IE, Chrome Compatible
  56. 56. Suggestion for stock quote search</li></li></ul><li>5. Simple Stock Market Analysis<br />5.3 Program UI<br /><ul><li>Index</li></li></ul><li>5. Simple Stock Market Analysis<br />5.3 Program UI<br /><ul><li>Sign In</li></li></ul><li>5. Simple Stock Market Analysis<br />5.3 Program UI<br /><ul><li>Home</li></li></ul><li>5. Simple Stock Market Analysis<br />5.3 Program UI<br /><ul><li>Search Quote (1/2)</li></li></ul><li>5. Simple Stock Market Analysis<br />5.3 Program UI<br /><ul><li>Search Quote (2/2)</li></li></ul><li>5. Simple Stock Market Analysis<br />5.3 Program UI<br /><ul><li> Remove Quote (Before)</li></li></ul><li>5. Simple Stock Market Analysis<br />5.3 Program UI<br /><ul><li>Remove Quote (2 items removed)</li></li></ul><li>5. Simple Stock Market Analysis<br />5.3 Program UI<br /><ul><li>IE Compatible</li></li></ul><li>5. Simple Stock Market Analysis<br />5.4 Code Snip<br /><ul><li> Sign In– RPC – Server</li></ul>public class LoginServiceImpl extends RemoteServiceServletimplements<br />LoginService{<br />public LoginInfo login(String requestUri) {<br />UserServiceuserService = UserServiceFactory.getUserService();<br />User user = userService.getCurrentUser();<br />LoginInfologinInfo = new LoginInfo();<br />if (user != null) {<br />loginInfo.setLoggedIn(true);<br />loginInfo.setEmailAddress(user.getEmail());<br />loginInfo.setNickname(user.getNickname());<br />loginInfo.setLogoutUrl(userService.createLogoutURL(requestUri));<br /> } else {<br />loginInfo.setLoggedIn(false);<br />loginInfo.setLoginUrl(userService.createLoginURL(requestUri)); }<br />return loginInfo;<br />}}<br />
  57. 57. 5. Simple Stock Market Analysis<br />5.4 Code Snip<br /><ul><li> GWT Entry Point Method (StockWather.java) - Client</li></ul>public void onModuleLoad() {<br /> //Using Login Service checks the login status.<br />LoginServiceAsyncloginService = GWT.create(LoginService.class);<br /> //void loyola.lqu.client.LoginServiceAsync.login(String requestUri, AsyncCallback<LoginInfo> async)<br />loginService.login(GWT.getHostPageBaseURL(), new AsyncCallback<LoginInfo>() {<br /> //new object of Type AsyncCallback<LoginInfo><br />public void onFailure(Throwable error) {}<br />public void onSuccess(LoginInfo result) {loginInfo = result;<br />if(loginInfo.isLoggedIn()) { <br />String name = "Welcome! " + loginInfo.getNickname();<br />userNickName= new Label(name);<br />loadStockWatcher();<br /> } else {<br />loadLogin();<br />}}<br />});<br />
  58. 58. 5. Simple Stock Market Analysis<br />5.4 Code Snip<br /><ul><li> Login Panel – GWT – Client</li></ul>private void loadLogin() { //in StockWather.java<br /> // Assemble login panel.<br />signInLink.setHref(loginInfo.getLoginUrl());<br />loginLabel.addStyleDependentName("loginLabel");<br />loginPanel.add(loginLabel);<br />loginPanel.add(signInLink);<br /> //Add the the GWT entry module into html page for displaying.<br />RootPanel.get("stockList").add(loginPanel);<br />}<br />In StockWatcher.html page: <br /><div id="errorMsgLabel"></div> <br /><div id="stockList"></div><br />
  59. 59. 5. Simple Stock Market Analysis<br />5.4 Code Snip<br /><ul><li> Main Panel – GWT – Client (1/5)</li></ul>private void loadStockWatcher() {<br />// Set up sign out hyperlink.<br />signOutLink.setHref(loginInfo.getLogoutUrl());<br />// Create required column for display stock data.<br />stocksFlexTable.setText(0, 0, "Symbol");<br />stocksFlexTable.setText(0, 1, "Name");<br />stocksFlexTable.setText(0, 2, "Price");<br />stocksFlexTable.setText(0, 3, "Change");<br />stocksFlexTable.setText(0, 4, "Volume");<br />stocksFlexTable.setText(0, 5, "Remove");<br />stocksFlexTable.setCellPadding(6);<br />
  60. 60. 5. Simple Stock Market Analysis<br />5.4 Code Snip<br /><ul><li> Main Panel – GWT – Client (2/5)</li></ul>// Add styles to elements in the stock list table.<br />stocksFlexTable.getRowFormatter().addStyleName(0, "watchListHeader");<br />stocksFlexTable.addStyleName("watchList");<br />stocksFlexTable.getCellFormatter().addStyleName(0, 1, "watchListNumericColumn");<br />stocksFlexTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn");<br />stocksFlexTable.getCellFormatter().addStyleName(0, 3, "watchListNumericColumn");<br />stocksFlexTable.getCellFormatter().addStyleName(0, 4, "watchListNumericColumn");<br />stocksFlexTable.getCellFormatter().addStyleName(0, 5, "watchListNumericColumn");<br />loadStocks();<br />addPanel.add(newSymbolTextBox);<br /> //Get suggest from ItemSuggestOracle instance.<br />ItemSuggestOracleoracle = new ItemSuggestOracle(); <br />newSymbolSuggestBox= new SuggestBox(oracle, newSymbolTextBox);<br />newSymbolSuggestBox.setLimit(5);<br />addPanel.add(newSymbolSuggestBox);<br />addPanel.add(addButton);<br />
  61. 61. 5. Simple Stock Market Analysis<br />5.4 Code Snip<br /><ul><li> Main Panel – GWT – Client (3/5)</li></ul>addPanel.add(newSymbolTextBox);<br /> //Get suggest from ItemSuggestOracle instance.<br />ItemSuggestOracleoracle = new ItemSuggestOracle(); <br />newSymbolSuggestBox= new SuggestBox(oracle, newSymbolTextBox);<br />newSymbolSuggestBox.setLimit(5);<br /> //Assemble the addPanel for searching quote<br />addPanel.add(newSymbolSuggestBox);<br />addPanel.add(addButton);<br />
  62. 62. 5. Simple Stock Market Analysis<br />5.4 Code Snip<br /><ul><li> Main Panel – GWT – Client (4/5)</li></ul>// Assemble the Main panel.<br />mainPanel.add(userNickName); //Display welcome information<br />mainPanel.add(lastUpdatedLabel); //Display last Updated time <br />mainPanel.add(addPanel);<br />mainPanel.add(stocksFlexTable);<br />mainPanel.add(newHTML("</br>”);<br />mainPanel.add(signOutLink);<br />// Associate the Main panel with the HTML host page, host page got an <div> id's name is stockList.<br />RootPanel.get("stockList").add(mainPanel);<br />// Move cursor focus to the inputbox.<br />newSymbolTextBox.setFocus(true);<br />
  63. 63. 5. Simple Stock Market Analysis<br />5.4 Code Snip<br /><ul><li> Main Panel – GWT – Client (5/5)</li></ul>Timer refreshTimer = new Timer(){<br />@Override<br />public void run() { refreshWatchList(); } <br />};<br />refreshTimer.scheduleRepeating(REFRESH_INTERVAL);<br />addButton.addClickHandler(new ClickHandler(){ //Deal with Button Click Event<br /> public void onClick(ClickEvent event){ addStock();}<br />});<br />newSymbolTextBox.addKeyPressHandler(new KeyPressHandler(){//Deal with Keyboard Event<br /> @Override<br /> public void onKeyPress(KeyPressEvent event) {<br /> if(event.getCharCode() == KeyCodes.KEY_ENTER){<br />addStock();<br /> }}<br />});<br />}<br />
  64. 64. 5. Simple Stock Market Analysis<br />5.4 Code Snip<br /><ul><li> appengine-web.xml</li></ul><?xml version="1.0" encoding="utf-8"?><br /><appengine-web-app xmlns="http://appengine.google.com/ns/1.0"><br /> <application>lqu-stockanalysis</application><br /> <version>11</version><br /> <!-- Configure java.util.logging --><br /> <system-properties><br /> <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/><br /> </system-properties><br /></appengine-web-app><br />
  65. 65. 5. Simple Stock Market Analysis<br />5.4 Code Snip<br /><ul><li> web.xml</li></ul> <welcome-file-list><br /> <welcome-file>StockWatcher.html</welcome-file><br /> </welcome-file-list><br /><servlet><br /> <servlet-name>loginService</servlet-name><br /> <servlet-class>loyola.lqu.server.LoginServiceImpl</servlet-class><br /></servlet><br /><servlet-mapping><br /> <servlet-name>loginService</servlet-name><br /> <url-pattern>/stockwatcher/login</url-pattern><br /></servlet-mapping><br />…<br />… <br />
  66. 66. 5. Simple Stock Market Analysis<br />5.5 Application Dashboard in Google App Engine<br />
  67. 67. 5. Simple Stock Market Analysis<br />5.5 Application Dashboard in Google App Engine<br />
  68. 68. 5. Simple Stock Market Analysis<br />5.6 Technology<br /><ul><li> Google App Engine[5]
  69. 69. The Users Java API[30]
  70. 70. Google Web Toolkit[34]
  71. 71. GWT-RPC[29]
  72. 72. JSON[32]
  73. 73. CSS, JavaScript etc.</li></li></ul><li>6. Reference<br />Cloud Computing and Grid Computing 360-Degree Compared, Ian Foster, Yong Zhao, IoanRaicu, Shiyong Lu.<br />Cloud computing service models, Part 2: Platform as a Service : Learn the benefits of PaaS.<br />Cloud and industry, Part 1: PaaS best practices and patterns : Learn about the requirements and functions of three models to deliver industry solutions, IaaS, PaaS, SaaS, and how you can use best practices and patterns with the PaaS framework in particular to deploy and manage cloud computing solutions. <br />Connecting to the cloud, Part 1: Leverage the cloud in applications: Explore cloud computing and the offerings from the major cloud platform vendors: Amazon, Google, Microsoft®, and SalesForce.com.<br />Google App Engine Home Page: Learn more about Google App Engine™ platform.<br />Install Google Plugin for Eclipse: Get started with the plug-ins.<br />
  74. 74. 6. Reference<br />Will it play in App Engine for Java?: Lists the level of compatibility of various Java technologies and App Engine (Java).<br />What's BigTable?: Read the Google research publication to find out.<br />Cloud computing fundamentals: Aid you in assimilating the reality of the revolution, so you can use it for your own profit and well being. <br />Stanford University Wiki – Google App Engine Project.<br />Slatkin, Brett. Building Scalable Web Applications with Google App Engine. Google IO 2008.<br />Ashcraft, Ken. Best Practices - Building a Production Quality Application on Google App Engine. Google IO 2008.<br />Dan Sanderson, Programming Google App Engine. O’Reilly, GoogleTM Press.<br />Getting Started: Java. Helpful sample from Google App Engine site.<br />
  75. 75. 6. Reference<br />Presentation by Guido van Rossum. Google App Engine: Run your web applications on Google's infrastructure. Stanford EE Computer Systems Colloquium. 5 Nov 2008.<br />Why App Engine. Brief explain why developers choose Google App Engine.<br />Google App Engine Samples. A list of samples and its source code.<br />Choosing a Datastore(Java). Comparing the Data Storage Options, choose the right one.<br />Datastore Overview(Python).<br />Barrett, Ryan. Under the Covers of the Google App Engine Datastore. Google IO 2008.<br />Introduction to Indexes. <br />Java Index Configuration Using YAML.<br />
  76. 76. 6. Reference<br />Queries in JDO. <br />GQL Reference.<br />The Google File System.  Get a in-depth understanding of GFS. <br />Google App Engine Articles. Articles related to Google App Engine in many aspects by category.<br />Google App Engine Python SDK Release Notes.<br />Google Web Toolkit Overview.<br />GWT-RPC. Making Remote Procedure Calls in Google Web Toolkit.<br />The Users Java API. Google App Engine applications can authenticate users who have Google Accounts<br />My Stock Watcher. Reference for code.<br />
  77. 77. 6. Reference<br />JSON. Official site of JSON.<br />YAHOO! FINANCE disclaimer. See the page footer.<br />Google Web Toolkit Home.<br />Google Web Toolkit showcase.<br />Google Web Toolkit Widget Gallery.<br />Google Web Toolkit Gallery. Actual GWT Apps projects collection.<br />What's New in GWT 2.3? Along with release notes.<br />GWT + Gears : The browser is the platform. Brief introduction to GWT.<br />Google Web Tookit(GWT). Slides by Sang Shin. Sun Microsystems, Inc.<br />
  78. 78. End<br />Cloud Computing<br />LinaQu<br />Independent Study instructed by Dr. Yacobellis<br />2011.05.10<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×