def Play(self): import datetime startTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') policyPanel = self.nb.playTab.policyPanel userCount = policyPanel.userField.GetValue() iterationCount = policyPanel.iterationField.GetValue() special = policyPanel.specialField.GetData() specialLabel = special.label if special else '<empty>' info = { 'Start Time': startTime, 'User Count': userCount, 'Iteration Count': iterationCount, 'Special': specialLabel, 'Project Path': self.path, } if self.report: ReportManager.start_report(self.report, self.project, info=info) func = self.PlayInCurrentThread import threading class ProxyThread(threading.Thread): def __init__(self, name='ListenThread'): threading.Thread.__init__(self, name=name) def run(self): func() thread = ProxyThread() thread.start()
def play_project(project, reporter = None, project_path = 'unkown', variables = None): assert isinstance(project, Project) if project.current_special == None: raise RuntimeError('No special to start!') user_count = project.user_count iteration_count = project.iteration_count special = project.current_special user_factory = project.user_factory iteration_factory = project.iteration_factory global_factory = project.global_factory if reporter != None: from Report import Report if type(reporter) in (str, unicode): reporter = Report(reporter) assert isinstance(reporter, Report) import datetime start_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') info = { 'Start Time': start_time, 'User Count': user_count, 'Iteration Count': iteration_count, 'Special': special.label, 'Project Path': project_path, } import ReportManager ReportManager.start_report(reporter = reporter, project = project, info = info) import PlayPolicy policy = PlayPolicy.IterationBasedPlayPolicy( player = special, user_count = user_count, iteration_count = iteration_count, user_factory = user_factory, iteration_factory = iteration_factory, global_factory = global_factory, reporter = reporter ) import sys sys.path.append(os.path.join(sys.path[0], 'runtime')) sys.path.append(os.path.join(sys.path[0], 'plugin')) if variables: from Scope import Scope scope = Scope() scope.variables = variables policy.play(scope) else: policy.play() if len(sys.path) >= 2 and sys.path[-2:] == ['runtime', 'plugin']: sys.path.pop() sys.path.pop() if reporter: reporter.finish()
symbols = GetStockSymbol(param.STOCKLIST_CPH, param.CPHEXCHANGE) + GetStockSymbol( param.STOCKLIST_AMS) + GetStockSymbol( param.STOCKLIST_FX, param.FXEXCHANGE) porto_symbols = GetStockSymbol(param.MYPF) #symbols = ['SALB.CO', 'GEN.CO', 'SIM.CO', 'NOVO-B.CO','PAAL-B'] #symbols = ['NOVO-B.CO'] #symbols = ['EUR=X', 'JPY=X'] from stock import GetStockQuote from recommendation import WriteRecommendation import ReportManager as rm ## dd/mm/yyyy format today = time.strftime("%d/%m/%Y") rm.CreateHTMLFile( param.HTML_REPORT_FILENAME) #Create the header part of HTML report rm.CreateHTMLFile(param.HTML_PORTOFOLIO_REPORT_FULLNAME) rm.CreateHTMLFile(param.HTML_TREND_REPORT_FILENAME, "Trend Report") line = [ "Symbol ", today + " Close", today + " High", today + "Low", "10-Day High", "10-Day Low", " Recommendation", "ADX > 25", "Cross SMA20", "Cross SMA50", "Cross SMA100", "Cross Bollinger", "Abover SMA20", "Above SMA50", "Above SMA100", "Above Bollinger 1", "Between Bollinger 1 & 2", "MACD Diff", "ADXR", "RSI", "J" ] rm.AddLineToHTMLTable(param.HTML_TREND_REPORT_FILENAME, line) for symbol in symbols: print(symbol) quote = GetStockQuote(symbol, param.QUOTE_LENGTH, 0) if (len(quote) > param.QUOTE_LENGTH *
def play_project(project, reporter=None, project_path='unkown', variables=None): assert isinstance(project, Project) if project.current_special == None: raise RuntimeError('No special to start!') user_count = project.user_count iteration_count = project.iteration_count special = project.current_special user_factory = project.user_factory iteration_factory = project.iteration_factory global_factory = project.global_factory if reporter != None: from Report import Report if type(reporter) in (str, unicode): reporter = Report(reporter) assert isinstance(reporter, Report) import datetime start_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') info = { 'Start Time': start_time, 'User Count': user_count, 'Iteration Count': iteration_count, 'Special': special.label, 'Project Path': project_path, } import ReportManager ReportManager.start_report(reporter=reporter, project=project, info=info) import PlayPolicy policy = PlayPolicy.IterationBasedPlayPolicy( player=special, user_count=user_count, iteration_count=iteration_count, user_factory=user_factory, iteration_factory=iteration_factory, global_factory=global_factory, reporter=reporter) import sys sys.path.append(os.path.join(sys.path[0], 'runtime')) sys.path.append(os.path.join(sys.path[0], 'plugin')) if variables: from Scope import Scope scope = Scope() scope.variables = variables policy.play(scope) else: policy.play() if len(sys.path) >= 2 and sys.path[-2:] == ['runtime', 'plugin']: sys.path.pop() sys.path.pop() if reporter: reporter.finish()