VBA Functions Reference: IG Index

All Excel Price Feed VBA functions can be used from VBA by using the Application.Run function.

Excel Price Feed includes several functions which are specially designed to be used from VBA. They all begin with EPF.IG.VBA and can be used for market analysis, automated trading etc.

Live Market/Price Functions

EPF.IG.VBA.Mid

EPF.IG.VBA.Bid

EPF.IG.VBA.Offer

EPF.IG.VBA.High

EPF.IG.VBA.Low

EPF.IG.VBA.Change

EPF.IG.VBA.ChangePercent

EPF.IG.VBA.MarketID

EPF.IG.VBA.TradeableStatus

EPF.IG.VBA.MarginFactor

EPF.IG.VBA.MinimumDealSize

EPF.IG.VBA.MinimumDealSizeUnits

EPF.IG.VBA.MinimumStopOrLimitDistance

EPF.IG.VBA.MinimumStopOrLimitDistanceUnits

EPF.IG.VBA.MaximumStopOrLimitDistance

EPF.IG.VBA.MaximumStopOrLimitDistanceUnits

Description

Returns the current value for the specified epic code.

Syntax

returnValue = Application.Run(functionName, epicCode)

All of these functions have the one single parameter:

Parameters
Parameter Description
epicCode The IG Index epic code for the instrument
Examples

1. Return the live mid price of EURUSD spot:

Dim midPrice As Variant
midPrice = Application.Run("EPF.IG.VBA.Mid", "CS.D.EURUSD.TODAY.IP")


2. Return the live bid price of Apple stock:

Dim bidPrice As Variant
bidPrice = Application.Run("EPF.IG.VBA.Bid", "UA.D.AAPL.DAILY.IP")


2. Return the minimum deal size for GBPUSD:

Dim bidPrice As Variant
bidPrice = Application.Run("EPF.IG.VBA.MinimumDealSize", "CS.D.GBPUSD.TODAY.IP")


Sentiment Functions

EPF.IG.VBA.SentimentLong

EPF.IG.VBA.SentimentShort

Description

Returns the current IG Index client sentiment (long or short) for the specified the market id.

Syntax

longSentiment = Application.Run("EPF.IG.VBA.SentimentLong", marketID)

shortSentiment = Application.Run("EPF.IG.VBA.SentimentShort", marketID)

These functions all have the one single parameter:

Parameters
Parameter Description
marketID The IG Index market id for the instrument
Examples

1. Return the current short sentiment value of EURUSD spot:

Dim shortSentiment As Variant
shortSentiment = Application.Run("EPF.IG.VBA.SentimentShort", "EURUSD")


2. Return the current long sentiment value of Apple stock:

Dim longSentiment As Variant
longSentiment = Application.Run("EPF.IG.VBA.SentimentLong", "AAPL")


Trading Functions

EPF.IG.VBA.NewMarketOrder

Description

Open a new position at the current market price and returns the Deal ID (note the Deal ID can be used with the ClosePosition and ClosePartialPosition functions).

Syntax

returnValue = Application.Run("EPF.IG.VBA.NewMarketOrder", epicCode, currencyCode, expiry, buySell, dealSize, stopDistance, limitDistance)

The EPF.IG.VBA.NewMarketOrder function has the following parameters:

Parameters
Parameter Description
epicCode The IG Index epic code eg: CS.D.EURUSD.TODAY.IP
currencyCode The currency denomination eg: USD, GBP or EUR
expiry The date (or sometimes time) a spreadbet or CFD will automatically close. Often for spreadbets this is "DFB" for a Daily Funded Bet or for CFDs which do not expire this is "-"
buySell Direction, either "BUY" for long or "SELL" for short
dealSize The deal size, eg: for a spreadbet at £1 a point this will be set to 1
stopDistance Stop distance from opening price, if no stop is required then this value should be 0
limitDistance Limit distance from opening price, if no limit is required then this value should be 0
Examples
1. Open a new position at current market price to BUY EURUSD at £1 per point with no stoploss or limit. On success, the returnValue will be the Deal ID:

Dim returnValue As Variant
returnValue = Application.Run("EPF.IG.VBA.NewMarketOrder", "CS.D.EURUSD.TODAY.IP", "GBP", "DFB", "BUY", 1, 0, 0)


EPF.IG.VBA.CloseAllPositions

