-
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.
- Loading branch information
yuanxueqi
committed
Oct 10, 2020
1 parent
dfeb907
commit 5c1965a
Showing
128 changed files
with
1,435 additions
and
281 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ project(huobi LANGUAGES CXX) | |
set(CMAKE_CXX_STANDARD 17) | ||
|
||
set(huobi_VERSION_MAJOR 2) | ||
set(huobi_VERSION_MINOR 1) | ||
set(huobi_VERSION_MINOR 2) | ||
|
||
configure_file( | ||
"${PROJECT_SOURCE_DIR}/huobiConfig.h.in" | ||
|
@@ -15,6 +15,7 @@ configure_file( | |
include_directories("${PROJECT_SOURCE_DIR}/include") | ||
|
||
include_directories(/usr/local/include) | ||
include_directories(/usr/local/opt/[email protected]/include) | ||
include_directories(/opt/cpprest-2.10.16/include) | ||
|
||
|
||
|
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,22 @@ | ||
cmake_minimum_required(VERSION 3.10...3.17) | ||
project(demo LANGUAGES CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
include_directories(/usr/local/huobi) | ||
|
||
add_subdirectory(account) | ||
add_subdirectory(crossmargin) | ||
add_subdirectory(isolatedmargin) | ||
add_subdirectory(market) | ||
add_subdirectory(reference) | ||
add_subdirectory(trade) | ||
add_subdirectory(wallet) | ||
add_subdirectory(websocketAsset) | ||
add_subdirectory(websocketMarket) | ||
add_subdirectory(websocketOrders) | ||
|
||
find_package(cpprestsdk REQUIRED) | ||
|
||
link_directories(/usr/local/lib/) | ||
link_directories(/usr/local/huobi/) |
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,15 @@ | ||
cmake_minimum_required(VERSION 3.10...3.17) | ||
project(account LANGUAGES CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
include_directories(/usr/local/huobi) | ||
|
||
find_package(cpprestsdk REQUIRED) | ||
|
||
link_directories(/usr/local/lib/) | ||
link_directories(/usr/local/huobi/) | ||
|
||
ADD_EXECUTABLE(algodemo ./algodemo.cpp) | ||
|
||
target_link_libraries(algodemo huobi curl ssl crypto cpprestsdk::cpprest z) |
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 @@ | ||
#include <client/algoClient.h> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
AlgoClient algoClient{APIKEY, SECRETKEY}; | ||
CreateAlgoOrderRequest createAlgoOrderRequest; | ||
createAlgoOrderRequest.orderType = "market"; | ||
createAlgoOrderRequest.symbol = "htusdt"; | ||
createAlgoOrderRequest.stopPrice = "4"; | ||
createAlgoOrderRequest.orderSide = "sell"; | ||
createAlgoOrderRequest.orderSize = "10"; | ||
createAlgoOrderRequest.clientOrderId = "clientOrderId"; | ||
cout << algoClient.createAlgoOrder(createAlgoOrderRequest) << endl; | ||
|
||
AlgoOrder algoOrder = algoClient.specificAlgoOrder("clientOrderId"); | ||
cout << algoOrder.clientOrderId << endl; | ||
vector<string> cancelOrders; | ||
cancelOrders.push_back("aaa"); | ||
CancelAlgoOrderResult cancelAlgoOrderResult = algoClient.cancelAlgoOrder(cancelOrders); | ||
cout << cancelAlgoOrderResult.rejected[0] << endl; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
|
||
#include <client/crossMarginClient.h> | ||
|
||
using namespace std; | ||
|
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,5 +1,3 @@ | ||
|
||
|
||
#include <client/isolatedMarginClient.h> | ||
|
||
using namespace std; | ||
|
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,5 +1,3 @@ | ||
|
||
|
||
#include <iostream> | ||
#include <client/referenceClient.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,15 @@ | ||
cmake_minimum_required(VERSION 3.10...3.17) | ||
project(account LANGUAGES CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
include_directories(/usr/local/huobi) | ||
|
||
find_package(cpprestsdk REQUIRED) | ||
|
||
link_directories(/usr/local/lib/) | ||
link_directories(/usr/local/huobi/) | ||
|
||
ADD_EXECUTABLE(subuserdemo ./subuserdemo.cpp) | ||
|
||
target_link_libraries(subuserdemo huobi curl ssl crypto cpprestsdk::cpprest z) |
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,39 @@ | ||
|
||
#include <client/subUserClient.h> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
SubUserClient subUserClient{APIKEY, SECRETKEY}; | ||
|
||
vector<Balance> subbalanceVec = subUserClient.getSubuserAggregateBalance(); | ||
cout << subbalanceVec[0].currency << endl; | ||
|
||
ManageSubUserRequest manageSubUserRequest{12345, "lock"}; | ||
subUserClient.manageSubUser(manageSubUserRequest); | ||
|
||
QuerySubUserDepositRequest querySubUserDepositRequest{12345}; | ||
vector<SubUserDeposit> subUserDepositVec = subUserClient.querySubUserDeposit(querySubUserDepositRequest); | ||
for (SubUserDeposit deposit:subUserDepositVec) { | ||
cout << deposit.amount << endl; | ||
} | ||
|
||
SubUserCreationRequest subUserCreationRequest; | ||
subUserCreationRequest.userName = "userName"; | ||
subUserCreationRequest.note = "note"; | ||
vector<SubUserCreationRequest> subUserCreationRequestVec{subUserCreationRequest}; | ||
vector<CreateSubUserResponse> createSubUserResponseVec = subUserClient.subUserCreation(subUserCreationRequestVec); | ||
cout << createSubUserResponseVec[0].userName << endl; | ||
|
||
SubUserTradableMarketRequest subUserTradableMarketRequest{"12345","spot","activated"}; | ||
vector<SubUserTradableMarketResponse> subUserTradableMarketResponseVec = subUserClient.subUserTradableMarket(subUserTradableMarketRequest); | ||
cout << subUserTradableMarketResponseVec[0].activation << endl; | ||
|
||
SubUserTransferabilityRequest subUserTransferabilityRequest{"12345", "spot",true}; | ||
vector<SubUserTransferabilityResponse> subUserTransferabilityResponseVec = subUserClient.subUserTransferability(subUserTransferabilityRequest); | ||
cout << subUserTransferabilityResponseVec[0].transferrable << endl; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
|
||
#include <client/tradeClient.h> | ||
|
||
using namespace std; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# | ||
# Ubuntu Dockerfile | ||
# | ||
# https://github.com/dockerfile/ubuntu | ||
# | ||
|
||
# Pull base image. | ||
FROM ubuntu:18.04 | ||
|
||
# Install. | ||
RUN \ | ||
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \ | ||
apt-get update && \ | ||
apt-get -y upgrade && \ | ||
apt-get install -y build-essential && \ | ||
apt-get install -y curl git vim wget cmake && \ | ||
apt-get install -y libssl-dev libcurl4-openssl-dev zlib1g-dev libcpprest-dev && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set environment variables. | ||
ENV HOME /root | ||
|
||
# Define working directory. | ||
WORKDIR /root | ||
|
||
RUN \ | ||
git clone https://github.com/huobiapi/huobi_Cpp.git && \ | ||
cd huobi_Cpp && \ | ||
mkdir build && \ | ||
cd build && \ | ||
cmake .. -DCMAKE_PREFIX_PATH=/opt/cpprest-2.10.16/lib64/cmake/ && \ | ||
make && \ | ||
make install | ||
|
||
WORKDIR /root | ||
|
||
RUN \ | ||
cd huobi_Cpp/demo/reference && \ | ||
mkdir build && \ | ||
cd build && \ | ||
cmake .. -DCMAKE_PREFIX_PATH=/opt/cpprest-2.10.16/lib64/cmake/ -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/cmake && \ | ||
make | ||
|
||
# Define default command. | ||
CMD ["bash"] |
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,29 @@ | ||
|
||
#ifndef HUOBI_ALGOCLIENT_H | ||
#define HUOBI_ALGOCLIENT_H | ||
|
||
#include "include.h" | ||
#include <vector> | ||
|
||
using namespace rapidjson; | ||
using namespace std; | ||
|
||
struct AlgoClient { | ||
|
||
AlgoClient(char *accessKey, char *secretKey) : signature{accessKey, secretKey} { | ||
} | ||
|
||
std::string createAlgoOrder(CreateAlgoOrderRequest &request); | ||
|
||
std::vector<AlgoOrder> openingAlgoOrders(OpeningAlgoOrdersRequest &request); | ||
|
||
std::vector<AlgoOrder> historyAlgoOrders(HistoryAlgoOrdersRequest &request); | ||
|
||
AlgoOrder specificAlgoOrder(std::string clientOrderId); | ||
|
||
CancelAlgoOrderResult cancelAlgoOrder(vector<std::string>clientOrderIds); | ||
private: | ||
Signature signature; | ||
}; | ||
|
||
#endif //HUOBI_ALGOCLIENT_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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
|
||
#ifndef HUOBI_CROSSMARGINCLIENT_H | ||
#define HUOBI_CROSSMARGINCLIENT_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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
|
||
#ifndef HUOBI_ISOLATEDMARGINCLIENT_H | ||
#define HUOBI_ISOLATEDMARGINCLIENT_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
|
||
#ifndef HUOBI_REFERENCECLIENT_H | ||
#define HUOBI_REFERENCECLIENT_H | ||
|
||
|
Oops, something went wrong.