-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMarketStrategy.py
More file actions
51 lines (38 loc) · 1.41 KB
/
Copy pathMarketStrategy.py
File metadata and controls
51 lines (38 loc) · 1.41 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
41
42
43
44
45
46
47
48
49
50
51
'''
Created on 02/09/2017
@author: michaelnew
'''
import sys
from Skyze_Standard_Library.Market import Market
# from StrategyAbstract import StrategyAbstract
import pandas as pd
class MarketStrategy(object):
'''
classdocs
'''
def __init__(self, p_market, p_strategy, p_start_date, p_end_date):
''' Constructor '''
self.market = Market(p_market)
self.result = pd.DataFrame
self.start_date = p_start_date
self.end_date = p_end_date
# dynamically create the strategy name
# https://stackoverflow.com/questions/4821104/python-dynamic-instantiation-from-string-name-of-a-class-in-dynamically-imported
module = __import__(p_strategy)
class_ = getattr(module, p_strategy)
self.strategy = class_(p_start_date, p_end_date)
def getMarket(self):
''' Getter '''
return self.market
def getStrategy(self):
''' Getter '''
return self.strategy
def getResult(self):
''' Getter '''
return self.result
def getMarketName(self):
''' Getter '''
return self.market.getMarketName()
def toPrint(self):
''' Printer '''
return "Market: " + self.market.getMarketName() + ", Strategy: " + self.strategy.strategy_name + ", Start: " + self.start_date.strftime("%B %d, %Y") + " End: " + self.end_date.strftime("%B %d, %Y")