Skip to content

Commit c0b7dab

Browse files
committed
Merge branch 'feature_tcp_client' of git.tigerbrokers.net:server/openapi/openapi-cpp-sdk into feature_tcp_client
2 parents abe7ccc + d0796ad commit c0b7dab

File tree

94 files changed

+45352
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+45352
-21
lines changed

demo/openapi_cpp_test/openapi_cpp_test.cpp

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// openapi_cpp_test.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
2+
#include "tigerapi/push_client.h"
23
#include "tigerapi/tiger_client.h"
34
#include "tigerapi/quote_client.h"
45
#include "tigerapi/trade_client.h"
@@ -238,7 +239,7 @@ class TestQuoteClient {
238239
symbols[1] = value::string(U("JD"));
239240
auto result = quote_client->get_quote_real_time_value(symbols);
240241
vector<RealtimeQuote> result1 = quote_client->get_quote_real_time(symbols);
241-
ucout << U("result: ") << result.at(0).to_string() << endl;
242+
ucout << U("result: ") << result.at(0).serialize() << endl;
242243
}
243244

244245
static void test_get_quote_delay(const std::shared_ptr<QuoteClient> quote_client) {
@@ -439,13 +440,36 @@ int main()
439440
{
440441
/************************** set config **********************/
441442
ClientConfig config = ClientConfig();
442-
config.private_key = U("");
443-
config.tiger_id = U("");
444-
config.account = U("");
445-
446-
447-
448-
443+
#if 1
444+
config.private_key = U("");
445+
config.tiger_id = U("");
446+
config.account = U("");
447+
config.socket_url = U("");
448+
config.socket_port = U("");
449+
#else
450+
config.private_key = U("");
451+
config.tiger_id = U("");
452+
config.account = U("");
453+
config.socket_url = U("");
454+
config.socket_port = U("");
455+
#endif
456+
457+
auto push_client = PushClient::create_push_client(config);
458+
push_client->connect(config);
459+
std::string input;
460+
while (true)
461+
{
462+
std::cout << "Enter command (type 'exit' to quit): ";
463+
std::getline(std::cin, input);
464+
465+
if (input == "exit") {
466+
std::cout << "Exiting loop." << std::endl;
467+
push_client->disconnect();
468+
break;
469+
}
470+
// Process other commands or input here
471+
std::cout << "You entered: " << input << std::endl;
472+
}
449473

450474
//config.lang = U("en_US");
451475

@@ -459,8 +483,8 @@ int main()
459483
/**
460484
* ʹ�÷�װ��Ľ��׽ӿ� TradeClient
461485
*/
462-
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
463-
TestTradeClient::test_trade(trade_client);
486+
//std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
487+
//TestTradeClient::test_trade(trade_client);
464488

465489
/**
466490
* ֱ��ʹ��δ��װ�� TigerApi

demo/openapi_cpp_test/openapi_cpp_test.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<ClCompile>
8787
<WarningLevel>Level3</WarningLevel>
8888
<SDLCheck>true</SDLCheck>
89-
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
89+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9090
<ConformanceMode>true</ConformanceMode>
9191
<AdditionalIncludeDirectories>..\..\include;..\..\..\vcpkg\installed\x86-windows\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
9292
</ClCompile>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
syntax = "proto3";
2+
3+
package tigeropen.push.pb;
4+
5+
6+
message AssetData {
7+
string account = 1; // user account
8+
string currency = 2; // currency. USD, HKD, etc.
9+
string segType = 3; // Securities Category C: (Commodities Futures), S: (Securities Stocks)
10+
11+
double availableFunds = 4; // available funds, overnight liquidity
12+
double excessLiquidity = 5; // excess liquidity, used to represent intraday risk value.
13+
double netLiquidation = 6; // Total Assets (Net Liquidation Value)
14+
double equityWithLoan = 7; // Equity with loan value (asset with loan value) - Securities Segment: Cash Value + Stock Value - Futures Segment: Cash Value - Maintenance Margin
15+
double buyingPower = 8; // buying power. An estimation of how many more dollars you can buy in stock assets. Only apply to stock segment
16+
double cashBalance = 9; // Cash amount. Sum of current cash balances in all currencies
17+
double grossPositionValue = 10; // total value of securities
18+
19+
double initMarginReq = 11; // initial margin requirement
20+
double maintMarginReq = 12; // maintenance margin requirement
21+
uint64 timestamp = 13;
22+
23+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
syntax = "proto3";
2+
package tigeropen.push.pb;
3+
4+
message KlineData {
5+
int64 time = 1; // bar timestamp.
6+
float open = 2; // The first transaction price of current minute.
7+
float high = 3; // The highest price of current minute.
8+
float low = 4; // The lowest price of current minute.
9+
float close = 5; // The last transaction price in the current minute
10+
float avg = 6; // The average price of current minute.
11+
int64 volume = 7; // Cumulative trading volume in current minute.
12+
int32 count = 8; // The number of transaction in current minute.
13+
string symbol = 9; // symbol
14+
double amount = 10; // Cumulative turnover in current minute.
15+
uint64 serverTimestamp = 11;
16+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
syntax = "proto3";
2+
3+
package tigeropen.push.pb;
4+
5+
message OptionTopData {
6+
string market = 1;
7+
int64 timestamp = 2;
8+
repeated TopData topData = 3;
9+
10+
message TopData {
11+
string targetName = 1; // bigOrder, volume, amount, openInt
12+
repeated BigOrder bigOrder = 2; // large order(bigOrder)
13+
repeated OptionItem item = 3; // target value top list(volume, amount, openInt)
14+
}
15+
16+
message BigOrder {
17+
string symbol = 1;
18+
string expiry = 2; // formate:yyyyMMdd
19+
string strike = 3; // strike price
20+
string right = 4; // CALL/PUT
21+
string dir = 5; // BUY/SELL
22+
double volume = 6; // target value: volume > 1000
23+
double price = 7; // trade price
24+
double amount = 8; // trade amount
25+
int64 tradeTime = 9;// trade timestamp
26+
}
27+
28+
message OptionItem {
29+
string symbol = 1;
30+
string expiry = 2; // formate:yyyyMMdd
31+
string strike = 3; // strike price
32+
string right = 4; // CALL/PUT
33+
double totalAmount = 5; // total trade amount
34+
double totalVolume = 6; // total trade volume
35+
double totalOpenInt = 7; // open interest
36+
double volumeToOpenInt = 8; // Volume to Open Interest
37+
double latestPrice = 9; // option latest price
38+
int64 updateTime = 10; // uptate timestamp
39+
}
40+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
syntax = "proto3";
2+
3+
package tigeropen.push.pb;
4+
5+
message OrderStatusData {
6+
sint64 id = 1; // unique order id
7+
string account = 2; // user account
8+
string symbol = 3;
9+
string expiry = 4; // for options, formate:yyyyMMdd
10+
string strike = 5; // for options
11+
string right = 6; // for options
12+
string identifier = 7;
13+
uint32 multiplier = 8; // multiplier for futures, options, warrants and CBBC
14+
string action = 9; // BUY or SELL
15+
string market = 10; // market. US, HK, etc.
16+
string currency = 11; // currency. USD, HKD, etc.
17+
string segType = 12; // Securities Category C: (Commodities Futures), S: (Securities Stocks)
18+
string secType = 13; // STK Stocks, OPT Options, WAR Warrants, IOPT CBBC, CASH FOREX, FUT Futures, FOP Future Options
19+
20+
string orderType = 14; // order type
21+
bool isLong = 15;
22+
sint64 totalQuantity = 16; // total quantity
23+
sint32 totalQuantityScale = 17; // total quantity scale
24+
sint64 filledQuantity = 18; // filled quantity
25+
sint32 filledQuantityScale = 19; // filled quantity scale
26+
double avgFillPrice = 20; // average price at which the orders got filled
27+
double limitPrice = 21; // limit price(required when orderType is 'LMT')
28+
double stopPrice = 22; // stop price(required when orderType is 'STP')
29+
double realizedPnl = 23; // realized profit and loss
30+
string status = 24; // order status
31+
string replaceStatus = 25; // order replace status
32+
string cancelStatus = 26; // order cancel status
33+
34+
bool outsideRth = 27; // if trade outside regular trading hours (only applicable to U.S. market)
35+
bool canModify = 28;
36+
bool canCancel = 29;
37+
bool liquidation = 30;
38+
string name = 31; // symbol name
39+
string source = 32; // order source(from 'OpenApi', or not)
40+
string errorMsg = 33; // error message
41+
string attrDesc = 34; // order description
42+
float commissionAndFee = 35; // commission and fee
43+
uint64 openTime = 36; // timestamp when the order is placed
44+
uint64 timestamp = 37;
45+
string userMark = 38;
46+
double totalCashAmount = 39;
47+
double filledCashAmount = 40;
48+
double gst = 41;
49+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
syntax = "proto3";
2+
3+
package tigeropen.push.pb;
4+
5+
message OrderTransactionData {
6+
sint64 id = 1; // transact id
7+
sint64 orderId = 2; // unique order id
8+
string account = 3; // user account
9+
string symbol = 4;
10+
string identifier = 5;
11+
uint32 multiplier = 6; // multiplier for futures, options, warrants and CBBC
12+
string action = 7; // BUY or SELL
13+
string market = 8; // market. US, HK, etc.
14+
string currency = 9; // currency. USD, HKD, etc.
15+
string segType = 10; // Securities Category C: (Commodities Futures), S: (Securities Stocks)
16+
string secType = 11; // STK Stocks, OPT Options, WAR Warrants, IOPT CBBC, CASH FOREX, FUT Futures, FOP Future Options
17+
double filledPrice = 12; // filled price
18+
sint64 filledQuantity = 13; // filled quantity
19+
uint64 createTime = 14;
20+
uint64 updateTime = 15;
21+
uint64 transactTime = 16; // transact time
22+
uint64 timestamp = 17;
23+
24+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
syntax = "proto3";
2+
3+
package tigeropen.push.pb;
4+
5+
message PositionData {
6+
string account = 1; // user account
7+
string symbol = 2;
8+
string expiry = 3; // for options
9+
string strike = 4; // for options
10+
string right = 5; // for options
11+
string identifier = 6;
12+
uint32 multiplier = 7; // multiplier for futures, options, warrants and CBBC
13+
string market = 8; // market. US, HK, etc.
14+
string currency = 9; // currency. USD, HKD, etc.
15+
string segType = 10; // Securities Category C: (Commodities Futures), S: (Securities Stocks)
16+
string secType = 11; // STK Stocks, OPT Options, WAR Warrants, IOPT CBBC, CASH FOREX, FUT Futures, FOP Future Options
17+
18+
sint64 position = 12; // total position
19+
sint32 positionScale = 13; // total position scale
20+
double averageCost = 14; // average holding cost
21+
double latestPrice = 15; // last price of the asset
22+
double marketValue = 16; // market value of the asset
23+
double unrealizedPnl = 17; // unrealized profit and loss
24+
string name = 18; // symbol name
25+
uint64 timestamp = 19;
26+
sint64 saleable = 20; // saleable quantity for Chinese A-share market stocks
27+
double positionQty = 21; // total position quantity
28+
double salableQty = 22; // saleable quantity
29+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
syntax = "proto3";
2+
import public "SocketCommon.proto";
3+
import public "OrderStatusData.proto";
4+
import public "PositionData.proto";
5+
import public "AssetData.proto";
6+
import public "QuoteData.proto";
7+
import public "QuoteDepthData.proto";
8+
import public "TradeTickData.proto";
9+
import public "OrderTransactionData.proto";
10+
import public "StockTopData.proto";
11+
import public "OptionTopData.proto";
12+
import public "KlineData.proto";
13+
import public "TickData.proto";
14+
15+
package tigeropen.push.pb;
16+
17+
message PushData {
18+
SocketCommon.DataType dataType = 1;
19+
oneof body {
20+
QuoteData quoteData = 2;
21+
QuoteDepthData quoteDepthData = 3;
22+
TradeTickData tradeTickData = 4;
23+
PositionData positionData = 5;
24+
AssetData assetData = 6;
25+
OrderStatusData orderStatusData = 7;
26+
OrderTransactionData orderTransactionData = 8;
27+
StockTopData stockTopData = 9;
28+
OptionTopData optionTopData = 10;
29+
KlineData klineData = 11;
30+
TickData tickData = 12;
31+
}
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
syntax = "proto3";
2+
import public "SocketCommon.proto";
3+
4+
package tigeropen.push.pb;
5+
6+
7+
message QuoteBBOData {
8+
9+
string symbol = 1;
10+
SocketCommon.QuoteType type = 2; // BBO
11+
uint64 timestamp = 3;
12+
13+
double askPrice = 17;
14+
sint64 askSize = 18;
15+
uint64 askTimestamp = 19; // Pre/Post-Mkt data not support
16+
double bidPrice = 20;
17+
sint64 bidSize = 21;
18+
uint64 bidTimestamp = 22; // Pre/Post-Mkt data not support
19+
20+
}

0 commit comments

Comments
 (0)