Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 20th, 2012  |  syntax: Groovy  |  size: 0.81 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. String region='US'
  2. String duration = "30 minutes"
  3. int precedingRowsToKeep = 0;
  4.  
  5. if (args.length >= 1) {
  6.     region = args[0]
  7. }
  8. def timeZone = com.twosigma.marketcache.RegionFactory.getInstance(region).timeZone
  9.  
  10. if (args.length >= 2) {
  11.     duration = args[1]
  12. }
  13. if (args.length >= 3) {
  14.     precedingRowsToKeep = Integer.parseInt(args[2])
  15. }
  16.  
  17. t = uri("tsdata:/clock/ts/trading-interval/"+region+"/30")
  18.  
  19. t = addPastWindows  (table: t, windows: [ "prev" : Window.tradingTime(duration, region, precedingRowsToKeep) ])
  20. t = addFutureWindows(table: t, windows: [ "next" : Window.tradingTime(duration, region, precedingRowsToKeep) ])
  21.  
  22. t = addColumns(t, {row -> ["prevstamp" : row.prev[ 0].getFinDateTime().toString(timeZone)] })
  23. t = addColumns(t, {row -> ["nextstamp" : row.next[-1].getFinDateTime().toString(timeZone)] })