ServerPortfolio
2.0
Python parsers and server
|
Define 2 abstract methods which need to be overridden by the Parsers
and a generic algorithm (run_parser) for parsing the data.
More...
Public Member Functions | |
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 | |
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 | |
Static Private Attributes | |
__metaclass__ = ABCMeta | |
Define 2 abstract methods which need to be overridden by the Parsers
and a generic algorithm (run_parser) for parsing the data.
Definition at line 29 of file Abstract.py.
def serverportfolio.Parsers.Abstract.AbstractParser.__init__ | ( | self, | |
e_action | |||
) |
def serverportfolio.Parsers.Abstract.AbstractParser.clean | ( | self | ) |
Reset internal data members after a parsing.
Because parsers can be re-used, it deletes previous data
Most (if not all) of the data member belongs to the abtract base class, the default may be sufficient for most of the specific parsers
Definition at line 152 of file Abstract.py.
References serverportfolio.Parsers.Abstract.AbstractParser.url.
def serverportfolio.Parsers.Abstract.AbstractParser.create_url | ( | self | ) |
Store links to stocks to update, dictionary 'symbol' : Stock object.
Contain all parsed data by one query, include multiple stocks query List of template_parser Source of the data is the parser name : YQL/YCSV/BOURSO, set in ParserFactory Abstract method to create the URL
Definition at line 55 of file Abstract.py.
def serverportfolio.Parsers.Abstract.AbstractParser.get_symbol_from_code | ( | self, | |
code, | |||
code_type | |||
) |
Retrieve the symbol (or Stock) from the code_yahoo or code_bourso.
Needed for parsing multiple CSV data, if order is not fixed.
code | read from the CSV line |
code_type | 'code_yahoo' or 'code_bourso' |
Definition at line 211 of file Abstract.py.
References serverportfolio.Parsers.Abstract.AbstractParser.url.
Referenced by serverportfolio.Parsers.YahooYQL.YahooYQL.parse_fund(), and serverportfolio.Parsers.YahooCSV.YahooCSV.parse_fund().
def serverportfolio.Parsers.Abstract.AbstractParser.parse | ( | self, | |
s | |||
) |
Parse the text file (html, CSV,...)
Definition at line 60 of file Abstract.py.
def serverportfolio.Parsers.Abstract.AbstractParser.run_parser | ( | self, | |
stock, | |||
option_post = None |
|||
) |
Main function to call for running the parser.
Regroup the different steps in one call:
stock | a stock symbol or a list of st.symb. "CAC40" or ["CAC40","GSZ"] |
Definition at line 82 of file Abstract.py.
def serverportfolio.Parsers.Abstract.AbstractParser.store_stock_copy | ( | self, | |
list_stock | |||
) |
Make a local copy of the Stock objects (linked of the original in DictionaryStocks in fact) into a local dictionary.
list | of stock symbols |
Definition at line 163 of file Abstract.py.
References serverportfolio.Parsers.Abstract.AbstractParser.e_action, and serverportfolio.Parsers.Abstract.AbstractParser.local_stock.
def serverportfolio.Parsers.Abstract.AbstractParser.update_stock | ( | self | ) |
Update the local stocks with the new retrieved data.
This version in the base class calls Stock.add_dict_stock(), which implements the update.
More tests could be done if a specific parser override it.
Definition at line 183 of file Abstract.py.
References serverportfolio.Parsers.Abstract.AbstractParser.e_action, serverportfolio.Parsers.Abstract.AbstractParser.list_return_data, serverportfolio.Parsers.Abstract.AbstractParser.local_stock, serverportfolio.Parsers.Abstract.AbstractParser.option_post, serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.source, serverportfolio.Parsers.YahooYQL.YahooYQL.source, and serverportfolio.Parsers.YahooCSV.YahooCSV.source.
|
staticprivate |
Definition at line 30 of file Abstract.py.
serverportfolio.Parsers.Abstract.AbstractParser.e_action |
enumeration (EAction) of the type of query to perform
Definition at line 40 of file Abstract.py.
Referenced by serverportfolio.UpdateStocks.UpdateStocks._set_parser(), serverportfolio.UpdateStocks.UpdateStocks._update_data(), serverportfolio.Parsers.YahooYQL.YahooYQL.create_url(), serverportfolio.UpdateStocks.UpdateStocks.get_string_data(), serverportfolio.Parsers.YahooYQL.YahooYQL.parse(), serverportfolio.Parsers.YahooCSV.YahooCSV.parse(), serverportfolio.Parsers.Abstract.AbstractParser.store_stock_copy(), and serverportfolio.Parsers.Abstract.AbstractParser.update_stock().
serverportfolio.Parsers.Abstract.AbstractParser.list_return_data |
Definition at line 158 of file Abstract.py.
Referenced by serverportfolio.Parsers.YahooCSV.YahooCSV.parse(), serverportfolio.Parsers.YahooCSV.YahooCSV.parse_dates_intro(), serverportfolio.Parsers.YahooCSV.YahooCSV.parse_div(), serverportfolio.Parsers.YahooYQL.YahooYQL.parse_fund(), serverportfolio.Parsers.YahooCSV.YahooCSV.parse_fund(), serverportfolio.Parsers.YahooYQL.YahooYQL.parse_info(), and serverportfolio.Parsers.Abstract.AbstractParser.update_stock().
serverportfolio.Parsers.Abstract.AbstractParser.local_stock |
Definition at line 156 of file Abstract.py.
Referenced by serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data(), serverportfolio.Parsers.YahooYQL.YahooYQL._format_symbols_url(), serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.create_url(), serverportfolio.Parsers.YahooYQL.YahooYQL.create_url(), serverportfolio.Parsers.YahooCSV.YahooCSV.create_url(), serverportfolio.Parsers.Abstract.AbstractParser.store_stock_copy(), and serverportfolio.Parsers.Abstract.AbstractParser.update_stock().
serverportfolio.Parsers.Abstract.AbstractParser.option_post |
Definition at line 86 of file Abstract.py.
Referenced by serverportfolio.Parsers.Abstract.AbstractParser.update_stock().
serverportfolio.Parsers.Abstract.AbstractParser.url |
save url, useful for reporting errors and exceptions
Definition at line 37 of file Abstract.py.
Referenced by serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data_dernier(), serverportfolio.Parsers.Abstract.AbstractParser.clean(), serverportfolio.Parsers.YahooYQL.YahooYQL.create_url_test(), serverportfolio.PortfolioException.ParserError.get_format_string(), serverportfolio.PortfolioException.QueryError.get_format_string(), serverportfolio.Parsers.Abstract.AbstractParser.get_symbol_from_code(), serverportfolio.Parsers.YahooYQL.YahooYQL.parse(), and serverportfolio.Parsers.YahooCSV.YahooCSV.parse().