-
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 14, 2020
1 parent
28ca7f7
commit 7984688
Showing
15 changed files
with
279 additions
and
6 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
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 @@ | ||
|
||
#ifndef HUOBI_WEBSOCKETTRADECLIENT_H | ||
#define HUOBI_WEBSOCKETTRADECLIENT_H | ||
|
||
#include "include.h" | ||
|
||
struct WebsocketTradeClient { | ||
WebsocketTradeClient(char *accessKey, char *secretKey) : signature{accessKey, secretKey} { | ||
} | ||
|
||
void subTradeClearing(const char* symbol, int mode,const std::function<void(const TradeClearing &)> &handler); | ||
|
||
Signature signature; | ||
}; | ||
#endif //HUOBI_WEBSOCKETTRADECLIENT_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
#ifndef HUOBI_ASSETVALUATIONREQUEST_H | ||
#define HUOBI_ASSETVALUATIONREQUEST_H | ||
|
||
#include <string> | ||
|
||
struct AssetValuationRequest{ | ||
std::string accountType; | ||
std::string valuationCurrency; | ||
long subUid; | ||
}; | ||
#endif //HUOBI_ASSETVALUATIONREQUEST_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,13 @@ | ||
|
||
#ifndef HUOBI_POINTTRANSFERREQUEST_H | ||
#define HUOBI_POINTTRANSFERREQUEST_H | ||
|
||
#include <string> | ||
|
||
struct PointTransferRequest{ | ||
long fromUid; | ||
std::string amount; | ||
long toUid; | ||
long groupId; | ||
}; | ||
#endif //HUOBI_POINTTRANSFERREQUEST_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,12 @@ | ||
|
||
#ifndef HUOBI_ASSETVALUATION_H | ||
#define HUOBI_ASSETVALUATION_H | ||
|
||
#include <string> | ||
|
||
struct AssetValuation { | ||
std::string balance; | ||
long timestamp; | ||
}; | ||
|
||
#endif //HUOBI_ASSETVALUATION_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,22 @@ | ||
|
||
#ifndef HUOBI_POINTACCOUNT_H | ||
#define HUOBI_POINTACCOUNT_H | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
struct Group{ | ||
long groupId; | ||
long expiryDate; | ||
std::string remainAmt; | ||
}; | ||
struct PointAccount{ | ||
long accountId; | ||
std::string accountStatus; | ||
std::string acctBalance; | ||
std::vector<Group> groupIds; | ||
}; | ||
|
||
|
||
|
||
#endif //HUOBI_POINTACCOUNT_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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
#ifndef HUOBI_TRADECLEARING_H | ||
#define HUOBI_TRADECLEARING_H | ||
|
||
#include <string> | ||
|
||
struct TradeClearing { | ||
std::string eventType; | ||
std::string symbol; | ||
long orderId; | ||
std::string tradePrice; | ||
std::string tradeVolume; | ||
std::string orderSide; | ||
std::string orderType; | ||
bool aggressor; | ||
long tradeId; | ||
long tradeTime; | ||
std::string transactFee; | ||
std::string feeCurrency; | ||
std::string feeDeduct; | ||
std::string feeDeductType; | ||
long accountId; | ||
std::string source; | ||
std::string orderPrice; | ||
std::string orderSize; | ||
std::string orderValue; | ||
std::string clientOrderId; | ||
std::string stopPrice; | ||
std::string operator_; | ||
long orderCreateTime; | ||
std::string orderStatus; | ||
std::string remainAmt; | ||
}; | ||
#endif //HUOBI_TRADECLEARING_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "client/WebsocketTradeClient.h" | ||
|
||
|
||
void WebsocketTradeClient::subTradeClearing(const char *symbol, int mode, | ||
const std::function<void(const TradeClearing &)> &handler) { | ||
string topic; | ||
topic.append("trade.clearing#").append(symbol).append("#").append(to_string(mode)); | ||
std::thread th(WebsocketHelper::monitor, topic, signature, [handler](Value &value) { | ||
Value &data = value["data"]; | ||
TradeClearing tradeClearing; | ||
tradeClearing.eventType = data["eventType"].GetString(); | ||
tradeClearing.symbol = data["symbol"].GetString(); | ||
if (data.HasMember("orderId")) | ||
tradeClearing.orderId = atol(data["orderId"].GetString()); | ||
if (data.HasMember("clientOrderId")) | ||
tradeClearing.clientOrderId = data["clientOrderId"].GetString(); | ||
if (data.HasMember("orderPrice")) | ||
tradeClearing.orderPrice = data["orderPrice"].GetString(); | ||
if (data.HasMember("orderSize")) | ||
tradeClearing.orderSize = data["orderSize"].GetString(); | ||
tradeClearing.orderStatus = data["orderStatus"].GetString(); | ||
if (data.HasMember("orderCreateTime")) | ||
tradeClearing.orderCreateTime = atol(data["orderCreateTime"].GetString()); | ||
if (data.HasMember("tradePrice")) | ||
tradeClearing.tradePrice = data["tradePrice"].GetString(); | ||
if (data.HasMember("tradeVolume")) | ||
tradeClearing.tradeVolume = data["tradeVolume"].GetString(); | ||
if (data.HasMember("tradeId")) | ||
tradeClearing.tradeId = atol(data["tradeId"].GetString()); | ||
if (data.HasMember("tradeTime")) | ||
tradeClearing.tradeTime = atol(data["tradeTime"].GetString()); | ||
if (data.HasMember("aggressor")) | ||
tradeClearing.aggressor = data["aggressor"].GetBool(); | ||
if (data.HasMember("orderStatus")) | ||
tradeClearing.orderStatus = data["orderStatus"].GetString(); | ||
if (data.HasMember("remainAmt")) | ||
tradeClearing.remainAmt = data["remainAmt"].GetString(); | ||
if (data.HasMember("orderSide")) | ||
tradeClearing.orderSide = data["orderSide"].GetString(); | ||
if (data.HasMember("remainAmt")) | ||
tradeClearing.remainAmt = data["remainAmt"].GetString(); | ||
if (data.HasMember("orderValue")) | ||
tradeClearing.orderValue = data["orderValue"].GetString(); | ||
if (data.HasMember("accountId")) | ||
tradeClearing.accountId = atol(data["accountId"].GetString()); | ||
if (data.HasMember("transactFee")) | ||
tradeClearing.transactFee = data["transactFee"].GetString(); | ||
if (data.HasMember("feeCurrency")) | ||
tradeClearing.feeCurrency = data["feeCurrency"].GetString(); | ||
if (data.HasMember("feeDeduct")) | ||
tradeClearing.feeDeduct = data["feeDeduct"].GetString(); | ||
if (data.HasMember("feeDeductType")) | ||
tradeClearing.feeDeductType = data["feeDeductType"].GetString(); | ||
if (data.HasMember("source")) | ||
tradeClearing.source = data["source"].GetString(); | ||
if (data.HasMember("stopPrice")) | ||
tradeClearing.stopPrice = data["stopPrice"].GetString(); | ||
if (data.HasMember("operator")) | ||
tradeClearing.operator_ = data["operator"].GetString(); | ||
handler(tradeClearing); | ||
}); | ||
th.detach(); | ||
} | ||
|