ServerPortfolio
2.0
Python parsers and server
|
Define template dictionaries to describe the data structure. More...
Public Member Functions | |
def | get_template_stock |
Return a copy of an action template for stocks, include 'template' and 'config', delete 'attrib' entry. More... | |
def | get_template_parser |
Return the template for parser to be included by all parsers. More... | |
def | get_template_xml |
Specific for xml dictionary, replace each value by a list. More... | |
def | get_template_one_value_xml |
Return a template for each xml value, include 'value' and 'atrib' for each one Or/And, with action, name can set default append/date. More... | |
def | get_template_valid_xml_value |
Retrun a template for the validation template, include 'new_value','xml_value','repl_add','date'. More... | |
def | set_tmpl_static |
Set the internal template for the static data, also for invalid stock. More... | |
def | get_tmpl_static_invalid |
Return the invalid static template. More... | |
def | to_save_xml |
Query to know if this template must be saved in XML file. More... | |
def | saved_as |
Query the format in which the data must be saved. More... | |
def | create_default_template_xml |
Create a default xml dictionary, called when creating a new XML file. More... | |
def | make_header |
Private Member Functions | |
def | _reset |
Reset the state of templates to the original. More... | |
Static Private Attributes | |
tuple | _logger = logging.getLogger("SP.StockTemplate") |
dictionary | _templ_fundamental |
Fundamental data, used by YQL and YahooCSV. More... | |
dictionary | _templ_info |
Normally these entries should not change. More... | |
dictionary | _templ_hp |
Historical Prices, the complete list (CSV) is written to file but not saved in dictionary format of date in template, string/timestamp/datetime.datetime ? C++ always timestamp, but datetime.datetime more convenient in python. More... | |
dictionary | _templ_inst_value |
For instantaneous value. More... | |
dictionary | _templ_div |
Dividend/Split same as HP, need dates certainly maybe easier to split div and split ? More... | |
dictionary | _templ_intro |
DatesIntro, first CSV date available (in CSV), integer format (extends to string? last date?) More... | |
dictionary | _templ_one_value_xml |
Template for one XML value, stored in a list (of _templ_spec_xml) Option specify the default value in case of a new file date : str(), force each entry to provide a value. More... | |
dictionary | _templ_static = {} |
Static data, keys are initialised only when reading the configuration file in DictionaryStocks::init. More... | |
dictionary | _templ_static_invalid = {} |
Static data for InvalidStock, all fields are set to 'invalid'. More... | |
dictionary | _templ_valid_xml_value |
dictionary | _templ_action |
Skeleton for the dictionaries of each action. More... | |
dictionary | _templ_parser |
Define a generic template to be included by all parsers, for each stock. More... | |
Define template dictionaries to describe the data structure.
Templates are named by the "action" to be performed by the parsers.
XML output extends the action template.
It is used by a global variable which must be accessed by StockTemplates.StTmpl
Group templates, by use of dictionaries, to be included by Stock when they run a specific request (EAction, e.g. InstValue, HistPrice..)
'Static' data are a particular template which is read from the configuration file (dictstocks.txt by default) by DictionaryStocks.
Definition at line 20 of file StockTemplates.py.
|
private |
Reset the state of templates to the original.
Definition at line 280 of file StockTemplates.py.
def serverportfolio.StockTemplates.StockTemplates.create_default_template_xml | ( | cls | ) |
Create a default xml dictionary, called when creating a new XML file.
Assign same templates as stock, with value replaced by a list (one_value_xml)
Apply only to action with a save option 'xml' in 'config'
Definition at line 459 of file StockTemplates.py.
def serverportfolio.StockTemplates.StockTemplates.get_template_one_value_xml | ( | cls | ) |
Return a template for each xml value, include 'value' and 'atrib' for each one Or/And, with action, name can set default append/date.
Definition at line 375 of file StockTemplates.py.
def serverportfolio.StockTemplates.StockTemplates.get_template_parser | ( | cls, | |
action = None |
|||
) |
Return the template for parser to be included by all parsers.
Include the symbol of the stock (used for multiple stocks query),
and the template specific an action.
In multiple stock query, these template are stored in a list (AbstractParser.list_return_data)
Definition at line 327 of file StockTemplates.py.
def serverportfolio.StockTemplates.StockTemplates.get_template_stock | ( | cls, | |
action, | |||
for_xml = False |
|||
) |
Return a copy of an action template for stocks, include 'template' and 'config', delete 'attrib' entry.
action | EAction or EAction.name |
Definition at line 300 of file StockTemplates.py.
def serverportfolio.StockTemplates.StockTemplates.get_template_valid_xml_value | ( | cls | ) |
Retrun a template for the validation template, include 'new_value','xml_value','repl_add','date'.
Definition at line 380 of file StockTemplates.py.
def serverportfolio.StockTemplates.StockTemplates.get_template_xml | ( | cls, | |
action | |||
) |
Specific for xml dictionary, replace each value by a list.
Definition at line 349 of file StockTemplates.py.
def serverportfolio.StockTemplates.StockTemplates.get_tmpl_static_invalid | ( | cls | ) |
Return the invalid static template.
Called at the creation of InvalidStock
Definition at line 418 of file StockTemplates.py.
def serverportfolio.StockTemplates.StockTemplates.make_header | ( | self, | |
action_name | |||
) |
Definition at line 497 of file StockTemplates.py.
def serverportfolio.StockTemplates.StockTemplates.saved_as | ( | cls, | |
action, | |||
specific = None |
|||
) |
Query the format in which the data must be saved.
action | |
specific |
Definition at line 436 of file StockTemplates.py.
Referenced by serverportfolio.ValidStockUpdate.ValidStockUpdate.check_new_xml_data().
def serverportfolio.StockTemplates.StockTemplates.set_tmpl_static | ( | cls, | |
list_key | |||
) |
Set the internal template for the static data, also for invalid stock.
Set cls._templ_static with keys read from dictstocks.txt
It should be executed only once when reading the configuration file.
list_key | keys to insert in the template for static data. Set default as empty string. |
Definition at line 392 of file StockTemplates.py.
def serverportfolio.StockTemplates.StockTemplates.to_save_xml | ( | cls, | |
action | |||
) |
Query to know if this template must be saved in XML file.
Definition at line 427 of file StockTemplates.py.
|
staticprivate |
Definition at line 23 of file StockTemplates.py.
|
staticprivate |
Skeleton for the dictionaries of each action.
Store: -a specific "template" for the parser
Set default values, save_xml, append, date, ... could add:
Definition at line 184 of file StockTemplates.py.
|
staticprivate |
Dividend/Split same as HP, need dates certainly maybe easier to split div and split ?
Definition at line 107 of file StockTemplates.py.
|
staticprivate |
Fundamental data, used by YQL and YahooCSV.
Definition at line 34 of file StockTemplates.py.
|
staticprivate |
Historical Prices, the complete list (CSV) is written to file but not saved in dictionary format of date in template, string/timestamp/datetime.datetime ? C++ always timestamp, but datetime.datetime more convenient in python.
If C++ read timestamp. internal C++ datetime.datetime easier, datetime if extended later to inst ?
Definition at line 78 of file StockTemplates.py.
|
staticprivate |
Normally these entries should not change.
Executed by YQL, quotes or quote table give the name
Definition at line 53 of file StockTemplates.py.
|
staticprivate |
For instantaneous value.
Only Boursorama parser implemented (plan to extend to Yahoo_HTML)
Definition at line 87 of file StockTemplates.py.
|
staticprivate |
DatesIntro, first CSV date available (in CSV), integer format (extends to string? last date?)
Definition at line 118 of file StockTemplates.py.
|
staticprivate |
Template for one XML value, stored in a list (of _templ_spec_xml) Option specify the default value in case of a new file date : str(), force each entry to provide a value.
None can use default. Could be assumed date is ALWAYS required (I think it is now)
Definition at line 126 of file StockTemplates.py.
|
staticprivate |
Define a generic template to be included by all parsers, for each stock.
symbol allows the parser to associate the results to each stock (case of multiple stocks query)
action_templ stores templates of the actions performed
Definition at line 253 of file StockTemplates.py.
|
staticprivate |
Static data, keys are initialised only when reading the configuration file in DictionaryStocks::init.
Must care about maintaining the link, and to not create a different dictionary
Definition at line 138 of file StockTemplates.py.
|
staticprivate |
Static data for InvalidStock, all fields are set to 'invalid'.
Definition at line 142 of file StockTemplates.py.
|
staticprivate |
Definition at line 161 of file StockTemplates.py.