Created
June 21, 2012 03:24
-
-
Save Vineeth-Mohan/2963633 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void run(){ | |
String fromDate = "2010-10-02"; | |
String toDate = "2010-10-03"; | |
String freequncy = "DAILY"; | |
String portfolio = "Equity Portfolio View"; | |
String user = "defaultUser"; | |
Map<String, String> config = new HashMap<String, String>(); | |
config.put("FROMDATE", fromDate); | |
config.put("TODATE", toDate); | |
config.put("FREEQUENCY", freequncy); | |
String UID="1"; | |
//tabManagement.updateTab(tabName,user, "PROCESSING" ,config); | |
ViewDefinition equityDefenition = viewDefinitionRepository.getDefinition(portfolio); | |
ViewClient vc = viewProcessor.createViewClient(new UserPrincipal(user,"0.0.0.0")); | |
EnumSet<ViewExecutionFlags> flags = EnumSet | |
.of(ViewExecutionFlags.RUN_AS_FAST_AS_POSSIBLE); | |
ViewCycleExecutionSequence executionSequence = getExecutionSequence(LocalDate.parse(fromDate),LocalDate.parse(toDate)); | |
ViewExecutionOptions executionOptions = ExecutionOptions.batch(executionSequence, null); | |
vc.setResultListener(new ResultListen(dates,positionMaster,securityMaster)); | |
vc.attachToViewProcess(equityDefenition.getUniqueId(), executionOptions); | |
return "{ \"message\" : \"Successfully submitted the Job , ID is " + UID | |
+ "\" }"; | |
} | |
private ViewCycleExecutionSequence getExecutionSequence(LocalDate fromDate , LocalDate toDate) { | |
List<ViewCycleExecutionOptions> executions = new ArrayList<ViewCycleExecutionOptions>(); | |
LocalDate temp = toDate; | |
System.out.println("Creating date " + temp); | |
while( fromDate.isBefore(temp) ) { | |
HistoricalMarketDataSpecification hd = new FixedHistoricalMarketDataSpecification(temp); | |
InstantProvider ip = Instant.now(); | |
ViewCycleExecutionOptions vce = new ViewCycleExecutionOptions(ip, hd); | |
vce.setValuationTime(ip); | |
executions.add(vce); | |
dates.add(LocalDate.of(temp)); | |
temp = temp.minusDays(1); | |
System.out.println("Creating date " + temp); | |
} | |
ViewCycleExecutionSequence executionSequence = new ArbitraryViewCycleExecutionSequence(executions); | |
return executionSequence; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment