Skip to content

Commit

Permalink
#1: updating stockscraper module
Browse files Browse the repository at this point in the history
  • Loading branch information
josuebrunel committed Jun 27, 2015
1 parent 95bbb94 commit 985be59
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 3 deletions.
124 changes: 124 additions & 0 deletions docs/stockscraper.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,130 @@ data = stocks.get_industry_index(112)
}
```

#### *StockRetriever.get_xchange_rate(pairs, items=None)*

```python
from myql.contrib.finance.stockscraper import StockRetriever
stocks = StockRetriever(format='json')
data = stocks.get_xchange_rate(['EURUSD','GBPUSD'])
```

```json
{
"query": {
"count": 2,
"created": "2015-06-27T13:48:51Z",
"lang": "en-US",
"results": {
"rate": [
{
"Ask": "1.1174",
"Bid": "1.1162",
"Date": "6/27/2015",
"Name": "EUR/USD",
"Rate": "1.1168",
"Time": "12:53pm",
"id": "EURUSD"
},
{
"Ask": "1.5756",
"Bid": "1.5738",
"Date": "6/27/2015",
"Name": "GBP/USD",
"Rate": "1.5747",
"Time": "12:53pm",
"id": "GBPUSD"
}
]
}
}
}

```

#### *StockRetriever.get_dividendhistory(symbol, startDate, endDate)*

```python
from myql.contrib.finance.stockscraper import StockRetriever
stocks = StockRetriever(format='json')
data = stocks.get_dividendhistory('AAPL',"2008-01-01", "2015-06-15")
```

```json
{
"query": {
"count": 12,
"created": "2015-06-27T13:42:27Z",
"lang": "en-US",
"results": {
"quote": [
{
"Date": "2015-05-07",
"Dividends": "0.520000",
"Symbol": "AAPL"
},
{
"Date": "2015-02-05",
"Dividends": "0.470000",
"Symbol": "AAPL"
},
{
"Date": "2014-11-06",
"Dividends": "0.470000",
"Symbol": "AAPL"
},
{
"Date": "2014-08-07",
"Dividends": "0.470000",
"Symbol": "AAPL"
},
{
"Date": "2014-05-08",
"Dividends": "0.470000",
"Symbol": "AAPL"
},
{
"Date": "2014-02-06",
"Dividends": "0.435710",
"Symbol": "AAPL"
},
{
"Date": "2013-11-06",
"Dividends": "0.435710",
"Symbol": "AAPL"
},
{
"Date": "2013-08-08",
"Dividends": "0.435710",
"Symbol": "AAPL"
},
{
"Date": "2013-05-09",
"Dividends": "0.435710",
"Symbol": "AAPL"
},
{
"Date": "2013-02-07",
"Dividends": "0.378570",
"Symbol": "AAPL"
},
{
"Date": "2012-11-07",
"Dividends": "0.378570",
"Symbol": "AAPL"
},
{
"Date": "2012-08-09",
"Dividends": "0.378570",
"Symbol": "AAPL"
}
]
}
}
}

```

#### *StockRetriever.get_symbols(company_name)*

     **Always returns data as JSON**
Expand Down
2 changes: 1 addition & 1 deletion myql/contrib/finance/stockscraper/stockretriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_industry_index(self, index_id,items=None):
response = self.select('yahoo.finance.industry',items).where(['id','=',index_id])
return response

def get_xchange(self, pairs, items=None):
def get_xchange_rate(self, pairs, items=None):
"""Retrieves currency exchange rate data for given pair(s).
Accepts both where pair='eurusd, gbpusd' and where pair in ('eurusd', 'gpbusd, usdaud')
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ def test_get_symbols(self,):
logging.debug(pretty_json(data.content))
self.assertEqual(data.status_code, 200)

def test_get_xchange(self,):
data = self.stock.get_xchange(['EURUSD','GBPUSD'])
def test_get_xchange_rate(self,):
data = self.stock.get_xchange_rate(['EURUSD','GBPUSD'])
logging.debug(pretty_json(data.content))
self.assertEqual(data.status_code, 200)

Expand Down

0 comments on commit 985be59

Please sign in to comment.