Skip to content

Commit 85fc6c6

Browse files
committed
Conflicts: QuantBox_TongShi_Quote/stdafx.h
2 parents b749cd0 + 054867c commit 85fc6c6

47 files changed

Lines changed: 1041 additions & 439 deletions

Some content is hidden

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

QuantBox.XAPI/Callback/XApi.MarketData.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ public DelegateOnRtnDepthMarketData OnRtnDepthMarketData
1818
}
1919
// 这种写法的主要目的是求快
2020
private DelegateOnRtnDepthMarketData OnRtnDepthMarketData_;
21+
22+
public DelegateOnFilterSubscribe OnFilterSubscribe
23+
{
24+
get { return OnFilterSubscribe_; }
25+
set { OnFilterSubscribe_ = value; }
26+
}
27+
// 这种写法的主要目的是求快
28+
private DelegateOnFilterSubscribe OnFilterSubscribe_;
2129

2230

2331
#region 已经订阅的行情
@@ -130,5 +138,13 @@ private void _OnRtnDepthMarketData(IntPtr ptr1)
130138

131139
OnRtnDepthMarketData_(this, ref obj);
132140
}
141+
142+
private bool _OnFilterSubscribe(double double1, int size1, int size2, int size3, IntPtr ptr1)
143+
{
144+
if (OnFilterSubscribe_ == null)
145+
return true;
146+
147+
return OnFilterSubscribe_(this, (ExchangeType)double1, size1, size2, size3, ptr1);
148+
}
133149
}
134150
}

QuantBox.XAPI/Callback/XApi.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ protected override IntPtr OnRespone(byte type, IntPtr pApi1, IntPtr pApi2, doubl
8888
case ResponeType.OnRspQryHistoricalBars:
8989
_OnRspQryHistoricalBars(ptr1, size1, ptr2, size2, double1);
9090
break;
91-
91+
case ResponeType.OnFilterSubscribe:
92+
if(_OnFilterSubscribe(double1, size1, size2, size3, ptr1))
93+
{
94+
return new IntPtr(1);
95+
}
96+
return IntPtr.Zero;
9297
default:
9398
base.OnRespone(type, pApi1, pApi2, double1, double2, ptr1, size1, ptr2, size2, ptr3, size3);
9499
break;

QuantBox.XAPI/Delegate.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ namespace QuantBox.XAPI
2424

2525
public delegate void DelegateOnRspQryHistoricalTicks(object sender, IntPtr pTicks, int size1, [In] ref HistoricalDataRequestField request, int size2, bool bIsLast);
2626
public delegate void DelegateOnRspQryHistoricalBars(object sender, IntPtr pBars, int size1, [In] ref HistoricalDataRequestField request, int size2, bool bIsLast);
27+
28+
public delegate bool DelegateOnFilterSubscribe(object sender, ExchangeType exchange, int instrument_part1, int instrument_part2, int instrument_part3, IntPtr pInstrument);
2729
}

QuantBox.XAPI/Enum.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,18 @@ public enum IdCardType : byte
256256
AccountsPermits,
257257
OtherCard,
258258
};
259+
260+
public enum ExchangeType : byte
261+
{
262+
Undefined,
263+
SHFE, // 上期所
264+
DCE, // 大商所
265+
CZCE, // 郑商所
266+
CFFEX, // 中金所
267+
INE, // 能源中心
268+
SSE, // 上交所
269+
SZE, // 深交所
270+
NEEQ, // 全国中小企业股份转让系统
271+
HKEx,
272+
};
259273
}

QuantBox.XAPI/Extensions.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,41 @@ public static string InvestorName([In]this RspUserLoginField field)
5151
}
5252
}
5353

54+
/*
55+
SHFE
56+
TradeDay: 交易日
57+
ActionDay: 行情日
58+
59+
DCE
60+
TradeDay: 交易日
61+
ActionDay: 交易日
62+
63+
CZC
64+
TradeDay: 行情日
65+
ActionDay:行情日
66+
*/
5467
public static class Extensions_Misc
5568
{
5669
public static DateTime ExchangeDateTime([In]this DepthMarketDataField field)
5770
{
58-
int yyyy = field.ActionDay / 10000;
59-
int MM = field.ActionDay % 10000 / 100;
60-
int dd = field.ActionDay % 100;
61-
71+
// 大商所夜盘时,ActionDay可能已经是指向的第二天
6272
int HH = field.UpdateTime / 10000;
73+
74+
if (HH > 20)
75+
{
76+
if (field.ExchangeID.CompareTo("DCE") == 0)
77+
{
78+
return field.ExchangeDateTime_();
79+
}
80+
}
81+
6382
int mm = field.UpdateTime % 10000 / 100;
6483
int ss = field.UpdateTime % 100;
6584

85+
int yyyy = field.ActionDay / 10000;
86+
int MM = field.ActionDay % 10000 / 100;
87+
int dd = field.ActionDay % 100;
88+
6689
return new DateTime(yyyy, MM, dd, HH, mm, ss, field.UpdateMillisec);
6790
}
6891

QuantBox.XAPI/Program.cs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,37 @@ static void OnRtnTrade(object sender, ref TradeField trade)
6060
Console.WriteLine("CC " + trade.Time + "CC " + trade.ID + "CC " + trade.TradeID);
6161
}
6262

