示例#1
0
 public NewSymbolDialog(ListBox symbols, FinancialCalculator calcualtor)
 {
     this.symbols = symbols;
     this.calculator = calcualtor;
     this.InitializeComponent();
     this.UpdatePreview();
 }
示例#2
0
 public NewCurrencyDialog(ListBox currencies, FinancialCalculator calcualtor)
 {
     this.currencies = currencies;
     this.calculator = calcualtor;
     this.InitializeComponent();
     this.UpdateState();
 }
示例#3
0
文件: SymbolEntry.cs 项目: ifzz/FDK
        /// <summary>
        /// Creates a new symbol entry from symbol in XXX/YYY format.
        /// </summary>
        /// <param name="owner">valid instance of financial calculator</param>
        /// <param name="symbol">symbol inf XXX/YYY format</param>
        public SymbolEntry(FinancialCalculator owner, string symbol)
            : base(owner)
        {
            if (symbol == null)
                throw new ArgumentNullException(nameof(symbol));

            var from = string.Empty;
            var to = string.Empty;
            var index = symbol.IndexOf('/');

            if (index != -1)
            {
                to = symbol.Substring(0, index);
                from = symbol.Substring(1 + index, symbol.Length - index - 1);
            }

            if (index == -1 || from.Contains('/') || to.Contains('/'))
            {
                var message = string.Format("Symbol = {0} should has XXX/YYY format", symbol);
                throw new ArgumentException(message, nameof(symbol));
            }

            this.Symbol = symbol;
            this.From = from;
            this.To = to;

            this.MarginCalcMode = MarginCalcMode.Forex;
        }
示例#4
0
        /// <summary>
        /// Creates new financial state of account calculator.
        /// </summary>
        /// <param name="trade">valid instance of not started data trade</param>
        /// <param name="feed">valid instance of not started data feed</param>
        public StateCalculator(DataTrade trade, DataFeed feed)
        {
            if (trade == null)
                throw new ArgumentNullException(nameof(trade), "Data trade argument can not be null");

            if (trade.IsStarted)
                throw new ArgumentException("Started data trade can not be used for creating state calculator.", nameof(trade));

            if (feed == null)
                throw new ArgumentNullException(nameof(feed), "Data feed argument can not be null");

            if (feed.IsStarted)
                throw new ArgumentException("Started data feed can not be used for creating state calculator.", nameof(feed));


            this.quotes = new Dictionary<string, Quote>();
            this.calculatorQuotes = new Dictionary<string, Quote>();

            this.calculator = new FinancialCalculator();
            this.account = new AccountEntry(calculator);
            this.calculator.Accounts.Add(this.account);

            this.trade = trade;
            this.feed = feed;

            this.processor = new Processor(this.Calculate);

            this.processor.Exception += this.OnException;
            this.processor.Executed += this.OnExecuted;

            this.updateHandler = new UpdateHandler(trade, feed, this.OnUpdate, processor);
        }
示例#5
0
        /// <summary>
        /// Creates a new symbol entry from symbol in XXX/YYY format.
        /// </summary>
        /// <param name="owner">valid instance of financial calculator</param>
        /// <param name="symbol">symbol inf XXX/YYY format</param>
        public SymbolEntry(FinancialCalculator owner, string symbol)
            : base(owner)
        {
            if (symbol == null)
            {
                throw new ArgumentNullException(nameof(symbol));
            }

            var from  = string.Empty;
            var to    = string.Empty;
            var index = symbol.IndexOf('/');

            if (index != -1)
            {
                to   = symbol.Substring(0, index);
                from = symbol.Substring(1 + index, symbol.Length - index - 1);
            }

            if (index == -1 || from.Contains('/') || to.Contains('/'))
            {
                var message = string.Format("Symbol = {0} should has XXX/YYY format", symbol);
                throw new ArgumentException(message, nameof(symbol));
            }

            this.Symbol = symbol;
            this.From   = from;
            this.To     = to;

            this.MarginCalcMode = MarginCalcMode.Forex;
        }
示例#6
0
文件: FdkSymbolInfo.cs 项目: ifzz/FDK
 public static void RegisterToFeed(DataFeed feed, FinancialCalculator calculator)
 {
     feed.Tick += (object sender, TickEventArgs e) =>
     {
         calculator.Prices.Update(e.Tick.Symbol, e.Tick.Bid, e.Tick.Ask);
     };
     feed.Server.SubscribeToQuotes(Symbols.Select(symbol=>symbol.Name), 1);            
 }
示例#7
0
        /// <summary>
        /// Creates a new instance of symbol entires.
        /// </summary>
        /// <param name="owner">a valid instance of financial calculator</param>
        public SymbolEntries(FinancialCalculator owner)
            : base(owner)
        {
            this.symbols         = new Dictionary <string, SymbolEntry>();
            this.currencyToIndex = new Dictionary <string, int>();
            this.indexToCurrency = new List <string>();

            this.HasBeenChanged = true;
        }
