diff --git a/backtester/option.py b/backtester/option.py index e7695f0..af9233b 100644 --- a/backtester/option.py +++ b/backtester/option.py @@ -3,10 +3,3 @@ from enum import Enum Type = Enum("Type", {"CALL": "call", "PUT": "put"}) Direction = Enum("Direction", {"BUY": "ask", "SELL": "bid"}) - -# Orders: -# BTO: Buy to Open -# BTC: Buy to Close -# STO: Sell to Open -# STC: Sell to Close -Order = Enum("Order", "BTO BTC STO STC") diff --git a/backtester/strategy/signal.py b/backtester/strategy/signal.py new file mode 100644 index 0000000..10568cd --- /dev/null +++ b/backtester/strategy/signal.py @@ -0,0 +1,21 @@ +from enum import Enum +from backtester.option import Direction + +Signal = Enum("Signal", "ENTRY EXIT") + +# Orders: +# BTO: Buy to Open +# BTC: Buy to Close +# STO: Sell to Open +# STC: Sell to Close +Order = Enum("Order", "BTO BTC STO STC") + + +def get_order(direction, signal): + """Returns Order type given direction (BUY | SELL) and + signal (ENTRY | EXIT). + """ + if direction == Direction.BUY: + return Order.BTO if signal == Signal.ENTRY else Order.STC + else: + return Order.STO if signal == Signal.ENTRY else Order.BTC