Beispiel #1
0
        public void SuccessfulPath()
        {
            var threshold = 0.001; // threshold for the Intrinsic Time, 0.01 is equal to 1%

            var priceDiscovery = new PriceDiscovery(threshold);


            var filePath   = @".\TestData";
            var fileName   = "EURCHF_UTC_Ticks_Bid_2017.05.21_2017.06.14.csv";
            var dateFormat = "yyyy.MM.dd HH:mm:ss.SSS";

            try
            {
                var  sr         = File.ReadLines(Path.Combine(filePath, fileName));
                long i          = 0;
                bool skipHeader = true;
                foreach (var priceLine in sr)
                {
                    if (skipHeader)
                    {
                        skipHeader = false;
                        continue;
                    }
                    var price = Tools.PriceLineToPrice(priceLine, ',', 5, dateFormat, 1, 2, 0);
                    priceDiscovery.Run(price); // should run this method for all historical ticks.
                    i++;
                }

                var          yearsToMaturity = 1.0 / 365.0 / 24.0; // (1.0 / 365.0 / 24.0) is equal to one hour. It is also the period of the activation time.
                const double dividend        = 0.0001;             // dividends from the original paper.
                priceDiscovery.Finish(dividend, yearsToMaturity);
                var computedVolatility = priceDiscovery.GetLatestVolatility();
                var putPrice           = priceDiscovery.LatestPutStrike;
                var callPrice          = priceDiscovery.LatestCallStrike;
                Console.WriteLine("Computed volatility (in Intrinsic Time): " + computedVolatility);
                Console.WriteLine($"Ask {priceDiscovery.LatestPrice.FloatAsk} Bid {priceDiscovery.LatestPrice.FloatBid}");

                Console.WriteLine("Fixed Ask (call): " + callPrice);
                Console.WriteLine("Fixed Bid (put): " + putPrice);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
        private async void Start()
        {
            try
            {
                var allPairs = await _marketProfileService.GetAllPairsAsync();

                foreach (var asset in allPairs)
                {
                    var key = asset.AssetPair;
                    _lastReceivedAsks[key] = new Quote
                    {
                        AssetPair = key,
                        Price     = asset.AskPrice,
                        Timestamp = asset.AskPriceTimestamp
                    };

                    _lastReceivedBids[key] = new Quote
                    {
                        AssetPair = key,
                        Price     = asset.BidPrice,
                        Timestamp = asset.BidPriceTimestamp
                    };
                    if (!_priceDiscoveries.TryGetValue(key, out var prd))
                    {
                        prd = new PriceDiscovery(Threshold);
                        _priceDiscoveries[key] = prd;
                        var timestamp = asset.AskPriceTimestamp > asset.BidPriceTimestamp
                            ? asset.AskPriceTimestamp
                            : asset.BidPriceTimestamp;
                        var price = new Price(asset.AskPrice, asset.BidPrice, timestamp);
                        prd.Run(price);
                    }
                }
            }
            catch (Exception ex)
            {
                await _log.WriteFatalErrorAsync(nameof(FixQuotesManager), nameof(Start), "Loading market profile", ex);

                throw;
            }
        }