sergey
Newbie

Сообщений: 1
|
 |
« : 11.01.2019, 14:35:51 » |
|
При тестировании скрипта на Демо счете выходит ошибка
Некорректный ордер: [18]Клиенту не доступны торговые операции на данном рынке
Причем пробую разные скрипты. Пробовал клиента устанавливать насильственно. На Интре всё хорошо.
Это какая-то особенность демо счета?
extern step_percent = 0.02; extern num = 3; extern amount = 1; extern take_profit_percent = 0.05; extern "string" client = "ACP/F000FNR";
var step; var take_profit; var book; static dealer_SecInfo; static buy_count = 0; static sell_count = 0; function init() { step = step_percent / 100; take_profit = take_profit_percent / 100; dealer_SecInfo = getSecInfo(); setClient(client); //book = new_object("book"); //book.subscribe(); } function buy(var price) { trade_action::buyMultiple(amount, ::lots, price); signal::output(getLastErrorMessage()); buy_count += 1; } function onNewCandle() { var a = ""; }
function sell(var price) { trade_action::sellMultiple(amount, ::lots, price); sell_count += 1; } function takeprofit(var price) {
trade_action::cancelAllOrders(); //var kolichestvo_akcii = 1; var tp_correction = "0.05%";
var takeorder_1 = new_object("hash"); takeorder_1["operation"] = OP_SELL; //order["quantity"] = kolichestvo_akcii; takeorder_1["tp_activationprice"] = price; takeorder_1["tp_quantity"] = "100%"; takeorder_1["tp_correction"] = tp_correction; takeorder_1["validbefore"] = TILL_CANCELED; takeorder_1["secid"] = dealer_SecInfo["secid"]; trade_action::transact(takeorder_1);
//var take_1 = new_object("hash"); // Выставляем тейк-профит_1 //take_1["operation"] = OP_SELL; // Заявка на продажу //take_1["tp_activationprice"] = price; //Цена активации тейка //take_1["tp_quantity"] = "100%"; //Закрыть всю позицию //take_1["tp_correction"] = "0.1%"; // Величина коррекции в процентах //take_1["validbefore"] = TILL_CANCELED; //Тейк-профит действует до отмены //take_1["secid"] = dealer_SecInfo["secid"]; //trade_action::transact(take_1); // Выставляем на биржу
}
function setOrders() { var i = 1; //book.load(); //var bidprice = book.getBidPrice(0) + 0.01; var bidprice = close; //buy(bidprice); //buy(bidprice * (1 - i*step)); //while (i <= num) { // buy(bidprice * (1 - i*step)); // //sell(close * (1 + i*step)); // i += 1; //}
signal::alert("Текущий клиент:" + getClient());
var order = new_object("hash"); order["operation"] = OP_BUY; order["quantity"] = amount; order["secid"] = dealer_SecInfo["secid"]; order["usecredit"] = true; while (i <= num) { order["price"] = close * (1 - i*step); trade_action::transactMultiple(order); buy_count += 1; i += 1; } signal::output(getLastErrorMessage()); } function onHistoryCalculated() { var a = 0; } function onStartRobot() { setOrders(); }
function onStopOrder(var id) { var order = getStopOrder(id); if (order["status"] == SS_TP_EXECUTED) { if (order["operation"] == OP_SELL) { trade_action::cancelAllOrders(); setOrders(); } } }
function onOrder(var id) { var order = getOrder(id); if (order["status"] == OS_MATCHED) { if (order["operation"] == OP_BUY) { buy_count -= 1; //var newprice = order["price"] * (1 - step * num); var newprice = order["price"] * (1 - step); //book.load(); //var bidprice = book.getBidPrice(1) + 0.01; var bidprice = newprice;
if (newprice > bidprice) {newprice = bidprice;}
//var newprice = order["price"] * (1 - step); var profitprice = order["price"] * (1 + take_profit); //if (buy_count < num) {buy(newprice);} //sell(oldprice); takeprofit(profitprice); buy(newprice); } } }
|