{"action":"opened","issue":{"url":"https://api.github.com/repos/QuantConnect/Lean/issues/2584","repository_url":"https://api.github.com/repos/QuantConnect/Lean","labels_url":"https://api.github.com/repos/QuantConnect/Lean/issues/2584/labels{/name}","comments_url":"https://api.github.com/repos/QuantConnect/Lean/issues/2584/comments","events_url":"https://api.github.com/repos/QuantConnect/Lean/issues/2584/events","html_url":"https://github.com/QuantConnect/Lean/issues/2584","id":367365397,"node_id":"MDU6SXNzdWUzNjczNjUzOTc=","number":2584,"title":"Equity security wrongly updated with quote data in live mode","user":{"login":"AlexCatarino","id":6889033,"node_id":"MDQ6VXNlcjY4ODkwMzM=","avatar_url":"https://avatars1.githubusercontent.com/u/6889033?v=4","gravatar_id":"","url":"https://api.github.com/users/AlexCatarino","html_url":"https://github.com/AlexCatarino","followers_url":"https://api.github.com/users/AlexCatarino/followers","following_url":"https://api.github.com/users/AlexCatarino/following{/other_user}","gists_url":"https://api.github.com/users/AlexCatarino/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexCatarino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexCatarino/subscriptions","organizations_url":"https://api.github.com/users/AlexCatarino/orgs","repos_url":"https://api.github.com/users/AlexCatarino/repos","events_url":"https://api.github.com/users/AlexCatarino/events{/privacy}","received_events_url":"https://api.github.com/users/AlexCatarino/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-05T20:54:55Z","updated_at":"2018-10-05T20:54:55Z","closed_at":null,"author_association":"MEMBER","body":"#### Expected Behavior\r\n`TickType.Quote` cannot be used to update securities without `TickType.Quote` subscription.\r\n\r\n#### Actual Behavior\r\nIn [LTRH](https://github.com/QuantConnect/Lean/blob/master/Engine/Results/LiveTradingResultHandler.cs#L1032), we spoof a quote tick to the system to start with and it updates `BidPrice` and `AskPrice` of `Equity`.\r\n\r\n#### Potential Solution\r\nDefine the tick type with information from the subscription and do not accept `TickType.Trade` update `BidPrice` and `AskPrice`.\r\n\r\n#### Reproducing the Problem\r\n```csharp\r\n[Test]\r\npublic void TickTypeDependencyTests()\r\n{\r\n    // Arrange\r\n    var time = DateTime.Now;\r\n    var price = 100m;\r\n    var bidPrice = 99m;\r\n    var askPrice = 101m;\r\n    var volume = 1m;\r\n\r\n    var tick = new Tick(time, Symbols.AAPL, price, bidPrice, askPrice) { Quantity = volume }; ;\r\n\r\n    var securityCache = new SecurityCache();\r\n    securityCache.AddData(tick);\r\n    Assert.AreEqual(securityCache.Price, price);\r\n    Assert.AreEqual(securityCache.BidPrice, bidPrice);\r\n    Assert.AreEqual(securityCache.AskPrice, askPrice);\r\n    Assert.AreEqual(securityCache.Volume, 0m);\r\n\r\n    tick.TickType = TickType.Trade;\r\n    securityCache = new SecurityCache();\r\n    securityCache.AddData(tick);\r\n    Assert.AreEqual(securityCache.Price, price);\r\n    Assert.AreEqual(securityCache.BidPrice, 0m);\r\n    Assert.AreEqual(securityCache.AskPrice, 0m);\r\n    Assert.AreEqual(securityCache.Volume, volume);\r\n}\r\n```\r\n#### Checklist\r\n- [x] I have completely filled out this template\r\n- [x] I have confirmed that this issue exists on the current `master` branch\r\n- [x] I have confirmed that this is not a duplicate issue by searching [issues](https://github.com/QuantConnect/Lean/issues)\r\n- [x] I have provided detailed steps to reproduce the issue"}}
{"actor":{"display_login":"AlexCatarino"}}