Hi,
Quote:
When will this newer version be avaible?
The new version will be available during this week.
Quote:
Is "bilateral" pairtrading possible?
I think the strategy by Mktwizard is a good example.. Probably we will include it in docs. Here is its corrected code:
Code:
using System;
using System.Drawing;
using OpenQuant.API;
using OpenQuant.API.Indicators;
public class MyStrategy : Strategy
{
Instrument DELL;
Instrument CSCO;
TimeSeries spread_series;
[Parameter("Order quantity (number of contracts to trade)")]
double Qty = 100;
[Parameter("Length of SMA")]
int SMALength = 20;
[Parameter("Order of BBU")]
double BBUOrder = 2;
[Parameter("Order of BBL")]
double BBLOrder = 2;
// indicators
BBU bbu;
BBL bbl;
SMA sma;
public override void OnStrategyStart()
{
DELL = Instruments["DELL"];
CSCO = Instruments["CSCO"];
spread_series = new TimeSeries("DELL - CSCO", Color.Pink);
// set up the moving averages
sma = new SMA(spread_series, SMALength);
sma.Color = Color.Yellow;
Draw(sma, 2);
// set up bollinger bands
bbu = new BBU(spread_series, SMALength, BBUOrder);
bbu.Color = Color.Green;
bbl = new BBL(spread_series, SMALength, BBLOrder);
bbl.Color = Color.Green;
Draw(bbu, 2);
Draw(bbl, 2);
Draw(spread_series, 2);
}
public override void OnBarSlice(long size)
{
if (Instrument == CSCO)
{
double spread = CSCO.Bar.Close / DELL.Bar.Close;
spread_series.Add(CSCO.Bar.DateTime, spread);
if (bbl.Count == 0)
return;
if (!HasPosition)
{
if (spread < bbl.Last)
{
Buy(CSCO, Qty);
Sell(DELL, Qty);
}
}
else
{
if (spread > bbu.Last)
{
Sell(CSCO, Qty);
Buy(DELL, Qty);
}
}
}
}
}
Btw, this strategy works fine in the current OQ version.
Regards,
Sergey.