Prechádzať zdrojové kódy

Added various methods to pull stock market indices from quadl through a script

Marco Quezada 10 rokov pred
rodič
commit
673f1659e1

+ 37 - 0
hackathon_starter/hackathon/scripts/quandl.py

@@ -0,0 +1,37 @@
+'''Module containing a handful of methods for 
+aggregating data from markets throughout the world'''
+
+import requests
+import simplejson as json
+from datetime import datetime
+
+APIKEY = ' fANs6ykrCdAxas7zpMz7'
+
+def DOWJonesIndustrialavg(APIKEY):
+    #Returns JSON data of the Dow Jones Average. 
+    parameters = {
+    'rows' : 1, 
+    'auth_token' : APIKEY,
+    }
+    r = requests.get('https://www.quandl.com/api/v1/datasets/BCB/UDJIAD1.json?',params=parameters)
+    d = json.loads(r.content)
+    return d['data']
+def SnP500Indexpull(APIKEY):
+    #Returns JSON data of the S&P 500 Index. 
+    parameters = {
+    'rows' : 1, 
+    'auth_token' : APIKEY,
+    }
+    r = requests.get('https://www.quandl.com/api/v1/datasets/YAHOO/INDEX_GSPC.json?',params=parameters)
+    d = json.loads(r.content)
+    return d['data']
+def Nasdaqpull(APIKEY):
+    #Returns JSON data of the Nasdaq Index. 
+    parameters = {
+    'rows' : 1, 
+    'auth_token' : APIKEY,
+    }
+    r = requests.get('https://www.quandl.com/api/v1/datasets/GOOG/NASDAQ_SWTX.json?',params=parameters)
+    d = json.loads(r.content)
+    return d['data']
+# print DOWJonesIndustrialavg(APIKEY)

+ 19 - 0
hackathon_starter/hackathon/templates/hackathon/facebook.html

@@ -72,6 +72,23 @@
         'Thanks for logging in, ' + response.name + '!';
     });
   }
+  // Here will be a function that'll create a dialog box to post upon your own wall. 
+  function posttoFeed() {
+    FB.ui({
+     method: 'Feed',
+     name: 'Django-Hackathon-Starter',
+     caption: 'starter dialog box',
+     description: 'This is a wall post brought to you by the Hackathon Starter',
+     message: 'It is alive!'
+    },
+    function(response){
+      if (response && response.post_id){
+        alert('post was published');
+      } else {
+        alert('post was not published');
+      }
+    });
+  }
 </script>
 
 <!--
@@ -83,6 +100,8 @@
 <fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
 </fb:login-button>
 
+<input type="button" onclick="posttoFeed()" value="Post to Feed" />
+
 <div id="status">
 </div>