Exemplo n.º 1
0
 Typesystem::Int64 MonotonicClock::Get(const Typesystem::Int64 oldTime)
 {
     using namespace boost::posix_time;
     const ptime now = microsec_clock::universal_time();
     const time_duration diff = now - epoch;
     const Typesystem::Int64 newTime = diff.total_microseconds();
     return std::max(newTime,oldTime+1);
 }
Exemplo n.º 2
0
/**
 * Return the number of seconds in a time_duration, as a double, including
 * fractional seconds.
 */
double DateAndTime::secondsFromDuration(time_duration duration) {
#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
  // Nanosecond resolution
  return static_cast<double>(duration.total_nanoseconds()) / 1e9;
#else
  // Microsecond resolution
  return static_cast<double>(duration.total_microseconds()) / 1e6;
#endif
}
Exemplo n.º 3
0
 RandomGenerator()
 {
     using namespace boost::posix_time;
     const ptime epoch(boost::gregorian::date(2008,1,1));
     const ptime now = microsec_clock::universal_time();
     const time_duration diff = now - epoch;
     const boost::uint32_t my_seed = 
         (static_cast<boost::uint32_t>(diff.total_microseconds()) * Safir::Utilities::ProcessInfo::GetPid()) 
         % std::numeric_limits<boost::uint32_t>::max();
     m_randomGenerator.seed(my_seed);
 }
Exemplo n.º 4
0
TSVolatility::TSVolatility( Prices& series, time_duration dtTau, time_duration dtTauPrime, double p, unsigned int n ) 
  : m_seriesSource( series ), 
    m_dtTau( dtTau ), 
    m_dtTauByTwo( microseconds( dtTau.total_microseconds() / 2 ) ),
//    m_dtTauPrime( microseconds( dtTauPrime.total_microseconds() / 2 ) ), 
    m_dtTauPrime( dtTauPrime ),
    m_p( p ), 
    m_n( n ),
    m_tsDif( series, dtTauPrime ), 
    m_tsNorm( m_tsDif, m_dtTauByTwo, n, p )
{
}
Exemplo n.º 5
0
/** time duration in nanoseconds. Duration is limited to
 * MAX_NANOSECONDS and MIN_NANOSECONDS to avoid overflows.
 * @param td :: time_duration instance.
 * @return an int64 of the number of nanoseconds
 */
int64_t DateAndTime::nanosecondsFromDuration(const time_duration &td) {
  int64_t nano;
#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
  // Nanosecond resolution
  nano = td.total_nanoseconds();
#else
  // Microsecond resolution
  nano = (td.total_microseconds() * 1000);
#endif
  // Use these limits to avoid integer overflows
  if (nano > MAX_NANOSECONDS)
    return MAX_NANOSECONDS;
  else if (nano < MIN_NANOSECONDS)
    return MIN_NANOSECONDS;
  else
    return nano;
}
Exemplo n.º 6
0
	inline boost::int64_t total_microseconds(time_duration td)
	{ return td.total_microseconds(); }