#include "macd.hh"
#include <cassert>

namespace AI {

MACD::MACD(int fastSMAPeriod, int slowSMAPeriod) :
    fastSMA_(fastSMAPeriod), slowSMA_(slowSMAPeriod)
{
    assert(fastSMAPeriod < slowSMAPeriod);
}

void MACD::operator()(double value)
{
    fastSMA_(value);
    slowSMA_(value);
}

double MACD::operator()() const
{
    return fastSMA_() - slowSMA_();
}

void MACD::clear()
{
    fastSMA_.clear();
    slowSMA_.clear();
}

}
