예제 #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);
        }
예제 #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);
        }
예제 #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;
            }
        }
예제 #4
0
파일: FdkBars.cs 프로젝트: ihalankou/rFdk
        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);
        }
예제 #5
0
파일: FdkRStatic.cs 프로젝트: hombrevrc/FDK
        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);
        }
예제 #6
0
파일: FdkBars.cs 프로젝트: ihalankou/rFdk
        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;
            }
        }
예제 #7
0
파일: FdkBars.cs 프로젝트: ihalankou/rFdk
        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);
        }
예제 #8
0
 static DateTime ValidTimeFromTwoTimes(DateTime bidTime, DateTime askTime)
 {
     return(FdkHelper.IsTimeZero(bidTime) ? askTime : bidTime);
 }
예제 #9
0
 public static void Disconnect()
 {
     Calculator = null;
     FdkHelper.Disconnect();
     FdkVars.ClearAll();
 }
예제 #10
0
 public static void DisplayDate(DateTime time)
 {
     FdkHelper.DisplayDate(time);
 }
예제 #11
0
파일: FdkRStatic.cs 프로젝트: hombrevrc/FDK
 public static void Disconnect()
 {
     FdkHelper.Disconnect();
 }