鼎元C++量化程式码主模块之【开仓语句:开多开空,平多平空】
bar格式下:1、买 入开仓语句:[code]
OrderInsert(it->first, sInst, '0', '0', sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick, "", "");//买入开仓语句
[/code]2、卖出开仓语句:[code]
OrderInsert(it->first, sInst, '1', '0', sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick, "", "");//卖出开仓语句
[/code]3、多单平仓语句:
//优先平昨[code]
closesell1(it->first, sInst, sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick);//卖出平仓,优先平昨仓
[/code]//优先平今[code]closesell2(it->first, sInst, sl, t->LastPrice - hd * mapInstrument[sInst].PriceTick);
[/code]3、空单平仓语句:
//优先平昨[code]
closebuy1(it->first, sInst, sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick); //买入平仓,优先平昨仓
[/code]//优先平昨今[code]
closebuy2(it->first, sInst, sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick); //买入平仓,优先平今仓
[/code] TICK模式下:
1、买 入开仓语句:[code]
OrderInsert(it->first, sInst, '0', '0', sl, t->LastPrice + hd * mapInstrument[sInst].PriceTick, "", ""); //开仓买入语句
[/code]2、卖出开仓语句:[code]
OrderInsert(it->first, sInst, '1', '0', sl, t->LastPrice - hd * mapInstrument[sInst].PriceTick, "", "");
[/code]3、多单平仓语句:
//优先平昨[code]closesell1(it->first, sInst, sl, t->LastPrice - hd * mapInstrument[sInst].PriceTick);[/code]//优先平昨[code]closesell2(it->first, sInst, sl, t->LastPrice - hd * mapInstrument[sInst].PriceTick);[/code]3、空单平仓语句:
//优先平昨[code]closebuy1(it->first, sInst, sl, t->LastPrice + hd * mapInstrument[sInst].PriceTick);[/code]//优先平今[code]closebuy2(it->first, sInst, sl, t->LastPrice + hd * mapInstrument[sInst].PriceTick);[/code]
页:
[1]