diff --git a/backtester/strategy/signal.py b/backtester/enums.py similarity index 50% rename from backtester/strategy/signal.py rename to backtester/enums.py index 4731bb3..7e0da67 100644 --- a/backtester/strategy/signal.py +++ b/backtester/enums.py @@ -1,21 +1,39 @@ +# Enums +from collections import namedtuple from enum import Enum -from backtester.option import Direction +# Stocks +Stock = namedtuple('Stock', 'symbol percentage') + + +# Options +class Type(Enum): + CALL = 'call' + PUT = 'put' + + def __invert__(self): + flip = Type.PUT if self == Type.CALL else Type.CALL + return flip + + +class Direction(Enum): + BUY = 'ask' # Schema field for BUY price + SELL = 'bid' # Schema field for SELL price + + def __invert__(self): + flip = Direction.SELL if self == Direction.BUY else Direction.BUY + return flip + + +# Signals 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") - class Order(Enum): - BTO = 'BTO' - BTC = 'BTC' - STO = 'STO' - STC = 'STC' + BTO = 'BTO' # Buy to Open + BTC = 'BTC' # Buy to Close + STO = 'STO' # Sell to Open + STC = 'STC' # Sell to Close def __invert__(self): if self == Order.BTO: diff --git a/backtester/option.py b/backtester/option.py deleted file mode 100644 index 02e6919..0000000 --- a/backtester/option.py +++ /dev/null @@ -1,20 +0,0 @@ -# Option Enum types -from enum import Enum - - -class Type(Enum): - CALL = 'call' - PUT = 'put' - - def __invert__(self): - flip = Type.PUT if self == Type.CALL else Type.CALL - return flip - - -class Direction(Enum): - BUY = 'ask' # Schema field for BUY price - SELL = 'bid' # Schema field for SELL price - - def __invert__(self): - flip = Direction.SELL if self == Direction.BUY else Direction.BUY - return flip