コード例 #1
0
ファイル: FdkBars.cs プロジェクト: ULepiashynski/rFdk
        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
ファイル: FdkRealTime.cs プロジェクト: hombrevrc/FDK
        public static string GetLocalQuoteSnapshot(double id)
        {
            var    quotes = BuildSnapshotFromMonitor(id);
            string result = FdkVars.RegisterVariable(quotes, "localSnapshot");

            return(result);
        }
コード例 #3
0
ファイル: FdkBarPairs.cs プロジェクト: ULepiashynski/rFdk
        public static double[] GetBarsAskHigh(string pairBars)
        {
            var barData = FdkVars.GetValue <PairBar[]>(pairBars);

            return(FdkBars.GetBarsHigh(barData
                                       .SelectToArray(barPair => barPair.Ask.ToBarData())));
        }
コード例 #4
0
ファイル: FdkLevel2.cs プロジェクト: ULepiashynski/rFdk
        /// <summary>
        /// Get quote packed
        /// </summary>
        /// <param name="symbol">Symbol to get quotes on</param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="levelDbl"></param>
        /// <returns></returns>
        public static string GetQuotePacked(string symbol, DateTime startTime, DateTime endTime, double levelDbl = 2)
        {
            try
            {
                var level = (int)levelDbl;

                Log.InfoFormat("FdkLevel2.GetQuotePacked( symbol: {0}, startTime: {1}, endTime: {2}, level: {3} {4})",
                               symbol, startTime, endTime, levelDbl, startTime.Kind.ToString());


                Quote[] quotesData      = FdkQuotes.CalculateHistoryForSymbolArray(symbol, startTime, endTime, level);
                var     quoteLevel2Data = BuildQuoteMultiLevelData(quotesData, level);

                var quoteHistory = FdkVars.RegisterVariable(quoteLevel2Data, "quotesL2");
                return(quoteHistory);
            }
            catch (OutOfMemoryException ex)
            {
                Log.Error("Too large amount of data. Adjust the query");
                throw;
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
            finally
            {
                GC.Collect();
            }
        }
コード例 #5
0
        /// <summary>
        /// Get the bar data as pairs
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="barPeriodStr"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="barCountDbl"></param>
        /// <returns></returns>
        public static string ComputeGetPairBars(string symbol, string barPeriodStr, DateTime startTime, DateTime endTime, double barCountDbl)
        {
            try
            {
                var barPeriod = FdkHelper.GetFieldByName <BarPeriod>(barPeriodStr);
                if (barPeriod == null)
                {
                    return(String.Empty);
                }

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

                PairBar[] barsData;
                if (FdkHelper.IsTimeZero(startTime))
                {
                    var barCount = (int)barCountDbl;
                    barsData = GetPairBarsSymbolArray(symbol, barPeriod, endTime, -barCount);
                }
                else
                {
                    barsData = GetPairBarsSymbolArrayRangeTime(symbol, barPeriod, startTime, endTime);
                }

                var bars = FdkVars.RegisterVariable(barsData, "barPairs");
                return(bars);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
コード例 #6
0
        public static DateTime[] GetBarsAskFrom(string pairBars)
        {
            var barData = FdkVars.GetValue <PairBar[]>(pairBars);

            return(barData
                   .Select(barPair => ValidTimeFromTwoTimes(TimeFrom(barPair.Bid), TimeFrom(barPair.Ask)))
                   .ToArray());
        }
コード例 #7
0
ファイル: FdkTradeReports.cs プロジェクト: ULepiashynski/rFdk
        public static string GetTradeTransactionReportAll()
        {
            var tradeRecordsStream = Trade.Server.GetTradeTransactionReports(TimeDirection.Forward, false, null, null)
                                     .ToArray().ToList();
            var tradeRecordList = tradeRecordsStream.ToArray();

            var varName = FdkVars.RegisterVariable(tradeRecordList, "tradeReports");

            return(varName);
        }
コード例 #8
0
ファイル: FdkBars.cs プロジェクト: ULepiashynski/rFdk
        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;
            }
        }
コード例 #9
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);
        }
