suggest using enum instead of int for status defination
There are lots of constant status definiation in backtest, for example:
bt.Order.Submitted, however they are simply integer. How about using enum instead.
the prons are:
- the enum value are truely constant, prevent people from change it by mistake
- the enum value could give meaningful string represent when print, instead of 1 we get order.Submitted
The API could stay compatible after the change and python2.7 could also be supported with third party enum library.
One of the goals of
backtraderwas (and still is) to remain as much as possible Pure Python and only dependent on the standard packages available in the standard python distribution.
Being the only exception
matplotlibfor plotting purposes. There is actually no need to have it installed if only backtesting is wished.
Other dependencies like the ones needed for example for
statsmodelswere added by means of declarations (or meta-programming) which allow defining an Indicator as needing that dependency.
enumswill be considered when a major rework of the platform is done and dependencies (or maybe python 2.7 support is dropped altogether) are included.
To print the name of
bt.Order.Submittedyou can query the
status_text = order.getstatusname(bt.Order.Submitted)