Merge pull request #2006 from LimingFang/dev

change sec2sopt
This commit is contained in:
vn.py 2019-08-07 16:36:24 +08:00 committed by GitHub
commit d151b13ef5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
64 changed files with 251 additions and 251 deletions

View File

@ -1,3 +0,0 @@
from .vnsecmd import MdApi
from .vnsectd import TdApi
from .sec_constant import *

View File

@ -1,41 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.757
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vnsecmd", "vnsecmd\vnsecmd.vcxproj", "{3C13B49C-4A10-45A3-9FD5-4CB3A587EF8A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vnsectd", "vnsectd\vnsectd.vcxproj", "{4A6E7B14-A7CB-488E-BE1B-86E1A438E67D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3C13B49C-4A10-45A3-9FD5-4CB3A587EF8A}.Debug|x64.ActiveCfg = Debug|x64
{3C13B49C-4A10-45A3-9FD5-4CB3A587EF8A}.Debug|x64.Build.0 = Debug|x64
{3C13B49C-4A10-45A3-9FD5-4CB3A587EF8A}.Debug|x86.ActiveCfg = Debug|Win32
{3C13B49C-4A10-45A3-9FD5-4CB3A587EF8A}.Debug|x86.Build.0 = Debug|Win32
{3C13B49C-4A10-45A3-9FD5-4CB3A587EF8A}.Release|x64.ActiveCfg = Release|x64
{3C13B49C-4A10-45A3-9FD5-4CB3A587EF8A}.Release|x64.Build.0 = Release|x64
{3C13B49C-4A10-45A3-9FD5-4CB3A587EF8A}.Release|x86.ActiveCfg = Release|Win32
{3C13B49C-4A10-45A3-9FD5-4CB3A587EF8A}.Release|x86.Build.0 = Release|Win32
{4A6E7B14-A7CB-488E-BE1B-86E1A438E67D}.Debug|x64.ActiveCfg = Debug|x64
{4A6E7B14-A7CB-488E-BE1B-86E1A438E67D}.Debug|x64.Build.0 = Debug|x64
{4A6E7B14-A7CB-488E-BE1B-86E1A438E67D}.Debug|x86.ActiveCfg = Debug|Win32
{4A6E7B14-A7CB-488E-BE1B-86E1A438E67D}.Debug|x86.Build.0 = Debug|Win32
{4A6E7B14-A7CB-488E-BE1B-86E1A438E67D}.Release|x64.ActiveCfg = Release|x64
{4A6E7B14-A7CB-488E-BE1B-86E1A438E67D}.Release|x64.Build.0 = Release|x64
{4A6E7B14-A7CB-488E-BE1B-86E1A438E67D}.Release|x86.ActiveCfg = Release|Win32
{4A6E7B14-A7CB-488E-BE1B-86E1A438E67D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3391089F-B3B3-4C35-80D0-C1EF17244F21}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,3 @@
from .vnsoptmd import MdApi
from .vnsopttd import TdApi
from .sopt_constant import *

View File

@ -0,0 +1,41 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.757
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vnsoptmd", "vnsoptmd\vnsoptmd.vcxproj", "{C2D4F5C9-D5EC-4823-93AF-7275E840E579}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vnsopttd", "vnsopttd\vnsopttd.vcxproj", "{059048EC-18DC-4B7E-8A41-E2450619519F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C2D4F5C9-D5EC-4823-93AF-7275E840E579}.Debug|x64.ActiveCfg = Debug|x64
{C2D4F5C9-D5EC-4823-93AF-7275E840E579}.Debug|x64.Build.0 = Debug|x64
{C2D4F5C9-D5EC-4823-93AF-7275E840E579}.Debug|x86.ActiveCfg = Debug|Win32
{C2D4F5C9-D5EC-4823-93AF-7275E840E579}.Debug|x86.Build.0 = Debug|Win32
{C2D4F5C9-D5EC-4823-93AF-7275E840E579}.Release|x64.ActiveCfg = Release|x64
{C2D4F5C9-D5EC-4823-93AF-7275E840E579}.Release|x64.Build.0 = Release|x64
{C2D4F5C9-D5EC-4823-93AF-7275E840E579}.Release|x86.ActiveCfg = Release|Win32
{C2D4F5C9-D5EC-4823-93AF-7275E840E579}.Release|x86.Build.0 = Release|Win32
{059048EC-18DC-4B7E-8A41-E2450619519F}.Debug|x64.ActiveCfg = Debug|x64
{059048EC-18DC-4B7E-8A41-E2450619519F}.Debug|x64.Build.0 = Debug|x64
{059048EC-18DC-4B7E-8A41-E2450619519F}.Debug|x86.ActiveCfg = Debug|Win32
{059048EC-18DC-4B7E-8A41-E2450619519F}.Debug|x86.Build.0 = Debug|Win32
{059048EC-18DC-4B7E-8A41-E2450619519F}.Release|x64.ActiveCfg = Release|x64
{059048EC-18DC-4B7E-8A41-E2450619519F}.Release|x64.Build.0 = Release|x64
{059048EC-18DC-4B7E-8A41-E2450619519F}.Release|x86.ActiveCfg = Release|Win32
{059048EC-18DC-4B7E-8A41-E2450619519F}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CF87C672-384E-4403-B8DE-7D354FB339C0}
EndGlobalSection
EndGlobal

