#include "TickDataRequestStrategy.h" using namespace std; TickDataRequestStrategy::TickDataRequestStrategy(std::string token, std::string strategy_id, int mode, void* context, std::function callback):Strategy(token.c_str(), strategy_id.c_str(),mode),callback(callback), parentContext(context) { } void TickDataRequestStrategy::subscribeSymbol(std::string symbol, std::string underlyingSymbol) { int result = subscribe(symbol.c_str(), "tick", true); result = subscribe(underlyingSymbol.c_str(), "tick", false); if (result != 0) { throw std::string("¶©ÔÄʧ°Ü£º").append(std::to_string(result)); } cout << "¶©ÔĽá¹û£º"<< result << endl; } void TickDataRequestStrategy::on_init() { cout<<"²ßÂÔ³õʼ»¯" << endl; } void TickDataRequestStrategy::on_tick(Tick* tick) { cout << "on_tick:"<< tick->price << endl; if (this->callback) { callback(tick, this->parentContext); } } void TickDataRequestStrategy::on_market_data_connected() { cout << "on_market_data_connected" << endl; } void TickDataRequestStrategy::on_market_data_disconnected() { cout << "on_market_data_disconnected" << endl; } //»Ø²âÍê³Éʼþ void TickDataRequestStrategy::on_backtest_finished(Indicator* indicator) { cout << "on_backtest_finished" << endl; }