mirror of
https://github.com/wassname/options_backtester.git
synced 2026-06-27 19:15:45 +08:00
Moved Order enum to signal module. Created Signal (ENTRY | EXIT) enum.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user