Excel Tools Pro > GlobalView COM SDK |
GlobalView COM SDK provides an easy way to get GlobalView historic data and quotes from dynamic languages such as VBA, VBS, JScript or Python.
Examples in this code will be given in Visual Basic for Automation, you'll need to adjust the syntax for other languages.
The main object needed to establish a connection to the server has a Program ID GvIpc.Com.ServerConnection. After it's created you need to call its Connect method and pass it your usenrname and password:
Set con = CreateObject("GvIpc.Com.ServerConnection")
con.Connect username, password
Once you have this object, you can call a plethora of methods on it. The methods retreive either last N data points of daily/weekly/monthly/quarterly/yearly data or a specific data range:
Array GetDailyTail(string symbol, int days, LeadLagOptions leadLagOptions = null, string currency = null, string currencySource = null, UnitConversion unit = null)
Array GetWeeklyTail(string symbol, int weeks, LeadLagOptions leadLagOptions = null, string currency = null, string currencySource = null, UnitConversion unit = null)
Array GetMonthlyTail(string symbol, int months, LeadLagOptions leadLagOptions = null, string currency = null, string currencySource = null, UnitConversion unit = null)
Array GetQuarterlyTail(string symbol, int quarters, LeadLagOptions leadLagOptions = null, string currency = null, string currencySource = null, UnitConversion unit = null)
Array GetYearlyTail(string symbol, int years, LeadLagOptions leadLagOptions = null, string currency = null, string currencySource = null, UnitConversion unit = null)
Array GetDailyRange(string symbol, DateTime from, DateTime to, LeadLagOptions leadLagOptions = null, string currency = null, string currencySource = null, UnitConversion unit = null)
Array GetWeeklyRange(string symbol, DateTime from, DateTime to, LeadLagOptions leadLagOptions = null, string currency = null, string currencySource = null, UnitConversion unit = null)
Array GetMonthlyRange(string symbol, DateTime from, DateTime to, LeadLagOptions leadLagOptions = null, string currency = null, string currencySource = null, UnitConversion unit = null)
Array GetQuarterlyRange(string symbol, DateTime from, DateTime to, LeadLagOptions leadLagOptions = null, string currency = null, string currencySource = null, UnitConversion unit = null)
Array GetYearlyRange(string symbol, DateTime from, DateTime to, LeadLagOptions leadLagOptions = null, string currency = null, string currencySource = null, UnitConversion unit = null)
These methods return an array of TimeSeriesElement objects, each of which contains the following properties:
DateTime
Open
High
Low
Close
Volume
OpenInterest
Here's a VBA example of a call:
array = con.GetDailyRange(Symbol:="/GCL", from:=DateSerial(2011, 5, 1), to:=DateSerial(2011, 5, 10))
Then, for each element of the array you can ask for the DateTime, Open, High, Low, Volume and OpenInterest properties.
If you need to do various conversions on the time series data, use the leadLagOptions, currencySource, currency and unit parameters:
con.GetDailyTail(Symbol:="/GCL", days:=5, leadLagOptions:=con.CalendarDays(5))
con.GetDailyTail(Symbol:="/GCL", days:=5, Currency:="EUR", currencySource:="USF")
con.GetDailyTail(Symbol:="/GCL", days:=5, unit:=con.Barrels)
The available unit conversions are Barrels, Liters, Kiloliters, CubicMeters, Gallons, ThouStdCubicFt, MetricTons, ShortTons, MMBTUs, Therms, Gigajoules, GigawattHours, KilowattHours and MegawattHours.
You can also get the current quote for a symbol:
Set quote = con.GetQuote("/GCL")
The returned quote object has the following properties:
Last
NetChange
PercentChange
High
Low
Open
Close
Settle
Bid
Ask
TradeSize
OpenInterest
TradeDateTimeUtc
Volume
PrevPrice
TickCount
ContractDate
ExpirationDate
MidPoint
CloseDate
Currency
LotUnit
PutCall
Strike
SettleDate
Underlier
BidDateTimeUtc
BidSize
AskDateTimeUtc
AskSize
PrevHigh
PrevLow
PrevOpen
PrevClose
PrevVol
MostRecentValue
MostRecentValueDate
Finally, when you are done with the connection object and don't want to retreive any more data, call its Dispose method:
con.Dispose
That's it!