View File

@ -1,5 +1,5 @@
#include "stdafx.h" #include "stdafx.h"
#include "vnsecmd.h" #include "vnsoptmd.h"
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/////////////原生回调接口生成task /////////////原生回调接口生成task
@ -793,7 +793,7 @@ public:
}; };
}; };
PYBIND11_MODULE(vnsecmd, m) PYBIND11_MODULE(vnsoptmd, m)
{ {
class_<MdApi, PyMdApi> mdapi(m, "MdApi", module_local()); class_<MdApi, PyMdApi> mdapi(m, "MdApi", module_local());
mdapi mdapi

View File

@ -17,7 +17,7 @@
#include "ThostFtdcMdApi.h" #include "ThostFtdcMdApi.h"
#include "pybind11.h" #include "pybind11.h"
#include "vnsec.h" #include "vnsopt.h"
using namespace pybind11; using namespace pybind11;
class MdApi :public CThostFtdcMdSpi class MdApi :public CThostFtdcMdSpi

View File

@ -20,9 +20,9 @@
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion> <VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{3C13B49C-4A10-45A3-9FD5-4CB3A587EF8A}</ProjectGuid> <ProjectGuid>{C2D4F5C9-D5EC-4823-93AF-7275E840E579}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>vnsecmd</RootNamespace> <RootNamespace>vnsoptmd</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -73,22 +73,22 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<TargetExt>.pyd</TargetExt> <TargetExt>.pyd</TargetExt>
<IncludePath>$(SolutionDir);$(SolutionDir)..\include\Sec;$(SolutionDir)..\include\pybind11\;C:\vnstudio\include;$(IncludePath)</IncludePath> <IncludePath>C:\vnstudio\include;$(SolutionDir)..\include\sopt;$(SolutionDir);$(SolutionDir)..\include\pybind11\;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<TargetExt>.pyd</TargetExt> <TargetExt>.pyd</TargetExt>
<IncludePath>$(SolutionDir);$(SolutionDir)..\include\Sec;$(SolutionDir)..\include\pybind11\;C:\vnstudio\include;$(IncludePath)</IncludePath> <IncludePath>C:\vnstudio\include;$(SolutionDir)..\include\sopt;$(SolutionDir);$(SolutionDir)..\include\pybind11\;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<TargetExt>.pyd</TargetExt> <TargetExt>.pyd</TargetExt>
<IncludePath>$(SolutionDir);$(SolutionDir)..\include\Sec;$(SolutionDir)..\include\pybind11\;C:\vnstudio\include;$(IncludePath)</IncludePath> <IncludePath>C:\vnstudio\include;$(SolutionDir)..\include\sopt;$(SolutionDir);$(SolutionDir)..\include\pybind11\;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<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>$(SolutionDir);$(SolutionDir)..\include\Sec;$(SolutionDir)..\include\pybind11\;C:\vnstudio\include;$(IncludePath)</IncludePath> <IncludePath>C:\vnstudio\include;$(SolutionDir)..\include\sopt;$(SolutionDir);$(SolutionDir)..\include\pybind11\;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@ -165,7 +165,7 @@
<ItemGroup> <ItemGroup>
<ClInclude Include="stdafx.h" /> <ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" /> <ClInclude Include="targetver.h" />
<ClInclude Include="vnsecmd.h" /> <ClInclude Include="vnsoptmd.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="dllmain.cpp" /> <ClCompile Include="dllmain.cpp" />
@ -175,7 +175,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile> </ClCompile>
<ClCompile Include="vnsecmd.cpp" /> <ClCompile Include="vnsoptmd.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -21,7 +21,7 @@
<ClInclude Include="targetver.h"> <ClInclude Include="targetver.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="vnsecmd.h"> <ClInclude Include="vnsoptmd.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
@ -29,7 +29,7 @@
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="vnsecmd.cpp"> <ClCompile Include="vnsoptmd.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">

View File

@ -1,5 +1,5 @@
#include "stdafx.h" #include "stdafx.h"
#include "vnsectd.h" #include "vnsopttd.h"
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/////////////原生回调接口生成task /////////////原生回调接口生成task
@ -11686,7 +11686,7 @@ public:
}; };
PYBIND11_MODULE(vnsectd, m) PYBIND11_MODULE(vnsopttd, m)
{ {
class_<TdApi, PyTdApi> tdapi(m, "TdApi", module_local()); class_<TdApi, PyTdApi> tdapi(m, "TdApi", module_local());
tdapi tdapi

View File

@ -136,7 +136,7 @@
#include "ThostFtdcTraderApi.h" #include "ThostFtdcTraderApi.h"
#include "pybind11.h" #include "pybind11.h"
#include "vnsec.h" #include "vnsopt.h"
using namespace pybind11; using namespace pybind11;

View File

@ -20,9 +20,9 @@
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion> <VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{4A6E7B14-A7CB-488E-BE1B-86E1A438E67D}</ProjectGuid> <ProjectGuid>{059048EC-18DC-4B7E-8A41-E2450619519F}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>vnsectd</RootNamespace> <RootNamespace>vnsopttd</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -73,22 +73,22 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<TargetExt>.pyd</TargetExt> <TargetExt>.pyd</TargetExt>
<IncludePath>$(SolutionDir);$(SolutionDir)..\include\Sec;$(SolutionDir)..\include\pybind11;C:\vnstudio\include;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir);$(SolutionDir)..\include\sopt;$(SolutionDir)..\include\pybind11;C:\vnstudio\include;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<TargetExt>.pyd</TargetExt> <TargetExt>.pyd</TargetExt>
<IncludePath>$(SolutionDir);$(SolutionDir)..\include\Sec;$(SolutionDir)..\include\pybind11;C:\vnstudio\include;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir);$(SolutionDir)..\include\sopt;$(SolutionDir)..\include\pybind11;C:\vnstudio\include;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<TargetExt>.pyd</TargetExt> <TargetExt>.pyd</TargetExt>
<IncludePath>$(SolutionDir);$(SolutionDir)..\include\Sec;$(SolutionDir)..\include\pybind11;C:\vnstudio\include;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir);$(SolutionDir)..\include\sopt;$(SolutionDir)..\include\pybind11;C:\vnstudio\include;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<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>$(SolutionDir);$(SolutionDir)..\include\Sec;$(SolutionDir)..\include\pybind11;C:\vnstudio\include;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir);$(SolutionDir)..\include\sopt;$(SolutionDir)..\include\pybind11;C:\vnstudio\include;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@ -165,7 +165,7 @@
<ItemGroup> <ItemGroup>
<ClInclude Include="stdafx.h" /> <ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" /> <ClInclude Include="targetver.h" />
<ClInclude Include="vnsectd.h" /> <ClInclude Include="vnsopttd.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="dllmain.cpp" /> <ClCompile Include="dllmain.cpp" />
@ -175,7 +175,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile> </ClCompile>
<ClCompile Include="vnsectd.cpp" /> <ClCompile Include="vnsopttd.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -21,7 +21,7 @@
<ClInclude Include="targetver.h"> <ClInclude Include="targetver.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="vnsectd.h"> <ClInclude Include="vnsopttd.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
@ -29,7 +29,7 @@
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="vnsectd.cpp"> <ClCompile Include="vnsopttd.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">

