Question: How to call a different functions within stat_frac_sales()
based on its argument stat_requested
?
I want to calculate a financial ratio that will have different numerators (earnings, gross profit, etc...) but always the same denominator (sales). It would look like something like that:
def stat_frac_sales(company, input1, input2, stat_requested):
stat_data = # call a function here based on the value of stat_requested
sales = import_sales(company) # Sales function that will not vary
ratio= stat_data/sales
return ratio
For instance, if stat_requested = 'FCT'
, then the function FCT()
should be called.
For example FCT
and EBIT
function look like:
def FCF(company, input1)
...some code
return FCF
def EBIT(company, input2)
...some different code
return EBIT
So if the user call FCF
(stat_data='FCF'
), it would look something like that:
def stat_frac_sales(company, input1, input2, stat_requested):
stat_data = FCF(company, input1) # <-- like so but unclear as to how to make this dynamic, where the function called here changes based on stat_requested
sales = import_sales(company) # Sales function that will not vary*
ratio= stat_data/sales
return ratio
Hope this is clear. Any idea on how to do that will be greatly appreciated.