In my project, I calculate some things. For example DTI and DSTI for mortgages. Some parts of the code (formulas) change frequently. I use these formulas in bigger calculations.
I want to provide a way to change these formulas at runtime to admins of the website. Example:
def calculation_A(input_a, input_b): return input_a * input_b
I expect this calculation to be changed (by current laws) soon so that it will be for example look like this:
def calculation_A(input_a, input_b): if input_a/2 < 15000: return input_a/100 else: return input_b
I don't want to change the codebase and I want admins to be able to change the code of the calculation.
What are my options?
I think that there must be some API that allows me to create formulas and then call them remotely but I can't find any.
I also thought about making database text fields that'd store
python code that would be then validated and called using
eval but that looks to be too "raw".
Do you have any ideas or tips?