Loading ...

时间高频

Author: 量价时空, Date: 2020-07-22 17:41:18
Tags: C++


void main() {
    Sleep(10000);
    Log(exchange.GetAccount());
    while (1) {
        if (exchange.IO("status") == 1) {
            exchange.SetContractType(Symbol);
           auto r1 = exchange.GetRecords(h);
         auto macd = TA.MACD(r1);
           auto slow = macd[0][macd[0].size() - 1];
           auto fast = macd[1][macd[1].size() - 1];
            auto r = exchange.GetRecords(w);
            auto b=r[r.size()-1].High - r[r.size()-1].Low;
            
            auto ticker = exchange.GetTicker();
            auto position = exchange.GetPosition();
            auto orders = exchange.GetOrders();
            if (position.size() > 0 && !(orders.size() > 0)) {
                if (!position[0].Type ) {
                   
                    exchange.SetContractType(Symbol);
                    exchange.SetDirection("closebuy_today");
                    exchange.Sell(ticker.Buy - 1000, 1);
                     
                         Sleep(500);
                }
                if (position[0].Type) {
                 
                    exchange.SetContractType(Symbol);
                    exchange.SetDirection("closesell_today");
                   exchange.Buy(ticker.Buy + 1000, 1);
                       
                         Sleep(500);
                }
            } else if (!(orders.size() > 0)) {
                auto position1 = exchange.GetPosition();
               if(!(position1.size() > 0)){
                    if (b<0 && fast < slow) {//
                        exchange.SetContractType(Symbol);
                        exchange.SetDirection("sell");
                       exchange.Sell(ticker.Sell - 1000, 1);
                        Sleep(1000*j);
                        continue;
                    } else if ( b>0 && fast > slow ) {
                        
                      exchange.SetContractType(Symbol);
                        exchange.SetDirection("buy");
                      exchange.Buy(ticker.Buy + 1000, 1);
                         Sleep(1000*j);
                        continue;
                    }
            
            } }
        } else {
            LogStatus(_D(), "未连接CTP !");
            Sleep(1000);
        }

    }
}

Related

More