Skip to content

Commit 66ef15a

Browse files
committed
接口由五档行情升级为N档行情
1 parent 3e30dc0 commit 66ef15a

52 files changed

Lines changed: 843 additions & 390 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

QuantBox_CTP_Quote/MdUserApi.cpp

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "../include/ApiStruct.h"
77

88
#include "../include/toolkit.h"
9+
#include "../include/ApiProcess.h"
910
#include "../QuantBox_CTP_Trade/TypeConvert.h"
1011

1112
#include "../QuantBox_Queue/MsgQueue.h"
@@ -492,7 +493,7 @@ void CMdUserApi::OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMark
492493
// // 测试平台穿越速度,用完后需要注释掉
493494
// WriteLog("CTP:OnRtnDepthMarketData:%s %f %s.%03d", pDepthMarketData->InstrumentID, pDepthMarketData->LastPrice, pDepthMarketData->UpdateTime, pDepthMarketData->UpdateMillisec);
494495

495-
DepthMarketDataField* pField = (DepthMarketDataField*)m_msgQueue->new_block(sizeof(DepthMarketDataField));
496+
DepthMarketDataNField* pField = (DepthMarketDataNField*)m_msgQueue->new_block(sizeof(DepthMarketDataNField)+sizeof(DepthField)* 10);
496497

497498
strcpy(pField->InstrumentID, pDepthMarketData->InstrumentID);
498499
pField->Exchange = TThostFtdcExchangeIDType_2_ExchangeType(pDepthMarketData->ExchangeID);
@@ -548,60 +549,52 @@ void CMdUserApi::OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMark
548549
pField->PreSettlementPrice = pDepthMarketData->PreSettlementPrice;
549550
pField->PreOpenInterest = pDepthMarketData->PreOpenInterest;
550551

552+
InitBidAsk(pField);
553+
551554
do
552555
{
553556
if (pDepthMarketData->BidVolume1 == 0)
554557
break;
555-
pField->BidPrice1 = pDepthMarketData->BidPrice1;
556-
pField->BidVolume1 = pDepthMarketData->BidVolume1;
558+
AddBid(pField, pDepthMarketData->BidPrice1, pDepthMarketData->BidVolume1, 0);
557559

558560
if (pDepthMarketData->BidVolume2 == 0)
559561
break;
560-
pField->BidPrice2 = pDepthMarketData->BidPrice2;
561-
pField->BidVolume2 = pDepthMarketData->BidVolume2;
562+
AddBid(pField, pDepthMarketData->BidPrice2, pDepthMarketData->BidVolume2, 0);
562563

563564
if (pDepthMarketData->BidVolume3 == 0)
564565
break;
565-
pField->BidPrice3 = pDepthMarketData->BidPrice3;
566-
pField->BidVolume3 = pDepthMarketData->BidVolume3;
566+
AddBid(pField, pDepthMarketData->BidPrice3, pDepthMarketData->BidVolume3, 0);
567567

568568
if (pDepthMarketData->BidVolume4 == 0)
569569
break;
570-
pField->BidPrice4 = pDepthMarketData->BidPrice4;
571-
pField->BidVolume4 = pDepthMarketData->BidVolume4;
570+
AddBid(pField, pDepthMarketData->BidPrice4, pDepthMarketData->BidVolume4, 0);
572571

573572
if (pDepthMarketData->BidVolume5 == 0)
574573
break;
575-
pField->BidPrice5 = pDepthMarketData->BidPrice5;
576-
pField->BidVolume5 = pDepthMarketData->BidVolume5;
574+
AddBid(pField, pDepthMarketData->BidPrice5, pDepthMarketData->BidVolume5, 0);
577575
} while (false);
578576

