Guest User

Untitled

a guest
Feb 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.61 KB | None | 0 0
  1. Private _session As ISession
  2.  
  3.         Private Const EURUSD_ID As Long = 4001
  4.  
  5.         Public Sub MarketDataUpdate(orderBookEvent As OrderBookEvent)
  6.         Form1.TextInfo.Text = "Market data: " & orderBookEvent.ToString()
  7.         End Sub
  8.  
  9.         Private Sub LoginCallback(session As ISession)
  10.             'Console.WriteLine()
  11.             _session = session
  12.  
  13.             Form1.TextInfo.Text = "Logged in, account ID: " & Convert.ToString(session.AccountDetails.AccountId)
  14.  
  15.             ' Register EventListeners, subscribe to data and start the session.
  16.             AddHandler session.MarketDataChanged, AddressOf MarketDataUpdate
  17.  
  18.             session.Subscribe(New OrderBookSubscriptionRequest(EURUSD_ID), Sub() Form1.TextInfo.Text = "Successful subscription", Sub() Form1.TextInfo.Text = "Failed to subscribe: -")
  19.             session.Start()
  20.         End Sub
  21.  
  22.         Public Sub FailureCallbac(failedFunction As String)
  23.             Form1.TextInfo.Text = "Failed to " & failedFunction & " due to: -"
  24.         End Sub
  25.  
  26.         Private Shared Function FailureCallback(failedFunction As String) As OnFailure
  27.             'Dim FailureResponse As New FailureResponse
  28.             Dim FailureResponse As String = "Failed to " + failedFunction + " due to: -"
  29.             Dim OnFailure As OnFailure
  30.  
  31.             Return OnFailure
  32.         End Function
  33.  
  34.  
  35.         Public Shared Sub Main()
  36.             Dim myTradingBot As New MyTradingBot()
  37.  
  38.             Dim lmaxApi As New LmaxApi(URL_LIVE)
  39.             lmaxApi.Login(New LoginRequest(UName, PWord), AddressOf myTradingBot.LoginCallback, FailureCallback("log in"))
  40.         End Sub
Add Comment
Please, Sign In to add comment