admin
2024-07-05 3ef188e6075649f4c72e3e7588d8966e1071f2ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "TickDataRequestStrategy.h"
 
using namespace std;
 
TickDataRequestStrategy::TickDataRequestStrategy(std::string token, std::string strategy_id, int mode, void* context, std::function<void(Tick* tick, void* context)> 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;
}