vagar,
All the best. I vent put more time in this one and hence sharing this raw files. these 3 scripts will get ATM strike prices realtime from now.
All the best. I vent put more time in this one and hence sharing this raw files. these 3 scripts will get ATM strike prices realtime from now.
Code:
Dim strexpd As String
Public Sub mainsub()
Dim price As Double
Dim i1, i2, strikeGap, i As Integer
Dim strpr
For i = 1 To 22
price = ThisWorkbook.Sheets("premium").Cells(i, 2).Value
strikeGap = ThisWorkbook.Sheets("premium").Cells(i, 3).Value
i1 = CInt(price / strikeGap)
i2 = i1 * strikeGap
ThisWorkbook.Sheets("premium").Cells(i, 4).Value = i2
Next i
End Sub
Public Sub getPrice()
Dim i As Integer
Dim strpr, strsym As String
strexpd = "16JUN"
i = 1
For i = 1 To 22
strsym = ThisWorkbook.Sheets("premium").Cells(i, 1).Value
strpr = "=RTD(""now.scriprtd"",,""MktWatch"",""nse_fo|" + strsym + strexpd + "FUT"",""Last Traded Price"")"
ThisWorkbook.Sheets("premium").Cells(i, 2).Value = strpr
Next i
End Sub
Public Sub getOptions()
Dim i As Integer
Dim strpr, strsym, strstrikes, strCE, strPE As String
i = 1
For i = 1 To 22
strsym = ThisWorkbook.Sheets("premium").Cells(i, 1).Value
strstrikes = CStr(ThisWorkbook.Sheets("premium").Cells(i, 4).Value)
strCE = "=RTD(""now.scriprtd"",,""MktWatch"",""nse_fo|" + strsym + strexpd + strstrikes + "CE"",""Last Traded Price"")"
strPE = "=RTD(""now.scriprtd"",,""MktWatch"",""nse_fo|" + strsym + strexpd + strstrikes + "PE"",""Last Traded Price"")"
ThisWorkbook.Sheets("premium").Cells(i, 6).Value = strCE
ThisWorkbook.Sheets("premium").Cells(i, 7).Value = strPE
Next i
End Sub