股票交易的C接口中可能包含多個調用函數,具體的調用函數取決于所使用的接口規范和交易所的要求。接下來看看下面是一些可能常見的股票交易C接口調用函數的示例:
1. 連接函數(Connect):用于與交易所建立網絡連接。
2. 登錄函數(Login):用于進行身份驗證并登錄到交易所系統。
3. 查詢行情函數(GetMarketData):用于獲取股票市場數據,如股票行情、指數行情等。
4. 查詢資金函數(GetAccountInfo):用于查詢用戶的資金余額、可用資金、持倉信息等。
如多賬戶批量查詢及獲取:
簽名 | void GetMultiAccountsQuotes(int ClientId[], const char* Zqdm[], int Count, char* Result[], char* ErrorInfo[]); | |
功能 | 多賬戶批量獲取五檔報價, 通過下標區分每項查詢 | |
參數 | ClientId[] | 客戶端 Id 數組 |
Zqdm[] | 證券代碼數組 | |
Count | 查詢項數, 即數組長度 | |
Result[] | 查詢結果數組, 每項結果需要分配 1024*1024 字節的空間 格式請參閱[Result 格式] | |
ErrorInfo[] | 錯誤信息數組, 每項錯誤信息需要分配 256 字節的空間 | |
返回值 | 無, 第 i 項查詢成功與否通過 ErrorInfo[i]是否為空字符串來判斷 |
5. 買入函數(BuyOrder):用于發送買入股票的指令。
6. 賣出函數(SellOrder):用于發送賣出股票的指令。
7. 撤單函數(CancelOrder):用于撤銷尚未成交的買入或賣出指令。
8. 查詢成交函數(GetTradeInfo):用于查詢已成交的委托信息。
9. 查詢持倉函數(GetPositionInfo):用于查詢當前持倉的股票信息。
請注意,上述函數僅為示例,具體的調用函數可能因交易所和接口規范而有所不同。在分析股票交易的C接口時,需要參考交易所提供的接口文檔和示例代碼,了解具體的函數調用方式和參數設置。就比如源代碼文檔:MetaTradeAPI (metatradeapi) - Gitee.com
1. #include <Windows.h> |
2. #include <iostream> |
3. #include <stdexcept> |
4. #include <string> |
5. |
6. // API?初始化, 返回授權成功的交易賬號數量 |
7. // 返回值 < 1 時, 無需調用 Deinit?接口, 也不能調用其它接口, 否則會出錯! |
8. typedef int (*InitFn)(); |
9. // API?反初始化 |
10. typedef void (*DeinitFn)(); |
11. // 登錄交易賬戶 |
12. typedef int (*LogonFn)(const char* Ip, short Port, const char* Version, |
13. short Yybid, const char*?Account, |
14. const char* TradeAccount, const char*?JyPassword, |
15. const char* TxPassword, char*?ErrorInfo); |
17. typedef void (*LogoffFn)(int ClientId); |
18. // 查詢各類交易數據 |
19. typedef void (*QueryDataFn)(int ClientId, int Category, char* Result, |
20. char* ErrorInfo); |
22. typedef void (*QueryDatasFn)(int ClientId, int Category[], int Count, |
23. char* Result[], char*?ErrorInfo[]); |
24. // 多賬戶批量查詢各類交易數據 |
25. typedef void (*QueryMultiAccountsDatasFn)(int ClientId[], int Category[], |
26. int Count, char*?Result[], |
27. char*?ErrorInfo[]); |
29. typedef void (*QueryHistoryDataFn)(int ClientId, int Category, |
30. const char* StartDate, const char*?EndDate, |
31. char* Result, char*?ErrorInfo); |
32. // 委托下單 |
33. typedef void (*SendOrderFn)(int ClientId, int Category, int EntrustType, |
34. const char* Gddm, const char* Zqdm, float?Price, |
35. int Quantity, char* Result, char*?ErrorInfo); |
37. typedef void (*SendOrdersFn)(int ClientId, int Category[], int EntrustType[], |
38. const char* Gddm[], const char*?Zqdm[], |
39. float Price[], int Quantity[], int?Count, |
40. char* Result[], char*?ErrorInfo[]); |
42. typedef void (*SendMultiAccountsOrdersFn)(int ClientId[], int Category[], |
43. int EntrustType[], const char* Gddm[], |
44. const char* Zqdm[], float Price[], |
?