-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstrategy.py
More file actions
40 lines (30 loc) · 1.01 KB
/
strategy.py
File metadata and controls
40 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
# -*- coding: utf-8 -*-
# strategy.py
from abc import ABCMeta, abstractmethod
try:
import Queue as queue
except ImportError:
import queue
import datetime
import numpy as np
import pandas as pd
from event import SignalEvent
class Strategy(object):
"""
Strategy is an abstract base class providing an interface for
all subsequent (inherited) strategy handling objects.
The goal of a (derived) Strategy object is to generate Signal
objects for particular symbols based on the inputs of Bars
(OHLCV) generated by a DataHandler object.
This is designed to work both with historic and live data as
the Strategy object is agnostic to where the data came from,
since it obtains the bar tuples from a queue object.
"""
__metaclass__ = ABCMeta
@abstractmethod
def calculate_signals(self):
"""
Provides the mechanisms to calculate the list of signals.
"""
raise NotImplementedError("Should implement calculate_signals()")