Ejemplo n.º 1
0
        private bool validateForm()
        {
            Gdk.Color redColor = new Gdk.Color();
            Gdk.Color.Parse("red", ref redColor);

            Gdk.Color whiteColor = new Gdk.Color();
            Gdk.Color.Parse("white", ref whiteColor);

            if (isInvalidDecimal(PriceEntry.Text))
            {
                PriceEntry.ModifyBase(StateType.Normal, redColor);
                return(false);
            }
            else
            {
                PriceEntry.ModifyBase(StateType.Normal, whiteColor);
            }

            if (String.IsNullOrEmpty(EmployeeComboBox.ActiveText))
            {
                EmployeeComboBox.ModifyText(StateType.Normal, redColor);
                return(false);
            }
            else
            {
                EmployeeComboBox.ModifyText(StateType.Normal, whiteColor);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Upload([Bind("Symbol, Contents")] PriceEntriesUpload priceEntriesUpload)
        {
            if (ModelState.IsValid)
            {
                if (_context.Stocks.Any(x => x.Symbol == priceEntriesUpload.Symbol))
                {
                    _context.Remove(_context.Stocks.FirstOrDefault(x => x.Symbol == priceEntriesUpload.Symbol));
                    _context.PriceEntries.Clear(_context.PriceEntries.Where(x => x.Stock.Symbol == priceEntriesUpload.Symbol));
                    await _context.SaveChangesAsync();
                }

                Stock stock = new Stock()
                {
                    Symbol = priceEntriesUpload.Symbol, Prices = new List <PriceEntry>()
                };

                using (TextReader tr = new StringReader(priceEntriesUpload.Contents))
                {
                    var csv = new CsvReader(tr, new CsvConfiguration()
                    {
                        HasHeaderRecord = false
                    });
                    while (csv.Read())
                    {
                        PriceEntry priceEntry = new PriceEntry();
                        priceEntry.Date   = csv.GetField <DateTime>(0);
                        priceEntry.High   = csv.GetField <Decimal>(1);
                        priceEntry.Low    = csv.GetField <Decimal>(2);
                        priceEntry.Open   = csv.GetField <Decimal>(3);
                        priceEntry.Close  = csv.GetField <Decimal>(4);
                        priceEntry.Volume = csv.GetField <int>(5);


                        stock.Prices.Add(priceEntry);
                    }

                    stock.FillCalculatedFields();

                    _context.Stocks.Add(stock);

                    await _context.SaveChangesAsync();
                }

                return(RedirectToAction("Index", "Home"));
            }
            return(View("Index", priceEntriesUpload));
        }
Ejemplo n.º 3
0
        //+ FIXES
        private void FixEntryPrefab()
        {
            PriceEntry       old   = priceEntryPrefab.GetComponent <PriceEntry>();
            ModdedPriceEntry entry = priceEntryPrefab.AddComponent <ModdedPriceEntry>();

            entry.amountText       = old.amountText;
            entry.changeAmountText = old.changeAmountText;
            entry.changeIcon       = old.changeIcon;
            entry.coinIcon         = old.coinIcon;
            entry.itemIcon         = old.itemIcon;
            entry.bonusFill        = old.bonusFill;

            entry.market = this;
            entry.dir    = econDir;

            Destroy(old);
        }
Ejemplo n.º 4
0
 private void TransactionNameEntry_Completed(object sender, System.EventArgs e)
 {
     PriceEntry.Focus();
 }
Ejemplo n.º 5
0
 public SymbolRate(string symbol, PriceEntry price)
 {
     this.price  = price;
     this.symbol = symbol;
 }
Ejemplo n.º 6
0
        public void Download(IJobCancellationToken cancellationToken)
        {
            var ti = uow.TimeIntervals.GetAll().FirstOrDefault(x => x.Duration == TimeSpan.FromDays(1));

            var result = uow.BrokerInstruments.GetAllForBroker("YA");//.Where(x => x.Id>54 && x.Id <58);

            logger.LogInformation("YahooDownloader will download " + result.Count() + " BrokerInstruments");
            foreach (var element in result)
            {
                logger.LogInformation("YahooDownloader start " + element.BrokerSymbol.Name);
                List <YahooHistoricalPriceData> yahooPriceHistory = null;
                try
                {
                    yahooPriceHistory =
                        _yahooFinance.GetDailyHistoricalPriceData(element.BrokerSymbol.Name,
                                                                  endDate: DateTime.Today + TimeSpan.FromDays(1),
                                                                  startDate: DateTime.Today - TimeSpan.FromDays(3));

                    yahooPriceHistory.Sort((x, y) => x.Date.CompareTo(y.Date));

                    foreach (var price in yahooPriceHistory)
                    {
                        if (price.Volume > 0)
                        {
                            var priceDate  = element.BrokerSymbol.Exchange.CloseTimeOnDate(price.Date);
                            var priceEntry = uow.PriceEntries.GetForBrokerInstrument(element.Id, ti, priceDate);
                            if (priceEntry == null)
                            {
                                priceEntry = new PriceEntry();
                                logger.LogInformation("YahooDownloader " + element.BrokerSymbol.Name +
                                                      " new Price for " + price.Date);
                                uow.PriceEntries.Add(priceEntry);
                            }
                            else
                            {
                                logger.LogInformation("YahooDownloader " + element.BrokerSymbol.Name + " updated Price for " + price.Date);
                            }
                            priceEntry.BrokerInstrument = element;
                            priceEntry.IsFinished       = true;
                            priceEntry.Open             = price.Open;
                            priceEntry.High             = price.High;
                            priceEntry.Low          = price.Low;
                            priceEntry.Close        = price.Close;
                            priceEntry.Volume       = price.Volume;
                            priceEntry.TimeInterval = ti;
                            priceEntry.TimeStamp    = priceDate;
                            uow.PriceEntries.UpdateIndicatorData(priceEntry);
                        }
                    }
                }
                catch (Exception e)
                {
                    logger.LogInformation("YahooDownloader Exception " + e.ToString());
                }

                var currentPriceEntry = uow.PriceEntries.GetForBrokerInstrument(element.Id, ti).FirstOrDefault(x => x.IsFinished == false);

                if (yahooPriceHistory?.FirstOrDefault()?.Date != DateTime.Now.Date &&
                    element.BrokerSymbol.Exchange.IsOpen
                    )
                {
                    YahooRealTimeData rt = _yahooFinance.GetRealTimeData(element.BrokerSymbol.Name);
                    if (rt != null && rt.LastTradeTime.TimeOfDay < DateTime.Now.TimeOfDay)
                    {
                        DateTime compare = rt.LastTradeTime.Date;

                        if (currentPriceEntry == null)
                        {
                            currentPriceEntry = new PriceEntry();
                            uow.PriceEntries.AddPrice(currentPriceEntry);
                        }
                        //var realTradeTime = rt.LastTradeTime + element.Exchange.TimeZoneOffset;

                        currentPriceEntry.BrokerInstrument = element;
                        currentPriceEntry.IsFinished       = false;
                        currentPriceEntry.Open             = rt.Open;
                        currentPriceEntry.High             = rt.High;
                        currentPriceEntry.Low          = rt.Low;
                        currentPriceEntry.Close        = rt.Last;
                        currentPriceEntry.Volume       = rt.Volume;
                        currentPriceEntry.TimeInterval = ti;
                        currentPriceEntry.TimeStamp    = element.BrokerSymbol.Exchange.getLocalTime(rt.LastTradeTime);
                        uow.PriceEntries.UpdateIndicatorData(currentPriceEntry);
                    }
                }
                else
                {
                    if (currentPriceEntry != null)
                    {
                        uow.PriceEntries.Remove(currentPriceEntry);
                    }
                }
            }

            uow.Complete();

            BackgroundJob.Enqueue <SignalProcessor>(x => x.ProcessAllSignals(JobCancellationToken.Null));
        }
Ejemplo n.º 7
0
 public SymbolRate(string symbol, PriceEntry price)
 {
     this.price = price;
     this.symbol = symbol;
 }