forked from yousra-aoudi/algorithmic_trading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
automated_trading_strategy.py
38 lines (28 loc) · 1.08 KB
/
automated_trading_strategy.py
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
#A Strategy object encapsulates all calculation on market data that generate advisory signals to a Portfolio object.
# strategy.py
from __future__ import print_function
from abc import ABCMeta, abstractmethod
import datetime
try:
import Queue as queue
except ImportError:
import queue
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()")