- 策略广场
- 黑科技
黑科技
Author:
量价时空, Date: 2020-07-17 10:36:27
Tags:
C++
void main() {
Sleep(10000);
Log(exchange.GetAccount());
auto id=0;
int t=0;
while (1) {
if (exchange.IO("status") == 1) {
exchange.SetContractType(Symbol);
auto r = exchange.GetRecords(60);
int i;
double a1=0;
double a2=0;
for (i=1;i<h;i++ ){
a1=a1+r[r.size()-i].Volume*(r[r.size()-i].High+r[r.size()-i].Low)/2;
a2=a2+r[r.size()-i].Volume;
}
a1=a1/a2;
auto ticker = exchange.GetTicker();
auto position = exchange.GetPosition();
auto orders = exchange.GetOrders();
if (position.size() > 0 && !(orders.size() > 0)) {
if (!position[0].Type) {
if(position[0].Profit >l*t || position[0].Profit<-k*t ){
exchange.SetContractType(Symbol);
exchange.SetDirection("closebuy_today");
exchange.Sell(ticker.Sell - 100, t);
exchange.SetContractType(Symbol);
}
}
if (position[0].Type) {
if(position[0].Profit >l || position[0].Profit<-k){
exchange.SetContractType(Symbol);
exchange.SetDirection("closesell_today");
exchange.Buy(ticker.Buy + 100, t);
}
}
} else if( !(orders.size() > 0)) {
auto position1 = exchange.GetPosition();
auto ticker = exchange.GetTicker();
if (!(position1.size() > 0)){
if (ticker.Sell-a1 > w) {
t=9;
exchange.SetContractType(Symbol);
exchange.SetDirection("sell");
exchange.Sell(ticker.Sell - 100, t);
continue;
}else if(ticker.Sell-a1 > w-20){
t=8;
exchange.SetContractType(Symbol);
exchange.SetDirection("sell");
exchange.Sell(ticker.Sell - 100, t);
}else if(ticker.Sell-a1 > w-40){
t=7;
exchange.SetContractType(Symbol);
exchange.SetDirection("sell");
exchange.Sell(ticker.Sell - 100, t);
}else if(ticker.Sell-a1 > w-60){
t=6;
exchange.SetContractType(Symbol);
exchange.SetDirection("sell");
exchange.Sell(ticker.Sell - 100, t);
}else if(ticker.Sell-a1 > w-80){
t=5;
exchange.SetContractType(Symbol);
exchange.SetDirection("sell");
exchange.Sell(ticker.Sell - 100, t);
}else if(ticker.Sell-a1 > w-100){
t=4;
exchange.SetContractType(Symbol);
exchange.SetDirection("sell");
exchange.Sell(ticker.Sell - 100, t);
}else if(ticker.Sell-a1 > w-120){
t=3;
exchange.SetContractType(Symbol);
exchange.SetDirection("sell");
exchange.Sell(ticker.Sell - 100, t);
}else if(ticker.Sell-a1 > w-140){
t=2;
exchange.SetContractType(Symbol);
exchange.SetDirection("sell");
exchange.Sell(ticker.Sell - 100, t);
}else if(ticker.Sell-a1 > w-160){
t=1;
exchange.SetContractType(Symbol);
exchange.SetDirection("sell");
exchange.Sell(ticker.Sell - 100, t);
}
if (a1- ticker.Sell > w ) {
t=9;
exchange.SetContractType(Symbol);
exchange.SetDirection("buy");
exchange.Buy(ticker.Buy + 100, t);
continue;
}else if(a1- ticker.Sell > w-20){
t=8;
exchange.SetContractType(Symbol);
exchange.SetDirection("buy");
exchange.Buy(ticker.Buy + 100, t);
continue;
}else if(a1- ticker.Sell > w-40){
t=7;
exchange.SetContractType(Symbol);
exchange.SetDirection("buy");
exchange.Buy(ticker.Buy + 100, t);
continue;
}else if(a1- ticker.Sell > w-60){
t=6;
exchange.SetContractType(Symbol);
exchange.SetDirection("buy");
exchange.Buy(ticker.Buy + 100, t);
continue;
}else if(a1- ticker.Sell > w-80){
t=5;
exchange.SetContractType(Symbol);
exchange.SetDirection("buy");
exchange.Buy(ticker.Buy + 100, 5);
continue;
}else if(a1- ticker.Sell > w-100){
t=4;
exchange.SetContractType(Symbol);
exchange.SetDirection("buy");
exchange.Buy(ticker.Buy + 100, t);
continue;
}else if(a1- ticker.Sell > w-120){
t=3;
exchange.SetContractType(Symbol);
exchange.SetDirection("buy");
exchange.Buy(ticker.Buy + 100, t);
continue;
}else if(a1- ticker.Sell > w-140){
t=2;
exchange.SetContractType(Symbol);
exchange.SetDirection("buy");
exchange.Buy(ticker.Buy + 100, t);
continue;
}else if(a1- ticker.Sell > w-160){
t=1;
exchange.SetContractType(Symbol);
exchange.SetDirection("buy");
exchange.Buy(ticker.Buy + 100, t);
continue;
}
}
}
} else {
LogStatus(_D(), "未连接CTP !");
Sleep(1000);
}
}
}
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6