public TransactionEntry AddSymbol(string exchange, string symbol, PortfolioEntry entry)
        {
            PositionFeed positionFeed = FinanceService.Query(new PositionQuery(entry.EditUri.Content + FinanceNamespace.POSITIONAPPENDQUERY + Details()));

            TransactionEntry transactionEntry = new TransactionEntry()
            {
                TransactionData = new TransactionData()
                {
                    Type = TransactionTypes.BUY
                }
            };

            PositionEntry positionEntry = new PositionEntry()
            {
                Symbol = new Symbol()
                {
                    StockSymbol = symbol,
                    Exchange    = exchange
                }
            };

            Uri uri = new Uri(positionFeed.Feed + "/" + positionEntry.Symbol.Exchange + ":" + positionEntry.Symbol.StockSymbol + "/" + FinanceNamespace.TRANSACTIONS);

            try
            {
                return(FinanceService.Insert(uri, transactionEntry));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception while trying to add symbol={0} to portfolio={1}", symbol + ":" + exchange, entry.Title.Text);
                Console.WriteLine("Exception: {0}", ex.Message);
                return(null);
            }
        }
Exemple #2
0
        public void TestDistanceBetweenPoints()
        {
            StopResolverConfig conf = new StopResolverConfig()
            {
                Time                     = 5,
                GroupRadius              = 30,
                MinStopAccuracy          = 400,
                StopMergeRadius          = 50,
                StopMergeMaxTravelRadius = 200,
            };

            StopResolver stopResolver = new StopResolver(conf);

            PositionEntry p1 = new PositionEntry()
            {
                Latitude = 52.083333, Longitude = 5.116667
            };
            PositionEntry p2 = new PositionEntry()
            {
                Latitude = 52.083333, Longitude = 4.316667
            };

            double distance = stopResolver.DistanceBetweenPoints(p1, p2);

            Assert.Equal(54712, Math.Round(distance));
        }
Exemple #3
0
        public void Add(PositionEntry entry)
        {
            prevpresPos = previousPositionEntry;

            if (initialPositionEntry == null)
            {
                initialPositionEntry = previousPositionEntry;
            }

            // Calculate distance between current and previous position
            if (previousPositionEntry != null)
            {
                PreviousDistance = previousPositionEntry.DistanceTo(entry);
            }

            // Use the accuracy of the current position to determine if
            // the current position could still be in range of the previous position.
            // Unless accuracy is (actual value) lower than the distance specified.
            double allowedDistance = entry.Accuracy < Distance ? Distance : entry.Accuracy;

            // Reset initial position if the new position compared to the previous and initial position
            // are outside the parameters
            if (initialPositionEntry != null && (initialPositionEntry.DistanceTo(entry) > allowedDistance || PreviousDistance > allowedDistance))
            {
                initialPositionEntry = null;
            }

            previousPositionEntry = entry;
        }
Exemple #4
0
        double DistanceWithoutAccuracy(PositionEntry position1, PositionEntry position2)
        {
            double distance           = DistanceBetweenPoints(position1, position2);
            double accuraciesDistance = position1.Accuracy + position2.Accuracy;

            return(distance - accuraciesDistance);
        }
Exemple #5
0
        public void OnLocationChanged(Location location)
        {
            _batteryHelper.CheckStoreBatteryLevel(TimeSpan.FromMinutes(10));

            positionCache.Distance = currentProfile.DistanceDeltaLowTracking;
            PositionEntry positionEntry = location.ToPositionEntry();

            positionCache.Add(positionEntry);
            Log.Trace($"GoogleApi: Location was changed {positionCache.PreviousDistance}");

            positionEntry.DistanceBetweenPreviousPosition = positionCache.PreviousDistance;

            if (positionCache.Check(TimeSpan.FromSeconds(currentProfile.TimePeriodLowTracking)))
            {
                // Enable Low Tracking if not already enabled
                if (currentRequestProfile != currentProfile.LowTrackingProfile)
                {
                    Log.Info("LowTracking");
                    currentRequestProfile = currentProfile.LowTrackingProfile;
                    RestartLocationUpdates();
                }
            }
            else if (currentRequestProfile != currentProfile.HighTrackingProfile)
            {
                Log.Info("HighTracking");
                currentRequestProfile = currentProfile.HighTrackingProfile;
                RestartLocationUpdates();
            }

            if (!positionEntry.Equals(previousPositionEntry))
            {
                positionEntryRepository.Add(positionEntry);
            }
        }
