|
' ******************************************************************************
' **
' ** Yahoo Finance Managed
' ** Written by Marius Häusler 2010
' ** It would be pleasant, if you contact me when you are using this code.
' ** Contact: YahooFinanceManaged@gmail.com
' ** Project Home: http://code.google.com/p/yahoo-finance-managed/
' **
' ******************************************************************************
' **
' ** Copyright 2010 Marius Häusler
' **
' ** Licensed under the Apache License, Version 2.0 (the "License");
' ** you may not use this file except in compliance with the License.
' ** You may obtain a copy of the License at
' **
' ** http://www.apache.org/licenses/LICENSE-2.0
' **
' ** Unless required by applicable law or agreed to in writing, software
' ** distributed under the License is distributed on an "AS IS" BASIS,
' ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' ** See the License for the specific language governing permissions and
' ** limitations under the License.
' **
' ******************************************************************************
Namespace Finance
''' <summary>
''' Stores informations of quote options.
''' </summary>
''' <remarks></remarks>
Public Class QuoteOptionData
Private mSymbol As String = String.Empty
Private mType As QuoteOptionType = QuoteOptionType.Call
Private mValues(4) As Double
Private mValuesInt(1) As Integer
''' <summary>
''' The basic parts of new option symbol are: Root symbol + Expiration Year(yy)+ Expiration Month(mm)+ Expiration Day(dd) + Call/Put Indicator (C or P) + Strike price
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Symbol() As String
Get
Return mSymbol
End Get
Set(ByVal value As String)
mSymbol = value
End Set
End Property
''' <summary>
''' Call/Put Indicator
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Type() As QuoteOptionType
Get
Return mType
End Get
Set(ByVal value As QuoteOptionType)
mType = value
End Set
End Property
''' <summary>
''' The stated price per share for which underlying stock can be purchased (in the case of a call) or sold (in the case of a put) by the option holder upon exercise of the option contract.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property StrikePrice() As Double
Get
Return mValues(0)
End Get
Set(ByVal value As Double)
mValues(0) = value
End Set
End Property
''' <summary>
''' The price of the last trade made for option contract.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property LastPrice() As Double
Get
Return mValues(1)
End Get
Set(ByVal value As Double)
mValues(1) = value
End Set
End Property
''' <summary>
''' The change in price for the day. This is the difference between the last trade and the previous day's closing price (Prev Close). The change is reported as "0" if the option hasn't traded today.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Change() As Double
Get
Return mValues(2)
End Get
Set(ByVal value As Double)
mValues(2) = value
End Set
End Property
''' <summary>
''' The Bid price is the price you get if you were to write (sell) an option.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Bid() As Double
Get
Return mValues(3)
End Get
Set(ByVal value As Double)
mValues(3) = value
End Set
End Property
''' <summary>
''' The Ask price is the price you have to pay to purchase an option.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Ask() As Double
Get
Return mValues(4)
End Get
Set(ByVal value As Double)
mValues(4) = value
End Set
End Property
''' <summary>
''' The volume indicates the number of option contracts that have traded for the current day.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property Volume() As Integer
Get
Return mValuesInt(0)
End Get
Set(ByVal value As Integer)
mValuesInt(0) = value
End Set
End Property
''' <summary>
''' The total number of derivative contracts traded that have not yet been liquidated either by an offsetting derivative transaction or by delivery.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property OpenInterest() As Integer
Get
Return mValuesInt(1)
End Get
Set(ByVal value As Integer)
mValuesInt(1) = value
End Set
End Property
''' <summary>
''' Default constructor
''' </summary>
''' <remarks></remarks>
Public Sub New()
End Sub
Friend Sub New(ByVal symb As String, ByVal typ As QuoteOptionType, ByVal strike As Double, ByVal last As Double, ByVal cng As Double, ByVal b As Double, ByVal a As Double, ByVal vol As Integer, ByVal interest As Integer)
Me.Symbol = symb
Me.Type = typ
Me.StrikePrice = strike
Me.LastPrice = last
Me.Change = cng
Me.Bid = b
Me.Ask = a
Me.Volume = vol
Me.OpenInterest = interest
End Sub
Public Overrides Function ToString() As String
Return mSymbol
End Function
End Class
Public Class QuoteOptionDataChain
Implements ISettableID
Implements IEnumerable(Of QuoteOptionData)
Private mID As String = String.Empty
Private mItems As List(Of QuoteOptionData)
Public ReadOnly Property ID() As String Implements IID.ID
Get
Return mID
End Get
End Property
Public Sub SetID(ByVal id As String) Implements ISettableID.SetID
mID = id
End Sub
Default Public Property ItemAt(ByVal index As Integer) As QuoteOptionData
Get
Return mItems(index)
End Get
Set(ByVal value As QuoteOptionData)
mItems(index) = value
End Set
End Property
Public ReadOnly Property Items() As List(Of QuoteOptionData)
Get
Return mItems
End Get
End Property
Public ReadOnly Property Count() As Integer
Get
Return mItems.Count
End Get
End Property
Public Sub New()
mItems = New List(Of QuoteOptionData)
End Sub
Public Sub New(ByVal id As String)
Me.New()
mID = id
End Sub
Public Sub New(ByVal items As IEnumerable(Of QuoteOptionData))
mItems = New List(Of QuoteOptionData)(items)
End Sub
Public Sub New(ByVal id As String, ByVal items As IEnumerable(Of QuoteOptionData))
Me.New(items)
mID = id
End Sub
Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of QuoteOptionData) Implements System.Collections.Generic.IEnumerable(Of QuoteOptionData).GetEnumerator
Return mItems.GetEnumerator
End Function
Public Function GetEnumerator1() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return mItems.GetEnumerator
End Function
End Class
End Namespace
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.