### Login Function Example (C++) Source: https://quantapi.eastmoney.com/Manual/CppMac?from=web Example demonstrating how to use the start function for logging in. It includes setting up a log callback, getting user input for credentials, and handling potential login failures. ```cpp int write2Log(const char* log) { printf("%s",log); return 0; } ​ std::string name; printf("Please enter user name: "); std::getline(std::cin, name); ​ std::string password; printf("Please enter password: "); std::getline(std::cin, password); EQLOGININFO logInfo; memset(&logInfo, 0, sizeof(EQLOGININFO)); strncpy(logInfo.userName, name.c_str(), name.length()); strncpy(logInfo.password, password.c_str(), password.length()); ​ //初始化和设置日志回调以及登录 option参数"TestLatency=0"服务器不测速 "TestLatency=1"服务器测速选择最优 EQErr errid = emstart(&logInfo, "TestLatency=0", write2Log); //EQErr errid = emstart(NULL, "TestLatency=0", write2Log); if(errid !=EQERR_SUCCESS) { //登录失败 } ``` -------------------------------- ### Manual Activation Python Example Source: https://quantapi.eastmoney.com/Manual?from=web Example of manual activation using Python. Create a Manualactivate.py script, fill in your credentials, and run it. ```python # -*- coding:utf-8 -*- __author__ = 'Administrator' from EmQuantAPI import * import platform #手动激活范例(单独使用) #获取当前安装版本为x86还是x64 data = platform.architecture() if data[0] == "64bit": bit = "x64" elif data[0] == "32bit": bit = "x86" data1 = platform.system() if data1 == 'Linux': system1 = 'linux' lj = c.setserverlistdir("libs/" + system1 + '/' + bit) elif data1 == 'Windows': system1 = 'windows' lj = c.setserverlistdir("libs/" + system1) elif data1 == 'Darwin': system1 = 'mac' lj = c.setserverlistdir("libs/" + system1) else: pass #填上用户名,密码,和有效的邮箱,运行返回成功, 注意:email=字样不要省略; data = c.manualactivate("账号", "密码", "email=") if data.ErrorCode != 0: print ("manualactivate failed, ", data.ErrorMsg) ``` -------------------------------- ### Login Function Example (Python 3.x) Source: https://quantapi.eastmoney.com/Manual?from=web This snippet demonstrates how to initialize the login function using the start() method in Python 3.x. After successful login, you can use API functions to fetch data. The returned value is of type c.EmQuantData. ```python from EmQuantAPI import * loginresult = c.start( ) #loginresult为c.EmQuantData类型数据 print (loginresult) ``` -------------------------------- ### Login Function Example (Python 2.x) Source: https://quantapi.eastmoney.com/Manual?from=web This snippet shows how to initialize the login function using the start() method in Python 2.x. Successful login allows access to API functions for data retrieval. The result is of type c.EmQuantData. ```python from EmQuantAPI import * loginresult = c.start( ) #loginresult为c.EmQuantData类型数据 print loginresult ``` -------------------------------- ### start Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Initializes the login process for the QuantAPI. After successful login, you can use the API functions to retrieve data. ```APIDOC ## Login Function ### Function Signature `start(options, logcallback, mainCallBack)` ### Description Initializes the login function. Once the login is verified, you can use the API functions to fetch data. ### Parameters - `options`: Optional parameters for login. - `logcallback`: Optional callback function for logging. - `mainCallBack`: Optional callback function for the main process. ### Return - `c.EmQuantData` type data indicating the login result. ### Example (Python 3.x) ```python from EmQuantAPI import * loginresult = c.start() # loginresult is of type c.EmQuantData print (loginresult) ``` ``` -------------------------------- ### Logout Example Source: https://quantapi.eastmoney.com/Manual/CppWindows?from=web Example of calling the stop function to log out from the API. Check the return value for success or failure. ```cpp EQErr errid = emstop (); ``` -------------------------------- ### Manual Activation Example Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 This example demonstrates how to manually activate the EmQuantAPI using the manualactive function. It includes logic to determine the system architecture (32-bit or 64-bit) and operating system (Linux, Windows, Mac) to set the correct library path. Ensure to replace '账号', '密码', and '有效邮箱地址' with your actual credentials and email. ```Python # -*- coding:utf-8 -*- from EmQuantAPI import * import platform #手动激活范例(单独使用) #获取当前安装版本为x86还是x64 data = platform.architecture() if data[0] == "64bit": bit = "x64" elif data[0] == "32bit": bit = "x86" data1 = platform.system() if data1 == 'Linux': system1 = 'linux' lj = c.setserverlistdir("libs/" + system1 + '/' + bit) elif data1 == 'Windows': system1 = 'windows' lj = c.setserverlistdir("libs/" + system1) elif data1 == 'Darwin': system1 = 'mac' lj = c.setserverlistdir("libs/" + system1) else: pass #调用manualactive函数,修改账号、密码、有效邮箱地址,email=字样需保留 data = c.manualactivate("账号", "密码", "email=有效邮箱地址") if data.ErrorCode != 0: print ("manualactivate failed, ", data.ErrorMsg) ``` -------------------------------- ### Manual Activation Function Example (C++) Source: https://quantapi.eastmoney.com/Manual/CppMac?from=web Example of using the emmanualactivate function for manual login activation. Ensure to replace placeholders with your actual credentials and email. ```cpp EQLOGININFO logInfo; memset(&logInfo, 0, sizeof(EQLOGININFO)); strncpy(logInfo.userName, "xxxx", strlen("xxxx"));//用户名 strncpy(logInfo.password,"xxxxx", strlen("xxxxx"));//密码 errid = emmanualactivate(&logInfo,"email=who@what.com",write2Log);//输入有效邮箱地址 ``` -------------------------------- ### Login Function Example (Python 3.x) Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Initializes the login process for the EmQuantAPI. After successful login, you can use other API functions to retrieve data. This example is for Python 3.x. ```Python from EmQuantAPI import * loginresult = c.start( ) #loginresult为c.EmQuantData类型数据 print (loginresult) ``` -------------------------------- ### Install Command Line Tools on Mac Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Use this command in the Mac terminal to install necessary command-line tools for activation. ```bash xcode-select --install ``` -------------------------------- ### Login Function Example (Python 2.x) Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Initializes the login process for the EmQuantAPI. After successful login, you can use other API functions to retrieve data. This example is for Python 2.x. ```Python from EmQuantAPI import * loginresult = c.start( ) #loginresult为c.EmQuantData类型数据 print loginresult ``` -------------------------------- ### Start EmQuantR Session with Options Source: https://quantapi.eastmoney.com/Manual/R?from=web Log in to the API account using the start function with specified options. Successful login is required before calling other data retrieval functions. ```R emdata <- em_start(options) ``` -------------------------------- ### Install Homebrew on Mac Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Install Homebrew package manager on Mac using this command. Ensure the installation is successful. ```bash ruby -e "$(curl --insecure -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)" ``` -------------------------------- ### Start API Login Function Source: https://quantapi.eastmoney.com/Manual/CSharp?from=web Use the start function to log in to the API. A callback function can be provided to receive log messages. The function returns an EQErr status code. ```csharp EQErr start (string options, ILogCallback callback); ``` ```csharp void CallbackStart (string strLog) { Console.WriteLine(strLog); } ``` ```csharp static Structs. ILogCallback callbackStart=CallbackStart; ``` ```csharp EQErr error = start ("TestLatency=0", callbackStart); ``` ```csharp if (error! = EQERR_SUCCESS) { //登录失败 } ``` -------------------------------- ### CSS Function Example (Python 2.x) Source: https://quantapi.eastmoney.com/Manual?from=web This example demonstrates fetching basic, financial, and valuation data for securities using the css() function in Python 2.x. It retrieves the 'TOTALSHARE' indicator for a specific stock code. Error handling is included. ```python from EmQuantAPI import * data = c.css("300059.SZ","TOTALSHARE","enddate=20190827") if data.ErrorCode != 0: print "request css Error, ", data.ErrorMsg else: for code in data.Codes: for i in range(0,len(data.Indicators)): print data.Data[code][i] ``` -------------------------------- ### Get Trading Dates (tradedates) Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Use tradedates to retrieve a sequence of dates for a specified trading market and time interval. Ensure the start and end dates are in the correct format. ```Python tradedates(startdate,enddate,options=None,*arga,**argb) ``` ```Python data = c.tradedates("2016-07-01", "2016-07-12") if data.ErrorCode != 0: print "request tradedates Error, ", data.ErrorMsg else: print u"tradedate输出结果======分隔线====== for item in data.Data: print item ``` ```Python data = c.tradedates("2016-07-01", "2016-07-12") if(data.ErrorCode != 0): print("request tradedates Error, ", data.ErrorMsg) else: print("tradedate输出结果======分隔线======) for item in data.Data: print(item) ``` -------------------------------- ### Initialize and Start EMQuantAPI with Callbacks Source: https://quantapi.eastmoney.com/Manual/Java?from=web Initializes the EMQuantAPI by setting up message and log callback functions. Ensure that UserDataCallBack and UserLogCallBack are implemented correctly. The system task queue is obtained from ExplainClient. ```Java HashMap userCallBackHashMap = new HashMap<>(); userCallBackHashMap.put("msg", new UserDataCallBack() { @Override public void callback(EQMSG eqmsg) { if(eqmsg.getRequestID()==10000) { LOG.info("csq callback:"+eqmsg.toString()); //eqmsg.getSerialID()与csq函数返回对象ReturnSignal中的returnSignal.getDataOreqid()相对应 if(eqmsg.getSerialID() == 请求序列号) { //TODO } }else if(eqmsg.getRequestID()==10001){ LOG.info("cst callback:"+eqmsg.toString()); }else if(eqmsg.getRequestID()==10002) { LOG.info("cnq callback:"+eqmsg.toString()); } } }); userCallBackHashMap.put("log", new UserLogCallBack() { @Override public void callback(String o) { //回调方式的日志 LOG.info(o); } }); ExplainClient.start(userCallBackHashMap); UserAPI userAPI = new UserAPI(ExplainClient.getSystemTaskQueue()); //设置配置文件路径,如果设置""或者为null,则默认配置文件在jar包的同级目录下 userAPI.setJniEnv(""); //上面为启动默认写法(下面均需要使用userAPI对象),start调用如下 int result = userAPI.start(""); if (result != 0) { LOG.info(ErrorType.getErrorString(result)); return; } ``` -------------------------------- ### Get Time-Series Data (csd) Source: https://quantapi.eastmoney.com/Manual/Matlab?from=web Retrieve time-series data for stocks, indices, funds, futures, etc. Requires specifying start and end dates. Note the rate limit of 700 requests per minute. ```matlab [datas,codes,indicators,dates,errorid]=csd(em,incodes,inindicators,instartdate, inenddate, varargin) ``` ```matlab [datas,codes,indicators,dates,errorid]= em.csd('300059.SZ','TOTALSHARE','2016/7/1','2016/7/13') ``` -------------------------------- ### Run General Activation Tool Source: https://quantapi.eastmoney.com/Manual?from=web Execute the general activation tool (for non-Ubuntu systems) from the command line. Ensure you have execute permissions. ```bash ./loginactivator ``` -------------------------------- ### Manual Activation using Python Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 This Python script shows how to perform manual activation. It checks the system architecture and OS to set the library path, then calls the `manualactivate` function with your credentials. Ensure the script is placed correctly and `installEmQuantAPI` has been run. ```python # -*- coding:utf-8 -*- __author__ = 'Administrator' from EmQuantAPI import * import platform #手动激活范例(单独使用) #获取当前安装版本为x86还是x64 data = platform.architecture() if data[0] == "64bit": bit = "x64" elif data[0] == "32bit": bit = "x86" data1 = platform.system() if data1 == 'Linux': system1 = 'linux' lj = c.setserverlistdir("libs/" + system1 + '/' + bit) elif data1 == 'Windows': system1 = 'windows' lj = c.setserverlistdir("libs/" + system1) elif data1 == 'Darwin': system1 = 'mac' lj = c.setserverlistdir("libs/" + system1) else: pass #填上用户名,密码,和有效的邮箱,运行返回成功, 注意:email=字样不要省略; data = c.manualactivate("账号", "密码", "email=") if data.ErrorCode != 0: print ("manualactivate failed, ", data.ErrorMsg) ``` -------------------------------- ### Run Ubuntu Activation Tool Source: https://quantapi.eastmoney.com/Manual?from=web Execute the Ubuntu-specific activation tool from the command line. Ensure you have execute permissions. ```bash ./loginactivator_ubuntu ``` -------------------------------- ### Login with User Input and Options Source: https://quantapi.eastmoney.com/Manual/CppWindows?from=web Initializes the API by prompting the user for username and password, then attempts to log in with specified options and a log callback. Handles potential login failures. ```cpp std::string name; printf("Please enter user name:\n"); std::getline(std::cin, name); std::string password; printf("Please enter password:\n"); std::getline(std::cin, password); EQLOGININFO logInfo; memset(&logInfo, 0, sizeof(EQLOGININFO)); strncpy(logInfo.userName, name.c_str(), name.length()); strncpy(logInfo.password, password.c_str(), password.length()); //初始化和设置日志回调以及登录 option参数"TestLatency=0"服务器不测速 "TestLatency=1"服务器测速选择最优 EQErr errid = emstart(&logInfo, "TestLatency=0", write2Log); //EQErr errid = emstart(NULL, "TestLatency=0", write2Log); if(errid !=EQERR_SUCCESS) { //登录失败 } ``` -------------------------------- ### Install Microsoft Visual C++ 2010 Redistributable Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Resolve 'MSVCP100.dll missing' or 'WinError126/193' errors on Windows by installing the appropriate Microsoft Visual C++ 2010 Redistributable package based on your Python installation version. ```powershell Start-Process "http://choiceclub.eastmoney.com/#/articleDetail/8769" ``` -------------------------------- ### start Source: https://quantapi.eastmoney.com/Manual/Java?from=web Initializes the login function. Upon successful login and verification, you can use the interface functions to retrieve data. Logs will be output in the log callback function. ```APIDOC ## start ```java int start(String options) ``` ### Description Initializes the login function. Upon successful login and verification, you can use the interface functions to retrieve data. Logs will be output in the log callback function. ### Parameters - **options** (String) - Optional parameters for starting the service. ### Returns - **int** - An integer indicating the result of the operation. 0 typically means success. ### Example ```java // Set callback functions ("msg" for data, "log" for logs) // Data callback function needs to implement UserDataCallBack subclass // Log callback function needs to implement UserLogCallBack subclass HashMap userCallBackHashMap = new HashMap<>(); userCallBackHashMap.put("msg", new UserDataCallBack() { @Override public void callback(EQMSG eqmsg) { if(eqmsg.getRequestID()==10000) { LOG.info("csq callback:"+eqmsg.toString()); // eqmsg.getSerialID() corresponds to ReturnSignal.getDataOreqid() in the csq function return object if(eqmsg.getSerialID() == requested_serial_id) { // TODO } } else if(eqmsg.getRequestID()==10001){ LOG.info("cst callback:"+eqmsg.toString()); } else if(eqmsg.getRequestID()==10002) { LOG.info("cnq callback:"+eqmsg.toString()); } } }); userCallBackHashMap.put("log", new UserLogCallBack() { @Override public void callback(String o) { // Callback logs LOG.info(o); } }); ExplainClient.start(userCallBackHashMap); UserAPI userAPI = new UserAPI(ExplainClient.getSystemTaskQueue()); // Set configuration file path. If set to "" or null, the default configuration file is in the same directory as the jar. userAPI.setJniEnv(""); // The above is the default startup code (subsequent calls require the userAPI object) int result = userAPI.start(""); if (result != 0) { LOG.info(ErrorType.getErrorString(result)); return; } ``` ``` -------------------------------- ### Install GTK+3.0 on Mac Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Install the GTK+3.0 library on Mac using Homebrew. This is often required for graphical activation tools. ```bash brew install gtk+3 ``` -------------------------------- ### Login Function Signature Source: https://quantapi.eastmoney.com/Manual/CppWindows?from=web The start function initializes the API and logs in. It requires login information, optional parameters, and a callback for logging. Successful login enables data retrieval. ```cpp EQErr start(EQLOGININFO* pLoginInfo, const char* options, logcallback pfnCallback); ``` -------------------------------- ### Run Linux Activation Tools Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Execute the appropriate activation tool for your Linux distribution from the command line. Use chmod to grant execute permissions if necessary. ```bash ./loginactivator_ubuntu ``` ```bash ./loginactivator ``` -------------------------------- ### Logout Function Example (Python 3.x) Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Logs out from the EmQuantAPI. This function should be called after you are finished using the API. This example is for Python 3.x. ```Python from EmQuantAPI import * loginresult = c.start() print (loginresult) #do something… logoutresult = c.stop() #logoutresult为c.EmQuantData类型数据 print (logoutresult) ``` -------------------------------- ### Manual Activation Example Source: https://quantapi.eastmoney.com/Manual?from=web This code demonstrates manual activation of the EMQuantAPI. Ensure to replace placeholder credentials with your actual account information and a valid email address. The script detects the system architecture and OS to set the correct library path. ```python # -*- coding:utf-8 -*- from EmQuantAPI import * import platform #手动激活范例(单独使用) #获取当前安装版本为x86还是x64 data = platform.architecture() if data[0] == "64bit": bit = "x64" elif data[0] == "32bit": bit = "x86" data1 = platform.system() if data1 == 'Linux': system1 = 'linux' lj = c.setserverlistdir("libs/" + system1 + '/' + bit) elif data1 == 'Windows': system1 = 'windows' lj = c.setserverlistdir("libs/" + system1) elif data1 == 'Darwin': system1 = 'mac' lj = c.setserverlistdir("libs/" + system1) else: pass #调用manualactive函数,修改账号、密码、有效邮箱地址,email=字样需保留 data = c.manualactivate("账号", "密码", "email=有效邮箱地址") if data.ErrorCode != 0: print ("manualactivate failed, ", data.ErrorMsg) ``` -------------------------------- ### Logout Function Example (Python 2.x) Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Logs out from the EmQuantAPI. This function should be called after you are finished using the API. This example is for Python 2.x. ```Python from EmQuantAPI import * loginresult = c.start() print loginresult #do something… logoutresult = c.stop() #logoutresult为c.EmQuantData类型数据 print logoutresult ``` -------------------------------- ### Install Visual C++ Redistributable Source: https://quantapi.eastmoney.com/Manual?from=web Install the Microsoft Visual C++ 2010 Redistributable Package if you encounter DLL errors like MSVCP100.dll or WinError193. ```html http://choiceclub.eastmoney.com/#/articleDetail/8769 ``` -------------------------------- ### .NET Core Interface Configuration Setup Steps Source: https://quantapi.eastmoney.com/Manual/CSharp?from=web Configure your .NET Core project by adding DLL references and setting the platform target. For Windows EXE generation, configure publishing settings. To support gb2312 encoding, register the CodePagesEncodingProvider. ```csharp Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); ``` -------------------------------- ### Initialize Login Info Structure Source: https://quantapi.eastmoney.com/Manual/CppLinux?from=web Initializes the EQLOGININFO structure with zeros before populating it with login credentials. ```cpp EQLOGININFO logInfo; memset(&logInfo, 0, sizeof(EQLOGININFO)); ``` -------------------------------- ### start() - Initialize Login Source: https://quantapi.eastmoney.com/Manual?from=web Initializes the login process. After successful login, you can use the interface functions to retrieve data. Supports Python 2.x and 3.x. ```APIDOC ## start() Initializes the login function. After successful login, you can use the interface functions to retrieve data. **Parameters** **Returns** **Example (Python 2.x)** ```python from EmQuantAPI import * loginresult = c.start( ) # loginresult is of type c.EmQuantData print loginresult ``` **Example (Python 3.x)** ```python from EmQuantAPI import * loginresult = c.start( ) # loginresult is of type c.EmQuantData print (loginresult) ``` **Note 1: Optional parameters for the login function:** ``` -------------------------------- ### Start API Session with Credentials Source: https://quantapi.eastmoney.com/Manual/CppLinux?from=web Initializes the EMQuantAPI interface using provided login credentials and optional parameters. Handles login success or failure. ```cpp //初始化和设置日志回调以及登录 option参数"TestLatency=0"服务器不测速 "TestLatency=1"服务器测速选择最优 EQErr errid = emstart(&logInfo, "TestLatency=0", write2Log); //EQErr errid = emstart(NULL, "TestLatency=0", write2Log); if(errid !=EQERR_SUCCESS) { //登录失败 } ``` -------------------------------- ### Running Demo on Linux Source: https://quantapi.eastmoney.com/Manual/Java?from=web Execute the Java demo application on Linux by setting the classpath to include necessary JAR files and the demo JAR. ```bash java -cp EmQuantAPITest/lib/EmQuantAPI-V2.5.4.6.0.jar:EmQuantAPITest/lib/EmQuantAPITest.jar:EmQuantAPITest/lib/log4j-api-2.17.0.jar:EmQuantAPITest/lib/log4j-core-2.17.0.jar:EmQuantAPITest/lib/log4j-slf4j-impl-2.17.0.jar:EmQuantAPITest/lib/slf4j-api-1.7.25.jar com.eastmoney.Demo ``` -------------------------------- ### Section Data Function Example (C++) Source: https://quantapi.eastmoney.com/Manual/CppMac?from=web Example of using the css function to fetch section data, such as total shares. Remember to release the data using emreleasedata after processing. ```cpp const char* codes="000002.SZ,300059.SZ"; const char* indicator = "TOTALSHARE"; EQDATA* pData = NULL; EQErr errid = emcss(codes, indicator, "EndDate=20160217", pData); if(errid == EQERR_SUCCUES){ //… 读取结果 emreleasedata(pData); } ``` -------------------------------- ### Manual Activation (for non-GUI environments) Source: https://quantapi.eastmoney.com/Manual/CSharp?from=web Performs manual activation, suitable for headless environments like remote Linux servers. Requires placing the 'userInfo' token in the ServerList.json.e directory after successful activation. ```csharp EQErr manualactivate(IntPtr loginInfo, string options, ILogCallback pLogCallback) ``` ```csharp string strName = "";// 用户名 if (strName.Length > OptionEnums.MaxStringLength) strName = strName.Substring(0, OptionEnums.MaxStringLength); string strPass = "";// 密码 if (strPass.Length > OptionEnums.MaxStringLength) strPass = strPass.Substring(0, OptionEnums.MaxStringLength); Structs.EQLOGININFO loginInfo = new Structs.EQLOGININFO(); loginInfo.UserName = strName; loginInfo.Password = strPass; int size = Marshal.SizeOf(typeof(Structs.EQLOGININFO)); IntPtr ptArray = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(loginInfo, ptArray, false); string strOption = "";// 邮箱地址传入格式为email=xxxx@xx.com OptionEnums.EQErr code = EmQuantAPI.manualactivate(ptArray, strOption, callbackLog); ``` -------------------------------- ### manualactivate Source: https://quantapi.eastmoney.com/Manual/Java?from=web Performs manual activation for login, useful in non-GUI environments. After successful activation, place the obtained "userInfo" file in the same directory as "ServerList.json.e" and then call the start function. ```APIDOC ## manualactivate ### Description Performs manual activation for login, useful in non-GUI environments. After successful activation, place the obtained "userInfo" file in the same directory as "ServerList.json.e" and then call the start function. ### Method Signature ```java int manualactivate(String userName, String password, String options) ``` ### Parameters * **userName** (String) - The username for activation. * **password** (String) - The password for activation. * **options** (String) - Optional parameters, e.g., "email=xxx@xx.com". ### Returns * **int** - An integer indicating the result of the operation (0 for success). ### Example ```java int result = userAPI.manualactivate("usr", "pwd", "email=xxx@xx.com"); if(result!=0) LOG.info(ErrorType.getErrorString(result)); ``` ``` -------------------------------- ### Get Thematic Report Data (C++) Source: https://quantapi.eastmoney.com/Manual/CppMac?from=web Retrieves thematic report data. Returns 0 on success, otherwise an error code. Use geterrstring to get error messages. ```cpp EQErr ctr(const char* ctrName, const char* indicators, const char* options, EQCTRDATA*& pEQCtrData); ``` ```cpp EQCTRDATA* pCtrData = NULL; ``` ```cpp EQErr errid = emctr("StockInfo","", "StartDate=2019-07-01,EndDate=2019-07-02", pCtrData); ``` ```cpp if(errid == EQERR_SUCCESS) ``` ```cpp {//… 读取结果 ``` ```cpp emreleasedata(pCtrData); ``` ```cpp } ``` -------------------------------- ### Logout Function Example (Python 2.x) Source: https://quantapi.eastmoney.com/Manual?from=web This example illustrates how to log out from the API using the stop() function in Python 2.x after a successful login. The result of the stop() function is of type c.EmQuantData. ```python from EmQuantAPI import * loginresult = c.start() print loginresult #do something… logoutresult = c.stop() #logoutresult为c.EmQuantData类型数据 print logoutresult ``` -------------------------------- ### Time Series Data Function Example (C++) Source: https://quantapi.eastmoney.com/Manual/CppMac?from=web Example of using the csd function to fetch historical daily data. Ensure to release the allocated memory using emreleasedata after use. ```cpp const char* codes="000002.SZ,300059.SZ"; const char* indicator = "TOTALSHARE"; EQDATA* pData = NULL; EQErr errid = emcsd(codes, indicator, "2016/01/10", "2016/04/13", "Period=1,Adjustflag=1", pData); if(errid == EQERR_SUCCUES){ //… 读取结果 //释放内存 emreleasedata(pData); } ``` -------------------------------- ### Manual Activation Source: https://quantapi.eastmoney.com/Manual/Java?from=web Performs manual activation of the API, useful for headless environments. After successful activation, place the 'userInfo' file in the same directory as 'ServerList.json.e' and then call the start function. ```Java int result = userAPI.manualactivate("usr", "pwd", "email=xxx@xx.com"); ``` ```Java if(result!=0) LOG.info(ErrorType.getErrorString(result)); ``` -------------------------------- ### CSD Data Retrieval Example Source: https://quantapi.eastmoney.com/Manual/CppWindows?from=web Example of using the csd function to fetch total share data over a specified period. It includes error checking and memory deallocation for the retrieved data. ```cpp const char* codes="000002.SZ,300059.SZ"; const char* indicator = "TOTALSHARE"; EQDATA* pData = NULL; EQErr errid = emcsd(codes, indicator, "2016/01/10", "2016/04/13", "Period=1,Adjustflag=1", pData); if(errid ==EQERR_SUCCESS) { //…   读取结果 //释放内存 releasedata(pData); } ``` -------------------------------- ### CSS Data Retrieval Example Source: https://quantapi.eastmoney.com/Manual/CppWindows?from=web Example of using the css function to fetch total share data for specified stock codes. It includes error checking and memory deallocation for the retrieved data. ```cpp const char* codes="000002.SZ,300059.SZ"; const char* indicator = "TOTALSHARE"; EQDATA* pData = NULL; EQErr errid = emcss(codes, indicator, " AdjustFlag=1,EndDate=20160217", pData); if(errid ==EQERR_SUCCESS){ //…   读取结果 emreleasedata(pData); } ``` -------------------------------- ### CSS Function Example (Python 3.x) Source: https://quantapi.eastmoney.com/Manual?from=web This example shows how to retrieve fundamental, financial, and valuation data for securities using the css() function in Python 3.x. It fetches the 'TOTALSHARE' indicator for a given stock code. Error handling is included. ```python from EmQuantAPI import * data = c.css("300059.SZ","TOTALSHARE","enddate=20190819") if data.ErrorCode != 0: print("request css Error, ", data.ErrorMsg) else: for code in data.Codes: for i in range(0,len(data.Indicators)): print(data.Data[code][i]) ``` -------------------------------- ### Create Portfolio Source: https://quantapi.eastmoney.com/Manual/Java?from=web Use pcreate to create a new investment portfolio. Ensure the combinCode and combinName are unique and valid. ```Java int pcreate(String combinCode, String combinName, long initialFound, String remark, String options) ``` ```Java int pcreate = userAPI.pcreate("quant001.PF", "组合牛股", 1000000, "这是一个牛股的组合", ""); ``` ```Java if(pcreate!=0) LOG.info(ErrorType.getErrorString(pcreate)); ``` -------------------------------- ### CSS Function Example (Python 3.x) Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Retrieves cross-sectional data for stocks, indices, funds, futures, and other securities. This example fetches the 'TOTALSHARE' indicator for a specific stock. Note that the CSS function has a rate limit of 700 requests per minute. ```Python from EmQuantAPI import * data = c.css("300059.SZ","TOTALSHARE","enddate=20190819") if data.ErrorCode != 0: print("request css Error, ", data.ErrorMsg) else: for code in data.Codes: for i in range(0,len(data.Indicators)): print(data.Data[code][i]) ``` -------------------------------- ### CSS Function Example (Python 2.x) Source: https://quantapi.eastmoney.com/Manual?from=web&loc=%E6%BF%80%E6%B4%BB%E6%B3%A8%E5%86%8C&ploc=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 Retrieves cross-sectional data for stocks, indices, funds, futures, and other securities. This example fetches the 'TOTALSHARE' indicator for a specific stock. Note that the CSS function has a rate limit of 700 requests per minute. ```Python from EmQuantAPI import * data = c.css("300059.SZ","TOTALSHARE","enddate=20190827") if data.ErrorCode != 0: print "request css Error, ", data.ErrorMsg else: for code in data.Codes: for i in range(0,len(data.Indicators)): print data.Data[code][i] ``` -------------------------------- ### Manual Activation (C++) Source: https://quantapi.eastmoney.com/Manual/CppLinux?from=web Activates the service manually, suitable for environments without a GUI or when the LoginActivator program cannot be run. After successful activation, the 'userInfo' token obtained via email should be placed in the same directory as 'ServerList.json.e' before calling start to log in. ```cpp EQErr manualactivate(EQLOGININFO* pLoginInfo, const char* options, logcallback pfnCallback); ``` ```cpp int write2Log(const char* log) {    printf("%s",log);    return 0; } EQLOGININFO logInfo; memset(&logInfo,0,sizeof(EQLOGININFO)); strcpy_s(logInfo.userName, "xxxxx"); strcpy_s(logInfo.password, "xxxxxxxx");    EQErr errid = emmanualactivate (&logInfo, "email=who@what.com",write2Log); ``` -------------------------------- ### Get Stock Sector Basic and Financial Data (C#) Source: https://quantapi.eastmoney.com/Manual/CSharp?from=web Retrieves basic, financial, and other cross-sectional data for stock sectors. Use this function to get detailed information about specific market segments. Ensure proper error handling by checking the return code and using geterrstring for descriptions. ```csharp string codes="B_018005001001,B_014010016006002"; ``` ```csharp string indicator = "SECTOPREAVG,CFOPSAVG,MANAEXPAVG"; ``` ```csharp IntPtr pData = IntPtr. Zero; ``` ```csharp EQErr error = cses (codes, indicator, "TradeDate=2020-10-19,DelType=1,type=1,ReportDate=2020-06-30,DataAdjustType=1,Ishistory=0,PREDICTYEAR=2020,StartDate=2019-05-30,EndDate=2020-10-19,Payyear=2019", out pData); ``` ```csharp if (error == EQERR_SUCCESS) { //… 读取结果 releasedata(pData); } ``` -------------------------------- ### Manual Activation (manualactivate) Source: https://quantapi.eastmoney.com/Manual/Matlab?from=web Performs manual activation for environments without a GUI or where LoginActivator cannot run. Place the obtained activation file 'userInfo' in the ServerList.json.e directory after successful activation. ```matlab errorid = manualactivate(em, uname, password, varargin) ``` ```matlab errorid = em.manualactivate('username','userpwd', 'email=who@what.com') ``` -------------------------------- ### Start EmQuantR Session Source: https://quantapi.eastmoney.com/Manual/R?from=web Initiate a session with the EmQuantR API. This function can be called with or without options. ```R res <- em_start() ``` -------------------------------- ### Get User Input for Login Source: https://quantapi.eastmoney.com/Manual/CppLinux?from=web Prompts the user to enter their username and password from standard input. ```cpp std::string name; printf("Please enter user name:\n"); std::getline(std::cin, name); std::string password; printf("Please enter password:\n"); std::getline(std::cin, password); ``` -------------------------------- ### start Function Source: https://quantapi.eastmoney.com/Manual/CSharp?from=web Logs into the API account. Successful login is required before calling other functions to retrieve data. Returns 0 on success, other values indicate failure. ```APIDOC ## start Function ```csharp EQErr start (string options, ILogCallback callback); ``` Logs into the API account. Successful login is required before calling other functions to retrieve data. **Parameters** * `options` (string): Configuration options for the login process. * `callback` (ILogCallback): A callback interface for receiving log messages. **Returns** 0 indicates successful execution; other values indicate failure. Error messages can be retrieved using the `geterrstring` function. **Example** ```csharp void CallbackStart (string strLog) { Console.WriteLine(strLog); } static Structs. ILogCallback callbackStart = CallbackStart; EQErr error = start ("TestLatency=0", callbackStart); if (error != EQERR_SUCCESS) { // Login failed } ``` **Note 1: Optional Parameters for start Function** (Details for optional parameters are not provided in the source text) ``` -------------------------------- ### Manual Activation (Python) Source: https://quantapi.eastmoney.com/Manual?from=web Performs manual login activation, suitable for headless environments or when the standard activator cannot be used. Requires placing the activation file in a specific directory. ```python data = c.manualactivate("usr", "pwd","email=xxx@163.com") ``` ```python if data.ErrorCode != 0: print("manualactivate failed, ", data.ErrorMsg) ``` -------------------------------- ### Get Error String Function Source: https://quantapi.eastmoney.com/Manual/CppWindows?from=web Retrieves the error message string corresponding to a given error code. ```APIDOC ## geterrstring ### Description Gets the error information corresponding to the error code. ### Parameters - **errcode** (EQErr) - The error code. - **lang** (EQLang) - The language for the error message (default is English). ### Returns A string containing the error message. ### Example ```c++ const char* pErrString = emgeterrstring(EQERR_LOGIN_FAIL, eLang_en); ``` ``` -------------------------------- ### manualactivate Source: https://quantapi.eastmoney.com/Manual/CSharp?from=web Performs manual activation, suitable for environments without a graphical interface or when the LoginActivator program cannot be run. After successful activation, the login token obtained via email should be placed in the same directory as ServerList.json.e, and then start can be called for login. ```APIDOC ## manualactivate ### Description Performs manual activation, suitable for environments without a graphical interface or when the LoginActivator program cannot be run. After successful activation, the login token obtained via email should be placed in the same directory as ServerList.json.e, and then start can be called for login. ### Parameters - **loginInfo** (IntPtr) - Pointer to login information structure. - **options** (string) - Additional options, e.g., email address in the format "email=xxxx@xx.com". - **pLogCallback** (ILogCallback) - Callback function for logging. ### Returns - **EQErr**: 0 for success, other values indicate failure. Error messages can be retrieved using geterrstring. ### Request Example ```csharp string strName = ""; // Username if (strName.Length > OptionEnums.MaxStringLength) strName = strName.Substring(0, OptionEnums.MaxStringLength); string strPass = ""; // Password if (strPass.Length > OptionEnums.MaxStringLength) strPass = strPass.Substring(0, OptionEnums.MaxStringLength); Structs.EQLOGININFO loginInfo = new Structs.EQLOGININFO(); loginInfo.UserName = strName; loginInfo.Password = strPass; int size = Marshal.SizeOf(typeof(Structs.EQLOGININFO)); IntPtr ptArray = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(loginInfo, ptArray, false); string strOption = ""; // Email address in the format email=xxxx@xx.com OptionEnums.EQErr code = EmQuantAPI.manualactivate(ptArray, strOption, callbackLog); ``` ``` -------------------------------- ### geterrstring - Get Error Code Information Source: https://quantapi.eastmoney.com/Manual/Matlab?from=web Retrieves the error message corresponding to a given error code. ```APIDOC ## geterrstring - Get Error Code Information ### Description Retrieves the error message corresponding to a given error code. ### Function Signature `errstr = geterrstring(em, iErrcode, iLang)` ### Parameters * **em**: The Eastmoney API object. * **iErrcode** (integer): The error code. * **iLang** (integer): The language code (e.g., 0 for Chinese). ### Example ```matlab errstr = em.geterrstring(0, 0) ``` ```