-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from TenzT/feat/master_md
Feat/master md
- Loading branch information
Showing
14 changed files
with
180 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,23 @@ | ||
# CTP接入测试 | ||
|
||
- [x] 接入openctp 7x24行情服务 | ||
- [x] 接入yijinjing | ||
- [x] 接入yijinjing | ||
- [x] 仿照kungfu分布式架构,分离出apprentice和master | ||
|
||
## 用法 | ||
|
||
- 编译 | ||
``` | ||
mkdir build && cd build | ||
cmake .. && make | ||
``` | ||
- 运行 | ||
``` | ||
./master | ||
sleep 3 | ||
./md tcp://121.37.80.177:20004 sc2410 sc2411 sc2412 sc2501 sc2502 | ||
sleep 3 | ||
./strategy_runner | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <iostream> | ||
|
||
#include "yijinjing/locator/MyLocator.h" | ||
#include "yijinjing/master/MyMaster.h" | ||
|
||
using namespace kungfu::yijinjing::data; | ||
|
||
int main(int argc, const char * argv[]) { | ||
std::cout << "Hello, Master!" << std::endl; | ||
|
||
locator_ptr locator = std::make_shared<MyLocator>("./home"); | ||
location_ptr location = location::make(mode::LIVE, category::SYSTEM, "master", "master", locator); | ||
MyMaster my_master(location, false); | ||
|
||
my_master.run(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// Created by 谭德志 on 2024/9/26. | ||
// | ||
|
||
#include "runner.h" | ||
#include "../entity/Quotes.h" | ||
using namespace kungfu::rx; | ||
using namespace kungfu::yijinjing; | ||
|
||
void runner::on_start() { | ||
auto md_location = location::make(mode::LIVE, category::MD, "ctp", "ctp", home_->locator); | ||
this->request_read_from(this->now(), md_location->uid, true); | ||
// this->request_write_to(this->now(), md_location->uid); // 写方向 | ||
market_data_["ctp"] = md_location->uid; | ||
SPDLOG_INFO("added md {} [{:08x}]", "ctp", md_location->uid); | ||
|
||
events_ | is(QUOTES) | | ||
$([&](event_ptr event) | ||
{ | ||
std::cout << "quotes received: instrumentId: " << event->data<Quotes>().instrument_id << std::endl; | ||
}); | ||
|
||
apprentice::on_start(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// Created by 谭德志 on 2024/9/26. | ||
// | ||
|
||
#ifndef RUNNER_H | ||
#define RUNNER_H | ||
#include <kungfu/practice/apprentice.h> | ||
#include <kungfu/yijinjing/common.h> | ||
|
||
using namespace kungfu::yijinjing::data; | ||
|
||
class runner : public kungfu::practice::apprentice { | ||
private: | ||
location_ptr home_; | ||
std::unordered_map<std::string, uint32_t> market_data_; | ||
public: | ||
explicit runner(location_ptr home, bool low_latency = false) : apprentice(home, low_latency) { | ||
home_ = home; | ||
} | ||
void on_start() override; | ||
}; | ||
|
||
|
||
|
||
#endif //RUNNER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <iostream> | ||
|
||
#include "strategy/runner.h" | ||
#include "yijinjing/locator/MyLocator.h" | ||
#include "yijinjing/master/MyMaster.h" | ||
|
||
using namespace kungfu::yijinjing::data; | ||
|
||
int main(int argc, const char * argv[]) { | ||
std::cout << "Hello, Runner!" << std::endl; | ||
|
||
locator_ptr locator = std::make_shared<MyLocator>("./home"); | ||
location_ptr location = location::make(mode::LIVE, category::STRATEGY, "ctp", "ctp", locator); | ||
runner r(location, false); | ||
|
||
r.run(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// | ||
// Created by 谭德志 on 2024/9/26. | ||
// | ||
|
||
#include "MyMaster.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Created by 谭德志 on 2024/9/26. | ||
// | ||
|
||
#ifndef MASTER_H | ||
#define MASTER_H | ||
#include <kungfu/practice/master.h> | ||
|
||
using namespace kungfu::yijinjing::data; | ||
|
||
class MyMaster : public kungfu::practice::master{ | ||
public: | ||
explicit MyMaster(location_ptr home, bool low_latency = false): master(home, low_latency) {}; | ||
}; | ||
|
||
|
||
|
||
#endif //MASTER_H |