Moved enums to a single module

This commit is contained in:
Juan Pablo Amoroso
2020-02-11 15:22:43 -03:00
parent 2f4563432b
commit 4191824b9e
2 changed files with 30 additions and 32 deletions
@@ -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:
-20
View File
@@ -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