[Del] 去除代码中多余的输出
This commit is contained in:
parent
e34781e6b4
commit
d8d05e4da9
@ -53,7 +53,6 @@ void MdApi::OnRspUserLogin(CUstpFtdcRspUserLoginField *pRspUserLogin, CUstpFtdcR
|
|||||||
}
|
}
|
||||||
if (pRspInfo)
|
if (pRspInfo)
|
||||||
{
|
{
|
||||||
cout << "md OnRspUserLogin pRspInfo" << endl;
|
|
||||||
CUstpFtdcRspInfoField *task_error = new CUstpFtdcRspInfoField();
|
CUstpFtdcRspInfoField *task_error = new CUstpFtdcRspInfoField();
|
||||||
*task_error = *pRspInfo;
|
*task_error = *pRspInfo;
|
||||||
task.task_error = task_error;
|
task.task_error = task_error;
|
||||||
@ -314,7 +313,6 @@ void MdApi::processRspUserLogin(Task *task)
|
|||||||
dict error;
|
dict error;
|
||||||
if (task->task_error)
|
if (task->task_error)
|
||||||
{
|
{
|
||||||
cout << "md processRspUserLogin task_error" << endl;
|
|
||||||
CUstpFtdcRspInfoField *task_error = (CUstpFtdcRspInfoField*)task->task_error;
|
CUstpFtdcRspInfoField *task_error = (CUstpFtdcRspInfoField*)task->task_error;
|
||||||
error["ErrorID"] = task_error->ErrorID;
|
error["ErrorID"] = task_error->ErrorID;
|
||||||
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
|
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
|
||||||
|
@ -80,8 +80,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>C:\ProgramData\VNConda\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>C:\ProgramData\VNConda\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
||||||
<TargetExt>.pyd</TargetExt>
|
<TargetExt>.pyd</TargetExt>
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -95,10 +95,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>C:\ProgramData\VNConda\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
||||||
<ReferencePath>$(ReferencePath)</ReferencePath>
|
<ReferencePath>$(ReferencePath)</ReferencePath>
|
||||||
<TargetExt>.pyd</TargetExt>
|
<TargetExt>.pyd</TargetExt>
|
||||||
<LibraryPath>C:\ProgramData\VNConda\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
@ -110,6 +110,7 @@
|
|||||||
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;VNFEMASMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;VNFEMASMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@ -125,6 +126,7 @@
|
|||||||
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_DEBUG;VNFEMASMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_DEBUG;VNFEMASMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@ -145,6 +147,9 @@
|
|||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@ -167,6 +172,9 @@
|
|||||||
</AdditionalIncludeDirectories>
|
</AdditionalIncludeDirectories>
|
||||||
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -21,24 +21,24 @@
|
|||||||
<ClInclude Include="targetver.h">
|
<ClInclude Include="targetver.h">
|
||||||
<Filter>头文件</Filter>
|
<Filter>头文件</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\include\ctp\USTPFtdcMduserApi.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\include\ctp\USTPFtdcTraderApi.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\include\ctp\USTPFtdcUserApiDataType.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\include\ctp\USTPFtdcUserApiStruct.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="vnfemasmd.h">
|
<ClInclude Include="vnfemasmd.h">
|
||||||
<Filter>头文件</Filter>
|
<Filter>头文件</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\vnfemas.h">
|
<ClInclude Include="..\vnfemas.h">
|
||||||
<Filter>头文件</Filter>
|
<Filter>头文件</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\femas\USTPFtdcMduserApi.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\femas\USTPFtdcTraderApi.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\femas\USTPFtdcUserApiDataType.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\femas\USTPFtdcUserApiStruct.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup />
|
<PropertyGroup>
|
||||||
|
<ShowAllFiles>false</ShowAllFiles>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
@ -91,11 +91,8 @@ void TdApi::OnRspUserLogin(CUstpFtdcRspUserLoginField *pRspUserLogin, CUstpFtdcR
|
|||||||
}
|
}
|
||||||
if (pRspInfo)
|
if (pRspInfo)
|
||||||
{
|
{
|
||||||
cout << "td OnRspUserLogin pRspInfo" << endl;
|
|
||||||
CUstpFtdcRspInfoField *task_error = new CUstpFtdcRspInfoField();
|
CUstpFtdcRspInfoField *task_error = new CUstpFtdcRspInfoField();
|
||||||
*task_error = *pRspInfo;
|
*task_error = *pRspInfo;
|
||||||
cout << "td OnRspUserLogin pRspInfo errorid" <<endl;
|
|
||||||
cout << pRspInfo->ErrorID << endl;
|
|
||||||
task.task_error = task_error;
|
task.task_error = task_error;
|
||||||
}
|
}
|
||||||
task.task_id = nRequestID;
|
task.task_id = nRequestID;
|
||||||
@ -630,15 +627,12 @@ void TdApi::OnRspQryInvestorAccount(CUstpFtdcRspInvestorAccountField *pRspInvest
|
|||||||
task.task_name = ONRSPQRYINVESTORACCOUNT;
|
task.task_name = ONRSPQRYINVESTORACCOUNT;
|
||||||
if (pRspInvestorAccount)
|
if (pRspInvestorAccount)
|
||||||
{
|
{
|
||||||
cout << "OnRspQryInvestorAccount" << endl;
|
|
||||||
cout << pRspInvestorAccount->AccountID << endl;
|
|
||||||
CUstpFtdcRspInvestorAccountField *task_data = new CUstpFtdcRspInvestorAccountField();
|
CUstpFtdcRspInvestorAccountField *task_data = new CUstpFtdcRspInvestorAccountField();
|
||||||
*task_data = *pRspInvestorAccount;
|
*task_data = *pRspInvestorAccount;
|
||||||
task.task_data = task_data;
|
task.task_data = task_data;
|
||||||
}
|
}
|
||||||
if (pRspInfo)
|
if (pRspInfo)
|
||||||
{
|
{
|
||||||
cout << pRspInfo->ErrorMsg << endl;
|
|
||||||
CUstpFtdcRspInfoField *task_error = new CUstpFtdcRspInfoField();
|
CUstpFtdcRspInfoField *task_error = new CUstpFtdcRspInfoField();
|
||||||
*task_error = *pRspInfo;
|
*task_error = *pRspInfo;
|
||||||
task.task_error = task_error;
|
task.task_error = task_error;
|
||||||
@ -1427,7 +1421,6 @@ void TdApi::processRspUserLogin(Task *task)
|
|||||||
dict error;
|
dict error;
|
||||||
if (task->task_error)
|
if (task->task_error)
|
||||||
{
|
{
|
||||||
cout << "td processRspUserLogin task_error" << endl;
|
|
||||||
CUstpFtdcRspInfoField *task_error = (CUstpFtdcRspInfoField*)task->task_error;
|
CUstpFtdcRspInfoField *task_error = (CUstpFtdcRspInfoField*)task->task_error;
|
||||||
error["ErrorID"] = task_error->ErrorID;
|
error["ErrorID"] = task_error->ErrorID;
|
||||||
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
|
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
|
||||||
|
@ -80,8 +80,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>C:\ProgramData\VNConda\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>C:\ProgramData\VNConda\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
||||||
<TargetExt>.pyd</TargetExt>
|
<TargetExt>.pyd</TargetExt>
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -95,8 +95,8 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetExt>.pyd</TargetExt>
|
<TargetExt>.pyd</TargetExt>
|
||||||
<IncludePath>C:\ProgramData\VNConda\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>C:\ProgramData\VNConda\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
@ -108,6 +108,7 @@
|
|||||||
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;VNFEMASTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;VNFEMASTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@ -123,6 +124,7 @@
|
|||||||
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;_DEBUG;VNFEMASTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;_DEBUG;VNFEMASTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@ -142,6 +144,9 @@
|
|||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@ -164,6 +169,9 @@
|
|||||||
</AdditionalIncludeDirectories>
|
</AdditionalIncludeDirectories>
|
||||||
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -21,21 +21,21 @@
|
|||||||
<ClInclude Include="targetver.h">
|
<ClInclude Include="targetver.h">
|
||||||
<Filter>头文件</Filter>
|
<Filter>头文件</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\include\ctp\USTPFtdcMduserApi.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\include\ctp\USTPFtdcTraderApi.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\include\ctp\USTPFtdcUserApiDataType.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\include\ctp\USTPFtdcUserApiStruct.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="vnfemastd.h">
|
<ClInclude Include="vnfemastd.h">
|
||||||
<Filter>头文件</Filter>
|
<Filter>头文件</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\femas\USTPFtdcMduserApi.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\femas\USTPFtdcTraderApi.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\femas\USTPFtdcUserApiDataType.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\femas\USTPFtdcUserApiStruct.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup />
|
<PropertyGroup>
|
||||||
|
<ShowAllFiles>false</ShowAllFiles>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
Binary file not shown.
Binary file not shown.
@ -14,7 +14,7 @@ from vnpy.api.femas import (
|
|||||||
USTP_FTDC_OS_PartTradedQueueing,
|
USTP_FTDC_OS_PartTradedQueueing,
|
||||||
USTP_FTDC_OS_AllTraded,
|
USTP_FTDC_OS_AllTraded,
|
||||||
USTP_FTDC_OS_Canceled,
|
USTP_FTDC_OS_Canceled,
|
||||||
USTP_FTDC_D_Buy,
|
USTP_FTDC_D_Buy,
|
||||||
USTP_FTDC_D_Sell,
|
USTP_FTDC_D_Sell,
|
||||||
USTP_FTDC_OPT_LimitPrice,
|
USTP_FTDC_OPT_LimitPrice,
|
||||||
USTP_FTDC_OPT_AnyPrice,
|
USTP_FTDC_OPT_AnyPrice,
|
||||||
@ -30,7 +30,7 @@ from vnpy.api.femas import (
|
|||||||
USTP_FTDC_VC_AV,
|
USTP_FTDC_VC_AV,
|
||||||
USTP_FTDC_TC_IOC,
|
USTP_FTDC_TC_IOC,
|
||||||
USTP_FTDC_VC_CV,
|
USTP_FTDC_VC_CV,
|
||||||
USTP_FTDC_AF_Delete
|
USTP_FTDC_AF_Delete,
|
||||||
)
|
)
|
||||||
from vnpy.trader.constant import (
|
from vnpy.trader.constant import (
|
||||||
Direction,
|
Direction,
|
||||||
@ -39,7 +39,7 @@ from vnpy.trader.constant import (
|
|||||||
OrderType,
|
OrderType,
|
||||||
Product,
|
Product,
|
||||||
Status,
|
Status,
|
||||||
OptionType
|
OptionType,
|
||||||
)
|
)
|
||||||
from vnpy.trader.gateway import BaseGateway
|
from vnpy.trader.gateway import BaseGateway
|
||||||
from vnpy.trader.object import (
|
from vnpy.trader.object import (
|
||||||
@ -56,8 +56,8 @@ from vnpy.trader.object import (
|
|||||||
from vnpy.trader.utility import get_folder_path
|
from vnpy.trader.utility import get_folder_path
|
||||||
from vnpy.trader.event import EVENT_TIMER
|
from vnpy.trader.event import EVENT_TIMER
|
||||||
|
|
||||||
USTP_FTDC_PD_Long = '2'
|
USTP_FTDC_PD_Long = "2"
|
||||||
USTP_FTDC_PD_Short = '3'
|
USTP_FTDC_PD_Short = "3"
|
||||||
|
|
||||||
STATUS_FEMAS2VT = {
|
STATUS_FEMAS2VT = {
|
||||||
USTP_FTDC_CAS_Submitted: Status.SUBMITTING,
|
USTP_FTDC_CAS_Submitted: Status.SUBMITTING,
|
||||||
@ -66,21 +66,21 @@ STATUS_FEMAS2VT = {
|
|||||||
USTP_FTDC_OS_NoTradeQueueing: Status.NOTTRADED,
|
USTP_FTDC_OS_NoTradeQueueing: Status.NOTTRADED,
|
||||||
USTP_FTDC_OS_PartTradedQueueing: Status.PARTTRADED,
|
USTP_FTDC_OS_PartTradedQueueing: Status.PARTTRADED,
|
||||||
USTP_FTDC_OS_AllTraded: Status.ALLTRADED,
|
USTP_FTDC_OS_AllTraded: Status.ALLTRADED,
|
||||||
USTP_FTDC_OS_Canceled: Status.CANCELLED
|
USTP_FTDC_OS_Canceled: Status.CANCELLED,
|
||||||
}
|
}
|
||||||
|
|
||||||
DIRECTION_VT2FEMAS = {
|
DIRECTION_VT2FEMAS = {
|
||||||
Direction.LONG: USTP_FTDC_D_Buy,
|
Direction.LONG: USTP_FTDC_D_Buy,
|
||||||
Direction.SHORT: USTP_FTDC_D_Sell
|
Direction.SHORT: USTP_FTDC_D_Sell,
|
||||||
}
|
}
|
||||||
|
|
||||||
ORDERTYPE_VT2FEMAS = {
|
ORDERTYPE_VT2FEMAS = {
|
||||||
OrderType.LIMIT: USTP_FTDC_OPT_LimitPrice,
|
OrderType.LIMIT: USTP_FTDC_OPT_LimitPrice,
|
||||||
OrderType.MARKET: USTP_FTDC_OPT_AnyPrice
|
OrderType.MARKET: USTP_FTDC_OPT_AnyPrice,
|
||||||
}
|
}
|
||||||
|
|
||||||
OFFSET_VT2FEMAS = {
|
OFFSET_VT2FEMAS = {
|
||||||
Offset.OPEN: USTP_FTDC_OF_Open,
|
Offset.OPEN: USTP_FTDC_OF_Open,
|
||||||
Offset.CLOSE: USTP_FTDC_OF_Close,
|
Offset.CLOSE: USTP_FTDC_OF_Close,
|
||||||
Offset.CLOSETODAY: USTP_FTDC_OF_CloseYesterday,
|
Offset.CLOSETODAY: USTP_FTDC_OF_CloseYesterday,
|
||||||
Offset.CLOSEYESTERDAY: USTP_FTDC_OF_CloseToday,
|
Offset.CLOSEYESTERDAY: USTP_FTDC_OF_CloseToday,
|
||||||
@ -92,18 +92,17 @@ DIRECTION_FEMAS2VT[USTP_FTDC_PD_Long] = Direction.LONG
|
|||||||
DIRECTION_FEMAS2VT[USTP_FTDC_PD_Short] = Direction.SHORT
|
DIRECTION_FEMAS2VT[USTP_FTDC_PD_Short] = Direction.SHORT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EXCHANGE_FEMAS2VT = {
|
EXCHANGE_FEMAS2VT = {
|
||||||
"CFFEX": Exchange.CFFEX,
|
"CFFEX": Exchange.CFFEX,
|
||||||
"SHFE": Exchange.SHFE,
|
"SHFE": Exchange.SHFE,
|
||||||
"CZCE": Exchange.CZCE,
|
"CZCE": Exchange.CZCE,
|
||||||
"DCE": Exchange.DCE,
|
"DCE": Exchange.DCE,
|
||||||
"INE": Exchange.INE
|
"INE": Exchange.INE,
|
||||||
}
|
}
|
||||||
|
|
||||||
OPTIONTYPE_FEMAS2VT = {
|
OPTIONTYPE_FEMAS2VT = {
|
||||||
USTP_FTDC_OT_CallOptions: OptionType.CALL,
|
USTP_FTDC_OT_CallOptions: OptionType.CALL,
|
||||||
USTP_FTDC_OT_PutOptions: OptionType.PUT
|
USTP_FTDC_OT_PutOptions: OptionType.PUT,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -122,7 +121,7 @@ class FemasGateway(BaseGateway):
|
|||||||
"password": "",
|
"password": "",
|
||||||
"brokerid": "",
|
"brokerid": "",
|
||||||
"td_address": "",
|
"td_address": "",
|
||||||
"md_address": ""
|
"md_address": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, event_engine):
|
def __init__(self, event_engine):
|
||||||
@ -140,15 +139,14 @@ class FemasGateway(BaseGateway):
|
|||||||
td_address = setting["td_address"]
|
td_address = setting["td_address"]
|
||||||
md_address = setting["md_address"]
|
md_address = setting["md_address"]
|
||||||
|
|
||||||
|
|
||||||
if not td_address.startswith("tcp://"):
|
if not td_address.startswith("tcp://"):
|
||||||
td_address = "tcp://" + td_address
|
td_address = "tcp://" + td_address
|
||||||
if not md_address.startswith("tcp://"):
|
if not md_address.startswith("tcp://"):
|
||||||
md_address = "tcp://" + md_address
|
md_address = "tcp://" + md_address
|
||||||
|
|
||||||
self.td_api.connect(td_address, userid, password, brokerid)
|
self.td_api.connect(td_address, userid, password, brokerid)
|
||||||
self.md_api.connect(md_address, userid, password, brokerid)
|
self.md_api.connect(md_address, userid, password, brokerid)
|
||||||
|
|
||||||
self.init_query()
|
self.init_query()
|
||||||
|
|
||||||
def subscribe(self, req: SubscribeRequest):
|
def subscribe(self, req: SubscribeRequest):
|
||||||
@ -176,24 +174,31 @@ class FemasGateway(BaseGateway):
|
|||||||
self.td_api.close()
|
self.td_api.close()
|
||||||
self.md_api.close()
|
self.md_api.close()
|
||||||
|
|
||||||
def write_error(self, msg: str, error: dict):
|
def write_error(self, msg: str, error_id: int, error_msg: str):
|
||||||
""""""
|
|
||||||
error_id = error["ErrorID"]
|
|
||||||
error_msg = error["ErrorMsg"]
|
|
||||||
msg = f"{msg},代码:{error_id},信息:{error_msg}"
|
msg = f"{msg},代码:{error_id},信息:{error_msg}"
|
||||||
self.write_log(msg)
|
self.write_log(msg)
|
||||||
|
|
||||||
|
def if_error_write_error(self, msg: str, error: dict):
|
||||||
|
"""
|
||||||
|
当有错误的时候就输出错误,并返回True
|
||||||
|
"""
|
||||||
|
error_id = error["ErrorID"]
|
||||||
|
if error_id:
|
||||||
|
error_msg = error["ErrorMsg"]
|
||||||
|
self.write_error(msg, error_id, error_msg)
|
||||||
|
return True
|
||||||
|
|
||||||
def process_timer_event(self, event):
|
def process_timer_event(self, event):
|
||||||
""""""
|
""""""
|
||||||
self.count += 1
|
self.count += 1
|
||||||
if self.count < 2:
|
if self.count < 2:
|
||||||
return
|
return
|
||||||
self.count = 0
|
self.count = 0
|
||||||
|
|
||||||
func = self.query_functions.pop(0)
|
func = self.query_functions.pop(0)
|
||||||
func()
|
func()
|
||||||
self.query_functions.append(func)
|
self.query_functions.append(func)
|
||||||
|
|
||||||
def init_query(self):
|
def init_query(self):
|
||||||
""""""
|
""""""
|
||||||
self.count = 0
|
self.count = 0
|
||||||
@ -207,20 +212,20 @@ class FemasMdApi(MdApi):
|
|||||||
def __init__(self, gateway):
|
def __init__(self, gateway):
|
||||||
"""Constructor"""
|
"""Constructor"""
|
||||||
super(FemasMdApi, self).__init__()
|
super(FemasMdApi, self).__init__()
|
||||||
|
|
||||||
self.gateway = gateway
|
self.gateway = gateway
|
||||||
self.gateway_name = gateway.gateway_name
|
self.gateway_name = gateway.gateway_name
|
||||||
|
|
||||||
self.reqid = 0
|
self.reqid = 0
|
||||||
|
|
||||||
self.connect_status = False
|
self.connect_status = False
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
self.subscribed = set()
|
self.subscribed = set()
|
||||||
|
|
||||||
self.userid = ""
|
self.userid = ""
|
||||||
self.password = ""
|
self.password = ""
|
||||||
self.brokerid = 0
|
self.brokerid = 0
|
||||||
|
|
||||||
def onFrontConnected(self):
|
def onFrontConnected(self):
|
||||||
"""
|
"""
|
||||||
Callback when front server is connected.
|
Callback when front server is connected.
|
||||||
@ -241,28 +246,25 @@ class FemasMdApi(MdApi):
|
|||||||
"""
|
"""
|
||||||
Callback when user is logged in.
|
Callback when user is logged in.
|
||||||
"""
|
"""
|
||||||
if not error["ErrorID"]:
|
if self.gateway.if_error_write_error("行情登录失败", error):
|
||||||
self.login_status = True
|
return
|
||||||
self.gateway.write_log("onRspUserLogin行情服务器登录成功")
|
self.login_status = True
|
||||||
self.gateway.write_log("行情服务器登录成功")
|
self.gateway.write_log("onRspUserLogin行情服务器登录成功")
|
||||||
|
self.gateway.write_log("行情服务器登录成功")
|
||||||
for symbol in self.subscribed:
|
|
||||||
self.subMarketData(symbol)
|
for symbol in self.subscribed:
|
||||||
else:
|
self.subMarketData(symbol)
|
||||||
self.gateway.write_error("行情登录失败", error)
|
|
||||||
|
|
||||||
def onRspError(self, error: dict, reqid: int, last: bool):
|
def onRspError(self, error: dict, reqid: int, last: bool):
|
||||||
"""
|
"""
|
||||||
Callback when error occured.
|
Callback when error occured.
|
||||||
"""
|
"""
|
||||||
self.gateway.write_error("行情接口报错", error)
|
self.gateway.if_error_write_error("行情接口报错", error)
|
||||||
|
|
||||||
def onRspSubMarketData(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspSubMarketData(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
""""""
|
""""""
|
||||||
if not error or not error["ErrorID"]:
|
if self.gateway.if_error_write_error("行情订阅失败", error):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.gateway.write_error("行情订阅失败", error)
|
|
||||||
|
|
||||||
def onRtnDepthMarketData(self, data: dict):
|
def onRtnDepthMarketData(self, data: dict):
|
||||||
"""
|
"""
|
||||||
@ -274,7 +276,7 @@ class FemasMdApi(MdApi):
|
|||||||
return
|
return
|
||||||
|
|
||||||
timestamp = f"{data['TradingDay']} {data['UpdateTime']}.{int(data['UpdateMillisec']/100)}"
|
timestamp = f"{data['TradingDay']} {data['UpdateTime']}.{int(data['UpdateMillisec']/100)}"
|
||||||
|
|
||||||
tick = TickData(
|
tick = TickData(
|
||||||
symbol=symbol,
|
symbol=symbol,
|
||||||
exchange=exchange,
|
exchange=exchange,
|
||||||
@ -292,9 +294,9 @@ class FemasMdApi(MdApi):
|
|||||||
ask_price_1=data["AskPrice1"],
|
ask_price_1=data["AskPrice1"],
|
||||||
bid_volume_1=data["BidVolume1"],
|
bid_volume_1=data["BidVolume1"],
|
||||||
ask_volume_1=data["AskVolume1"],
|
ask_volume_1=data["AskVolume1"],
|
||||||
gateway_name=self.gateway_name
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
self.gateway.on_tick(tick)
|
self.gateway.on_tick(tick)
|
||||||
|
|
||||||
def connect(self, address: str, userid: str, password: str, brokerid: int):
|
def connect(self, address: str, userid: str, password: str, brokerid: int):
|
||||||
"""
|
"""
|
||||||
@ -303,7 +305,7 @@ class FemasMdApi(MdApi):
|
|||||||
self.userid = userid
|
self.userid = userid
|
||||||
self.password = password
|
self.password = password
|
||||||
self.brokerid = brokerid
|
self.brokerid = brokerid
|
||||||
|
|
||||||
# If not connected, then start connection first.
|
# If not connected, then start connection first.
|
||||||
if not self.connect_status:
|
if not self.connect_status:
|
||||||
path = get_folder_path(self.gateway_name.lower())
|
path = get_folder_path(self.gateway_name.lower())
|
||||||
@ -315,7 +317,7 @@ class FemasMdApi(MdApi):
|
|||||||
# If already connected, then login immediately.
|
# If already connected, then login immediately.
|
||||||
elif not self.login_status:
|
elif not self.login_status:
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
"""
|
"""
|
||||||
Login onto server.
|
Login onto server.
|
||||||
@ -323,12 +325,12 @@ class FemasMdApi(MdApi):
|
|||||||
req = {
|
req = {
|
||||||
"UserID": self.userid,
|
"UserID": self.userid,
|
||||||
"Password": self.password,
|
"Password": self.password,
|
||||||
"BrokerID": self.brokerid
|
"BrokerID": self.brokerid,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.reqid += 1
|
self.reqid += 1
|
||||||
self.reqUserLogin(req, self.reqid)
|
self.reqUserLogin(req, self.reqid)
|
||||||
|
|
||||||
def subscribe(self, req: SubscribeRequest):
|
def subscribe(self, req: SubscribeRequest):
|
||||||
"""
|
"""
|
||||||
Subscribe to tick data update.
|
Subscribe to tick data update.
|
||||||
@ -336,7 +338,7 @@ class FemasMdApi(MdApi):
|
|||||||
if self.login_status:
|
if self.login_status:
|
||||||
self.subMarketData(req.symbol)
|
self.subMarketData(req.symbol)
|
||||||
self.subscribed.add(req.symbol)
|
self.subscribed.add(req.symbol)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""
|
"""
|
||||||
Close the connection.
|
Close the connection.
|
||||||
@ -351,58 +353,59 @@ class FemasTdApi(TdApi):
|
|||||||
def __init__(self, gateway):
|
def __init__(self, gateway):
|
||||||
"""Constructor"""
|
"""Constructor"""
|
||||||
super(FemasTdApi, self).__init__()
|
super(FemasTdApi, self).__init__()
|
||||||
|
|
||||||
self.gateway = gateway
|
self.gateway = gateway
|
||||||
self.gateway_name = gateway.gateway_name
|
self.gateway_name = gateway.gateway_name
|
||||||
|
|
||||||
self.reqid = 0
|
self.reqid = int(10e5)
|
||||||
self.localID = 0
|
self.localID = int(10e5 + 8888)
|
||||||
|
|
||||||
self.connect_status = False
|
self.connect_status = False
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
self.login_failed = False
|
self.login_failed = False
|
||||||
|
|
||||||
self.userid = ""
|
self.userid = ""
|
||||||
self.password = ""
|
self.password = ""
|
||||||
self.brokerid = 0
|
self.brokerid = 0
|
||||||
|
|
||||||
self.order_data = []
|
self.order_data = []
|
||||||
self.trade_data = []
|
self.trade_data = []
|
||||||
self.positions = {}
|
self.positions = {}
|
||||||
self.sysid_orderid_map = {}
|
self.sysid_orderid_map = {}
|
||||||
|
|
||||||
def onFrontConnected(self):
|
def onFrontConnected(self):
|
||||||
""""""
|
""""""
|
||||||
self.connect_status = True
|
self.connect_status = True
|
||||||
self.gateway.write_log("onFrontConnected交易连接成功")
|
self.gateway.write_log("onFrontConnected交易连接成功")
|
||||||
|
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
def onFrontDisconnected(self, reason: int):
|
def onFrontDisconnected(self, reason: int):
|
||||||
""""""
|
""""""
|
||||||
self.connect_status = False
|
self.connect_status = False
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
self.gateway.write_log(f"交易连接断开,原因{reason}")
|
self.gateway.write_log(f"交易连接断开,原因{reason}")
|
||||||
|
|
||||||
def onRspUserLogin(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspUserLogin(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
""""""
|
""""""
|
||||||
if not error["ErrorID"]:
|
if not error["ErrorID"]:
|
||||||
for k, v in data.items():
|
if data["MaxOrderLocalID"]:
|
||||||
print(k, ':', v)
|
self.localID = max(
|
||||||
|
self.localID, int(data["MaxOrderLocalID"])
|
||||||
if data['MaxOrderLocalID']:
|
) # 目前最大本地报单号
|
||||||
self.localID = int(data['MaxOrderLocalID']) # 目前最大本地报单号
|
|
||||||
self.login_status = True
|
self.login_status = True
|
||||||
self.gateway.write_log("onRspUserLogin交易登录成功")
|
self.gateway.write_log("onRspUserLogin交易登录成功")
|
||||||
self.reqid += 1
|
self.reqid += 1
|
||||||
self.reqQryInstrument({}, self.reqid)
|
self.reqQryInstrument({}, self.reqid)
|
||||||
else:
|
else:
|
||||||
self.login_failed = True
|
self.login_failed = True
|
||||||
|
|
||||||
self.gateway.write_error("交易登录失败", error)
|
self.gateway.if_error_write_error("交易登录失败", error)
|
||||||
|
|
||||||
def onRspOrderInsert(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspOrderInsert(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
""""""
|
""""""
|
||||||
|
if self.gateway.if_error_write_error("交易委托失败", error):
|
||||||
|
return
|
||||||
|
|
||||||
orderid = data["UserOrderLocalID"]
|
orderid = data["UserOrderLocalID"]
|
||||||
symbol = data["InstrumentID"]
|
symbol = data["InstrumentID"]
|
||||||
@ -416,34 +419,35 @@ class FemasTdApi(TdApi):
|
|||||||
price=data["LimitPrice"],
|
price=data["LimitPrice"],
|
||||||
volume=data["Volume"],
|
volume=data["Volume"],
|
||||||
status=Status.REJECTED,
|
status=Status.REJECTED,
|
||||||
gateway_name=self.gateway_name
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
self.gateway.on_order(order)
|
self.gateway.on_order(order)
|
||||||
|
|
||||||
self.gateway.write_error("交易委托失败", error)
|
|
||||||
|
|
||||||
def onRspOrderAction(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspOrderAction(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
""""""
|
""""""
|
||||||
self.gateway.write_error("交易撤单失败", error)
|
if self.gateway.if_error_write_error("交易撤单失败", error):
|
||||||
|
return
|
||||||
|
|
||||||
def onRspQueryMaxOrderVolume(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspQueryMaxOrderVolume(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onRspSettlementInfoConfirm(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspSettlementInfoConfirm(
|
||||||
|
self, data: dict, error: dict, reqid: int, last: bool
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Callback of settlment info confimation.
|
Callback of settlment info confimation.
|
||||||
"""
|
"""
|
||||||
self.gateway.write_log("结算信息确认成功")
|
self.gateway.write_log("结算信息确认成功")
|
||||||
|
|
||||||
self.reqid += 1
|
self.reqid += 1
|
||||||
self.reqQryInstrument({}, self.reqid)
|
self.reqQryInstrument({}, self.reqid)
|
||||||
|
|
||||||
def onRspQryInvestorPosition(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspQryInvestorPosition(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
""""""
|
""""""
|
||||||
if not data:
|
if not data:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get buffered position object
|
# Get buffered position object
|
||||||
key = f"{data['InstrumentID'], data['Direction']}"
|
key = f"{data['InstrumentID'], data['Direction']}"
|
||||||
position = self.positions.get(key, None)
|
position = self.positions.get(key, None)
|
||||||
@ -452,50 +456,49 @@ class FemasTdApi(TdApi):
|
|||||||
symbol=data["InstrumentID"],
|
symbol=data["InstrumentID"],
|
||||||
exchange=symbol_exchange_map[data["InstrumentID"]],
|
exchange=symbol_exchange_map[data["InstrumentID"]],
|
||||||
direction=DIRECTION_FEMAS2VT[data["Direction"]],
|
direction=DIRECTION_FEMAS2VT[data["Direction"]],
|
||||||
gateway_name=self.gateway_name
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
self.positions[key] = position
|
self.positions[key] = position
|
||||||
|
|
||||||
position.yd_volume = data["YdPosition"]
|
position.yd_volume = data["YdPosition"]
|
||||||
# Calculate previous position cost
|
# Calculate previous position cost
|
||||||
cost = position.price * position.volume
|
cost = position.price * position.volume
|
||||||
|
|
||||||
# Update new position volume
|
# Update new position volume
|
||||||
position.volume += data["Position"]
|
position.volume += data["Position"]
|
||||||
|
|
||||||
# Calculate average position price
|
# Calculate average position price
|
||||||
if position.volume:
|
if position.volume:
|
||||||
cost += data["PositionCost"]
|
cost += data["PositionCost"]
|
||||||
position.price = cost / position.volume
|
position.price = cost / position.volume
|
||||||
|
|
||||||
# Get frozen volume
|
# Get frozen volume
|
||||||
position.frozen += data["FrozenPosition"]
|
position.frozen += data["FrozenPosition"]
|
||||||
|
|
||||||
if last:
|
if last:
|
||||||
for position in self.positions.values():
|
for position in self.positions.values():
|
||||||
self.gateway.on_position(position)
|
self.gateway.on_position(position)
|
||||||
|
|
||||||
self.positions.clear()
|
self.positions.clear()
|
||||||
|
|
||||||
def onRspQryInvestorAccount(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspQryInvestorAccount(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
""""""
|
""""""
|
||||||
print ("onRspQryInvestorAccount")
|
|
||||||
account = AccountData(
|
account = AccountData(
|
||||||
accountid=data["AccountID"],
|
accountid=data["AccountID"],
|
||||||
frozen = data['LongMargin']+data['ShortMargin'],
|
frozen=data["LongMargin"] + data["ShortMargin"],
|
||||||
balance= data['PreBalance'],
|
balance=data["PreBalance"],
|
||||||
gateway_name=self.gateway_name
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
|
# todo: check for error
|
||||||
self.gateway.on_account(account)
|
self.gateway.on_account(account)
|
||||||
|
|
||||||
def onRspQryInstrument(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspQryInstrument(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
"""
|
"""
|
||||||
Callback of instrument query.
|
Callback of instrument query.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
contract = ContractData(
|
contract = ContractData(
|
||||||
product = data["ProductID"],
|
product=data["ProductID"],
|
||||||
symbol=data["InstrumentID"],
|
symbol=data["InstrumentID"],
|
||||||
exchange=EXCHANGE_FEMAS2VT[data["ExchangeID"]],
|
exchange=EXCHANGE_FEMAS2VT[data["ExchangeID"]],
|
||||||
name=data["InstrumentName"],
|
name=data["InstrumentName"],
|
||||||
@ -505,15 +508,15 @@ class FemasTdApi(TdApi):
|
|||||||
option_type=OPTIONTYPE_FEMAS2VT.get(data["OptionsType"], None),
|
option_type=OPTIONTYPE_FEMAS2VT.get(data["OptionsType"], None),
|
||||||
option_strike=data["StrikePrice"],
|
option_strike=data["StrikePrice"],
|
||||||
option_expiry=datetime.strptime(data["ExpireDate"], "%Y%m%d"),
|
option_expiry=datetime.strptime(data["ExpireDate"], "%Y%m%d"),
|
||||||
gateway_name=self.gateway_name
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.gateway.on_contract(contract)
|
self.gateway.on_contract(contract)
|
||||||
|
|
||||||
symbol_exchange_map[contract.symbol] = contract.exchange
|
symbol_exchange_map[contract.symbol] = contract.exchange
|
||||||
symbol_name_map[contract.symbol] = contract.name
|
symbol_name_map[contract.symbol] = contract.name
|
||||||
symbol_size_map[contract.symbol] = contract.size
|
symbol_size_map[contract.symbol] = contract.size
|
||||||
|
|
||||||
if last:
|
if last:
|
||||||
self.gateway.write_log("合约信息查询成功")
|
self.gateway.write_log("合约信息查询成功")
|
||||||
|
|
||||||
@ -522,7 +525,7 @@ class FemasTdApi(TdApi):
|
|||||||
Callback of order status update.
|
Callback of order status update.
|
||||||
"""
|
"""
|
||||||
# 更新最大报单编号
|
# 更新最大报单编号
|
||||||
self.localID = max(self.localID, int(data['UserOrderLocalID'])) # 检查并增加本地报单编号
|
self.localID = max(self.localID, int(data["UserOrderLocalID"])) # 检查并增加本地报单编号
|
||||||
|
|
||||||
symbol = data["InstrumentID"]
|
symbol = data["InstrumentID"]
|
||||||
exchange = symbol_exchange_map.get(symbol, "")
|
exchange = symbol_exchange_map.get(symbol, "")
|
||||||
@ -530,8 +533,7 @@ class FemasTdApi(TdApi):
|
|||||||
self.order_data.append(data)
|
self.order_data.append(data)
|
||||||
return
|
return
|
||||||
|
|
||||||
orderid = data['UserOrderLocalID']
|
orderid = data["UserOrderLocalID"]
|
||||||
print ("---------onRtnOrder-----------")
|
|
||||||
order = OrderData(
|
order = OrderData(
|
||||||
symbol=symbol,
|
symbol=symbol,
|
||||||
exchange=exchange,
|
exchange=exchange,
|
||||||
@ -543,12 +545,12 @@ class FemasTdApi(TdApi):
|
|||||||
traded=data["VolumeTraded"],
|
traded=data["VolumeTraded"],
|
||||||
status=STATUS_FEMAS2VT[data["OrderStatus"]],
|
status=STATUS_FEMAS2VT[data["OrderStatus"]],
|
||||||
time=data["InsertTime"],
|
time=data["InsertTime"],
|
||||||
gateway_name=self.gateway_name
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
self.gateway.on_order(order)
|
self.gateway.on_order(order)
|
||||||
|
|
||||||
self.sysid_orderid_map[data["OrderSysID"]] = orderid
|
self.sysid_orderid_map[data["OrderSysID"]] = orderid
|
||||||
|
|
||||||
def onRtnTrade(self, data: dict):
|
def onRtnTrade(self, data: dict):
|
||||||
"""
|
"""
|
||||||
Callback of trade status update.
|
Callback of trade status update.
|
||||||
@ -560,7 +562,7 @@ class FemasTdApi(TdApi):
|
|||||||
return
|
return
|
||||||
|
|
||||||
orderid = self.sysid_orderid_map[data["OrderSysID"]]
|
orderid = self.sysid_orderid_map[data["OrderSysID"]]
|
||||||
|
|
||||||
trade = TradeData(
|
trade = TradeData(
|
||||||
symbol=symbol,
|
symbol=symbol,
|
||||||
exchange=exchange,
|
exchange=exchange,
|
||||||
@ -571,10 +573,10 @@ class FemasTdApi(TdApi):
|
|||||||
price=data["TradePrice"],
|
price=data["TradePrice"],
|
||||||
volume=data["TradeVolume"],
|
volume=data["TradeVolume"],
|
||||||
time=data["TradeTime"],
|
time=data["TradeTime"],
|
||||||
gateway_name=self.gateway_name
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
self.gateway.on_trade(trade)
|
self.gateway.on_trade(trade)
|
||||||
|
|
||||||
def connect(self, address: str, userid: str, password: str, brokerid: int):
|
def connect(self, address: str, userid: str, password: str, brokerid: int):
|
||||||
"""
|
"""
|
||||||
Start connection to server.
|
Start connection to server.
|
||||||
@ -584,21 +586,20 @@ class FemasTdApi(TdApi):
|
|||||||
self.brokerid = brokerid
|
self.brokerid = brokerid
|
||||||
self.address = address
|
self.address = address
|
||||||
|
|
||||||
|
|
||||||
if not self.connect_status:
|
if not self.connect_status:
|
||||||
path = get_folder_path(self.gateway_name.lower())
|
path = get_folder_path(self.gateway_name.lower())
|
||||||
self.createFtdcTraderApi(str(path) + "\\Td")
|
self.createFtdcTraderApi(str(path) + "\\Td")
|
||||||
|
|
||||||
self.subscribePrivateTopic(0)
|
self.subscribePrivateTopic(0)
|
||||||
self.subscribePublicTopic(0)
|
self.subscribePublicTopic(0)
|
||||||
self.subscribeUserTopic(0)
|
self.subscribeUserTopic(0)
|
||||||
|
|
||||||
self.registerFront(address)
|
self.registerFront(address)
|
||||||
self.init()
|
self.init()
|
||||||
else:
|
else:
|
||||||
if not self.login_status:
|
if not self.login_status:
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
"""
|
"""
|
||||||
Login onto server.
|
Login onto server.
|
||||||
@ -609,22 +610,21 @@ class FemasTdApi(TdApi):
|
|||||||
req = {
|
req = {
|
||||||
"UserID": self.userid,
|
"UserID": self.userid,
|
||||||
"Password": self.password,
|
"Password": self.password,
|
||||||
"BrokerID": self.brokerid
|
"BrokerID": self.brokerid,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.reqid += 1
|
self.reqid += 1
|
||||||
self.reqUserLogin(req, self.reqid)
|
self.reqUserLogin(req, self.reqid)
|
||||||
|
|
||||||
def send_order(self, req: OrderRequest):
|
def send_order(self, req: OrderRequest):
|
||||||
"""
|
"""
|
||||||
Send new order.
|
Send new order.
|
||||||
"""
|
"""
|
||||||
self.localID += 1
|
self.localID += 1
|
||||||
strLocalID = str(self.localID)
|
strLocalID = str(self.localID).rjust(12, "0")
|
||||||
print ('----femasgateway type' + str(req.type))
|
|
||||||
femas_req = {
|
femas_req = {
|
||||||
"InstrumentID": req.symbol,
|
"InstrumentID": req.symbol,
|
||||||
"ExchangeID": str(req.exchange).split('.')[1],
|
"ExchangeID": str(req.exchange).split(".")[1],
|
||||||
"BrokerID": self.brokerid,
|
"BrokerID": self.brokerid,
|
||||||
"InvestorID": self.userid,
|
"InvestorID": self.userid,
|
||||||
"UserID": self.userid,
|
"UserID": self.userid,
|
||||||
@ -639,55 +639,48 @@ class FemasTdApi(TdApi):
|
|||||||
"IsAutoSuspend": 0,
|
"IsAutoSuspend": 0,
|
||||||
"TimeCondition": USTP_FTDC_TC_GFD,
|
"TimeCondition": USTP_FTDC_TC_GFD,
|
||||||
"VolumeCondition": USTP_FTDC_VC_AV,
|
"VolumeCondition": USTP_FTDC_VC_AV,
|
||||||
"MinVolume": 1
|
"MinVolume": 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.type == OrderType.FAK:
|
if req.type == OrderType.FAK:
|
||||||
femas_req["OrderPriceType"] = USTP_FTDC_OPT_LimitPrice
|
femas_req["OrderPriceType"] = USTP_FTDC_OPT_LimitPrice
|
||||||
femas_req["TimeCondition"] = USTP_FTDC_TC_IOC
|
femas_req["TimeCondition"] = USTP_FTDC_TC_IOC
|
||||||
femas_req["VolumeCondition"] = USTP_FTDC_VC_AV
|
femas_req["VolumeCondition"] = USTP_FTDC_VC_AV
|
||||||
print ("------------fak")
|
|
||||||
elif req.type == OrderType.FOK:
|
elif req.type == OrderType.FOK:
|
||||||
femas_req["OrderPriceType"] = USTP_FTDC_OPT_LimitPrice
|
femas_req["OrderPriceType"] = USTP_FTDC_OPT_LimitPrice
|
||||||
femas_req["TimeCondition"] = USTP_FTDC_TC_IOC
|
femas_req["TimeCondition"] = USTP_FTDC_TC_IOC
|
||||||
femas_req["VolumeCondition"] = USTP_FTDC_VC_CV
|
femas_req["VolumeCondition"] = USTP_FTDC_VC_CV
|
||||||
print ("------------fok")
|
|
||||||
|
|
||||||
for key in femas_req:
|
|
||||||
print(key + ':' + str(femas_req[key]))
|
|
||||||
|
|
||||||
self.reqid += 1
|
self.reqid += 1
|
||||||
self.reqOrderInsert(femas_req, self.reqid)
|
self.reqOrderInsert(femas_req, self.reqid)
|
||||||
|
|
||||||
orderid = femas_req["UserOrderLocalID"]
|
orderid = femas_req["UserOrderLocalID"]
|
||||||
req.volume = femas_req["Volume"]
|
req.volume = femas_req["Volume"]
|
||||||
order = req.create_order_data(orderid, self.gateway_name)
|
order = req.create_order_data(orderid, self.gateway_name)
|
||||||
self.gateway.on_order(order)
|
self.gateway.on_order(order)
|
||||||
|
|
||||||
return order.vt_orderid
|
return order.vt_orderid
|
||||||
|
|
||||||
def cancel_order(self, req: CancelRequest):
|
def cancel_order(self, req: CancelRequest):
|
||||||
"""
|
"""
|
||||||
Cancel existing order.
|
Cancel existing order.
|
||||||
"""
|
"""
|
||||||
self.localID += 1
|
self.localID += 1
|
||||||
strLocalID = str(self.localID)
|
strLocalID = str(self.localID)
|
||||||
print ('--cancel exchange--' + str(req.exchange).split('.')[1])
|
|
||||||
print ('--cancel orderid--' + req.orderid)
|
|
||||||
femas_req = {
|
femas_req = {
|
||||||
"InstrumentID": req.symbol,
|
"InstrumentID": req.symbol,
|
||||||
"ExchangeID": str(req.exchange).split('.')[1],
|
"ExchangeID": str(req.exchange).split(".")[1],
|
||||||
"UserOrderLocalID": req.orderid,
|
"UserOrderLocalID": req.orderid,
|
||||||
"UserOrderActionLocalID": strLocalID,
|
"UserOrderActionLocalID": strLocalID,
|
||||||
"ActionFlag": USTP_FTDC_AF_Delete,
|
"ActionFlag": USTP_FTDC_AF_Delete,
|
||||||
"BrokerID": self.brokerid,
|
"BrokerID": self.brokerid,
|
||||||
"InvestorID": self.userid,
|
"InvestorID": self.userid,
|
||||||
"UserID": self.userid
|
"UserID": self.userid,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.reqid += 1
|
self.reqid += 1
|
||||||
self.reqOrderAction(femas_req, self.reqid)
|
self.reqOrderAction(femas_req, self.reqid)
|
||||||
|
|
||||||
def query_account(self):
|
def query_account(self):
|
||||||
"""
|
"""
|
||||||
Query account balance data.
|
Query account balance data.
|
||||||
@ -695,27 +688,27 @@ class FemasTdApi(TdApi):
|
|||||||
req = {
|
req = {
|
||||||
"BrokerID": self.brokerid,
|
"BrokerID": self.brokerid,
|
||||||
"InvestorID": self.userid,
|
"InvestorID": self.userid,
|
||||||
"UserID": self.userid
|
"UserID": self.userid,
|
||||||
}
|
}
|
||||||
self.reqid += 1
|
self.reqid += 1
|
||||||
self.reqQryInvestorAccount(req, self.reqid)
|
self.reqQryInvestorAccount(req, self.reqid)
|
||||||
|
|
||||||
def query_position(self):
|
def query_position(self):
|
||||||
"""
|
"""
|
||||||
Query position holding data.
|
Query position holding data.
|
||||||
"""
|
"""
|
||||||
if not symbol_exchange_map:
|
if not symbol_exchange_map:
|
||||||
return
|
return
|
||||||
|
|
||||||
req = {
|
req = {
|
||||||
"BrokerID": self.brokerid,
|
"BrokerID": self.brokerid,
|
||||||
"InvestorID": self.userid,
|
"InvestorID": self.userid,
|
||||||
"UserID": self.userid
|
"UserID": self.userid,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.reqid += 1
|
self.reqid += 1
|
||||||
self.reqQryInvestorPosition(req, self.reqid)
|
self.reqQryInvestorPosition(req, self.reqid)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
""""""
|
""""""
|
||||||
if self.connect_status:
|
if self.connect_status:
|
||||||
|
Loading…
Reference in New Issue
Block a user