Back

Fully Automated Orders during Live Session

Hello there,

Issues with enabling fully automated orders during live testing.  I have looked at the documentation, but not entirely certain on how to activate automated ordering in C#. I saw one code structure where you input ' if(live mode) ', but not sure were to place it, or even if that is all that is needed.  My personal strategy is developed, but just having an issue with the full automation of the orders.  I am currently learning the platform.  Currently using basic forex algorithm with a basic strategy to test things out. Also, is this even a feature in the demo  area, as in does it need to be real money to do fully automated? No problems with running backtests, as in it reports where trades are opened/closed and plots correctly.  Any help would be appreciated!

Update Backtest








check the "live trading servers" - line:

https://www.quantconnect.com/pricing

:)

0

I checked the 'Live trading server', not exactly sure what you meant.  Below is a basic algorithm with a basic strategy, am I missing something related to fully automated orders?  The backtest displays orders filled, but when switched to 'go live', it only responds to a manually input order (wanting this action completed automatically, without per trade inputs from myself).  When developing my personal strategy, I never actually learned to automate orders, only to collect/analize/plot the data.  Came to this platform to try to figure that part out. Scouring through the github got me a little further, but to full automation.  I think I have followed the documentation, if not, where do I need to delve a bit deeper? The **'d section is where I am thinking I have done something incorrectly, but not really certain, and am stuck on what to do.

using System;

using System.Linq;

using QuantConnect.Indicators;
using QuantConnect.Models;

namespace QuantConnect.Algorithm.CSharp
{

    public class FirstLiveTest : QCAlgorithm
    {
        Symbol _nzd;
        RelativeStrengthIndex _rsi;
        ExponentialMovingAverage _emaLong;
        ExponentialMovingAverage _emaShort;
        OrderTicket _limitTicket;
        OrderTicket _stopMarketTicket;
        OrderTicket _stopLimitTicket;
        public override void Initialize()
        {
            SetStartDate(2017, 12, 04);  //Set Start Date
            SetEndDate(2018, 02, 23);    //Set End Date
            SetCash(1000);             //Set Strategy Cash
            _nzd = AddForex("NZDUSD", Resolution.Hour, Market.Oanda).Symbol;
            _rsi = RSI("NZDUSD", 14, MovingAverageType.Simple, Resolution.Hour);
            _emaShort = EMA("NZDUSD", 10, Resolution.Hour);
            _emaLong = EMA("NZDUSD", 17, Resolution.Hour);

        }

*******************************************************************************************

*******************************************************************************************

        public override void OnData(Slice data)
        {
                if (!_emaLong.IsReady) return;
                var quantity = Portfolio["NZDUSD"].Quantity;
            
                if (_rsi > 70 && quantity == 0 && _emaShort > _emaLong) 
                {
                    SetHoldings("NZDUSD", 5);
                    Debug("Purchased NZDUSD");
                }
                else if (_rsi < 30 && quantity > 0)
                {
                    Liquidate();
                    Debug("Liquidate NZDUSD");
                }
            
                if (_limitTicket == null)
                {
                    MarketOrder(_nzd, 100, tag: "market order");
                    _limitTicket = LimitOrder(_nzd, 100, data["NZDUSD"].Close * 0.99m, tag: "limit order");
                    _stopMarketTicket = StopMarketOrder(_nzd, -100, data["NZDUSD"].Close + 0.95m, tag: "stop market");
                  _stopLimitTicket = StopLimitOrder(_nzd, -100, data["NZDUSD"].Close * 0.90m, data["NZDUSD"].Close * 0.80m, tag: "stop limit");
                }
        }

        public override void OnEndOfDay() {
            Plot("RSI", _rsi);
            Plot("EMA", _emaLong, _emaShort);
           if  (_limitTicket == null) return;
                Plot("Order Tickets", "NZDUSD", Portfolio[_nzd].Price);
           if (_stopMarketTicket.Status != OrderStatus.Filled)
                Plot("Order Tickets", "Stop Price", _stopMarketTicket.Get(OrderField.StopPrice));
           if (_stopLimitTicket.Status != OrderStatus.Filled)
                Plot("Order Tickets", "Limit Price", _stopLimitTicket.Get(OrderField.LimitPrice));
        }        

*****************************************************************************************************************

*****************************************************************************************************************
        public override void OnOrderEvent(OrderEvent orderEvent)
        {
            if (orderEvent.FillQuantity == 0) return;
            var fetched = Transactions.GetOrderById(orderEvent.OrderId);
           Debug(fetched.Type + " was filled: Symbol: " + orderEvent.Symbol + " Quantity: " + orderEvent.FillQuantity + " Direction: " + orderEvent.Direction);
        }
    }
}

0

Generally speaking all of QC orders are fully automated. All the docs are

about placing fully automated trades.
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 for the responses, I will continue researching to figure it out.

I will get it eventually.
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