Index
IndexSecurity - the index built from instruments. For example, to set a spread in arbitrage or pair trading. It has the following implementations.
ExpressionIndexSecurity - is the index built from a combination of several instruments through the ExpressionIndexSecurity.Formula mathematical formula.
WeightedIndexSecurity - is the index built from instruments using weighting factors WeightedIndexSecurity.Weights.
The ExpressionIndexSecurity creating
To declare the compound instruments that will be included in ExpressionIndexSecurity and in the ExpressionIndexSecurity itself:
ConfigManager.RegisterService<ICompilerService>(new RoslynCompilerService()); // Or //ConfigManager.RegisterService<ICompilerService>(new Fw40CompilerService(Directory.GetCurrentDirectory(), Directory.GetCurrentDirectory())); private Security _instr1; private Security _instr2; private ExpressionIndexSecurity _indexInstr; private const string _secCode1 = "GZM5"; private const string _secCode2 = "LKM5";
To create the ExpressionIndexSecurity:
_indexInstr = new ExpressionIndexSecurity { Id = "IndexInstr@NYSE", Expression = "ESM5@NYSE/APM5@NYSE", Board = ExchangeBoard.Nyse, };
The WeightedIndexSecurity creating
To declare the compound instruments that will be included in WeightedIndexSecurity and in the WeightedIndexSecurity itself:
private Security _instr1; private Security _instr2; private WeightedIndexSecurity _indexInstr; private const string _secCode1 = "GZM5"; private const string _secCode2 = "LKM5";
To create the WeightedIndexSecurity:
_indexInstr = new WeightedIndexSecurity() { ExchangeBoard = ExchangeBoard.Nyse, Id = "IndexInstr" };
To add the compound instruments to it:
_indexInstr.Weights.Add(_instr1, 1); _indexInstr.Weights.Add(_instr2, -1);