Exemple #6
0
        public async Task<ActionResult> Post([FromBody] Rootobject rootobject)
        {
            var playload = Convert.FromBase64String(rootobject.PayloadRaw);

            var cow = await _context.Cows.FirstOrDefaultAsync(x => x.HardwareSerial == rootobject.HardwareSerial);
            if (cow == null)
            {
                cow = new Cow
                {
                    Name = "Marguerite",
                    HardwareSerial = rootobject.HardwareSerial
                };

                await _context.Cows.AddAsync(cow);
            }

            var dateTime = new DateTime(rootobject.Metadata.Time.Ticks, DateTimeKind.Utc);

            var gpsEntry = new GpsEntry
            {
                Cow = cow,
                DateTime = dateTime,
                LatitudeDeg = Convert.ToInt32(playload[0]),
                LatitudeMinutes = Convert.ToInt32(playload[1]),
                LatitudeMinutesDecimals = Convert.ToInt32($"{Convert.ToInt32(playload[2]):00}" + $"{Convert.ToInt32(playload[3]):00}"),
                LatitudeDirection = Convert.ToChar(playload[4]),
                LongitudeDeg = Convert.ToInt32(playload[5]),
                LongitudeMinutes = Convert.ToInt32(playload[6]),
                LongitudeMinutesDecimals = Convert.ToInt32($"{Convert.ToInt32(playload[7]):00}" + $"{Convert.ToInt32(playload[8]):00}"),
                LongitudeDirection = Convert.ToChar(playload[9])
            };

            cow.GpsEntries.Add(gpsEntry);

            var temperatureEntry = new TemperatureEntry
            {
                Cow = cow,
                DateTime = dateTime,
                Temperature = Convert.ToSingle(Convert.ToInt32(playload[10]) + "." + Convert.ToInt32(playload[11]))
            };

            cow.TemperatureEntries.Add(temperatureEntry);

            var positionEntry = new PositionEntry
            {
                Cow = cow,
                DateTime = dateTime,
                IsUp = Convert.ToBoolean(Convert.ToInt32(playload[12])),
                X = Convert.ToInt32(playload[13]),
                Y = Convert.ToInt32(playload[14]),
                Z = Convert.ToInt32(playload[15])
            };

            cow.PositionEntries.Add(positionEntry);

            await _context.SaveChangesAsync();

            return Ok();
        }
        public void DeleteSymbol(PositionEntry positionEntry)
        {
            TransactionFeed transactionFeed = FinanceService.Query(new TransactionQuery(positionEntry.TransactionHerf + Details())); //+ FinanceNamespace.TRANSACTIONSAPPENDQUERY));

            foreach (TransactionEntry transactionEntry in transactionFeed.Entries)
            {
                FinanceService.Delete(new Uri(transactionEntry.EditUri.Content));
            }
        }
        public TransactionEntry AddSymbol(string exchange, string symbol, TransactionDataArgs args, PortfolioEntry entry)
        {
            PositionFeed positionFeed = FinanceService.Query(new PositionQuery(entry.EditUri.Content + FinanceNamespace.POSITIONAPPENDQUERY + Details()));

            TransactionEntry transactionEntry = new TransactionEntry()
            {
                TransactionData = new TransactionData()
                {
                    Type       = args.TransactionType,
                    Date       = args.Date.ToString(),
                    Shares     = args.Shares,
                    Notes      = args.Notes,
                    Commission = new Commission(),
                    Price      = new Price()
                }
            };

            PositionEntry positionEntry = new PositionEntry()
            {
                Symbol = new Symbol()
                {
                    StockSymbol = symbol,
                    Exchange    = exchange
                }
            };

            transactionEntry.TransactionData.Commission.Money.Add(new Money()
            {
                Amount = args.Commission, CurrencyCode = args.CurrencyCode
            });
            transactionEntry.TransactionData.Price.Money.Add(new Money()
            {
                Amount = args.Price, CurrencyCode = args.CurrencyCode
            });

            Uri uri = new Uri(positionFeed.Feed + "/" + positionEntry.Symbol.Exchange + ":" + positionEntry.Symbol.StockSymbol + "/" + FinanceNamespace.TRANSACTIONS);

            try
            {
                return(FinanceService.Insert(uri, transactionEntry));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception while trying to add symbol={0} to portfolio={1} and transaction: ", positionEntry.Symbol.Exchange + ":" + positionEntry.Symbol.StockSymbol, entry.Title.Text);
                Console.WriteLine("Type={0}, Date={1}, Shares={2}, Notes={3}, Commission={4}, Price={5}",
                                  transactionEntry.TransactionData.Type,
                                  transactionEntry.TransactionData.Date,
                                  transactionEntry.TransactionData.Shares,
                                  transactionEntry.TransactionData.Notes,
                                  transactionEntry.TransactionData.Commission,
                                  transactionEntry.TransactionData.Price);
                Console.WriteLine("Exception: {0}", ex.Message);
                return(null);
            }
        }