View File

@ -1 +0,0 @@
from .sec_gateway import SecGateway

View File

@ -0,0 +1 @@
from .sopt_gateway import SoptGateway

View File

@ -3,7 +3,7 @@
from datetime import datetime from datetime import datetime
from vnpy.api.sec import ( from vnpy.api.sopt import (
MdApi, MdApi,
TdApi, TdApi,
THOST_FTDC_OAS_Submitted, THOST_FTDC_OAS_Submitted,
@ -62,7 +62,7 @@ from vnpy.trader.utility import get_folder_path
from vnpy.trader.event import EVENT_TIMER from vnpy.trader.event import EVENT_TIMER
STATUS_SEC2VT = { STATUS_SOPT2VT = {
THOST_FTDC_OAS_Submitted: Status.SUBMITTING, THOST_FTDC_OAS_Submitted: Status.SUBMITTING,
THOST_FTDC_OAS_Accepted: Status.SUBMITTING, THOST_FTDC_OAS_Accepted: Status.SUBMITTING,
THOST_FTDC_OAS_Rejected: Status.REJECTED, THOST_FTDC_OAS_Rejected: Status.REJECTED,
@ -72,40 +72,40 @@ STATUS_SEC2VT = {
THOST_FTDC_OST_Canceled: Status.CANCELLED THOST_FTDC_OST_Canceled: Status.CANCELLED
} }
DIRECTION_VT2SEC = { DIRECTION_VT2SOPT = {
Direction.LONG: THOST_FTDC_D_Buy, Direction.LONG: THOST_FTDC_D_Buy,
Direction.SHORT: THOST_FTDC_D_Sell Direction.SHORT: THOST_FTDC_D_Sell
} }
DIRECTION_SEC2VT = {v: k for k, v in DIRECTION_VT2SEC.items()} DIRECTION_SOPT2VT = {v: k for k, v in DIRECTION_VT2SOPT.items()}
DIRECTION_SEC2VT[THOST_FTDC_PD_Long] = Direction.LONG DIRECTION_SOPT2VT[THOST_FTDC_PD_Long] = Direction.LONG
DIRECTION_SEC2VT[THOST_FTDC_PD_Short] = Direction.SHORT DIRECTION_SOPT2VT[THOST_FTDC_PD_Short] = Direction.SHORT
ORDERTYPE_VT2SEC = { ORDERTYPE_VT2SOPT = {
OrderType.LIMIT: THOST_FTDC_OPT_LimitPrice, OrderType.LIMIT: THOST_FTDC_OPT_LimitPrice,
OrderType.MARKET: THOST_FTDC_OPT_AnyPrice OrderType.MARKET: THOST_FTDC_OPT_AnyPrice
} }
ORDERTYPE_SEC2VT = {v: k for k, v in ORDERTYPE_VT2SEC.items()} ORDERTYPE_SOPT2VT = {v: k for k, v in ORDERTYPE_VT2SOPT.items()}
OFFSET_VT2SEC = { OFFSET_VT2SOPT = {
Offset.OPEN: THOST_FTDC_OF_Open, Offset.OPEN: THOST_FTDC_OF_Open,
Offset.CLOSE: THOST_FTDC_OFEN_Close, Offset.CLOSE: THOST_FTDC_OFEN_Close,
Offset.CLOSETODAY: THOST_FTDC_OFEN_CloseToday, Offset.CLOSETODAY: THOST_FTDC_OFEN_CloseToday,
Offset.CLOSEYESTERDAY: THOST_FTDC_OFEN_CloseYesterday, Offset.CLOSEYESTERDAY: THOST_FTDC_OFEN_CloseYesterday,
} }
OFFSET_SEC2VT = {v: k for k, v in OFFSET_VT2SEC.items()} OFFSET_SOPT2VT = {v: k for k, v in OFFSET_VT2SOPT.items()}
EXCHANGE_SEC2VT = { EXCHANGE_SOPT2VT = {
"SZSE": Exchange.SZSE, "SZSE": Exchange.SZSE,
"SSE": Exchange.SSE "SSE": Exchange.SSE
} }
PRODUCT_SEC2VT = { PRODUCT_SOPT2VT = {
THOST_FTDC_PC_Stock: Product.EQUITY, THOST_FTDC_PC_Stock: Product.EQUITY,
THOST_FTDC_PC_ETFOption: Product.OPTION, THOST_FTDC_PC_ETFOption: Product.OPTION,
THOST_FTDC_PC_Combination: Product.SPREAD THOST_FTDC_PC_Combination: Product.SPREAD
} }
OPTIONTYPE_SEC2VT = { OPTIONTYPE_SOPT2VT = {
THOST_FTDC_CP_CallOptions: OptionType.CALL, THOST_FTDC_CP_CallOptions: OptionType.CALL,
THOST_FTDC_CP_PutOptions: OptionType.PUT THOST_FTDC_CP_PutOptions: OptionType.PUT
} }
@ -116,9 +116,9 @@ symbol_name_map = {}
symbol_size_map = {} symbol_size_map = {}
class SecGateway(BaseGateway): class SoptGateway(BaseGateway):
""" """
VN Trader Gateway for SEC . VN Trader Gateway for SOPT .
""" """
default_setting = { default_setting = {
@ -132,14 +132,14 @@ class SecGateway(BaseGateway):
"产品信息": "" "产品信息": ""
} }
exchanges = list(EXCHANGE_SEC2VT.values()) exchanges = list(EXCHANGE_SOPT2VT.values())
def __init__(self, event_engine): def __init__(self, event_engine):
"""Constructor""" """Constructor"""
super().__init__(event_engine, "SEC") super().__init__(event_engine, "SOPT")
self.td_api = SecTdApi(self) self.td_api = SoptTdApi(self)
self.md_api = SecMdApi(self) self.md_api = SoptMdApi(self)
def connect(self, setting: dict): def connect(self, setting: dict):
"""""" """"""
@ -212,12 +212,12 @@ class SecGateway(BaseGateway):
self.event_engine.register(EVENT_TIMER, self.process_timer_event) self.event_engine.register(EVENT_TIMER, self.process_timer_event)
class SecMdApi(MdApi): class SoptMdApi(MdApi):
"""""" """"""
def __init__(self, gateway): def __init__(self, gateway):
"""Constructor""" """Constructor"""
super(SecMdApi, self).__init__() super(SoptMdApi, self).__init__()
self.gateway = gateway self.gateway = gateway
self.gateway_name = gateway.gateway_name self.gateway_name = gateway.gateway_name
@ -352,12 +352,12 @@ class SecMdApi(MdApi):
self.exit() self.exit()
class SecTdApi(TdApi): class SoptTdApi(TdApi):
"""""" """"""
def __init__(self, gateway): def __init__(self, gateway):
"""Constructor""" """Constructor"""
super(SecTdApi, self).__init__() super(SoptTdApi, self).__init__()
self.test = [] self.test = []
@ -442,8 +442,8 @@ class SecTdApi(TdApi):
symbol=symbol, symbol=symbol,
exchange=exchange, exchange=exchange,
orderid=orderid, orderid=orderid,
direction=DIRECTION_SEC2VT[data["Direction"]], direction=DIRECTION_SOPT2VT[data["Direction"]],
offset=OFFSET_SEC2VT[data["CombOffsetFlag"]], offset=OFFSET_SOPT2VT[data["CombOffsetFlag"]],
price=data["LimitPrice"], price=data["LimitPrice"],
volume=data["VolumeTotalOriginal"], volume=data["VolumeTotalOriginal"],
status=Status.REJECTED, status=Status.REJECTED,
@ -482,7 +482,7 @@ class SecTdApi(TdApi):
position = PositionData( position = PositionData(
symbol=data["InstrumentID"], symbol=data["InstrumentID"],
exchange=symbol_exchange_map[data["InstrumentID"]], exchange=symbol_exchange_map[data["InstrumentID"]],
direction=DIRECTION_SEC2VT[data["PosiDirection"]], direction=DIRECTION_SOPT2VT[data["PosiDirection"]],
gateway_name=self.gateway_name gateway_name=self.gateway_name
) )
self.positions[key] = position self.positions[key] = position
@ -538,12 +538,12 @@ class SecTdApi(TdApi):
""" """
Callback of instrument query. Callback of instrument query.
""" """
product = PRODUCT_SEC2VT.get(data["ProductClass"], None) product = PRODUCT_SOPT2VT.get(data["ProductClass"], None)
if product: if product:
contract = ContractData( contract = ContractData(
symbol=data["InstrumentID"], symbol=data["InstrumentID"],
exchange=EXCHANGE_SEC2VT[data["ExchangeID"]], exchange=EXCHANGE_SOPT2VT[data["ExchangeID"]],
name=data["InstrumentName"], name=data["InstrumentName"],
product=product, product=product,
size=data["VolumeMultiple"], size=data["VolumeMultiple"],
@ -554,7 +554,7 @@ class SecTdApi(TdApi):
# For option only # For option only
if contract.product == Product.OPTION: if contract.product == Product.OPTION:
contract.option_underlying = data["UnderlyingInstrID"], contract.option_underlying = data["UnderlyingInstrID"],
contract.option_type = OPTIONTYPE_SEC2VT.get(data["OptionsType"], None), contract.option_type = OPTIONTYPE_SOPT2VT.get(data["OptionsType"], None),
contract.option_strike = data["StrikePrice"], contract.option_strike = data["StrikePrice"],
contract.option_expiry = datetime.strptime(data["ExpireDate"], "%Y%m%d"), contract.option_expiry = datetime.strptime(data["ExpireDate"], "%Y%m%d"),
@ -594,13 +594,13 @@ class SecTdApi(TdApi):
symbol=symbol, symbol=symbol,
exchange=exchange, exchange=exchange,
orderid=orderid, orderid=orderid,
type=ORDERTYPE_SEC2VT[data["OrderPriceType"]], type=ORDERTYPE_SOPT2VT[data["OrderPriceType"]],
direction=DIRECTION_SEC2VT[data["Direction"]], direction=DIRECTION_SOPT2VT[data["Direction"]],
offset=OFFSET_SEC2VT[data["CombOffsetFlag"]], offset=OFFSET_SOPT2VT[data["CombOffsetFlag"]],
price=data["LimitPrice"], price=data["LimitPrice"],
volume=data["VolumeTotalOriginal"], volume=data["VolumeTotalOriginal"],
traded=data["VolumeTraded"], traded=data["VolumeTraded"],
status=STATUS_SEC2VT[data["OrderStatus"]], status=STATUS_SOPT2VT[data["OrderStatus"]],
time=data["InsertTime"], time=data["InsertTime"],
gateway_name=self.gateway_name gateway_name=self.gateway_name
) )
@ -625,8 +625,8 @@ class SecTdApi(TdApi):
exchange=exchange, exchange=exchange,
orderid=orderid, orderid=orderid,
tradeid=data["TradeID"], tradeid=data["TradeID"],
direction=DIRECTION_SEC2VT[data["Direction"]], direction=DIRECTION_SOPT2VT[data["Direction"]],
offset=OFFSET_SEC2VT[data["OffsetFlag"]], offset=OFFSET_SOPT2VT[data["OffsetFlag"]],
price=data["Price"], price=data["Price"],
volume=data["Volume"], volume=data["Volume"],
time=data["TradeTime"], time=data["TradeTime"],
@ -711,14 +711,14 @@ class SecTdApi(TdApi):
""" """
self.order_ref += 1 self.order_ref += 1
sec_req = { sopt_req = {
"InstrumentID": req.symbol, "InstrumentID": req.symbol,
"ExchangeID": req.exchange.value, "ExchangeID": req.exchange.value,
"LimitPrice": req.price, "LimitPrice": req.price,
"VolumeTotalOriginal": int(req.volume), "VolumeTotalOriginal": int(req.volume),
"OrderPriceType": ORDERTYPE_VT2SEC.get(req.type, ""), "OrderPriceType": ORDERTYPE_VT2SOPT.get(req.type, ""),
"Direction": DIRECTION_VT2SEC.get(req.direction, ""), "Direction": DIRECTION_VT2SOPT.get(req.direction, ""),
"CombOffsetFlag": OFFSET_VT2SEC.get(req.offset, ""), "CombOffsetFlag": OFFSET_VT2SOPT.get(req.offset, ""),
"OrderRef": str(self.order_ref), "OrderRef": str(self.order_ref),
"InvestorID": self.userid, "InvestorID": self.userid,
"UserID": self.userid, "UserID": self.userid,
@ -733,16 +733,16 @@ class SecTdApi(TdApi):
} }
if req.type == OrderType.FAK: if req.type == OrderType.FAK:
sec_req["OrderPriceType"] = THOST_FTDC_OPT_LimitPrice sopt_req["OrderPriceType"] = THOST_FTDC_OPT_LimitPrice
sec_req["TimeCondition"] = THOST_FTDC_TC_IOC sopt_req["TimeCondition"] = THOST_FTDC_TC_IOC
sec_req["VolumeCondition"] = THOST_FTDC_VC_AV sopt_req["VolumeCondition"] = THOST_FTDC_VC_AV
elif req.type == OrderType.FOK: elif req.type == OrderType.FOK:
sec_req["OrderPriceType"] = THOST_FTDC_OPT_LimitPrice sopt_req["OrderPriceType"] = THOST_FTDC_OPT_LimitPrice
sec_req["TimeCondition"] = THOST_FTDC_TC_IOC sopt_req["TimeCondition"] = THOST_FTDC_TC_IOC
sec_req["VolumeCondition"] = THOST_FTDC_VC_CV sopt_req["VolumeCondition"] = THOST_FTDC_VC_CV
self.reqid += 1 self.reqid += 1
self.reqOrderInsert(sec_req, self.reqid) self.reqOrderInsert(sopt_req, self.reqid)
orderid = f"{self.frontid}_{self.sessionid}_{self.order_ref}" orderid = f"{self.frontid}_{self.sessionid}_{self.order_ref}"
order = req.create_order_data(orderid, self.gateway_name) order = req.create_order_data(orderid, self.gateway_name)
@ -756,7 +756,7 @@ class SecTdApi(TdApi):
""" """
frontid, sessionid, order_ref = req.orderid.split("_") frontid, sessionid, order_ref = req.orderid.split("_")
sec_req = { sopt_req = {
"InstrumentID": req.symbol, "InstrumentID": req.symbol,
"Exchange": req.exchange, "Exchange": req.exchange,
"OrderRef": order_ref, "OrderRef": order_ref,
@ -768,7 +768,7 @@ class SecTdApi(TdApi):
} }
self.reqid += 1 self.reqid += 1
self.reqOrderAction(sec_req, self.reqid) self.reqOrderAction(sopt_req, self.reqid)
def query_account(self): def query_account(self):
""" """