-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/HuobiRDCenter/huobi_Cpp
- Loading branch information
Showing
9 changed files
with
275 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
#define CURRENT_VERSION 1.0.13 | ||
#define CURRENT_VERSION 1.0.14 |
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,131 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
|
||
#设置编译器 | ||
IF (CMAKE_COMPILER_TYPE MATCHES "GCC") | ||
SET(CMAKE_C_COMPILER "gcc") | ||
SET(CMAKE_CXX_COMPILER "g++") | ||
ELSEIF (CMAKE_COMPILER_TYPE MATCHES "CLANG") | ||
SET(CMAKE_C_COMPILER "clang") | ||
SET(CMAKE_CXX_COMPILER "clang++") | ||
ENDIF () | ||
|
||
SET(CMAKE_C_FLAGS "-Wall -std=c99") | ||
SET(CMAKE_C_FLAGS_DEBUG "-g") | ||
SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") | ||
SET(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") | ||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") | ||
|
||
SET(CMAKE_CXX_FLAGS "-Wall -std=c++11") | ||
SET(CMAKE_CXX_FLAGS_DEBUG "-g") | ||
SET(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") | ||
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") | ||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") | ||
|
||
|
||
#判断操作系统 | ||
IF (WIN32) | ||
MESSAGE(STATUS "Now is windows") | ||
ELSEIF (APPLE) | ||
MESSAGE(STATUS "Now is Apple systens.") | ||
ELSEIF (UNIX) | ||
MESSAGE(STATUS "Now is UNIX-like OS's. Including aPPLE os x and CygWin") | ||
ENDIF () | ||
|
||
if (UNIX AND NOT APPLE) | ||
set(platform x64) | ||
set(LINUX TRUE) | ||
endif () | ||
|
||
if (APPLE) | ||
endif () | ||
|
||
|
||
|
||
if (LINUX) | ||
message(STATUS "当前操作系统: Linux") | ||
endif () | ||
|
||
if (APPLE) | ||
message(STATUS "当前操作系统: MacOS") | ||
endif () | ||
|
||
MESSAGE(STATUS "operation system is ${CMAKE_SYSTEM}") | ||
|
||
PROJECT(example) | ||
|
||
AUX_SOURCE_DIRECTORY(. DIR_SRCS) | ||
ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) | ||
|
||
IF (CMAKE_BUILD_TYPE MATCHES "Release") | ||
SET(CMAKE_BUILD_POSTFIX ${CMAKE_BUILD_TYPE}) | ||
ELSEIF(CMAKE_BUILD_TYPE MATCHES "Debug") | ||
SET(CMAKE_BUILD_POSTFIX ${CMAKE_BUILD_TYPE}) | ||
ELSE() | ||
MESSAGE(FATAL_ERROR "The CMAKE_BUILD_TYPE only supports Release or Debug") | ||
ENDIF() | ||
|
||
|
||
find_library(LIBHUOBICLIENT_PATH HuobiClient) | ||
IF(NOT LIBHUOBICLIENT_PATH) | ||
message(${HUOBI_CLIENT_DIR}/lib/${CMAKE_BUILD_POSTFIX}) | ||
MESSAGE(FATAL_ERROR "HuobiClient not found") | ||
ENDIF(NOT LIBHUOBICLIENT_PATH) | ||
MESSAGE(STATUS ${LIBHUOBICLIENT_PATH} " found") | ||
|
||
|
||
find_library(LIBWEBSOCKET_PATH websockets) | ||
IF(NOT LIBWEBSOCKET_PATH) | ||
MESSAGE(FATAL_ERROR "libwebsockets not found") | ||
ENDIF(NOT LIBWEBSOCKET_PATH) | ||
MESSAGE(STATUS ${LIBWEBSOCKET_PATH} " found") | ||
|
||
find_library(LIBSSL_PATH ssl) | ||
IF(NOT LIBSSL_PATH) | ||
MESSAGE(FATAL_ERROR "libssl not found") | ||
ENDIF(NOT LIBSSL_PATH) | ||
MESSAGE(STATUS ${LIBSSL_PATH} " found") | ||
|
||
find_library(LIBCRYPTO_PATH crypto) | ||
IF(NOT LIBCRYPTO_PATH) | ||
MESSAGE(FATAL_ERROR "libcrypto not found") | ||
ENDIF(NOT LIBCRYPTO_PATH) | ||
MESSAGE(STATUS ${LIBCRYPTO_PATH} " found") | ||
|
||
find_library(LIBCURL_PATH curl) | ||
IF(NOT LIBCURL_PATH) | ||
MESSAGE(FATAL_ERROR "curl not found") | ||
ENDIF(NOT LIBCURL_PATH) | ||
MESSAGE(STATUS ${LIBCURL_PATH} " found") | ||
|
||
find_library(LIBZ_PATH z) | ||
IF(NOT LIBZ_PATH) | ||
MESSAGE(FATAL_ERROR "z not found") | ||
ENDIF(NOT LIBZ_PATH) | ||
MESSAGE(STATUS ${LIBZ_PATH} " found") | ||
|
||
find_library(LIBPTHREAD_PATH pthread) | ||
IF(NOT LIBPTHREAD_PATH) | ||
MESSAGE(FATAL_ERROR "pthread not found") | ||
ENDIF(NOT LIBPTHREAD_PATH) | ||
MESSAGE(STATUS ${LIBPTHREAD_PATH} " found") | ||
|
||
find_library(LIBDECNUMBER_PATH decnumber) | ||
IF(NOT LIBDECNUMBER_PATH) | ||
MESSAGE(FATAL_ERROR "decnumber not found") | ||
ENDIF(NOT LIBDECNUMBER_PATH) | ||
MESSAGE(STATUS ${LIBDECNUMBER_PATH} " found") | ||
|
||
FIND_PATH( | ||
LIBDECNUMBER_INCLUDE_DIR | ||
decNumber.h | ||
/usr/include/decnumber/ | ||
/usr/local/include/decnumber/ | ||
) | ||
include_directories(${LIBDECNUMBER_INCLUDE_DIR}) | ||
include_directories(/usr/local/include) | ||
|
||
add_definitions(-std=c++11) | ||
|
||
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIBHUOBICLIENT_PATH} ${LIBDECNUMBER_PATH} ${LIBSSL_PATH} ${LIBCRYPTO_PATH} ${LIBWEBSOCKET_PATH} ${LIBCURL_PATH} ${LIBZ_PATH} ${LIBPTHREAD_PATH}) | ||
|
||
|
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,23 @@ | ||
#include<iostream> | ||
#include "Huobi/HuobiClient.h" | ||
#include "../key.h" | ||
using namespace Huobi; | ||
using namespace std; | ||
|
||
int main(int argc, char** argv) { | ||
|
||
SubscriptionClient* subscriptionClient = createSubscriptionClient( | ||
Key::apiKey, Key::secretKey); | ||
subscriptionClient->subscribeOrderUpdateV2("htusdt", [](OrderUpdateV2Event event) { | ||
cout << "---- aggressor: " << event.aggressor << " ----" << endl; | ||
cout << "---- orderId: " << event.orderId << " ----" << endl; | ||
cout << "---- symbol: " << event.symbol << " ----" << endl; | ||
cout << "---- tradeId: " << event.tradeId << " ----" << endl; | ||
cout << "---- tradePrice: " << event.tradePrice << " ----" << endl; | ||
cout << "---- tradeTime: " << event.tradeTime << " ----" << endl; | ||
cout << "---- tradeVolume: " << event.tradeVolume << " ----" << endl; | ||
|
||
}); | ||
subscriptionClient->startService(); | ||
|
||
} |
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,40 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
/* | ||
* File: OrderUpdateV2Event.h | ||
* Author: yuanxueqi | ||
* | ||
* Created on 2020年4月15日, 下午2:52 | ||
*/ | ||
|
||
#ifndef ORDERUPDATEV2EVENT_H | ||
#define ORDERUPDATEV2EVENT_H | ||
namespace Huobi { | ||
|
||
struct OrderUpdateV2Event { | ||
std::string eventType; | ||
std::string symbol; | ||
long orderId; | ||
std::string clientOrderId; | ||
std::string orderPrice; | ||
std::string orderSize; | ||
std::string type; | ||
std::string orderStatus; | ||
long orderCreateTime; | ||
std::string tradePrice; | ||
std::string tradeVolume; | ||
long tradeId; | ||
long tradeTime; | ||
bool aggressor; | ||
std::string remainAmt; | ||
long lastActTime; | ||
}; | ||
} | ||
|
||
|
||
#endif /* ORDERUPDATEV2EVENT_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
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