63+
static bool OnFilterSubscribe(object sender, ExchangeType exchange, int instrument_part1, int instrument_part2, int instrument_part3, IntPtr pInstrument)
64+
{
65+
// 当数字为0时,只判断交易所
66+
// 当交易所为
67+
if (instrument_part1 == 0)
68+
// 只要上海与深圳,不处理三板
69+
return exchange != ExchangeType.NEEQ;
70+
71+
//type = ExchangeType::SZE;
72+
//double1 = 399300;
73+
74+
int prefix1 = instrument_part1 / 100000;
75+
int prefix3 = instrument_part1 / 1000;
76+
switch (exchange)
77+
{
78+
case ExchangeType.SSE:
79+
return (prefix1 == 6);
80+
case ExchangeType.SZE:
81+
return (prefix1 == 0) || (prefix3 == 300);
82+
default:
83+
break;
84+
}
85+
86+
return true;
87+
}
88+
6389
static void Main(string[] args)
6490
{
6591
//for (int i = 0; i < 10000; ++i)
6692
{
67-
test_CTP_Main(args);
93+
test_TongShi_Main(args);
6894
}
6995
Console.ReadKey();
7096
}
@@ -158,6 +184,28 @@ static void test_LTS_Main(string[] args)
158184

159185
static XApi api;
160186

187+
static void test_TongShi_Main(string[] args)
188+
{
189+
190+
api = new XApi(@"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\TongShi\x86\QuantBox_TongShi_Quote.dll");
191+
192+
api.Server.Address = "D:\\Scengine\\Stock.dll";
193+
194+
api.OnConnectionStatus = OnConnectionStatus;
195+
api.OnRtnDepthMarketData = OnRtnDepthMarketData;
196+
api.OnFilterSubscribe = OnFilterSubscribe;
197+
198+
api.Connect();
199+
Thread.Sleep(10 * 1000);
200+
api.ReqQryInstrument("", "");
201+
202+
Thread.Sleep(300 * 1000);
203+
204+
api.Dispose();
205+
206+
Thread.Sleep(5 * 1000);
207+
}
208+
161209
static void test_CTP_Main(string[] args)
162210
{
163211
//api = new XApi(@"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\CTP\x86\QuantBox_CTP_Quote.dll");

QuantBox.XAPI/Proxy.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
namespace QuantBox.XAPI
88
{
99
public delegate IntPtr XCall(byte type, IntPtr pApi1, IntPtr pApi2, double double1, double double2, IntPtr ptr1, int size1, IntPtr ptr2, int size2, IntPtr ptr3, int size3);
10-
1110
public class Proxy
1211
{
1312
private InvokeBase _Invoke;

QuantBox.XAPI/RequestType.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,5 @@ public enum RequestType:byte
4848
ReqQryHistoricalTicks,
4949
ReqQryHistoricalBars,
5050
ReqQryInvestor,
51-
5251
}
5352
}

QuantBox.XAPI/ResponeType.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ public enum ResponeType : byte
2323
OnRspQryHistoricalTicks,
2424
OnRspQryHistoricalBars,
2525
OnRspQryInvestor,
26+
27+
OnFilterSubscribe,
2628
}
2729
}

QuantBox_CTP_Quote/MdUserApi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ void CMdUserApi::OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMark
503503

504504
pField->UpdateMillisec = pDepthMarketData->UpdateMillisec;
505505

506-
pField->LastPrice = pDepthMarketData->LastPrice;
506+
pField->LastPrice = pDepthMarketData->LastPrice == DBL_MAX ? 0 : pDepthMarketData->LastPrice;
507507
pField->Volume = pDepthMarketData->Volume;
508508
pField->Turnover = pDepthMarketData->Turnover;
509509
pField->OpenInterest = pDepthMarketData->OpenInterest;

0 commit comments

Comments
 (0)