Skip to content

Commit d49bf29

Browse files
committed
通视接口基本功能
1 parent ed8e025 commit d49bf29

18 files changed

Lines changed: 622 additions & 682 deletions

QuantBox_Esunny_HistoricalData/HistoricalDataApi.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ int __cdecl CHistoricalDataApi::OnRspHistoryQuot(struct STKHISDATA *pHisData)
277277
BarField* pF = &pFields[i];
278278
//memset(pF, 0, sizeof(BarField));
279279
DateTimeChat2Int(item.time, pF->Date, pF->Time);
280-
pF->Open = round(item.fOpen);
281-
pF->High = round(item.fHigh);
280+
pF->Open = my_round(item.fOpen);
281+
pF->High = my_round(item.fHigh);
282282
pF->Low = item.fLow;
283283
pF->Close = item.fClose;
284284
pF->Volume = item.fVolume;
@@ -371,12 +371,6 @@ int CHistoricalDataApi::RtnEmptyRspQryHistoricalTicks()
371371
return 0;
372372
}
373373

374-
double my_round(float val, int x = 0)
375-
{
376-
double i = ((int)(val * 10000 + 0.5)) / 10000.0;
377-
return i;
378-
}
379-
380374
int __cdecl CHistoricalDataApi::OnRspTraceData(struct STKTRACEDATA *pTraceData)
381375
{
382376
m_timer_1 = 0;

QuantBox_Esunny_HistoricalData/QuantBox_Esunny_HistoricalData.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,13 @@
208208
</ItemGroup>
209209
<ItemGroup>
210210
<ClInclude Include="..\include\Esunny_HistoricalData\EsunnyQuot.h" />
211+
<ClInclude Include="..\include\toolkit.h" />
211212
<ClInclude Include="HistoricalDataApi.h" />
212213
<ClInclude Include="stdafx.h" />
213214
<ClInclude Include="targetver.h" />
214215
</ItemGroup>
215216
<ItemGroup>
217+
<ClCompile Include="..\include\toolkit.cpp" />
216218
<ClCompile Include="dllmain.cpp">
217219
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
218220
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>

QuantBox_Esunny_HistoricalData/QuantBox_Esunny_HistoricalData.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
<ClInclude Include="..\include\Esunny_HistoricalData\EsunnyQuot.h">
3434
<Filter>include</Filter>
3535
</ClInclude>
36+
<ClInclude Include="..\include\toolkit.h">
37+
<Filter>Header Files</Filter>
38+
</ClInclude>
3639
</ItemGroup>
3740
<ItemGroup>
3841
<ClCompile Include="stdafx.cpp">
@@ -47,5 +50,8 @@
4750
<ClCompile Include="main.cpp">
4851
<Filter>Source Files</Filter>
4952
</ClCompile>
53+
<ClCompile Include="..\include\toolkit.cpp">
54+
<Filter>Source Files</Filter>
55+
</ClCompile>
5056
</ItemGroup>
5157
</Project>

QuantBox_LTS_Trade/TypeConvert.cpp

Lines changed: 6 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <stdlib.h>
55

66
#include <string.h>
7+
8+
#include "../include/ChinaStock.h"
79
/// 类似于OpenQuant FIX一样的效果,插件层简单,基本不要做怎么计算或处理
810
/// 对于一个单子的某个状态可能是这样的,新单,部分成交,完全成交
911
/// EmitAccept,EmitFill
@@ -220,100 +222,6 @@ PutCall CSecurityFtdcInstrumentField_2_PutCall(CSecurityFtdcInstrumentField* pIn
220222
return PutCall::Put;
221223
}
222224

223-
// 上海证券交易所证券代码分配规则
224-
// http://wenku.baidu.com/link?url=fhnAW62VTXqHTn8p9xlyXKa_oDIfR2xIxBF3y_fryeoFnz7MFbeWJbMLx4n1H61ERFnhr6PtaxF_j01x8iIT0wArZzrBtABRysi-KEpBa9S
225-
InstrumentType CSecurityFtdcInstrumentField_2_InstrumentType_SSE(CSecurityFtdcInstrumentField* pIn)
226-
{
227-
// 只有6位,8位的期权已经提前过滤
228-
int prefix1 = atoi(pIn->InstrumentID) / 100000;
229-
int prefix3 = atoi(pIn->InstrumentID) / 1000;
230-
switch (prefix1)
231-
{
232-
case 0:
233-
switch (prefix3)
234-
{
235-
case 0:
236-
return InstrumentType::Index;
237-
case 9:
238-
case 10:
239-
case 90:
240-
case 99:
241-
return InstrumentType::Bond;
242-
default:
243-
return InstrumentType::Index;
244-
}
245-
case 1:
246-
return InstrumentType::Bond;
247-
case 2:
248-
return InstrumentType::Bond;
249-
case 3:
250-
return InstrumentType::Future;
251-
case 5:
252-
switch (prefix3)
253-
{
254-
case 500:
255-
case 510:
256-
case 519:
257-
case 521:
258-
case 522:
259-
case 523:
260-
case 524:
261-
return InstrumentType::ETF;
262-
case 580:
263-
case 582:
264-
return InstrumentType::Option;
265-
default:
266-
return InstrumentType::ETF;
267-
}
268-
case 6:
269-
return InstrumentType::Stock;
270-
case 9:
271-
return InstrumentType::Stock;
272-
default:
273-
return InstrumentType::Synthetic;
274-
}
275-
}
276-
277-
// 深圳证券交易所证券代码编码方案
278-
// http://wenku.baidu.com/view/e41fba85ec3a87c24028c416.html
279-
InstrumentType CSecurityFtdcInstrumentField_2_InstrumentType_SZE(CSecurityFtdcInstrumentField* pIn)
280-
{
281-
// 只有6位,取前2
282-
int prefix1 = atoi(pIn->InstrumentID) / 100000;
283-
int prefix2 = atoi(pIn->InstrumentID) / 10000;
284-
switch (prefix2)
285-
{
286-
case 0:
287-
case 7:
288-
case 9:
289-
return InstrumentType::Stock;
290-
case 3:
291-
case 8:
292-
return InstrumentType::Option;
293-
case 10:
294-
case 11:
295-
case 12:
296-
case 13:
297-
return InstrumentType::Bond;
298-
case 17:
299-
case 18:
300-
return InstrumentType::ETF;
301-
case 20:
302-
case 30:
303-
return InstrumentType::Stock;
304-
case 27:
305-
case 37:
306-
return InstrumentType::Stock;
307-
case 28:
308-
case 38:
309-
return InstrumentType::Option;
310-
case 39:
311-
return InstrumentType::Index;
312-
default:
313-
return InstrumentType::Synthetic;
314-
}
315-
}
316-
317225
InstrumentType CSecurityFtdcInstrumentField_2_InstrumentType(CSecurityFtdcInstrumentField* pIn)
318226
{
319227
switch (pIn->ProductClass)
@@ -337,81 +245,15 @@ InstrumentType CSecurityFtdcInstrumentField_2_InstrumentType(CSecurityFtdcInstru
337245
}
338246
if (pIn->ExchangeID[1] == 'Z')
339247
{
340-
return CSecurityFtdcInstrumentField_2_InstrumentType_SZE(pIn);
248+
return InstrumentID_2_InstrumentType_SZE(pIn->InstrumentID);
341249
}
342250
else
343251
{
344-
return CSecurityFtdcInstrumentField_2_InstrumentType_SSE(pIn);
252+
return InstrumentID_2_InstrumentType_SSE(pIn->InstrumentID);
345253
}
346254
}
347255
}
348256

