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-
317225InstrumentType 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-
415257PriceType 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