forked from QuantBox/QuantBox_XAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXApi.HistoricalData.cs
61 lines (46 loc) · 2.18 KB
/
XApi.HistoricalData.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
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 : IXHistoricalData
{
public DelegateOnRspQryHistoricalTicks OnRspQryHistoricalTicks { get; set; }
public DelegateOnRspQryHistoricalBars OnRspQryHistoricalBars { get; set; }
public int ReqQryHistoricalTicks(ref HistoricalDataRequestField request)
{
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HistoricalDataRequestField)));
Marshal.StructureToPtr(request, ptr, false);
IntPtr ret = proxy.XRequest((byte)RequestType.ReqQryHistoricalTicks, Handle, IntPtr.Zero, 0, 0,
ptr, 0, IntPtr.Zero, 0, IntPtr.Zero, 0);
Marshal.FreeHGlobal(ptr);
return ret.ToInt32();
}
public int ReqQryHistoricalBars(ref HistoricalDataRequestField request)
{
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HistoricalDataRequestField)));
Marshal.StructureToPtr(request, ptr, false);
IntPtr ret = proxy.XRequest((byte)RequestType.ReqQryHistoricalBars, Handle, IntPtr.Zero, 0, 0,
ptr, 0, IntPtr.Zero, 0, IntPtr.Zero, 0);
Marshal.FreeHGlobal(ptr);
return ret.ToInt32();
}
private void _OnRspQryHistoricalTicks(IntPtr ptr1, int size1, IntPtr ptr2, int size2, double double1)
{
if (OnRspQryHistoricalTicks == null)
return;
HistoricalDataRequestField obj = PInvokeUtility.GetObjectFromIntPtr<HistoricalDataRequestField>(ptr2);
OnRspQryHistoricalTicks(this, ptr1, size1,ref obj, size2, double1 != 0);
}
private void _OnRspQryHistoricalBars(IntPtr ptr1, int size1, IntPtr ptr2, int size2, double double1)
{
if (OnRspQryHistoricalBars == null)
return;
HistoricalDataRequestField obj = PInvokeUtility.GetObjectFromIntPtr<HistoricalDataRequestField>(ptr2);
OnRspQryHistoricalBars(this, ptr1, size1,ref obj, size2, double1 != 0);
}
}
}