Esempio n. 1
0
 public LiveTradeEngine()
 {
     _session = new FXSession();
     _opEngine = new OrderPlacementEngine(_session);
     _priceEngine = new HistoricPriceEngine(_session);
     _accountManager = new LiveAccountManager(_opEngine);
 }
Esempio n. 2
0
 public void LoadData()
 {
     FXSession session = new FXSession();
     session.InitializeSession();
     
     foreach (string s in sList)
     {
         HistoricPriceEngine h = new HistoricPriceEngine(session);
         h.GetLongHistoricPrices(symbol, s, ticks);
         while(!h.Complete) Thread.Sleep(100);   
         mData.Add(h.Data);
     }
 }
Esempio n. 3
0
        public void LoadDataLive(string symbol, string timeframe, int ticks)
        {
            var session  = new FXSession();
            session.InitializeSession();
            while (!session.LoggedIn)
            {
                Thread.Sleep(100);
            }
            var price = new HistoricPriceEngine(session);
            price.GetLongHistoricPrices(symbol, timeframe, ticks);

            while (!price.Complete)
            {
                Thread.Sleep(100);
            }

            _dataSet.Add(price.Data);

            session.EndSession();
        }
Esempio n. 4
0
        public static void TestChannelLive(this AbstractChannel ind, string symbol, string timeframe, int length)
        {
            //------------grab data
            FXSession session = new FXSession();
            session.InitializeSession();
            while (!session.LoggedIn)
            {
                Thread.Sleep(100);
            }

            HistoricPriceEngine h = new HistoricPriceEngine(session);
            h.GetLongHistoricPrices(symbol, timeframe, length);

            while (!h.Complete)
            {
                Thread.Sleep(100);
            }
            //-----------------------

            var highList = new List<double>();
            var medList = new List<double>();
            var lowList = new List<double>();

            var dataList = new List<double>();
            var dateTimeList = new SortedList<DateTime, int>();

            Quantum q = h.Data;

            int count = 0;
            foreach (Tick t in q)
            {
                try{

                    ind.HandleNextTick(t);
                    highList.Add(ind.HI(0));
                    medList.Add(ind.MID(0));
                    lowList.Add(ind.LOW(0));

                    dataList.Add(t.BidClose);
                    dateTimeList.Add(t.Time, 1);
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }
                if (count++ > length) break;
            }

            var dz = new DenseMatrix(4, medList.Count);
            dz.SetRow(0, new DenseVector(dataList.ToArray()));
            dz.SetRow(1, new DenseVector(highList.ToArray()));
            dz.SetRow(2, new DenseVector(medList.ToArray()));
            dz.SetRow(3, new DenseVector(lowList.ToArray()));

            Visualize.GenerateMultiPaneGraph(new[] { "data", "high", ind.ToString(), "low" }, dateTimeList.Keys.ToArray(), dz, QSConstants.DEFAULT_DATA_FILEPATH + @"results.html"
                , new ChartOption[]
                {
                    new ChartOption(){Height = 500}, 
                    new ChartOption(){Height = 0, Layover = true, YPosition = 0},
                    new ChartOption(){Height = 0, Layover = true, YPosition = 0},
                    new ChartOption(){Height = 0, Layover = true, YPosition = 0}
                });

            Console.WriteLine("Done Generating Graph for " + ind.ToString());
            }
Esempio n. 5
0
        public static void TestGraphLive(this AbstractIndicator ind, string timeframe, string symbol, int length)
        {
            //------------grab data
            FXSession session = new FXSession();
            session.InitializeSession();

            HistoricPriceEngine h = new HistoricPriceEngine(session);
            h.GetLongHistoricPrices(symbol, timeframe, length);

            while (!h.Complete)
            {
                Thread.Sleep(100);
            }
            //-----------------------

            Quantum q = h.Data;
            var dz = new DenseMatrix(4 + 1 + ind.SubIndicatorSize, q.Data.Count);
            List<string> names = new List<string>();
            names.Add("symbol");
            names.Add(ind.ToString());
            foreach (var indicator in ind.SubIndicators) names.Add(indicator.Key);

            //chartoptions
            ChartOption[] chartOptions = new ChartOption[names.Count];
            chartOptions[0] = new ChartOption() { Height = 400, YPosition = 0 };
            chartOptions[1] = new ChartOption() { Height = 200, YPosition = 1 };
            for (int i = 2; i < chartOptions.Length; i++)
                chartOptions[i] = new ChartOption() { Height = 0, YPosition = 1, Layover = true };

            int counter = 0;
            foreach (Tick tick in q)
            {
                dz[0, counter] = tick.BidOpen;
                dz[1, counter] = tick.BidHigh;
                dz[2, counter] = tick.BidLow;
                dz[3, counter] = tick.BidClose;

                dz[4, counter] = ind.HandleNextTick(tick);

                int icounter = 5;
                foreach (var subind in ind.SubIndicators.Values)
                {
                    dz[icounter, counter] = subind[0];
                    icounter++;
                }

                counter++;
            }


            Visualize.GenerateMultiPaneGraph(names.ToArray(), q.Data.Keys.ToArray(), dz, QSConstants.DEFAULT_DATA_FILEPATH + @"results.html",
                chartOptions);

            Console.WriteLine("Done Generating Graph for " + ind.ToString());
        }