Exemple #9
0
        private void ClManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            _lastLocation = DateTime.Now;

            _batteryHelper.CheckStoreBatteryLevel(TimeSpan.FromMinutes(10));

            if (!_locationsDeferred && _currentCoreLocationProfile.AllowDeferredLocationUpdates)
            {
                _clManager.AllowDeferredLocationUpdatesUntil(_currentCoreLocationProfile.DeferredLocationUpdatesDistance,
                                                             _currentCoreLocationProfile.DeferredLocationUpdatesTimeout);
            }

            foreach (CLLocation l in e.Locations)
            {
                PositionEntry p = l.ToPosition();

                p.DesiredAccuracy = _clManager.DesiredAccuracy;

                _positionCache.Distance = _currentProfile.DistanceDeltaLowTracking;
                _positionCache.Add(p);

                p.DistanceBetweenPreviousPosition = _positionCache.PreviousDistance;

                // Check if new position is around the same location using distance and time period
                if (_positionCache.Check(TimeSpan.FromSeconds(_currentProfile.TimePeriodLowTracking)))
                {
                    // Enable Low Tracking if not already enabled
                    if (_currentCoreLocationProfile != _currentProfile.LowTrackingProfile)
                    {
                        Log.Info("LowTracking");
                        MonitorCurrentRegion(p.Latitude, p.Longitude, 100, "StopRegion");
                        _currentCoreLocationProfile = _currentProfile.LowTrackingProfile;
                        ApplyCoreLocationProfile(_currentCoreLocationProfile);
                    }
                }
                else if (_currentCoreLocationProfile != _currentProfile.HighTrackingProfile)
                {
                    Log.Info("HighTracking");
                    _currentCoreLocationProfile = _currentProfile.HighTrackingProfile;
                    ApplyCoreLocationProfile(_currentCoreLocationProfile);
                }


                // Do not store location twice if it has exact same properties.
                if (!p.Equals(previousPositionEntry))
                {
                    _positionEntryRepo.Add(p);
                }

                previousPositionEntry = p;
            }
        }
Exemple #10
0
        public MapSpan GetMapSpan()
        {
            MapSpan mapSpan = MapSpan.FromCenterAndRadius(new Position(52.092876, 5.104480), Distance.FromKilometers(30));

            if (positions.Any())
            {
                PositionEntry avg = Util.AveragePosition(positions);
                System.Diagnostics.Debug.WriteLine($"AVG {avg.Latitude} {avg.Longitude}");
                MapSpan.FromCenterAndRadius(new Position(avg.Latitude, avg.Longitude), Distance.FromMiles(20.0));
            }

            return(mapSpan);
        }
        public List <TransactionEntry> RetrieveSymbolTransaction(PositionEntry entry)
        {
            TransactionFeed transactionFeed = FinanceService.Query(new TransactionQuery(entry.TransactionHerf + Details()));

            List <TransactionEntry> transactionEntries = new List <TransactionEntry>();

            //transactionFeed.Entries.ToList<AtomEntryCollection>().ForEach(t => transactionEntries.Add(t));
            foreach (TransactionEntry te in transactionFeed.Entries)
            {
                transactionEntries.Add(te);
            }
            return(transactionEntries);
        }
Exemple #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void olderLogFileContainingAStartAndNewerFileContainingACheckPointPointingToALaterPositionThanStart()
        public virtual void OlderLogFileContainingAStartAndNewerFileContainingACheckPointPointingToALaterPositionThanStart()
        {
            // given
            PositionEntry position = position();

            SetupLogFiles(LogFile(Start(), Commit(3), position), LogFile(CheckPoint(position)));

            // when
            LogTailInformation logTailInformation = _tailScanner.TailInformation;

            // then
            AssertLatestCheckPoint(true, false, NO_TRANSACTION_ID, _endLogVersion, logTailInformation);
        }