コード例 #10
0
ファイル: FdkSessionInfo.cs プロジェクト: ULepiashynski/rFdk
 public static string GetSessionInfo()
 {
     try
     {
         var sessionInfo = Feed.Server.GetSessionInfo();
         var result      = FdkVars.RegisterVariable(sessionInfo, "SessionInfo");
         return(result);
     }
     catch (Exception ex)
     {
         Log.Error(ex);
         throw;
     }
 }
コード例 #11
0
ファイル: FdkRealTime.cs プロジェクト: hombrevrc/FDK
 public static string SnapshotMonitoredSymbol(double id)
 {
     try
     {
         var quotes        = BuildSnapshotFromMonitor(id);
         var resultVarName = FdkVars.RegisterVariable(quotes, "rt_quotes_snapshot");
         return(resultVarName);
     }
     catch (Exception ex)
     {
         Log.Error(ex);
         throw;
     }
 }
コード例 #12
0
 public static string GetSymbolInfos()
 {
     try
     {
         var symbolInfos = Symbols;
         var varName     = FdkVars.RegisterVariable(symbolInfos, "symbolsInfo");
         return(varName);
     }
     catch (Exception ex)
     {
         Log.Error(ex);
         throw;
     }
 }
コード例 #13
0
ファイル: FdkCurrencyInfo.cs プロジェクト: ihalankou/rFdk
        public static string GetCurrencyInfos()
        {
            try
            {
                var symbolInfos = FdkHelper.Wrapper.ConnectLogic.Feed.Cache.Currencies;
                var varName     = FdkVars.RegisterVariable(symbolInfos, "currencyInfo");
                return(varName);
            }
            catch (Exception ex)
            {
                Log.Error(ex);

                throw;
            }
        }
