forked from QuantBox/QuantBox_XAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXApi.cs
105 lines (94 loc) · 3.44 KB
/
XApi.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using QuantBox.XAPI.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace QuantBox.XAPI.Callback
{
public partial class XApi : BaseApi, IDisposable, IXApi
{
public XApi(string path)
: base(path)
{
}
public XApi()
: base()
{
}
public override void Connect()
{
base.Connect();
lock (locker)
{
foreach (var kv in _SubscribedInstruments)
{
foreach (var kvv in kv.Value.ToList())
{
Subscribe(kvv, kv.Key);
}
}
// 做市商询价
foreach (var kv in _SubscribedQuotes)
{
foreach (var kvv in kv.Value.ToList())
{
SubscribeQuote(kvv, kv.Key);
}
}
}
}
protected override IntPtr OnRespone(byte type, IntPtr pApi1, IntPtr pApi2, double double1, double double2, IntPtr ptr1, int size1, IntPtr ptr2, int size2, IntPtr ptr3, int size3)
{
switch ((ResponeType)type)
{
case ResponeType.OnRspQryInstrument:
_OnRspQryInstrument(ptr1, size1, double1);
break;
case ResponeType.OnRspQryTradingAccount:
_OnRspQryTradingAccount(ptr1, size1, double1);
break;
case ResponeType.OnRspQryInvestorPosition:
_OnRspQryInvestorPosition(ptr1, size1, double1);
break;
case ResponeType.OnRspQrySettlementInfo:
_OnRspQrySettlementInfo(ptr1, size1, double1);
break;
case ResponeType.OnRspQryInvestor:
_OnRspQryInvestor(ptr1, size1, double1);
break;
case ResponeType.OnRtnOrder:
_OnRtnOrder(ptr1, size1);
break;
case ResponeType.OnRtnTrade:
_OnRtnTrade(ptr1, size1);
break;
case ResponeType.OnRtnQuote:
_OnRtnQuote(ptr1, size1);
break;
case ResponeType.OnRtnDepthMarketData:
_OnRtnDepthMarketData(ptr1,size1,double1);
break;
case ResponeType.OnRtnQuoteRequest:
_OnRtnQuoteRequest(ptr1, size1);
break;
case ResponeType.OnRspQryHistoricalTicks:
_OnRspQryHistoricalTicks(ptr1, size1, ptr2, size2, double1);
break;
case ResponeType.OnRspQryHistoricalBars:
_OnRspQryHistoricalBars(ptr1, size1, ptr2, size2, double1);
break;
case ResponeType.OnFilterSubscribe:
if(_OnFilterSubscribe(double1, size1, size2, size3, ptr1))
{
return new IntPtr(1);
}
return IntPtr.Zero;
default:
base.OnRespone(type, pApi1, pApi2, double1, double2, ptr1, size1, ptr2, size2, ptr3, size3);
break;
}
return IntPtr.Zero;
}
}
}