A
A
Alex Helber2019-04-19 09:27:26
Django
Alex Helber, 2019-04-19 09:27:26

How to implement a constructor of algorithms (rules) in Python?

Is there a way to implement an interface for creating algorithms from the UI, avoiding a lot of if-s?
Scope of application - financial exchange. For example, when a certain price is reached (<, >, =), place/cancel an order.
It is necessary to create these conditions from the interface (previously Django).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir, 2019-04-19
@vintello

such systems are called the English word "query builder"
you can see an example here

A
Alex Helber, 2019-04-19
@Helber

At the moment, I settled on the idea of ​​​​creating a template engine using eval ().

S
Sergey Gornostaev, 2019-04-19
@sergey-gornostaev

Things like this are implemented with a decision tree . And if it is necessary that the result of the decision was a code that implements some algorithm, then in the process of bypassing the nodes of the decision tree, you can form an abstract syntax tree . In general, the task is from the category of creating a DSL and an interpreter for it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question