Пример #1
0
        public string[] toStringArray(FinanceStrategies strategy = FinanceStrategies.Google)
        {
            List <string> result = new List <string>();

            result.Add(name);
            result.Add(symbol);
            result.Add(FinanceUnifier.getExchangeFullTitle(exch));
            result.Add((type != null) ? type : typeDisp);
            result.Add(Quantity.ToString());
            result.Add(((double)PricePurchase).ToString("0.00") + " " + Currency.Symbol);
            result.Add(PriceCurrent.ToString("0.00") + " " + Currency.Symbol);
            result.Add(ChangePercentage);
            result.Add(CurrentValue.ToString("0.00") + " " + Currency.Symbol);
            result.Add(CurrentValueChange.ToString("+0.00%;-0.00%"));
            result.Add((CurrentValue - ((double)Quantity * (double)PricePurchase)).ToString("+0.00;-0.00") + " " + Currency.Symbol);

            if (strategy == FinanceStrategies.Yahoo)
            {
                result.Add(BookValue.ToString() + " " + Currency.Symbol);
                result.Add(MarketCapitalization);
                result.Add(FiftydayMovingAverage.ToString());
                result.Add(TwoHundreddayMovingAverage.ToString());
            }

            return(result.ToArray());
        }
Пример #2
0
        /// <summary>
        /// Sets the finance strategy
        /// </summary>
        private void setStrategy(FinanceStrategies strategy)
        {
            this.strategy = strategy;
            switch (strategy)
            {
            case FinanceStrategies.Yahoo:
                financeStrategy     = new YahooFinanceStrategy(symbol, exchange);
                financeDataStrategy = new YahooDataTransformer();
                break;

            case FinanceStrategies.Google:
            default:
                // unify yahoo & google
                exchange = FinanceUnifier.transformExchangeToGoogle(symbol, exchange);
                symbol   = FinanceUnifier.transformSymbolToGoogle(symbol);

                financeStrategy     = new GoogleFinanceStrategy(symbol, exchange);
                financeDataStrategy = new GoogleDataTransformer();
                break;
            }
        }
Пример #3
0
 /// <summary>
 /// Constructor sets the strategy
 /// </summary>
 public FinanceAPI(FinanceStrategies strategy, string symbol, string exchange = null)
 {
     this.symbol   = symbol;
     this.exchange = exchange;
     setStrategy(strategy);
 }