Skip to content

Instantly share code, notes, and snippets.

@Vineeth-Mohan
Created June 21, 2012 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vineeth-Mohan/2963633 to your computer and use it in GitHub Desktop.
Save Vineeth-Mohan/2963633 to your computer and use it in GitHub Desktop.
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