Description

Closes ALL open positions.

Syntax

returnValue = Application.Run("EPF.IG.VBA.CloseAllPositions")

The EPF.IG.VBA.CloseAllPositions function has no parameters and returns either "SUCCES" or an error message.


EPF.IG.VBA.ClosePositions

Description

Closes ALL positions for the specified epic code.

Syntax

returnValue = Application.Run("EPF.IG.VBA.ClosePositions", epicCode)

The EPF.IG.VBA.ClosePositions function has the following parameter:

Parameters
Parameter Description
epicCode The IG Index epic code eg: CS.D.EURUSD.TODAY.IP

EPF.IG.VBA.ClosePosition

Description

Closes the position for the specified Deal ID.

Syntax

returnValue = Application.Run("EPF.IG.VBA.ClosePosition", dealID)

The EPF.IG.VBA.ClosePosition function has the following parameter:

Parameters
Parameter Description
dealID The Deal ID of the position to close

EPF.IG.VBA.ClosePartialPosition

Description

Partially closes the position for the specified Deal ID.

Syntax

returnValue = Application.Run("EPF.IG.VBA.ClosePartialPosition", dealID, size)

The EPF.IG.VBA.ClosePartialPosition function has the following parameters:

Parameters
Parameter Description
dealID The Deal ID of the position to close
size The size to close, eg: to close half the position for a spreadbet at £2 a point this will be set to 1

EPF.IG.VBA.NewWorkingOrder

Description

Open a new working order, either a limit or stop order. The order can be either "Good Till Cancelled" or "Good Till Date".

Syntax

returnValue = Application.Run("EPF.IG.VBA.NewWorkingOrder", epicCode, currencyCode, expiry, buySell, dealSize, priceLevel, orderType, timeInForce, goodTillDate, stopDistance, limitDistance)

The EPF.IG.VBA.NewWorkingOrder function has the following parameters:

Parameters
Parameter Description
epicCode The IG Index epic code eg: CS.D.EURUSD.TODAY.IP
currencyCode The currency denomination eg: USD, GBP or EUR
expiry The date (or sometimes time) a spreadbet or CFD will automatically close. Often for spreadbets this is "DFB" for a Daily Funded Bet or for CFDs which do not expire this is "-"
buySell Direction, either "BUY" for long or "SELL" for short
dealSize The deal size, eg: for a spreadbet at £1 a point this will be set to 1
priceLevel Price level for the order
orderType Order type, either "LIMIT" or "STOP"
timeInForce Time in force for the order, either "GOOD_TILL_CANCELLED" or "GOOD_TILL_DATE"
goodTillDate If timeInForce is set to "GOOD_TILL_DATE" then this value can be either a UTC date/time in this format: "yyyy/mm/dd hh:mm:ss" or a Unix Timestamp in milliseconds
stopDistance Stop distance from opening price, if no stop is required then this value should be 0
limitDistance Limit distance from opening price, if no limit is required then this value should be 0
Examples
1. Submit a working Limit order to SELL GBPUSD at £1 per point if the price goes above 1.3200 with no expiry date on the order (Good Till Cancelled) with no stoploss or limit:

Dim returnValue As Variant
returnValue = Application.Run("EPF.IG.VBA.NewWorkingOrder", "CS.D.GBPUSD.TODAY.IP", "GBP", "DFB", "SELL", 1, 13200, "LIMIT", "GOOD_TILL_CANCELLED", "", 0, 0)


2. Submit a working Stop order to BUY EURUSD at $1 per point if the price goes above 1.1500 with an expiry date on the order (Good Till Date) of 1 March 2018 8AM (UTC) with no stoploss or limit:

Dim returnValue As Variant
returnValue = Application.Run("EPF.IG.VBA.NewWorkingOrder", "CS.D.EURUSD.TODAY.IP", "USD", "DFB", "BUY", 1, 11500, "STOP", "GOOD_TILL_DATE", "2019/03/01 08:00:00", 0, 0)


EPF.IG.VBA.DeleteAllWorkingOrders

Description

Deletes ALL working orders.

Syntax

returnValue = Application.Run("EPF.IG.VBA.DeleteAllWorkingOrders")

The EPF.IG.VBA.DeleteAllWorkingOrders function has no parameters and returns either "SUCCESS" or an error message.