Exemple #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void twoLogFilesCheckPointTargetsPrevious()
        public virtual void TwoLogFilesCheckPointTargetsPrevious()
        {
            // given
            long          txId     = 6;
            PositionEntry position = position();

            SetupLogFiles(LogFile(Start(), Commit(txId - 1), position), LogFile(Start(), Commit(txId)), LogFile(CheckPoint(position)));

            // when
            LogTailInformation logTailInformation = _tailScanner.TailInformation;

            // then
            AssertLatestCheckPoint(true, true, txId, _endLogVersion, logTailInformation);
        }
Exemple #14
0
 public static TabiApiClient.Models.PositionEntry ToApiModel(this PositionEntry position)
 {
     return(new TabiApiClient.Models.PositionEntry()
     {
         Latitude = position.Latitude,
         Longitude = position.Longitude,
         Accuracy = position.Accuracy,
         DesiredAccuracy = position.DesiredAccuracy,
         Altitude = position.Altitude,
         Speed = position.Speed,
         DistanceBetweenPreviousPosition = position.DistanceBetweenPreviousPosition,
         Timestamp = position.Timestamp
     });
 }
        public MapSpan AveragePosition()
        {
            MapSpan result = MapSpan.FromCenterAndRadius(new Position(52.092876, 5.104480), Distance.FromKilometers(30));
            List <PositionEntry> positions = _repoManager.PositionEntryRepository.FilterPeriodAccuracy(_trackEntry.StartTime, _trackEntry.EndTime, 100);

            if (positions.Count() > 0)
            {
                PositionEntry avg = Util.AveragePosition(positions);
                System.Diagnostics.Debug.WriteLine($"AVG {avg.Latitude} {avg.Longitude}");

                double distance = _trackEntry.DistanceTravelled < 50000 ? _trackEntry.DistanceTravelled : 50000;

                result = MapSpan.FromCenterAndRadius(new Position(avg.Latitude, avg.Longitude), Distance.FromMeters(distance));
            }

            return(result);
        }
        public static PositionEntry ToPosition(this CLLocation location)
        {
            PositionEntry p = new PositionEntry();

            p.Accuracy  = location.HorizontalAccuracy;
            p.Latitude  = location.Coordinate.Latitude;
            p.Longitude = location.Coordinate.Longitude;

            p.Speed  = location.Speed;
            p.Course = location.Course;

            p.Altitude         = location.Altitude;
            p.VerticalAccuracy = location.VerticalAccuracy;

            p.Timestamp = location.Timestamp.ToDateTime();

            return(p);
        }
Exemple #17
0
        ResolvedStop ResolvedStopFromPositions(List <PositionEntry> positions)
        {
            PositionEntry avg = Util.AveragePosition(positions);

            (double average, double min, double max) = CalculateAccuracies(positions);

            ResolvedStop stop = new ResolvedStop()
            {
                Latitude        = avg.Latitude,
                Longitude       = avg.Longitude,
                BeginTimestamp  = positions.First().Timestamp,
                EndTimestamp    = positions.Last().Timestamp,
                AverageAccuracy = average,
                MinAccuracy     = min,
                MaxAccuracy     = max,
            };

            return(stop);
        }
        public static PositionEntry ToPositionEntry(this Location location)
        {
            PositionEntry p = new PositionEntry();

            p.Accuracy  = location.Accuracy;
            p.Latitude  = location.Latitude;
            p.Longitude = location.Longitude;
            p.Course    = location.Bearing;

            p.Altitude = location.HasAltitude ? location.Altitude : 0;

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
            {
                p.VerticalAccuracy = location.HasVerticalAccuracy ? location.VerticalAccuracyMeters : 0;
            }

            p.Speed     = location.Speed;
            p.Timestamp = Util.TimeLongToDateTime(location.Time);
            return(p);
        }