579577
do
580578
{
581579
if (pDepthMarketData->AskVolume1 == 0)
582580
break;
583-
pField->AskPrice1 = pDepthMarketData->AskPrice1;
584-
pField->AskVolume1 = pDepthMarketData->AskVolume1;
581+
AddAsk(pField, pDepthMarketData->AskPrice1, pDepthMarketData->AskVolume1, 0);
585582

586583
if (pDepthMarketData->AskVolume2 == 0)
587584
break;
588-
pField->AskPrice2 = pDepthMarketData->AskPrice2;
589-
pField->AskVolume2 = pDepthMarketData->AskVolume2;
585+
AddAsk(pField, pDepthMarketData->AskPrice2, pDepthMarketData->AskVolume2, 0);
590586

591587
if (pDepthMarketData->AskVolume3 == 0)
592588
break;
593-
pField->AskPrice3 = pDepthMarketData->AskPrice3;
594-
pField->AskVolume3 = pDepthMarketData->AskVolume3;
589+
AddAsk(pField, pDepthMarketData->AskPrice3, pDepthMarketData->AskVolume3, 0);
595590

596591
if (pDepthMarketData->AskVolume4 == 0)
597592
break;
598-
pField->AskPrice4 = pDepthMarketData->AskPrice4;
599-
pField->AskVolume4 = pDepthMarketData->AskVolume4;
593+
AddAsk(pField, pDepthMarketData->AskPrice4, pDepthMarketData->AskVolume4, 0);
600594

601595
if (pDepthMarketData->AskVolume5 == 0)
602596
break;
603-
pField->AskPrice5 = pDepthMarketData->AskPrice5;
604-
pField->AskVolume5 = pDepthMarketData->AskVolume5;
597+
AddAsk(pField, pDepthMarketData->AskPrice5, pDepthMarketData->AskVolume5, 0);
605598
} while (false);
606599

607600
// 这两个队列先头循序不要搞混,有删除功能的语句要放在后面
@@ -613,7 +606,7 @@ void CMdUserApi::OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMark
613606
}
614607
#endif
615608

616-
m_msgQueue->Input_NoCopy(ResponeType::OnRtnDepthMarketData, m_msgQueue, m_pClass, 0, 0, pField, sizeof(DepthMarketDataField), nullptr, 0, nullptr, 0);
609+
m_msgQueue->Input_NoCopy(ResponeType::OnRtnDepthMarketData, m_msgQueue, m_pClass, DepthLevelType::FULL, 0, pField, pField->Size, nullptr, 0, nullptr, 0);
617610
// 要关注一下其内的
618611
//}
619612
}

QuantBox_CTP_Quote/QuantBox_CTP_Quote.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<PropertyGroup Label="UserMacros" />
9595
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
9696
<LinkIncremental>true</LinkIncremental>
97+
<OutDir>C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\CTP\x86</OutDir>
9798
</PropertyGroup>
9899
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
99100
<LinkIncremental>true</LinkIncremental>
@@ -214,13 +215,15 @@ xcopy "$(SolutionDir)include\CTP\win32\*.dll" "$(SolutionDir)XAPI\CTP\x86\" /Y<
214215
<Text Include="ReadMe.txt" />
215216
</ItemGroup>
216217
<ItemGroup>
218+
<ClInclude Include="..\include\ApiProcess.h" />
217219
<ClInclude Include="..\include\toolkit.h" />
218220
<ClInclude Include="..\QuantBox_CTP_Trade\TypeConvert.h" />
219221
<ClInclude Include="MdUserApi.h" />
220222
<ClInclude Include="stdafx.h" />
221223
<ClInclude Include="targetver.h" />
222224
</ItemGroup>
223225
<ItemGroup>
226+
<ClCompile Include="..\include\ApiProcess.cpp" />
224227
<ClCompile Include="..\include\toolkit.cpp">
225228
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
226229
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Use</PrecompiledHeader>

QuantBox_CTP_Quote/QuantBox_CTP_Quote.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
<ClInclude Include="..\QuantBox_CTP_Trade\TypeConvert.h">
3434
<Filter>Header Files</Filter>
3535
</ClInclude>
36+
<ClInclude Include="..\include\ApiProcess.h">
37+
<Filter>Header Files</Filter>
38+
</ClInclude>
3639
</ItemGroup>
3740
<ItemGroup>
3841
<ClCompile Include="stdafx.cpp">
@@ -53,5 +56,8 @@
5356
<ClCompile Include="..\QuantBox_CTP_Trade\TypeConvert.cpp">
5457
<Filter>Source Files</Filter>
5558
</ClCompile>
59+
<ClCompile Include="..\include\ApiProcess.cpp">
60+
<Filter>Source Files</Filter>
61+
</ClCompile>
5662
</ItemGroup>
5763
</Project>

QuantBox_CTP_Trade/QuantBox_CTP_Trade.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<PropertyGroup Label="UserMacros" />
9595
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
9696
<LinkIncremental>true</LinkIncremental>
97+
<OutDir>C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\CTP\x86</OutDir>
9798
</PropertyGroup>
9899
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
99100
<LinkIncremental>true</LinkIncremental>

QuantBox_Femas_Quote/MdUserApi.cpp

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "../include/ApiStruct.h"
88

99
#include "../include/toolkit.h"
10+
#include "../include/ApiProcess.h"
1011

