API Docs

Manual, tutorials and complete function reference

Data Sampling


These settings regulate how results of portfolio computations are returned. Depending on your usage scenario, some of them might bring significantly imporvement to speed of your portfolio computations:


Results Sampling Interval

Interval to be used for sampling computed results before returning them to the caller. Available interval values are:

  • "Xs" - seconds
  • "Xm" - minutes
  • "Xh" - hours
  • "Xd" - trading days (6.5 hours in a trading day)
  • "Xw" - weeks (5 trading days in 1 week)
  • "Xmo" - month (21 trading day in 1 month)
  • "Xy" - years (256 trading days in 1 year)
  • "none" - no sampling.
  • "last"- only the very last data point is returned

Large sampling interval would produce smaller vector of results and would require less time spent on data transfer. Default value of "1s" indicates that data is returned for every second during trading hours.

require(PortfolioEffectHFT)
portfolio=portfolio_create(fromTime="2014-10-01 09:30:00", toTime="2014-10-02 16:00:00")
portfolio_addPosition(portfolio,c('C','SPY'),c(500,600))

# sample results every 30 seconds
portfolio_settings(portfolio, resultsSamplingInterval="30s")
portfolio_return(portfolio)

# sample results every 5 minutes
portfolio_settings(portfolio, resultsSamplingInterval="5m")
portfolio_return(portfolio)
portfolio=portfolio_create('index','SPY','fromTime','2014-10-01 09:30:00','toTime','2014-10-02 16:00:00')
portfolio_addPosition(portfolio,['GOOG';'AAPL'],[200;100])

% sample results every 30 seconds
portfolio_settings(portfolio, 'resultsSamplingInterval', '30s')
portfolio_return(portfolio)

% sample results every 5 minutes
portfolio_settings(portfolio, 'resultsSamplingInterval', '5m')
portfolio_return(portfolio)

Input Sampling Interval

Interval to be used as a minimum step for sampling input prices. Available interval values are:

  • "Xs" - seconds
  • "Xm" - minutes
  • "Xh" - hours
  • "Xd" - trading days (6.5 hours in a trading day)
  • "Xw" - weeks (5 trading days in 1 week)
  • "Xmo" - month (21 trading day in 1 month)
  • "Xy" - years (256 trading days in 1 year)
  • "none" - no sampling.
Default value is "none", which indicates that no sampling is applied.

require(PortfolioEffectHFT)
portfolio=portfolio_create(fromTime="2014-10-01 09:30:00", toTime="2014-10-02 16:00:00")
portfolio_addPosition(portfolio,c('C','SPY'),c(500,600))

# sample input prices every 30 seconds
portfolio_settings(portfolio, inputSamplingInterval="30s")
portfolio_return(portfolio)

# sample input prices every 5 min
portfolio_settings(portfolio, inputSamplingInterval="5m")
portfolio_return(portfolio)
portfolio=portfolio_create('index','SPY','fromTime','2014-10-01 09:30:00','toTime','2014-10-02 16:00:00')
portfolio_addPosition(portfolio,['C';'SPY'],[500;600])

% sample input prices every 30 seconds
portfolio_settings(portfolio, 'inputSamplingInterval', '30s')
portfolio_return(portfolio)

% sample input prices every 5 min
portfolio_settings(portfolio, 'inputSamplingInterval', '5m')
portfolio_return(portfolio)