Exemple #19
0
        public void PortfolioParseTest()
        {
            string xml = "<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gf='http://schemas.google.com/finance/2007' xmlns:gd='http://schemas.google.com/g/2005'><id>http://finance.google.com/finance/feeds/[email protected]/portfolios</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#portfolio'/><title type='text'>Portfolio Feed</title><link rel='alternate' type='text/html' href='http://finance.google.com/finance/portfolio?action=view'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios'/><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios'/><link rel='self' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios?positions=true&amp;returns=true'/><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>1</openSearch:itemsPerPage><entry><id>http://finance.google.com/finance/feeds/[email protected]/portfolios/1</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#portfolio'/><title type='text'>My Portfolio</title><link rel='self' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/1'/><link rel='edit' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/1'/><gd:feedLink href='http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions'><feed><id>http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#position'/><title type='text'>My Portfolio</title><link rel='alternate' type='text/html' href='http://finance.google.com/finance/portfolio?action=view&amp;pid=1'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios'/><openSearch:totalResults>9</openSearch:totalResults><openSearch:itemsPerPage>9</openSearch:itemsPerPage><entry><id>http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NASDAQ:MSFT</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#position'/><title type='text'>Microsoft Corporation</title><link rel='self' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NASDAQ%3AMSFT'/><link rel='edit' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NASDAQ%3AMSFT'/><gd:feedLink href='http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NASDAQ:MSFT/transactions'/><gf:positionData gainPercentage='20.82242991' return1w='0.0' return1y='0.0' return3m='0.0' return3y='0.0' return4w='0.0' return5y='0.0' returnOverall='0.0' returnYTD='0.0' shares='1000.0'><gf:costBasis><gd:money amount='1070.0' currencyCode='USD'/></gf:costBasis><gf:daysGain><gd:money amount='-440.001' currencyCode='USD'/></gf:daysGain><gf:gain><gd:money amount='22280.0' currencyCode='USD'/></gf:gain><gf:marketValue><gd:money amount='23350.0' currencyCode='USD'/></gf:marketValue></gf:positionData><gf:symbol exchange='NASDAQ' fullName='Microsoft Corporation' symbol='MSFT'/></entry><entry><id>http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NASDAQ:AAPL</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#position'/><title type='text'>Apple Inc.</title><link rel='self' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NASDAQ%3AAAPL'/><link rel='edit' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NASDAQ%3AAAPL'/><gd:feedLink href='http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NASDAQ:AAPL/transactions'/><gf:positionData gainPercentage='355.1' return1w='0.02122168053' return1y='355.1' return3m='355.1' return3y='355.1' return4w='355.1' return5y='355.1' returnOverall='355.1' returnYTD='355.1' shares='100.0'><gf:costBasis><gd:money amount='40.0' currencyCode='USD'/></gf:costBasis><gf:daysGain><gd:money amount='258.0002' currencyCode='USD'/></gf:daysGain><gf:gain><gd:money amount='14204.0' currencyCode='USD'/></gf:gain><gf:marketValue><gd:money amount='14244.0' currencyCode='USD'/></gf:marketValue></gf:positionData><gf:symbol exchange='NASDAQ' fullName='Apple Inc.' symbol='AAPL'/></entry><entry><id>http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NASDAQ:ACAS</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#position'/><title type='text'>American Capital Ltd.</title><link rel='self' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NASDAQ%3AACAS'/><link rel='edit' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NASDAQ%3AACAS'/><gd:feedLink href='http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NASDAQ:ACAS/transactions'/><gf:positionData gainPercentage='0.1045296167' return1w='0.0' return1y='0.0' return3m='0.0' return3y='0.0' return4w='0.0' return5y='0.0' returnOverall='0.0' returnYTD='0.0' shares='10000.0'><gf:costBasis><gd:money amount='28700.0' currencyCode='USD'/></gf:costBasis><gf:daysGain><gd:money amount='4500.0' currencyCode='USD'/></gf:daysGain><gf:gain><gd:money amount='3000.0' currencyCode='USD'/></gf:gain><gf:marketValue><gd:money amount='31700.0' currencyCode='USD'/></gf:marketValue></gf:positionData><gf:symbol exchange='NASDAQ' fullName='American Capital Ltd.' symbol='ACAS'/></entry><entry><id>http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NYSE:ING</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#position'/><title type='text'>ING Groep N.V. (ADR)</title><link rel='self' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NYSE%3AING'/><link rel='edit' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NYSE%3AING'/><gd:feedLink href='http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NYSE:ING/transactions'/><gf:positionData gainPercentage='0.05503634476' return1w='0.0' return1y='0.0' return3m='0.0' return3y='0.0' return4w='0.0' return5y='0.0' returnOverall='0.0' returnYTD='0.0' shares='124.0'><gf:costBasis><gd:money amount='1194.12' currencyCode='USD'/></gf:costBasis><gf:daysGain><gd:money amount='-2.48' currencyCode='USD'/></gf:daysGain><gf:gain><gd:money amount='65.72' currencyCode='USD'/></gf:gain><gf:marketValue><gd:money amount='1259.84' currencyCode='USD'/></gf:marketValue></gf:positionData><gf:symbol exchange='NYSE' fullName='ING Groep N.V. (ADR)' symbol='ING'/></entry><entry><id>http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NASDAQ:FORTY</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#position'/><title type='text'>Formula Systems (1985) Ltd. (ADR)</title><link rel='self' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NASDAQ%3AFORTY'/><link rel='edit' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NASDAQ%3AFORTY'/><gd:feedLink href='http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NASDAQ:FORTY/transactions'/><gf:positionData gainPercentage='0.03818953324' return1w='0.0' return1y='0.0' return3m='0.0' return3y='0.0' return4w='0.0' return5y='0.0' returnOverall='0.0' returnYTD='0.0' shares='130.0'><gf:costBasis><gd:money amount='919.1' currencyCode='USD'/></gf:costBasis><gf:daysGain><gd:money amount='17.55' currencyCode='USD'/></gf:daysGain><gf:gain><gd:money amount='35.1' currencyCode='USD'/></gf:gain><gf:marketValue><gd:money amount='954.2' currencyCode='USD'/></gf:marketValue></gf:positionData><gf:symbol exchange='NASDAQ' fullName='Formula Systems (1985) Ltd. (ADR)' symbol='FORTY'/></entry><entry><id>http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NYSE:DT</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#position'/><title type='text'>Deutsche Telekom AG (ADR)</title><link rel='self' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NYSE%3ADT'/><link rel='edit' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NYSE%3ADT'/><gd:feedLink href='http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NYSE:DT/transactions'/><gf:positionData gainPercentage='0.01224846894' return1w='0.0' return1y='0.0' return3m='0.0' return3y='0.0' return4w='0.0' return5y='0.0' returnOverall='0.0' returnYTD='0.0' shares='242.0'><gf:costBasis><gd:money amount='2766.06' currencyCode='USD'/></gf:costBasis><gf:daysGain><gd:money amount='14.519758' currencyCode='USD'/></gf:daysGain><gf:gain><gd:money amount='33.88' currencyCode='USD'/></gf:gain><gf:marketValue><gd:money amount='2799.94' currencyCode='USD'/></gf:marketValue></gf:positionData><gf:symbol exchange='NYSE' fullName='Deutsche Telekom AG (ADR)' symbol='DT'/></entry><entry><id>http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NYSE:CHN</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#position'/><title type='text'>China Fund Inc. (The)</title><link rel='self' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NYSE%3ACHN'/><link rel='edit' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NYSE%3ACHN'/><gd:feedLink href='http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NYSE:CHN/transactions'/><gf:positionData gainPercentage='0.03348104382' return1w='0.0' return1y='0.0' return3m='0.0' return3y='0.0' return4w='0.0' return5y='0.0' returnOverall='0.0' returnYTD='0.0' shares='244.0'><gf:costBasis><gd:money amount='4955.64' currencyCode='USD'/></gf:costBasis><gf:daysGain><gd:money amount='7.320244' currencyCode='USD'/></gf:daysGain><gf:gain><gd:money amount='165.92' currencyCode='USD'/></gf:gain><gf:marketValue><gd:money amount='5121.56' currencyCode='USD'/></gf:marketValue></gf:positionData><gf:symbol exchange='NYSE' fullName='China Fund Inc. (The)' symbol='CHN'/></entry><entry><id>http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NYSE:FTE</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#position'/><title type='text'>France Telecom SA (ADR)</title><link rel='self' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NYSE%3AFTE'/><link rel='edit' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NYSE%3AFTE'/><gd:feedLink href='http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NYSE:FTE/transactions'/><gf:positionData gainPercentage='0.02424786709' return1w='0.0' return1y='0.0' return3m='0.0' return3y='0.0' return4w='0.0' return5y='0.0' returnOverall='0.0' returnYTD='0.0' shares='420.0'><gf:costBasis><gd:money amount='9353.4' currencyCode='USD'/></gf:costBasis><gf:daysGain><gd:money amount='-42.0' currencyCode='USD'/></gf:daysGain><gf:gain><gd:money amount='226.8' currencyCode='USD'/></gf:gain><gf:marketValue><gd:money amount='9580.2' currencyCode='USD'/></gf:marketValue></gf:positionData><gf:symbol exchange='NYSE' fullName='France Telecom SA (ADR)' symbol='FTE'/></entry><entry><id>http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NYSE:GNK</id><updated>2009-06-27T05:40:34.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/finance/2007#position'/><title type='text'>Genco Shipping &amp; Trading Limited</title><link rel='self' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NYSE%3AGNK'/><link rel='edit' type='application/atom+xml' href='http://finance.google.com/finance/feeds/default/portfolios/NYSE%3AGNK'/><gd:feedLink href='http://finance.google.com/finance/feeds/[email protected]/portfolios/1/positions/NYSE:GNK/transactions'/><gf:positionData gainPercentage='0.1024649589' return1w='0.0' return1y='0.0' return3m='0.0' return3y='0.0' return4w='0.0' return5y='0.0' returnOverall='0.0' returnYTD='0.0' shares='10.0'><gf:costBasis><gd:money amount='206.9' currencyCode='USD'/></gf:costBasis><gf:daysGain><gd:money amount='14.69999' currencyCode='USD'/></gf:daysGain><gf:gain><gd:money amount='21.2' currencyCode='USD'/></gf:gain><gf:marketValue><gd:money amount='228.1' currencyCode='USD'/></gf:marketValue></gf:positionData><gf:symbol exchange='NYSE' fullName='Genco Shipping &amp; Trading Limited' symbol='GNK'/></entry></feed></gd:feedLink><gf:portfolioData currencyCode='USD' gainPercentage='0.8135848188' return1w='0.02122168053' return1y='355.1' return3m='355.1' return3y='355.1' return4w='355.1' return5y='355.1' returnOverall='355.1' returnYTD='355.1'><gf:costBasis><gd:money amount='49205.22' currencyCode='USD'/></gf:costBasis><gf:daysGain><gd:money amount='4327.609192' currencyCode='USD'/></gf:daysGain><gf:gain><gd:money amount='40032.62' currencyCode='USD'/></gf:gain><gf:marketValue><gd:money amount='140032.62' currencyCode='USD'/></gf:marketValue></gf:portfolioData></entry></feed>";

            PortfolioFeed feed = Parse(xml);
            //PortfolioEntry entry = feed.Entries[0] as PortfolioEntry;
            PortfolioEntry enTest = feed.Entries[0] as PortfolioEntry;
            //enTest.portfolioDataElement.CurrencyCode

            ExtensionCollection <Money> i = enTest.PortfolioData.CostBasis.Money;

            ExtensionCollection <Money> ii   = enTest.PortfolioData.DaysGain.Money;
            ExtensionCollection <Money> iii  = enTest.PortfolioData.Gain.Money;
            ExtensionCollection <Money> iiii = enTest.PortfolioData.MarketValue.Money;

            foreach (Money m in ii)
            {
                Console.WriteLine(m.Amount);
                Console.WriteLine(m.CurrencyCode);
            }

            foreach (Money m in iii)
            {
                Console.WriteLine(m.Amount);
                Console.WriteLine(m.CurrencyCode);
            }

            foreach (Money m in iiii)
            {
                Console.WriteLine(m.Amount);
                Console.WriteLine(m.CurrencyCode);
            }

            PositionFeed  feed2          = ParsePositionFeed(xml);
            PositionEntry enPositionTest = feed.Entries[0] as PositionEntry;
        }
Exemple #20
0
 public TimeSpan TimeBetweenPositions(PositionEntry begin, PositionEntry end)
 {
     return(end.Timestamp - begin.Timestamp);
 }
Exemple #21
0
 private StopVisit PositionInStop(PositionEntry pos, List <StopVisit> visits)
 {
     return(visits.FirstOrDefault(sv => pos.Timestamp >= sv.BeginTimestamp && pos.Timestamp <= sv.EndTimestamp));
 }
Exemple #22
0
 public double DistanceBetweenPoints(PositionEntry position1, PositionEntry position2)
 {
     return(position1.DistanceTo(position2));
 }
Exemple #23
0
        bool PointsWithinAccuracy(PositionEntry position1, PositionEntry position2)
        {
            double distance = DistanceBetweenPoints(position1, position2);

            return(distance < (position1.Accuracy + position2.Accuracy));
        }