Dim WithEvents ctp As ICTPClientAPI
Private Sub Login_Click()
Dim errorID As Long
Dim succ As Long
Set ctp = New CTPCOMLib.ICTPClientAPI
Call ctp.Login("config.xml", "00100", "888888", errorID)
If errorID = 0 Then
MsgBox "登录ok"
Else
MsgBox "登录错误:" & errorID
End If
End Sub
Private Sub Buy_Click()
Dim OrderID As Long
Dim index As Integer
Dim tm1, tm2 As Date
Call ctp.Buy("IF1008", 1, 0, OrderID)
End Sub
Private SubMD_Click()
Call ctp.SubscribeMD("IF1008")
End Sub
Private Sub Close_Click()
Set ctp = Nothing
End Sub
Private Sub Sell_Click()
Dim OrderID As Long
Call ctp.Sell("IF1008", 1, 0, OrderID)
End Sub
Private Sub ctp_OnAccount(ByVal PreBalance As Double, ByVal Balance As Double, ByVal Available As Long, ByVal Commission As Double, ByVal FrozenCommission As Double, ByVal Margin As Double, ByVal FrozenMargin As Double, ByVal CloseProfit As Double, ByVal PositionProfit As Double)
Label1.Caption = Available
End Sub
Private Sub ctp_OnMarketData(ByVal InstrumentID As String, ByVal BidPrice1 As Double, ByVal BidVolume1 As Long, ByVal AskPrice1 As Double, ByVal AskVolume1 As Long, ByVal OpenPrice As Double, ByVal HighestPrice As Double, ByVal LowestPrice As Double, ByVal LastPrice As Double, ByVal OpenInterest As Long, ByVal Volume As Long, ByVal UpperLimitPrice As Double, ByVal LowerLimitPrice As Double, ByVal PreSettlementPrice As Double, ByVal AveragePriceAs Double,ByVal UpdateTime As String, ByVal UpdateMilliSecond As Long)
End Sub
Private Sub ctp_OnPosition(ByVal InstrumentID As String, ByVal IsLong As Long, ByVal Volume As Long, ByVal CloseProfit As Double, ByVal PositionProfit As Double, ByVal TotalClosable As Long, ByVal TodayClosable As Long)
Label2.Caption = Volume
End Sub