349-
PriceType CSecurityFtdcInstrumentField_2_PriceTick_SSE(CSecurityFtdcInstrumentField* pIn)
350-
{
351-
// 只有6位,8位的期权已经提前过滤
352-
int prefix1 = atoi(pIn->InstrumentID) / 100000;
353-
int prefix3 = atoi(pIn->InstrumentID) / 1000;
354-
switch (prefix1)
355-
{
356-
case 0:
357-
return 0.01;
358-
case 1:
359-
return 0.01;
360-
case 2:
361-
return 0.001;
362-
case 3:
363-
return 0.01;
364-
case 5:
365-
return 0.001;
366-
case 6:
367-
return 0.01;
368-
case 9:
369-
return 0.001;
370-
default:
371-
return 0.01;
372-
}
373-
374-
return 0.01;
375-
}
376-
377-
PriceType CSecurityFtdcInstrumentField_2_PriceTick_SZE(CSecurityFtdcInstrumentField* pIn)
378-
{
379-
// 只有6位,取前2
380-
int prefix1 = atoi(pIn->InstrumentID) / 100000;
381-
int prefix2 = atoi(pIn->InstrumentID) / 10000;
382-
switch (prefix2)
383-
{
384-
case 0:
385-
case 7:
386-
case 9:
387-
return 0.01;
388-
case 3:
389-
case 8:
390-
return 0.001;
391-
case 10:
392-
case 11:
393-
case 12:
394-
case 13:
395-
return 0.001;
396-
case 17:
397-
case 18:
398-
return 0.001;
399-
case 20:
400-
case 30:
401-
return 0.01;
402-
case 27:
403-
case 37:
404-
return 0.01;
405-
case 28:
406-
case 38:
407-
return 0.001;
408-
case 39:
409-
return 0.01;
410-
default:
411-
return 0.01;
412-
}
413-
}
414-
415257
PriceType CSecurityFtdcInstrumentField_2_PriceTick(CSecurityFtdcInstrumentField* pIn)
416258
{
417259
if (pIn->PriceTick != 0)
@@ -425,11 +267,11 @@ PriceType CSecurityFtdcInstrumentField_2_PriceTick(CSecurityFtdcInstrumentField*
425267

426268
if (pIn->ExchangeID[1] == 'Z')
427269
{
428-
return CSecurityFtdcInstrumentField_2_PriceTick_SZE(pIn);
270+
return InstrumentID_2_PriceTick_SZE(pIn->InstrumentID);
429271
}
430272
else
431273
{
432-
return CSecurityFtdcInstrumentField_2_PriceTick_SSE(pIn);
274+
return InstrumentID_2_PriceTick_SSE(pIn->InstrumentID);
433275
}
434276
}
435277

0 commit comments

Comments
 (0)