// Update the current EMAdifference (see design documentation), perform // required steps at the current state and then find the next FSM state void PairsTrading::doPairsTrading(double current_money, void *m_pclient) { // Calculate EMAdifference and return if EMAs are not yet valid if (calculateDiff() == false) return; // Debugging only fTest << "Entering state " << state << ", EMA diff: " << EMAdifference << ", ccount: " << correlatedCount; // handle current state if (state == 1) State1(); else if (state == 2) State2(); else if (state == 3) State3(current_money, m_pclient); else State4(m_pclient); // Debugging only fTest << ". Leaving state " << state << std::endl; }
void States_Task() { switch(State) { case 0: State0();break; case 1: State1();break; case 2: State2();break; case 3: State3();break; case 4: State4();break; case 10: State10();break; } }