国外先进的自动交易软件,openquant,quantdeveloper都是把c#作为交易语言,并且,技术指标全部用c#编写。
那样的话,用户直接就用VS2008的C#编写交易策略就行了,还用金字塔何干。
此外,金字塔也提供了基于C++的接口规范,你同样可以使用这些高级语言编写策略然后通过金字塔下单。
要用到金字塔的交易测试,执行体系;
mt还是用c、c++写的指标、交易体系呢
主流开发语言写策略,没有编程基础的人很难接受自动化交易,如果用简单的语言,那客户群体就大多了。
可以通过C++插件接口,采用IPC技术,把接口封装成可以被C#调用的DLL。
using OpenQuant.API;
using OpenQuant.API.Indicators;
using System.Drawing;
public class MyStrategy : Strategy
{
// quantity to buy on a trade
[Parameter("Order quantity (number of contracts to trade)")]
double Qty = 100;
[Parameter("Bar Block Size")]
int BarBlockSize = 6;
[Parameter("Length of SMA in blocks (weeks)", "SMA")]
int FastSMALength = 22;
[Parameter("Length of SMA in blocks (weeks)", "SMA")]
int SlowSMALength = 55;
int positionInBlock = 0;
bool buyOnNewBlock;
bool sellOnNewBlock;
// two moving averages
SMA fastSMA;
SMA slowSMA;
public override void OnStrategyStart()
{
// set up the fast average
fastSMA = new SMA(Bars, FastSMALength * 7, Color.Yellow);
Draw(fastSMA, 0);
// set up the slow average
slowSMA = new SMA(Bars, SlowSMALength * 7, Color.Pink);
Draw(slowSMA, 0);
}
public override void OnBarOpen(Bar bar)
{
// calc quantity to reverse a position
double orderQty = 2 * Qty;
if (!HasPosition)
orderQty = Qty;
if (positionInBlock == 0)
{
if (buyOnNewBlock)
{
Buy(orderQty, "Reverse to Long");
buyOnNewBlock = false;
}
if (sellOnNewBlock)
{
Sell(orderQty, "Reverse to Short");
sellOnNewBlock = false;
}
}
}
public override void OnBar(Bar bar)
{
// if our SMAs contain the current bar date
if (fastSMA.Contains(bar.DateTime) && slowSMA.Contains(bar.DateTime))
{
// see which one is above the other
Cross cross = fastSMA.Crosses(slowSMA, bar);
if (cross == Cross.Above)
buyOnNewBlock = true;
if (cross == Cross.Below)
sellOnNewBlock = true;
}
positionInBlock = (positionInBlock++) % BarBlockSize;
}
}
using OpenQuant.API;
using OpenQuant.API.Indicators;
using System.Drawing;
public class MyStrategy : Strategy
{
// quantity to buy on a trade
[Parameter("Order quantity (number of contracts to trade)")]
double Qty = 100;
[Parameter("Bar Block Size")]
int BarBlockSize = 6;
[Parameter("Length of SMA in blocks (weeks)", "SMA")]
int FastSMALength = 22;
[Parameter("Length of SMA in blocks (weeks)", "SMA")]
int SlowSMALength = 55;
int positionInBlock = 0;
bool buyOnNewBlock;
bool sellOnNewBlock;
// two moving averages
SMA fastSMA;
SMA slowSMA;
public override void OnStrategyStart()
{
// set up the fast average
fastSMA = new SMA(Bars, FastSMALength * 7, Color.Yellow);
Draw(fastSMA, 0);
// set up the slow average
slowSMA = new SMA(Bars, SlowSMALength * 7, Color.Pink);
Draw(slowSMA, 0);
}
public override void OnBarOpen(Bar bar)
{
// calc quantity to reverse a position
double orderQty = 2 * Qty;
if (!HasPosition)
orderQty = Qty;
if (positionInBlock == 0)
{
if (buyOnNewBlock)
{
Buy(orderQty, "Reverse to Long");
buyOnNewBlock = false;
}
if (sellOnNewBlock)
{
Sell(orderQty, "Reverse to Short");
sellOnNewBlock = false;
}
}
}
public override void OnBar(Bar bar)
{
// if our SMAs contain the current bar date
if (fastSMA.Contains(bar.DateTime) && slowSMA.Contains(bar.DateTime))
{
// see which one is above the other
Cross cross = fastSMA.Crosses(slowSMA, bar);
if (cross == Cross.Above)
buyOnNewBlock = true;
if (cross == Cross.Below)
sellOnNewBlock = true;
}
positionInBlock = (positionInBlock++) % BarBlockSize;
}
}
C#编写ACTIVEX控件的知识,网上多得是,建议你到书店买书回去正规学习。
相对于VB,对于大众化不讲,个人觉得lua脚本简单一些,金字塔有没有考虑过调用lua脚本公式