Ejemplo n.º 1
0
        internal static string CombinedBarsRangeTime(string symbol, BarPeriod barPeriod, DateTime startTime, DateTime endTime, double barCountDbl)
        {
            var isTimeZero = FdkHelper.IsTimeZero(startTime);


            BarData[] barsDataBid;
            BarData[] barsDataAsk;
            if (FdkHelper.IsTimeZero(startTime))
            {
                var barCount = (int)barCountDbl;
                if (barCount == 0)
                {
                    barCount = FdkBars.HugeCount;
                }
                barsDataAsk = CalculateBarsForSymbolArray(symbol, PriceType.Ask, endTime, barPeriod, barCount);
                barsDataBid = CalculateBarsForSymbolArray(symbol, PriceType.Bid, endTime, barPeriod, barCount);
            }
            else
            {
                barsDataAsk = CalculateBarsForSymbolArrayRangeTime(symbol, PriceType.Ask, startTime, endTime, barPeriod);
                barsDataBid = CalculateBarsForSymbolArrayRangeTime(symbol, PriceType.Bid, startTime, endTime, barPeriod);
            }
            ReversIfNeed(barsDataAsk);
            ReversIfNeed(barsDataBid);

            var barsData = FdkBarsMerger.ProcessedBarsResult(barsDataBid, barsDataAsk);
            //LogBars(barsData);
            var bars = FdkVars.RegisterVariable(barsData, "bars");

            return(bars);
        }
Ejemplo n.º 2
0
        public static int ConnectToFdk(string address, string login, string password, string path)
        {
            Calculator = null;
            Console.WriteLine("Connecting ... ");
            var result = FdkHelper.ConnectToFdk(address, login, password, path);

            Console.WriteLine("Done");
            return(result);
        }
Ejemplo n.º 3
0
        public static string ComputeBarsRangeTime(string symbol, string priceTypeStr, string barPeriodStr,
                                                  DateTime startTime, DateTime endTime, double barCountDbl)
        {
            Stopwatch stopWatch = Stopwatch.StartNew();

            try
            {
                var barPeriod = FdkHelper.GetFieldByName <BarPeriod>(barPeriodStr);
                if (barPeriod == null)
                {
                    return(string.Empty);
                }

                if (priceTypeStr == "BidAsk")
                {
                    return(CombinedBarsRangeTime(symbol, barPeriod, startTime, endTime, barCountDbl));
                }

                var priceType = FdkHelper.ParseEnumStr <PriceType>(priceTypeStr);
                if (priceType == null)
                {
                    return(string.Empty);
                }

                Log.InfoFormat("FdkBars.ComputeBarsRangeTime( symbol: {0}, barPeriod: {1}, startTime: {2}, endTime: {3}, barCount: {4} priceType: {5})",
                               symbol, barPeriodStr, startTime, endTime, barCountDbl, priceType);

                BarData[] barsData;
                if (FdkHelper.IsTimeZero(startTime))
                {
                    var barCount = (int)barCountDbl;
                    if (barCount == 0)
                    {
                        barCount = HugeCount;
                    }
                    barsData = CalculateBarsForSymbolArray(symbol, priceType.Value, endTime, barPeriod, barCount);
                }
                else
                {
                    barsData = CalculateBarsForSymbolArrayRangeTime(symbol, priceType.Value, startTime, endTime, barPeriod);
                }

                Log.InfoFormat("Elapsed time: {0} ms for {1} items", stopWatch.ElapsedMilliseconds, barsData.Length);

                var bars = FdkVars.RegisterVariable(barsData, "bars");
                return(bars);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
Ejemplo n.º 4
0
        public static string ComputeGetPairBarsRange(string symbol, string barPeriodStr, DateTime startTime, DateTime endTime)
        {
            var barPeriod = FdkHelper.GetFieldByName <BarPeriod>(barPeriodStr);

            if (barPeriod == null)
            {
                return(string.Empty);
            }
            var barsData = FdkBarPairs.GetPairBarsSymbolArrayRangeTime(symbol, barPeriod, startTime, endTime);
            var bars     = FdkVars.RegisterVariable(barsData, "barPairs");

            return(bars);
        }
Ejemplo n.º 5
0
        public static int ConnectToFdk(string address, string login, string password, string path)
        {
            Console.WriteLine("Connecting ... ");
            var result = FdkHelper.ConnectToFdk(address, login, password, path);

            if (result == 0)
            {
                var symbolInfoDic           = FdkHelper.Wrapper.GetSymbolsDict();
                var symbolInfoList          = symbolInfoDic.Values.ToList();
                SetRatesOfCurrentTime rates = new SetRatesOfCurrentTime(symbolInfoList, Calculator);
                rates.Process();
            }
            Console.WriteLine("Done");
            return(result);
        }
Ejemplo n.º 6
0
        public static string ComputeBarsRangeTime(string symbol, string priceTypeStr, string barPeriodStr,
                                                  DateTime startTime, DateTime endTime, double barCountDbl)
        {
            try
            {
                var barPeriod = FdkHelper.GetFieldByName <BarPeriod>(barPeriodStr);
                if (barPeriod == null)
                {
                    return(string.Empty);
                }

                var priceType = FdkHelper.ParseEnumStr <PriceType>(priceTypeStr);
                if (priceType == null)
                {
                    return(string.Empty);
                }

                Log.InfoFormat("FdkBars.ComputeBarsRangeTime( symbol: {0}, barPeriod: {1}, startTime: {2}, endTime: {3}, barCount: {4})",
                               symbol, barPeriodStr, startTime, endTime, barCountDbl);

                Bar[] barsData;
                if (FdkHelper.IsTimeZero(startTime))
                {
                    var barCount = (int)barCountDbl;
                    barsData = CalculateBarsForSymbolArray(symbol, priceType.Value, endTime, barPeriod, barCount);
                }
                else
                {
                    barsData = CalculateBarsForSymbolArrayRangeTime(symbol, priceType.Value, startTime, endTime, barPeriod);
                }

                var bars = FdkVars.RegisterVariable(barsData, "bars");
                return(bars);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
Ejemplo n.º 7
0
        public static DateTime[] ComputeGetBarsInfo(string symbol, string priceTypeStr, string barPeriodStr)
        {
            var barPeriod = FdkHelper.GetFieldByName <BarPeriod>(barPeriodStr);

            if (barPeriod == null)
            {
                return(new DateTime[0]);
            }
            var priceType = FdkHelper.ParseEnumStr <PriceType>(priceTypeStr);

            if (priceType == null)
            {
                return(new DateTime[0]);
            }
            var barsData = GetBarsInfo(symbol, priceType.Value, barPeriod);
            var bars     = new[]
            {
                barsData.AvailableFrom,
                barsData.AvailableTo
            };

            return(bars);
        }
Ejemplo n.º 8
0
 static DateTime ValidTimeFromTwoTimes(DateTime bidTime, DateTime askTime)
 {
     return(FdkHelper.IsTimeZero(bidTime) ? askTime : bidTime);
 }
Ejemplo n.º 9
0
 public static void Disconnect()
 {
     Calculator = null;
     FdkHelper.Disconnect();
     FdkVars.ClearAll();
 }
Ejemplo n.º 10
0
 public static void DisplayDate(DateTime time)
 {
     FdkHelper.DisplayDate(time);
 }
Ejemplo n.º 11
0
 public static void Disconnect()
 {
     FdkHelper.Disconnect();
 }