Skip to content

Commit 905f739

Browse files
authored
Merge pull request #1 from linboqiao/master
mdlink_tencent added
2 parents 00f7ced + ccf2ee2 commit 905f739

File tree

13 files changed

+22868
-16743
lines changed

13 files changed

+22868
-16743
lines changed

dataserver/server/etc/instrument.csv

+22,015-16,740
Large diffs are not rendered by default.

dataserver/server/etc/market.csv

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ market,nationcode,timezone,marketcode,auctbeg1,auctend1,auctbeg2,auctend2,auctbe
55
4,1,8,CZC,900,1015,1030,1130,1330,1500,0,0
66
5,1,8,DCE,900,1015,1030,1130,1330,1500,0,0
77
6,1,8,SHF,900,1015,1030,1130,1330,1500,0,0
8-
7,1,8,HK,1000,1230,1430,1600,0,0,0,0
8+
7,1,8,HK,930,1200,1300,1600,0,0,0,0
99
8,1,8,JZ,930,1130,1300,1500,0,0,0,0
1010
9,1,8,CSI,930,1130,1300,1500,0,0,0,0
1111
10,1,8,SGE,900,1130,1330,1530,0,0,0,0
12+
11,1,8,IB,830,1700,0,0,0,0,0,0
13+
12,1,8,HKH,930,1200,1300,1600,0,0,0,0
14+
13,1,8,HKS,930,1200,1300,1600,0,0,0,0

mdlink/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ add_subdirectory(src/mdlink/mdlink_merge)
7878
add_subdirectory(src/mdlink/mdlink_ctp)
7979
add_subdirectory(src/mdlink/mdlink_tdf)
8080
add_subdirectory(src/mdlink/mdlink_sina)
81+
add_subdirectory(src/mdlink/mdlink_tencent)
8182
add_subdirectory(src/qms)
83+
#add_subdirectory(src/tkreader)
84+
add_subdirectory(src/client)
8285
add_subdirectory(src/protocol)
8386

8487
# TODO: move to each module

mdlink/etc/jzs.json

+17-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"sources": [
2121
{ "addr": "tcp://127.0.0.1:10001", "id": "future1" },
2222
{ "addr": "tcp://127.0.0.1:10002", "id": "stock1" },
23-
{ "addr": "tcp://127.0.0.1:10003", "id": "stock2" }
23+
{ "addr": "tcp://127.0.0.1:10003", "id": "stock2" },
24+
{ "addr": "tcp://127.0.0.1:10004", "id": "stock3" }
2425
]
2526
},
2627

@@ -75,6 +76,21 @@
7576
"insttypes": "1;2;3;4;5;100;"
7677
}
7778
]
79+
},
80+
81+
"stock3": {
82+
"pub_addr": "tcp://0.0.0.0:10004",
83+
"route": "TENCENT",
84+
"source_id": 4,
85+
"sources": [
86+
{
87+
"id": "stock3",
88+
"route": "TENCENT",
89+
"addr": "http://qt.gtimg.cn/q=",
90+
"markets": "SZ;SH;",
91+
"insttypes": "1;2;3;4;5;100;"
92+
}
93+
]
7894
}
7995
}
8096
}

mdlink/scripts/start.bat

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ start cmd /k "cd .. && bin\qms2.exe qms2"
22
start cmd /k "cd .. && bin\mdlink2.exe mdlink2"
33
::start cmd /k "cd .. && bin\mdlink_tdf.exe stock1"
44
start cmd /k "cd .. && bin\mdlink_sina.exe stock2"
5+
start cmd /k "cd .. && bin\mdlink_tencent.exe stock3"
56
start cmd /k "cd .. && bin\mdlink_ctp.exe future1"

