change sec2sopt
This commit is contained in:
parent
e93362a2c0
commit
75147ffb80
@ -1,3 +0,0 @@
|
||||
from .vnsecmd import MdApi
|
||||
from .vnsectd import TdApi
|
||||
from .sec_constant import *
|
@ -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
|
3
vnpy/api/sopt/__init__.py
Normal file
3
vnpy/api/sopt/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
from .vnsoptmd import MdApi
|
||||
from .vnsopttd import TdApi
|
||||
from .sopt_constant import *
|
41
vnpy/api/sopt/vnsopt/vnsopt.sln
Normal file
41
vnpy/api/sopt/vnsopt/vnsopt.sln
Normal 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
|
@ -1,5 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include "vnsecmd.h"
|
||||
#include "vnsoptmd.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/////////////原生回调接口生成task
|
||||
@ -793,7 +793,7 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
PYBIND11_MODULE(vnsecmd, m)
|
||||
PYBIND11_MODULE(vnsoptmd, m)
|
||||
{
|
||||
class_<MdApi, PyMdApi> mdapi(m, "MdApi", module_local());
|
||||
mdapi
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include "ThostFtdcMdApi.h"
|
||||
#include "pybind11.h"
|
||||
#include "vnsec.h"
|
||||
#include "vnsopt.h"
|
||||
using namespace pybind11;
|
||||
|
||||
class MdApi :public CThostFtdcMdSpi
|
@ -20,9 +20,9 @@
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{3C13B49C-4A10-45A3-9FD5-4CB3A587EF8A}</ProjectGuid>
|
||||
<ProjectGuid>{C2D4F5C9-D5EC-4823-93AF-7275E840E579}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>vnsecmd</RootNamespace>
|
||||
<RootNamespace>vnsoptmd</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
@ -73,22 +73,22 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<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 Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<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 Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<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 Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<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>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@ -165,7 +165,7 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="vnsecmd.h" />
|
||||
<ClInclude Include="vnsoptmd.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
@ -175,7 +175,7 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="vnsecmd.cpp" />
|
||||
<ClCompile Include="vnsoptmd.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
@ -21,7 +21,7 @@
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="vnsecmd.h">
|
||||
<ClInclude Include="vnsoptmd.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
@ -29,7 +29,7 @@
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="vnsecmd.cpp">
|
||||
<ClCompile Include="vnsoptmd.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="dllmain.cpp">
|
@ -1,5 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include "vnsectd.h"
|
||||
#include "vnsopttd.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/////////////原生回调接口生成task
|
||||
@ -11686,7 +11686,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
PYBIND11_MODULE(vnsectd, m)
|
||||
PYBIND11_MODULE(vnsopttd, m)
|
||||
{
|
||||
class_<TdApi, PyTdApi> tdapi(m, "TdApi", module_local());
|
||||
tdapi
|
@ -136,7 +136,7 @@
|
||||
|
||||
#include "ThostFtdcTraderApi.h"
|
||||
#include "pybind11.h"
|
||||
#include "vnsec.h"
|
||||
#include "vnsopt.h"
|
||||
|
||||
using namespace pybind11;
|
||||
|
@ -20,9 +20,9 @@
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{4A6E7B14-A7CB-488E-BE1B-86E1A438E67D}</ProjectGuid>
|
||||
<ProjectGuid>{059048EC-18DC-4B7E-8A41-E2450619519F}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>vnsectd</RootNamespace>
|
||||
<RootNamespace>vnsopttd</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
@ -73,22 +73,22 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<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 Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<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 Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<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 Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<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>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@ -165,7 +165,7 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="vnsectd.h" />
|
||||
<ClInclude Include="vnsopttd.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
@ -175,7 +175,7 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="vnsectd.cpp" />
|
||||
<ClCompile Include="vnsopttd.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
@ -21,7 +21,7 @@
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="vnsectd.h">
|
||||
<ClInclude Include="vnsopttd.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
@ -29,7 +29,7 @@
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="vnsectd.cpp">
|
||||
<ClCompile Include="vnsopttd.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="dllmain.cpp">
|
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
from .sec_gateway import SecGateway
|
1
vnpy/gateway/sopt/__init__.py
Normal file
1
vnpy/gateway/sopt/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from .sopt_gateway import SoptGateway
|
@ -3,7 +3,7 @@
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from vnpy.api.sec import (
|
||||
from vnpy.api.sopt import (
|
||||
MdApi,
|
||||
TdApi,
|
||||
THOST_FTDC_OAS_Submitted,
|
||||
@ -62,7 +62,7 @@ from vnpy.trader.utility import get_folder_path
|
||||
from vnpy.trader.event import EVENT_TIMER
|
||||
|
||||
|
||||
STATUS_SEC2VT = {
|
||||
STATUS_SOPT2VT = {
|
||||
THOST_FTDC_OAS_Submitted: Status.SUBMITTING,
|
||||
THOST_FTDC_OAS_Accepted: Status.SUBMITTING,
|
||||
THOST_FTDC_OAS_Rejected: Status.REJECTED,
|
||||
@ -72,40 +72,40 @@ STATUS_SEC2VT = {
|
||||
THOST_FTDC_OST_Canceled: Status.CANCELLED
|
||||
}
|
||||
|
||||
DIRECTION_VT2SEC = {
|
||||
DIRECTION_VT2SOPT = {
|
||||
Direction.LONG: THOST_FTDC_D_Buy,
|
||||
Direction.SHORT: THOST_FTDC_D_Sell
|
||||
}
|
||||
DIRECTION_SEC2VT = {v: k for k, v in DIRECTION_VT2SEC.items()}
|
||||
DIRECTION_SEC2VT[THOST_FTDC_PD_Long] = Direction.LONG
|
||||
DIRECTION_SEC2VT[THOST_FTDC_PD_Short] = Direction.SHORT
|
||||
DIRECTION_SOPT2VT = {v: k for k, v in DIRECTION_VT2SOPT.items()}
|
||||
DIRECTION_SOPT2VT[THOST_FTDC_PD_Long] = Direction.LONG
|
||||
DIRECTION_SOPT2VT[THOST_FTDC_PD_Short] = Direction.SHORT
|
||||
|
||||
ORDERTYPE_VT2SEC = {
|
||||
ORDERTYPE_VT2SOPT = {
|
||||
OrderType.LIMIT: THOST_FTDC_OPT_LimitPrice,
|
||||
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.CLOSE: THOST_FTDC_OFEN_Close,
|
||||
Offset.CLOSETODAY: THOST_FTDC_OFEN_CloseToday,
|
||||
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,
|
||||
"SSE": Exchange.SSE
|
||||
}
|
||||
|
||||
PRODUCT_SEC2VT = {
|
||||
PRODUCT_SOPT2VT = {
|
||||
THOST_FTDC_PC_Stock: Product.EQUITY,
|
||||
THOST_FTDC_PC_ETFOption: Product.OPTION,
|
||||
THOST_FTDC_PC_Combination: Product.SPREAD
|
||||
}
|
||||
|
||||
OPTIONTYPE_SEC2VT = {
|
||||
OPTIONTYPE_SOPT2VT = {
|
||||
THOST_FTDC_CP_CallOptions: OptionType.CALL,
|
||||
THOST_FTDC_CP_PutOptions: OptionType.PUT
|
||||
}
|
||||
@ -116,9 +116,9 @@ symbol_name_map = {}
|
||||
symbol_size_map = {}
|
||||
|
||||
|
||||
class SecGateway(BaseGateway):
|
||||
class SoptGateway(BaseGateway):
|
||||
"""
|
||||
VN Trader Gateway for SEC .
|
||||
VN Trader Gateway for SOPT .
|
||||
"""
|
||||
|
||||
default_setting = {
|
||||
@ -132,14 +132,14 @@ class SecGateway(BaseGateway):
|
||||
"产品信息": ""
|
||||
}
|
||||
|
||||
exchanges = list(EXCHANGE_SEC2VT.values())
|
||||
exchanges = list(EXCHANGE_SOPT2VT.values())
|
||||
|
||||
def __init__(self, event_engine):
|
||||
"""Constructor"""
|
||||
super().__init__(event_engine, "SEC")
|
||||
super().__init__(event_engine, "SOPT")
|
||||
|
||||
self.td_api = SecTdApi(self)
|
||||
self.md_api = SecMdApi(self)
|
||||
self.td_api = SoptTdApi(self)
|
||||
self.md_api = SoptMdApi(self)
|
||||
|
||||
def connect(self, setting: dict):
|
||||
""""""
|
||||
@ -212,12 +212,12 @@ class SecGateway(BaseGateway):
|
||||
self.event_engine.register(EVENT_TIMER, self.process_timer_event)
|
||||
|
||||
|
||||
class SecMdApi(MdApi):
|
||||
class SoptMdApi(MdApi):
|
||||
""""""
|
||||
|
||||
def __init__(self, gateway):
|
||||
"""Constructor"""
|
||||
super(SecMdApi, self).__init__()
|
||||
super(SoptMdApi, self).__init__()
|
||||
|
||||
self.gateway = gateway
|
||||
self.gateway_name = gateway.gateway_name
|
||||
@ -352,12 +352,12 @@ class SecMdApi(MdApi):
|
||||
self.exit()
|
||||
|
||||
|
||||
class SecTdApi(TdApi):
|
||||
class SoptTdApi(TdApi):
|
||||
""""""
|
||||
|
||||
def __init__(self, gateway):
|
||||
"""Constructor"""
|
||||
super(SecTdApi, self).__init__()
|
||||
super(SoptTdApi, self).__init__()
|
||||
|
||||
self.test = []
|
||||
|
||||
@ -442,8 +442,8 @@ class SecTdApi(TdApi):
|
||||
symbol=symbol,
|
||||
exchange=exchange,
|
||||
orderid=orderid,
|
||||
direction=DIRECTION_SEC2VT[data["Direction"]],
|
||||
offset=OFFSET_SEC2VT[data["CombOffsetFlag"]],
|
||||
direction=DIRECTION_SOPT2VT[data["Direction"]],
|
||||
offset=OFFSET_SOPT2VT[data["CombOffsetFlag"]],
|
||||
price=data["LimitPrice"],
|
||||
volume=data["VolumeTotalOriginal"],
|
||||
status=Status.REJECTED,
|
||||
@ -482,7 +482,7 @@ class SecTdApi(TdApi):
|
||||
position = PositionData(
|
||||
symbol=data["InstrumentID"],
|
||||
exchange=symbol_exchange_map[data["InstrumentID"]],
|
||||
direction=DIRECTION_SEC2VT[data["PosiDirection"]],
|
||||
direction=DIRECTION_SOPT2VT[data["PosiDirection"]],
|
||||
gateway_name=self.gateway_name
|
||||
)
|
||||
self.positions[key] = position
|
||||
@ -538,12 +538,12 @@ class SecTdApi(TdApi):
|
||||
"""
|
||||
Callback of instrument query.
|
||||
"""
|
||||
product = PRODUCT_SEC2VT.get(data["ProductClass"], None)
|
||||
product = PRODUCT_SOPT2VT.get(data["ProductClass"], None)
|
||||
|
||||
if product:
|
||||
contract = ContractData(
|
||||
symbol=data["InstrumentID"],
|
||||
exchange=EXCHANGE_SEC2VT[data["ExchangeID"]],
|
||||
exchange=EXCHANGE_SOPT2VT[data["ExchangeID"]],
|
||||
name=data["InstrumentName"],
|
||||
product=product,
|
||||
size=data["VolumeMultiple"],
|
||||
@ -554,7 +554,7 @@ class SecTdApi(TdApi):
|
||||
# For option only
|
||||
if contract.product == Product.OPTION:
|
||||
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_expiry = datetime.strptime(data["ExpireDate"], "%Y%m%d"),
|
||||
|
||||
@ -594,13 +594,13 @@ class SecTdApi(TdApi):
|
||||
symbol=symbol,
|
||||
exchange=exchange,
|
||||
orderid=orderid,
|
||||
type=ORDERTYPE_SEC2VT[data["OrderPriceType"]],
|
||||
direction=DIRECTION_SEC2VT[data["Direction"]],
|
||||
offset=OFFSET_SEC2VT[data["CombOffsetFlag"]],
|
||||
type=ORDERTYPE_SOPT2VT[data["OrderPriceType"]],
|
||||
direction=DIRECTION_SOPT2VT[data["Direction"]],
|
||||
offset=OFFSET_SOPT2VT[data["CombOffsetFlag"]],
|
||||
price=data["LimitPrice"],
|
||||
volume=data["VolumeTotalOriginal"],
|
||||
traded=data["VolumeTraded"],
|
||||
status=STATUS_SEC2VT[data["OrderStatus"]],
|
||||
status=STATUS_SOPT2VT[data["OrderStatus"]],
|
||||
time=data["InsertTime"],
|
||||
gateway_name=self.gateway_name
|
||||
)
|
||||
@ -625,8 +625,8 @@ class SecTdApi(TdApi):
|
||||
exchange=exchange,
|
||||
orderid=orderid,
|
||||
tradeid=data["TradeID"],
|
||||
direction=DIRECTION_SEC2VT[data["Direction"]],
|
||||
offset=OFFSET_SEC2VT[data["OffsetFlag"]],
|
||||
direction=DIRECTION_SOPT2VT[data["Direction"]],
|
||||
offset=OFFSET_SOPT2VT[data["OffsetFlag"]],
|
||||
price=data["Price"],
|
||||
volume=data["Volume"],
|
||||
time=data["TradeTime"],
|
||||
@ -711,14 +711,14 @@ class SecTdApi(TdApi):
|
||||
"""
|
||||
self.order_ref += 1
|
||||
|
||||
sec_req = {
|
||||
sopt_req = {
|
||||
"InstrumentID": req.symbol,
|
||||
"ExchangeID": req.exchange.value,
|
||||
"LimitPrice": req.price,
|
||||
"VolumeTotalOriginal": int(req.volume),
|
||||
"OrderPriceType": ORDERTYPE_VT2SEC.get(req.type, ""),
|
||||
"Direction": DIRECTION_VT2SEC.get(req.direction, ""),
|
||||
"CombOffsetFlag": OFFSET_VT2SEC.get(req.offset, ""),
|
||||
"OrderPriceType": ORDERTYPE_VT2SOPT.get(req.type, ""),
|
||||
"Direction": DIRECTION_VT2SOPT.get(req.direction, ""),
|
||||
"CombOffsetFlag": OFFSET_VT2SOPT.get(req.offset, ""),
|
||||
"OrderRef": str(self.order_ref),
|
||||
"InvestorID": self.userid,
|
||||
"UserID": self.userid,
|
||||
@ -733,16 +733,16 @@ class SecTdApi(TdApi):
|
||||
}
|
||||
|
||||
if req.type == OrderType.FAK:
|
||||
sec_req["OrderPriceType"] = THOST_FTDC_OPT_LimitPrice
|
||||
sec_req["TimeCondition"] = THOST_FTDC_TC_IOC
|
||||
sec_req["VolumeCondition"] = THOST_FTDC_VC_AV
|
||||
sopt_req["OrderPriceType"] = THOST_FTDC_OPT_LimitPrice
|
||||
sopt_req["TimeCondition"] = THOST_FTDC_TC_IOC
|
||||
sopt_req["VolumeCondition"] = THOST_FTDC_VC_AV
|
||||
elif req.type == OrderType.FOK:
|
||||
sec_req["OrderPriceType"] = THOST_FTDC_OPT_LimitPrice
|
||||
sec_req["TimeCondition"] = THOST_FTDC_TC_IOC
|
||||
sec_req["VolumeCondition"] = THOST_FTDC_VC_CV
|
||||
sopt_req["OrderPriceType"] = THOST_FTDC_OPT_LimitPrice
|
||||
sopt_req["TimeCondition"] = THOST_FTDC_TC_IOC
|
||||
sopt_req["VolumeCondition"] = THOST_FTDC_VC_CV
|
||||
|
||||
self.reqid += 1
|
||||
self.reqOrderInsert(sec_req, self.reqid)
|
||||
self.reqOrderInsert(sopt_req, self.reqid)
|
||||
|
||||
orderid = f"{self.frontid}_{self.sessionid}_{self.order_ref}"
|
||||
order = req.create_order_data(orderid, self.gateway_name)
|
||||
@ -756,7 +756,7 @@ class SecTdApi(TdApi):
|
||||
"""
|
||||
frontid, sessionid, order_ref = req.orderid.split("_")
|
||||
|
||||
sec_req = {
|
||||
sopt_req = {
|
||||
"InstrumentID": req.symbol,
|
||||
"Exchange": req.exchange,
|
||||
"OrderRef": order_ref,
|
||||
@ -768,7 +768,7 @@ class SecTdApi(TdApi):
|
||||
}
|
||||
|
||||
self.reqid += 1
|
||||
self.reqOrderAction(sec_req, self.reqid)
|
||||
self.reqOrderAction(sopt_req, self.reqid)
|
||||
|
||||
def query_account(self):
|
||||
"""
|
Loading…
Reference in New Issue
Block a user