Back

Please help to newbie

Hi, for all. My name is Eugene.
Early I worked with mql4 and now when I decide to develop strategy in QuantConnect, I can't find some features.
After couple days of study, I decide to write my questions here.
May be somebody has enough time to answer for my questions. Any help would be appreciated.
1) How I can get list of all orders which opened in current time. (Order count, orders Id)?
2) How I can get access to specific order by id (Order info like profit, price, lot, order direction, order symbol, order date)?
3) How I can close specific order by id?
Thank you for your time :)
Update Backtest








Welcome Eugene! Orders are stored in the Transactions class. If you're an advanced user you can manipulate them directly, otherwise we provide some helper methods to avoid breaking things :)

1) Open Orders - good question; because we didn't have anything like this I added a brand new helper method for you! I think others will want this method as well. See the new code here on github for how you could have done it manually.

2) Transactions.GetOrderById() - Here.

3) I also added another alias CancelOrder(int orderId) / RemoveOrder(int orderId). If you're using a limit or stop limit order which hasn't been filled it will remove for you.
2

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Note: Don't modify the Orders in the Orders collection directly, they [will soon be] immutable. Simply take the Order and submit an updated copy of it to the OrdersQueue.

The OrdersQueue is processed synchronously in a separate thread; then the Orders collection is updated if it passes the "security checks".
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Thank you Jared! I am sorry, I was busy and can't answer to you! From next week I will plan continue to learn. Thank you for reply :)

P.S.
Very cool platform! In current time you are without a rival.
0

Hi for all. I have some question and will be much obliged if you help me.
1) I am not found function for closing orders (not remove and not cancel, close order function which closes an open trade with the matching ticket number (order id) at the specified price).
2) As I see calculate order profit function absent (but maybe I mistaken). So I wrote some code:
///
/// This method return order profit based on close price from trade bar
///

private decimal GetOrderProfit(Order order, decimal close)
{
decimal retVal=0;
if (order.Direction==OrderDirection.Sell)
{
retVal=(order.Price-close)*order.Quantity*100000;
}
else if (order.Direction==OrderDirection.Buy)
{
retVal=(close-order.Price)*order.Quantity*100000;
}
return retVal;
}
But I am not sure standard lot size 100000. In many documents 10000, but I can mistaken.

Thank you for your time :)
0

Hey Eugene -- all this is taken care of for you, you don't need to manually close any trades. There are "Order Transaction Models" which generate OrderFill objects.

These order fills are matched with the orders; and the fill is applied to your portfolio automatically.

If you're interested in the underlying engine I'd recommend checking out the open source project which drives QuantConnect -- https://lean.quantconnect.com
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Jared,...... you rock........ That is all.

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed