forked from tobiasbrodd/backtester
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecution.py
More file actions
21 lines (17 loc) · 740 Bytes
/
Copy pathexecution.py
File metadata and controls
21 lines (17 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import queue
from datetime import datetime
from abc import ABCMeta, abstractmethod
from event import FillEvent, OrderEvent
class ExecutionHandler(metaclass=ABCMeta):
@abstractmethod
def execute_order(self, event):
raise NotImplementedError
class SimulateExecutionHandler(ExecutionHandler):
def __init__(self, events, verbose=False):
self.events = events
self.verbose = verbose
def execute_order(self, event):
if event.type == 'ORDER':
if self.verbose: print("Order Executed:", event.symbol, event.quantity, event.direction)
fill_event = FillEvent(datetime.utcnow(), event.symbol, 'ARCA', event.quantity, event.direction, 0)
self.events.put(fill_event)