mirror of
https://github.com/wassname/options_backtester.git
synced 2026-08-01 12:40:47 +08:00
Moved enums to a single module
This commit is contained in:
@@ -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:
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user