mdlink/src/config/SysConfig.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,15 @@ namespace jzs
162162
LOG(INFO) << "\taddr: " << source["addr"].asString() << endl;
163163
LOG(INFO) << "\tinsttypes: " << source["insttypes"].asString() << endl;
164164
LOG(INFO) << "\tmarkets: " << source["markets"].asString() << endl;
165-
}
165+
}
166+
else if (cfg.route == "TENCENT") {
167+
svrcfg.addr = source["addr"].asString();
168+
svrcfg.markets = source["markets"].asString();
169+
svrcfg.insttypes = source["insttypes"].asString();
170+
LOG(INFO) << "\taddr: " << source["addr"].asString() << endl;
171+
LOG(INFO) << "\tinsttypes: " << source["insttypes"].asString() << endl;
172+
LOG(INFO) << "\tmarkets: " << source["markets"].asString() << endl;
173+
}
166174
cfg.mdvec.push_back(svrcfg);
167175
}
168176
md = cfg;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
3+
project(jzs)
4+
set(CMAKE_INSTALL_PREFIX dist)
5+
add_definitions(
6+
-DUSE_PBMSG
7+
-DISLIB
8+
)
9+
10+
if (WIN32)
11+
set(BIN_PATH bin)
12+
set(LIB_PATH bin)
13+
set(DATA_PATH data)
14+
set(ETC_PATH etc)
15+
else()
16+
set(BIN_PATH bin)
17+
set(LIB_PATH lib)
18+
set(DATA_PATH data)
19+
set(ETC_PATH etc)
20+
endif()
21+
22+
set(SRC
23+
../../../deps/zmq/zhelpers.h
24+
../../../deps/jsoncpp/jsoncpp.cpp
25+
../public/MapTables.h
26+
../public/MapTables.cpp
27+
../public/MdServer.cpp
28+
../public/MdServer.h
29+
TencentApi.cpp
30+
TencentApi.h
31+
TencentMdServer.cpp
32+
TencentMdServer.h
33+
MdLinkMain.cpp
34+
)
35+
36+
include_directories(
37+
../../
38+
../../../deps
39+
../../../deps/zmq
40+
../../../deps/jsoncpp
41+
../../../deps/libcurl/include/curl
42+
)
43+
44+
45+
if (WIN32)
46+
link_directories(
47+
${CMAKE_CURRENT_SOURCE_DIR}/../../../deps/libcurl/lib
48+
)
49+
50+
include_directories(
51+
../../../deps/windows/zlib-1.2.8
52+
)
53+
54+
else()
55+
56+
add_definitions(-std=c++11)
57+
58+
59+
endif()
60+
61+
add_executable(mdlink_tencent ${SRC})
62+
63+
if (WIN32)
64+
target_link_libraries( mdlink_tencent
65+
libcurl
66+
base
67+
msgbus
68+
zmq
69+
protobuf
70+
z
71+
glog
72+
ws2_32
73+
)
74+
75+
else()
76+
77+
target_link_libraries( mdlink_tencent
78+
libcurl.so
79+
base
80+
msgbus
81+
zmq
82+
protobuf
83+
glog
84+
z
85+
)
86+
87+
endif()
88+
89+
if (WIN32)
90+
install (FILES
91+
../../../deps/libcurl/lib/libcurl.dll
92+
DESTINATION ${LIB_PATH}
93+
)
94+
endif()
95+
96+
install (TARGETS mdlink_tencent RUNTIME DESTINATION ${BIN_PATH})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include <cstring>
2+
#include <fstream>
3+
#include <thread>
4+
#include <chrono>
5+
#include <memory>
6+
#include <iomanip>
7+
#include <set>
8+
#include "config/IniApi.h"
9+
#include "config/SysConfig.h"
10+
#include "base/StringUtil.h"
11+
#include "base/Logger.h"
12+
#include "base/Init.h"
13+
#include "base/TimeUtil.h"
14+
#include "protocol/cpp/md.pb.h"
15+
#include <unistd.h>
16+
#include <getopt.h>
17+
#include <json/json.h>
18+
#include <mutex>
19+
#include <unordered_map>
20+
#include <set>
21+
#include "TencentMdServer.h"
22+
#include "TencentApi.h"
23+
#include "protocol/cpp/md.pb.h"
24+
#include "base/Calendar.h"
25+
#include "../public/MapTables.h"
26+
27+
28+
using namespace std;
29+
using namespace jzs;
30+
using namespace jzs::msg;
31+
using namespace jzs::msg::md;
32+
using namespace jzs::msgbus;
33+
using namespace tencent_api;
34+
void test_tencent()
35+
{
36+
string url_test = "http://qt.gtimg.cn/q=";
37+
tencent_api::TencentApi api;
38+
api.set_url(url_test);
39+
40+
vector<shared_ptr<tencent_api::MarketQuote>> quotes;
41+
42+
vector<string> codes;
43+
codes.push_back("sz000001");
44+
codes.push_back("sh000001");
45+
codes.push_back("sh502028");
46+
codes.push_back("sz399001");
47+
api.get_quotes(codes, &quotes);
48+
49+
cout << "test tencent\n";
50+
for (auto q : quotes) {
51+
cout << q->code << "," << q->date << "," << q->time << "," << q->last << "," << q->volume << endl;
52+
}
53+
getchar();
54+
}
55+
56+
int main(int argc, char* argv[])
57+
{
58+
string mdid;
59+
if (argc == 2) {
60+
mdid = string(argv[1]);
61+
init(argv[1]);
62+
}
63+
else {
64+
init(argv[0]);
65+
LOG(ERROR) << "Wrong number of arguments given!" << endl;
66+
return -1;
67+
}
68+
69+
MdlinkCfg mdcfg;
70+
SysConfig::getMdlinkCfg(mdid, mdcfg);
71+
TencentMdServer* svr = new TencentMdServer;
72+
if (!svr->init(mdcfg)) {
73+
return -1;
74+
}
75+
76+
svr->StartMdlink();
77+
while (true) {
78+
this_thread::sleep_for(chrono::seconds(5));
79+
auto next_time = chrono::system_clock::now() + chrono::seconds(5);
80+
while (chrono::system_clock::now() < next_time)
81+
this_thread::sleep_until(next_time);
82+
svr->ShowStatus();
83+
}
84+
return 0;
85+
}
86+

0 commit comments

Comments
 (0)