1112
#include "../QuantBox_Queue/MsgQueue.h"
1213

@@ -383,7 +384,7 @@ void CMdUserApi::OnRspUnSubMarketData(CUstpFtdcSpecificInstrumentField *pSpecifi
383384
//行情回调,得保证此函数尽快返回
384385
void CMdUserApi::OnRtnDepthMarketData(CUstpFtdcDepthMarketDataField *pDepthMarketData)
385386
{
386-
DepthMarketDataField* pField = (DepthMarketDataField*)m_msgQueue->new_block(sizeof(DepthMarketDataField));
387+
DepthMarketDataNField* pField = (DepthMarketDataNField*)m_msgQueue->new_block(sizeof(DepthMarketDataNField)+sizeof(DepthField)* 10);
387388

388389
strcpy(pField->InstrumentID, pDepthMarketData->InstrumentID);
389390
//strcpy(pField->ExchangeID, pDepthMarketData->ExchangeID);
@@ -413,61 +414,53 @@ void CMdUserApi::OnRtnDepthMarketData(CUstpFtdcDepthMarketDataField *pDepthMarke
413414
pField->PreSettlementPrice = pDepthMarketData->PreSettlementPrice;
414415
pField->PreOpenInterest = pDepthMarketData->PreOpenInterest;
415416

417+
InitBidAsk(pField);
418+
416419
do
417420
{
418421
if (pDepthMarketData->BidVolume1 == 0)
419422
break;
420-
pField->BidPrice1 = pDepthMarketData->BidPrice1;
421-
pField->BidVolume1 = pDepthMarketData->BidVolume1;
423+
AddBid(pField, pDepthMarketData->BidPrice1, pDepthMarketData->BidVolume1, 0);
422424

423425
if (pDepthMarketData->BidVolume2 == 0)
424426
break;
425-
pField->BidPrice2 = pDepthMarketData->BidPrice2;
426-
pField->BidVolume2 = pDepthMarketData->BidVolume2;
427+
AddBid(pField, pDepthMarketData->BidPrice2, pDepthMarketData->BidVolume2, 0);
427428

428429
if (pDepthMarketData->BidVolume3 == 0)
429430
break;
430-
pField->BidPrice3 = pDepthMarketData->BidPrice3;
431-
pField->BidVolume3 = pDepthMarketData->BidVolume3;
431+
AddBid(pField, pDepthMarketData->BidPrice3, pDepthMarketData->BidVolume3, 0);
432432

433433
if (pDepthMarketData->BidVolume4 == 0)
434434
break;
435-
pField->BidPrice4 = pDepthMarketData->BidPrice4;
436-
pField->BidVolume4 = pDepthMarketData->BidVolume4;
435+
AddBid(pField, pDepthMarketData->BidPrice4, pDepthMarketData->BidVolume4, 0);
437436

438437
if (pDepthMarketData->BidVolume5 == 0)
439438
break;
440-
pField->BidPrice5 = pDepthMarketData->BidPrice5;
441-
pField->BidVolume5 = pDepthMarketData->BidVolume5;
439+
AddBid(pField, pDepthMarketData->BidPrice5, pDepthMarketData->BidVolume5, 0);
442440
} while (false);
443441

444442
do
445443
{
446444
if (pDepthMarketData->AskVolume1 == 0)
447445
break;
448-
pField->AskPrice1 = pDepthMarketData->AskPrice1;
449-
pField->AskVolume1 = pDepthMarketData->AskVolume1;
446+
AddAsk(pField, pDepthMarketData->AskPrice1, pDepthMarketData->AskVolume1, 0);
450447

451448
if (pDepthMarketData->AskVolume2 == 0)
452449
break;
453-
pField->AskPrice2 = pDepthMarketData->AskPrice2;
454-
pField->AskVolume2 = pDepthMarketData->AskVolume2;
450+
AddAsk(pField, pDepthMarketData->AskPrice2, pDepthMarketData->AskVolume2, 0);
455451

456452
if (pDepthMarketData->AskVolume3 == 0)
457453
break;
458-
pField->AskPrice3 = pDepthMarketData->AskPrice3;
459-
pField->AskVolume3 = pDepthMarketData->AskVolume3;
454+
AddAsk(pField, pDepthMarketData->AskPrice3, pDepthMarketData->AskVolume3, 0);
460455

461456
if (pDepthMarketData->AskVolume4 == 0)
462457
break;
463-
pField->AskPrice4 = pDepthMarketData->AskPrice4;
464-
pField->AskVolume4 = pDepthMarketData->AskVolume4;
458+
AddAsk(pField, pDepthMarketData->AskPrice4, pDepthMarketData->AskVolume4, 0);
465459

466460
if (pDepthMarketData->AskVolume5 == 0)
467461
break;
468-
pField->AskPrice5 = pDepthMarketData->AskPrice5;
469-
pField->AskVolume5 = pDepthMarketData->AskVolume5;
462+
AddAsk(pField, pDepthMarketData->AskPrice5, pDepthMarketData->AskVolume5, 0);
470463
} while (false);
471464

472-
m_msgQueue->Input_NoCopy(ResponeType::OnRtnDepthMarketData, m_msgQueue, m_pClass, 0, 0, pField, sizeof(DepthMarketDataField), nullptr, 0, nullptr, 0);
465+
m_msgQueue->Input_NoCopy(ResponeType::OnRtnDepthMarketData, m_msgQueue, m_pClass, DepthLevelType::FULL, 0, pField, pField->Size, nullptr, 0, nullptr, 0);
473466
}

QuantBox_Femas_Quote/QuantBox_Femas_Quote.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,14 @@ xcopy "$(SolutionDir)include\Femas\win32\*.dll" "$(SolutionDir)XAPI\Femas\x86\"
210210
<Text Include="ReadMe.txt" />
211211
</ItemGroup>
212212
<ItemGroup>
213+
<ClInclude Include="..\include\ApiProcess.h" />
213214
<ClInclude Include="..\include\toolkit.h" />
214215
<ClInclude Include="MdUserApi.h" />
215216
<ClInclude Include="stdafx.h" />
216217
<ClInclude Include="targetver.h" />
217218
</ItemGroup>
218219
<ItemGroup>
220+
<ClCompile Include="..\include\ApiProcess.cpp" />
219221
<ClCompile Include="..\include\toolkit.cpp" />
220222
<ClCompile Include="dllmain.cpp">
221223
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>

QuantBox_Femas_Quote/QuantBox_Femas_Quote.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
<ClInclude Include="..\include\toolkit.h">
3131
<Filter>Header Files</Filter>
3232
</ClInclude>
33+
<ClInclude Include="..\include\ApiProcess.h">
34+
<Filter>Header Files</Filter>
35+
</ClInclude>
3336
</ItemGroup>
3437
<ItemGroup>
3538
<ClCompile Include="stdafx.cpp">
@@ -47,5 +50,8 @@
4750
<ClCompile Include="..\include\toolkit.cpp">
4851
<Filter>Source Files</Filter>
4952
</ClCompile>
53+
<ClCompile Include="..\include\ApiProcess.cpp">
54+
<Filter>Source Files</Filter>
55+
</ClCompile>
5056
</ItemGroup>
5157
</Project>

QuantBox_KingstarGold/QuantBox_KingstarGold.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,15 @@ xcopy "$(SolutionDir)include\Kingstar_Gold\win32\*.dll" "$(SolutionDir)XAPI\Kin
210210
<Text Include="ReadMe.txt" />
211211
</ItemGroup>
212212
<ItemGroup>
213+
<ClInclude Include="..\include\ApiProcess.h" />
213214
<ClInclude Include="..\include\toolkit.h" />
214215
<ClInclude Include="stdafx.h" />
215216
<ClInclude Include="targetver.h" />
216217
<ClInclude Include="TraderApi.h" />
217218
<ClInclude Include="TypeConvert.h" />
218219
</ItemGroup>
219220
<ItemGroup>
221+
<ClCompile Include="..\include\ApiProcess.cpp" />
220222
<ClCompile Include="..\include\toolkit.cpp" />
221223
<ClCompile Include="dllmain.cpp">
222224
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>

QuantBox_KingstarGold/QuantBox_KingstarGold.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
<ClInclude Include="..\include\toolkit.h">
3434
<Filter>Header Files</Filter>
3535
</ClInclude>
36+
<ClInclude Include="..\include\ApiProcess.h">
37+
<Filter>Header Files</Filter>
38+
</ClInclude>
3639
</ItemGroup>
3740
<ItemGroup>
3841
<ClCompile Include="stdafx.cpp">
@@ -53,5 +56,8 @@
5356
<ClCompile Include="..\include\toolkit.cpp">
5457
<Filter>Source Files</Filter>
5558
</ClCompile>
59+
<ClCompile Include="..\include\ApiProcess.cpp">
60+
<Filter>Source Files</Filter>
61+
</ClCompile>
5662
</ItemGroup>
5763
</Project>

0 commit comments

Comments
 (0)