ServerPortfolio
2.0
Python parsers and server
|
Use the Yahoo YQL API. More...
Public Member Functions | |
def | __init__ |
Constructor. More... | |
def | create_url |
Create the URL from a sql query. More... | |
def | create_url_test |
Only for testing, take a full sql query as input(hard-coded in main section) More... | |
def | parse |
Parse YQL request, always XML format. More... | |
def | parse_info |
Parse XML for info action To get Industry,Sector and Name, this function is called 2 times by run_parser_info() . More... | |
def | parse_fund |
Extract fundamental data from the XML root element. More... | |
def | run_parser_info |
Specific call to get Info. More... | |
Public Member Functions inherited from serverportfolio.Parsers.Abstract.AbstractParser | |
def | __init__ |
Constructor. More... | |
def | create_url |
Store links to stocks to update, dictionary 'symbol' : Stock object. More... | |
def | parse |
Parse the text file (html, CSV,...) More... | |
def | run_parser |
Main function to call for running the parser. More... | |
def | clean |
Reset internal data members after a parsing. More... | |
def | store_stock_copy |
Make a local copy of the Stock objects (linked of the original in DictionaryStocks in fact) into a local dictionary. More... | |
def | update_stock |
Update the local stocks with the new retrieved data. More... | |
def | get_symbol_from_code |
Retrieve the symbol (or Stock) from the code_yahoo or code_bourso. More... | |
Public Attributes | |
logger | |
source | |
e_action | |
url | |
list_return_data | |
option_post | |
Public Attributes inherited from serverportfolio.Parsers.Abstract.AbstractParser | |
url | |
save url, useful for reporting errors and exceptions More... | |
e_action | |
enumeration (EAction) of the type of query to perform More... | |
option_post | |
local_stock | |
list_return_data | |
Private Member Functions | |
def | _fill_dict_from_xml |
Fill a dictionary template from the tags in the XML. More... | |
def | _format_symbols_url |
Static Private Attributes | |
string | __YQL_PUBLIC_URL = 'https://query.yahooapis.com/v1/public/yql?q=' |
Use the Yahoo YQL API.
Definition at line 49 of file YahooYQL.py.
def serverportfolio.Parsers.YahooYQL.YahooYQL.__init__ | ( | self, | |
e_action | |||
) |
|
private |
Fill a dictionary template from the tags in the XML.
All unknown entries are stored in an 'other' sub-dictionary.
stock_xml | lxml element as input |
dict_stock | dictionary to be filled as output |
Definition at line 314 of file YahooYQL.py.
Referenced by serverportfolio.Parsers.YahooYQL.YahooYQL.parse_fund().
|
private |
Definition at line 334 of file YahooYQL.py.
References serverportfolio.Parsers.Abstract.AbstractParser.local_stock.
def serverportfolio.Parsers.YahooYQL.YahooYQL.create_url | ( | self | ) |
Create the URL from a sql query.
table (quote/quotes/stocks/.. defined in the query) all YQL queries accept multi-stocks ? seems yes
Definition at line 68 of file YahooYQL.py.
References serverportfolio.Parsers.Abstract.AbstractParser.e_action, and serverportfolio.Parsers.Abstract.AbstractParser.local_stock.
def serverportfolio.Parsers.YahooYQL.YahooYQL.create_url_test | ( | self, | |
sql_query | |||
) |
Only for testing, take a full sql query as input(hard-coded in main section)
sql | string query |
Definition at line 96 of file YahooYQL.py.
References serverportfolio.Parsers.YahooYQL.YahooYQL.__YQL_PUBLIC_URL, serverportfolio.Parsers.YahooYQL.clean_query(), and serverportfolio.Parsers.Abstract.AbstractParser.url.
def serverportfolio.Parsers.YahooYQL.YahooYQL.parse | ( | self, | |
s | |||
) |
Parse YQL request, always XML format.
Name of the fields are available in the XML output.
s | page retrived by web_query |
Definition at line 113 of file YahooYQL.py.
References serverportfolio.Parsers.Abstract.AbstractParser.e_action, serverportfolio.Parsers.YahooYQL.YahooYQL.parse_fund(), serverportfolio.Parsers.YahooCSV.YahooCSV.parse_fund(), and serverportfolio.Parsers.Abstract.AbstractParser.url.
def serverportfolio.Parsers.YahooYQL.YahooYQL.parse_fund | ( | self, | |
root | |||
) |
Extract fundamental data from the XML root element.
root | XML root element |
Definition at line 192 of file YahooYQL.py.
References serverportfolio.Parsers.YahooYQL.YahooYQL._fill_dict_from_xml(), serverportfolio.Parsers.Abstract.AbstractParser.get_symbol_from_code(), and serverportfolio.Parsers.Abstract.AbstractParser.list_return_data.
Referenced by serverportfolio.Parsers.YahooYQL.YahooYQL.parse().
def serverportfolio.Parsers.YahooYQL.YahooYQL.parse_info | ( | self, | |
s | |||
) |
Parse XML for info action To get Industry,Sector and Name, this function is called 2 times by run_parser_info()
.
s | page retrieved by web_query |
Definition at line 140 of file YahooYQL.py.
References serverportfolio.Parsers.Abstract.AbstractParser.list_return_data.
def serverportfolio.Parsers.YahooYQL.YahooYQL.run_parser_info | ( | self, | |
stock, | |||
option_post = None |
|||
) |
Specific call to get Info.
This version should be called at the place of run_parser only in the case of the EAction.Info with YahooYQL.
Two parsing are needed to fill the template.
stock | list of stock symbol(s) |
Definition at line 225 of file YahooYQL.py.
|
staticprivate |
Definition at line 52 of file YahooYQL.py.
Referenced by serverportfolio.Parsers.YahooYQL.YahooYQL.create_url_test().
serverportfolio.Parsers.YahooYQL.YahooYQL.e_action |
Definition at line 74 of file YahooYQL.py.
Referenced by serverportfolio.UpdateStocks.UpdateStocks._set_parser(), serverportfolio.UpdateStocks.UpdateStocks._update_data(), and serverportfolio.UpdateStocks.UpdateStocks.get_string_data().
serverportfolio.Parsers.YahooYQL.YahooYQL.list_return_data |
Definition at line 146 of file YahooYQL.py.
serverportfolio.Parsers.YahooYQL.YahooYQL.logger |
Definition at line 60 of file YahooYQL.py.
Referenced by serverportfolio.Validation.ValidationTkHP.__init__(), and serverportfolio.SocketServer_Server.MyHandler_Parser.handle().
serverportfolio.Parsers.YahooYQL.YahooYQL.option_post |
Definition at line 229 of file YahooYQL.py.
serverportfolio.Parsers.YahooYQL.YahooYQL.source |
Definition at line 63 of file YahooYQL.py.
Referenced by serverportfolio.Parsers.Abstract.AbstractParser.update_stock().
serverportfolio.Parsers.YahooYQL.YahooYQL.url |
Definition at line 91 of file YahooYQL.py.
Referenced by serverportfolio.PortfolioException.ParserError.get_format_string(), and serverportfolio.PortfolioException.QueryError.get_format_string().