示例#8
0
        public CurrencyEntry(FinancialCalculator owner, string name, int precision, int priority)
            : base(owner)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (precision == 0)
            {
                throw new ArgumentNullException(nameof(precision));
            }

            Name      = name;
            Precision = precision;
            SortOrder = priority;
        }
示例#9
0
文件: SymbolEntry.cs 项目: ifzz/FDK
        /// <summary>
        /// Creates a new symbol entry.
        /// </summary>
        /// <param name="owner">va</param>
        /// <param name="symbol">Financial instrument name</param>
        /// <param name="profitCurrency">Profit currency</param>
        /// <param name="marginCurrency">Trade currency</param>
        public SymbolEntry(FinancialCalculator owner, string symbol, string profitCurrency, string marginCurrency)
            : base(owner)
        {
            if (symbol == null)
                throw new ArgumentNullException(nameof(symbol));

            if (profitCurrency == null)
                throw new ArgumentNullException(nameof(profitCurrency));

            if (marginCurrency == null)
                throw new ArgumentNullException(nameof(marginCurrency));

            this.Symbol = symbol;
            this.From = profitCurrency;
            this.To = marginCurrency;

            this.MarginCalcMode = MarginCalcMode.Forex;
        }
示例#10
0
        /// <summary>
        /// Creates new financial state of account calculator.
        /// </summary>
        /// <param name="trade">valid instance of not started data trade</param>
        /// <param name="feed">valid instance of not started data feed</param>
        public StateCalculator(DataTrade trade, DataFeed feed)
        {
            if (trade == null)
            {
                throw new ArgumentNullException(nameof(trade), "Data trade argument can not be null");
            }

            if (trade.IsStarted)
            {
                throw new ArgumentException("Started data trade can not be used for creating state calculator.", nameof(trade));
            }

            if (feed == null)
            {
                throw new ArgumentNullException(nameof(feed), "Data feed argument can not be null");
            }

            if (feed.IsStarted)
            {
                throw new ArgumentException("Started data feed can not be used for creating state calculator.", nameof(feed));
            }


            this.quotes           = new Dictionary <string, Quote>();
            this.calculatorQuotes = new Dictionary <string, Quote>();

            this.calculator = new FinancialCalculator();
            this.account    = new AccountEntry(calculator);
            this.calculator.Accounts.Add(this.account);

            this.trade = trade;
            this.feed  = feed;

            this.processor = new Processor(this.Calculate);

            this.processor.Exception += this.OnException;
            this.processor.Executed  += this.OnExecuted;

            this.updateHandler = new UpdateHandler(trade, feed, this.OnUpdate, processor);
        }
示例#11
0
        public SetRatesOfCurrentTime(List<SymbolInfo> symbolInfoDic, FinancialCalculator calculator)
        {
            _symbolInfoDic = symbolInfoDic;
            _calculator = calculator;
            _currencies = new HashSet<string>();
            Symbols = new Dictionary<string, SymbolInfo>();
            foreach (var sym in symbolInfoDic)
            {
                _currencies.Add(sym.Currency);
                _currencies.Add(sym.SettlementCurrency);
                Symbols[sym.Name] = sym;
            }

            foreach (var curr in _calculator.Currencies)
            {
                _currencies.Remove(curr);
            }

            foreach (var sym in _calculator.Symbols)
            {
                Symbols.Remove(sym.Symbol);
            }
        }
示例#12
0
        /// <summary>
        /// Creates a new symbol entry.
        /// </summary>
        /// <param name="owner">va</param>
        /// <param name="symbol">Financial instrument name</param>
        /// <param name="profitCurrency">Profit currency</param>
        /// <param name="marginCurrency">Trade currency</param>
        public SymbolEntry(FinancialCalculator owner, string symbol, string profitCurrency, string marginCurrency)
            : base(owner)
        {
            if (symbol == null)
            {
                throw new ArgumentNullException(nameof(symbol));
            }

            if (profitCurrency == null)
            {
                throw new ArgumentNullException(nameof(profitCurrency));
            }

            if (marginCurrency == null)
            {
                throw new ArgumentNullException(nameof(marginCurrency));
            }

            this.Symbol = symbol;
            this.From   = profitCurrency;
            this.To     = marginCurrency;

            this.MarginCalcMode = MarginCalcMode.Forex;
        }
示例#13
0
 static string FormatTextFromCalculator(FinancialCalculator calc)
 {
     using (var stream = new MemoryStream())
     {
         calc.Save(stream);
         stream.Position = 0;
         using (var reader = new StreamReader(stream))
         {
             var result = reader.ReadToEnd();
             return result;
         }
     }
 }
示例#14
0
文件: FdkRStatic.cs 项目: ifzz/FDK
 static FdkStatic()
 {
     Calculator = new FinancialCalculator();
     SetupLog4Net();
 }
示例#15
0
 /// <summary>
 /// Creates a new instance of currency entires.
 /// </summary>
 /// <param name="owner">a valid instance of financial calculator</param>
 public CurrencyEntries(FinancialCalculator owner)
     : base(owner)
 {
     this.currencies     = new Dictionary <string, CurrencyEntry>();
     this.HasBeenChanged = true;
 }