コード例 #14
0
        public static string GetTradeHistory()
        {
            try
            {
                TradeRecord[] tradeRecords = Trade.Server.GetTradeRecords()
                                             .ToArray();

                var varName = FdkVars.RegisterVariable(tradeRecords, "trades");
                return(varName);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
コード例 #15
0
ファイル: FdkQuotes.cs プロジェクト: ULepiashynski/rFdk
        public static string ComputeQuoteHistory(string symbol, DateTime startTime, DateTime endTime, double depthDbl)
        {
            try
            {
                var depth = (int)depthDbl;
                Log.InfoFormat("FdkQuotes.ComputeQuoteHistory( symbol: {0}, startTime: {1}, endTime: {2}, level: {3})",
                               symbol, startTime, endTime, depthDbl);

                var quotesData   = CalculateHistoryForSymbolArray(symbol, startTime, endTime, depth);
                var quoteHistory = FdkVars.RegisterVariable(quotesData, "quotes");
                return(quoteHistory);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
コード例 #16
0
ファイル: FdkTradeReports.cs プロジェクト: ULepiashynski/rFdk
        public static string GetTradeTransactionReport(DateTime from, DateTime to)
        {
            try
            {
                Log.InfoFormat("FdkTradeReports.GetTradeTransactionReport( from: {0}, to: {1}",
                               from, to);

                var tradeRecordsStream = Trade.Server.GetTradeTransactionReports(TimeDirection.Forward, false, from, to)
                                         .ToArray().ToList();
                var tradeRecordList = tradeRecordsStream.ToArray();

                var varName = FdkVars.RegisterVariable(tradeRecordList, "tradeReports");
                return(varName);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
コード例 #17
0
        /// <summary>
        /// Get quote packed
        /// </summary>
        /// <param name="symbol">Symbol to get quotes on</param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="levelDbl"></param>
        /// <returns></returns>
        public static string GetQuotePacked(string symbol, DateTime startTime, DateTime endTime, double levelDbl = 2)
        {
            try
            {
                var level = (int)levelDbl;

                Log.InfoFormat("FdkLevel2.GetQuotePacked( symbol: {0}, startTime: {1}, endTime: {2}, level: {3})",
                               symbol, startTime, endTime, levelDbl);

                Quote[] quotesData      = FdkQuotes.CalculateHistoryForSymbolArray(symbol, startTime, endTime, level);
                var     quoteLevel2Data = BuildQuoteMultiLevelData(quotesData, level);

                var quoteHistory = FdkVars.RegisterVariable(quoteLevel2Data, "quotesL2");
                return(quoteHistory);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
コード例 #18
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;
            }
        }
コード例 #19
0
        public static string GetTradeRecords(DateTime startTime, DateTime endTime)
        {
            try
            {
                var           allTrades    = Trade.Server.GetTradeRecords();
                TradeRecord[] tradeRecords = allTrades
                                             .Where(trade => OpenTradeTypes.Contains(trade.Type))
                                             .Where(tr => tr.Created != null && (tr.Created >= startTime && tr.Created <= endTime))
                                             .ToArray();

                Log.InfoFormat("FdkTrade.GetTradeRecords( start: {0}, end: {1}",
                               startTime, endTime);

                var varName = FdkVars.RegisterVariable(tradeRecords, "trades");
                return(varName);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
コード例 #20
0
ファイル: FdkQuotes.cs プロジェクト: ULepiashynski/rFdk
        public static double[] QuotesSpread(string bars)
        {
            var quotes = FdkVars.GetValue <Quote[]>(bars);

            return(QuoteArraySpread(quotes));
        }
コード例 #21
0
ファイル: FdkRealTime.cs プロジェクト: hombrevrc/FDK
        public static DateTime[] QuoteRealTimeReceivingTime(string snapshotName)
        {
            var quotes = FdkVars.GetValue <FdkRealTimeQuote[]>(snapshotName);

            return(quotes.SelectToArray(bid => bid.ReceivingTime.AddUtc()));
        }
コード例 #22
0
ファイル: FdkRealTime.cs プロジェクト: hombrevrc/FDK
        public static double[] QuoteRealTimeAskVolume(string snapshotName)
        {
            var quotes = FdkVars.GetValue <FdkRealTimeQuote[]>(snapshotName);

            return(quotes.SelectToArray(bid => bid.AskVolume));
        }
コード例 #23
0
        public static double[] GetBarsBidClose(string pairBars)
        {
            var barData = FdkVars.GetValue <PairBar[]>(pairBars);

            return(FdkBars.GetBarsClose(barData.SelectToArray(barPair => barPair.Bid)));
        }
コード例 #24
0
        public static DateTime[] GetBarsBidTo(string pairBars)
        {
            var barData = FdkVars.GetValue <PairBar[]>(pairBars);

            return(FdkBars.GetBarsTo(barData.SelectToArray(barPair => barPair.Bid)));
        }
コード例 #25
0
ファイル: FdkCurrencyInfo.cs プロジェクト: ihalankou/rFdk
        public static double[] GetCurrencySortOrder(string currencyInfo)
        {
            var currencyInfos = FdkVars.GetValue <CurrencyInfo[]>(currencyInfo);

            return(currencyInfos.SelectToArray(b => (double)b.SortOrder));
        }
コード例 #26
0
ファイル: FdkCurrencyInfo.cs プロジェクト: ihalankou/rFdk
        public static double[] GetCurrencyPrecision(string currencyInfo)
        {
            var currencyInfos = FdkVars.GetValue <CurrencyInfo[]>(currencyInfo);

            return(currencyInfos.SelectToArray(b => (double)b.Precision));
        }
コード例 #27
0
ファイル: FdkCurrencyInfo.cs プロジェクト: ihalankou/rFdk
        public static string[] GetCurrencyName(string currencyInfo)
        {
            var currencyInfos = FdkVars.GetValue <CurrencyInfo[]>(currencyInfo);

            return(currencyInfos.SelectToArray(b => b.Name));
        }
コード例 #28
0
ファイル: FdkCurrencyInfo.cs プロジェクト: ihalankou/rFdk
        public static string[] GetCurrencyDescription(string currencyInfo)
        {
            var currencyInfos = FdkVars.GetValue <CurrencyInfo[]>(currencyInfo);

            return(currencyInfos.SelectToArray(b => b.Description));
        }
コード例 #29
0
ファイル: FdkQuotes.cs プロジェクト: ULepiashynski/rFdk
        public static DateTime[] QuotesCreatingTime(string bars)
        {
            var quotes = FdkVars.GetValue <Quote[]>(bars);

            return(QuoteArrayCreateTime(quotes));
        }
コード例 #30
0
        public static double[] GetBarsAskVolume(string pairBars)
        {
            var barData = FdkVars.GetValue <PairBar[]>(pairBars);

            return(FdkBars.GetBarsVolume(barData.SelectToArray(barPair => barPair.Ask)));
        }