Skip to content

Commit

Permalink
Remove: deprecated IPriceProvider (#15)
Browse files Browse the repository at this point in the history
* remove: deprecated interface PriceProvider

* fix: history test (it has not captured for 1 min trades)
  • Loading branch information
Romazes authored Jan 9, 2024
1 parent 4abd087 commit a8190ae
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class BitfinexBrokerageAdditionalTests
[SetUp]
public void Setup()
{
var priceProvider = new Mock<IPriceProvider>();
priceProvider.Setup(x => x.GetLastPrice(It.IsAny<Symbol>())).Returns(1.234m);
var aggregator = new Mock<IDataAggregator>();

_brokerage = new BitfinexBrokerage(
Expand All @@ -47,7 +45,6 @@ public void Setup()
"apikey",
"apisecret",
_algorithm,
priceProvider.Object,
aggregator.Object,
null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private static TestCaseData[] History()
return new[]
{
// valid
new TestCaseData(StaticSymbol, Resolution.Minute, Time.OneMinute, false, false, TickType.Trade),
new TestCaseData(StaticSymbol, Resolution.Minute, TimeSpan.FromMinutes(2), false, false, TickType.Trade),
new TestCaseData(StaticSymbol, Resolution.Hour, Time.OneDay, false, false, TickType.Trade),
new TestCaseData(StaticSymbol, Resolution.Daily, TimeSpan.FromDays(15), false, false, TickType.Trade),

Expand Down Expand Up @@ -75,7 +75,7 @@ public void GetsHistory(Symbol symbol, Resolution resolution, TimeSpan period, b
var historyProvider = new BrokerageHistoryProvider();
historyProvider.SetBrokerage(brokerage);
historyProvider.Initialize(new HistoryProviderInitializeParameters(null, null, null, null, null, null, null, false, new DataPermissionManager()));
historyProvider.Initialize(new HistoryProviderInitializeParameters(null, null, null, null, null, null, null, false, new DataPermissionManager(), null));
var now = DateTime.UtcNow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,17 @@ protected override IBrokerage CreateBrokerage(IOrderProvider orderProvider, ISec

var transactions = new SecurityTransactionManager(null, securities);
transactions.SetOrderProcessor(new FakeOrderProcessor());
var algorithmSettings = new AlgorithmSettings();

var algorithm = new Mock<IAlgorithm>();
algorithm.Setup(a => a.Transactions).Returns(transactions);
algorithm.Setup(a => a.BrokerageModel).Returns(new BitfinexBrokerageModel());
algorithm.Setup(a => a.Portfolio).Returns(new SecurityPortfolioManager(securities, transactions));

var priceProvider = new Mock<IPriceProvider>();
priceProvider.Setup(a => a.GetLastPrice(It.IsAny<Symbol>())).Returns(1.234m);
algorithm.Setup(a => a.Portfolio).Returns(new SecurityPortfolioManager(securities, transactions, algorithmSettings));

return new BitfinexBrokerage(
Config.Get("bitfinex-api-key"),
Config.Get("bitfinex-api-secret"),
algorithm.Object,
priceProvider.Object,
new AggregationManager(),
null
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class BitfinexDataDownloader : IDataDownloader, IDisposable
/// </summary>
public BitfinexDataDownloader()
{
_brokerage = new BitfinexBrokerage(null, null, null, null, null, null);
_brokerage = new BitfinexBrokerage(null, null, null, null, null);
_brokerage.Connect();
}

Expand Down
8 changes: 3 additions & 5 deletions QuantConnect.BitfinexBrokerage/BitfinexBrokerage.Messaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ public BitfinexBrokerage() : base("Bitfinex")
/// <param name="apiKey">api key</param>
/// <param name="apiSecret">api secret</param>
/// <param name="algorithm">the algorithm instance is required to retrieve account type</param>
/// <param name="priceProvider">The price provider for missing FX conversion rates</param>
/// <param name="aggregator">consolidate ticks</param>
/// <param name="job">The live job packet</param>
public BitfinexBrokerage(string apiKey, string apiSecret, IAlgorithm algorithm, IPriceProvider priceProvider, IDataAggregator aggregator, LiveNodePacket job)
: this(new WebSocketClientWrapper(), new RestClient(RestApiUrl), apiKey, apiSecret, algorithm, priceProvider, aggregator, job)
public BitfinexBrokerage(string apiKey, string apiSecret, IAlgorithm algorithm, IDataAggregator aggregator, LiveNodePacket job)
: this(new WebSocketClientWrapper(), new RestClient(RestApiUrl), apiKey, apiSecret, algorithm, aggregator, job)
{
}

Expand All @@ -93,10 +92,9 @@ public BitfinexBrokerage(string apiKey, string apiSecret, IAlgorithm algorithm,
/// <param name="apiKey">api key</param>
/// <param name="apiSecret">api secret</param>
/// <param name="algorithm">the algorithm instance is required to retrieve account type</param>
/// <param name="priceProvider">The price provider for missing FX conversion rates</param>
/// <param name="aggregator">consolidate ticks</param>
/// <param name="job">The live job packet</param>
public BitfinexBrokerage(IWebSocket websocket, IRestClient restClient, string apiKey, string apiSecret, IAlgorithm algorithm, IPriceProvider priceProvider, IDataAggregator aggregator, LiveNodePacket job)
public BitfinexBrokerage(IWebSocket websocket, IRestClient restClient, string apiKey, string apiSecret, IAlgorithm algorithm, IDataAggregator aggregator, LiveNodePacket job)
: base("Bitfinex")
{
Initialize(
Expand Down
4 changes: 0 additions & 4 deletions QuantConnect.BitfinexBrokerage/BitfinexBrokerageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Configuration;
using QuantConnect.Data;
using QuantConnect.Interfaces;
Expand Down Expand Up @@ -77,13 +76,10 @@ public override IBrokerage CreateBrokerage(Packets.LiveNodePacket job, IAlgorith
throw new Exception($"BitfinexBrokerageFactory.CreateBrokerage: Missing {item} in config.json");
}

var priceProvider = new ApiPriceProvider(job.UserId, job.UserToken);

var brokerage = new BitfinexBrokerage(
job.BrokerageData["bitfinex-api-key"],
job.BrokerageData["bitfinex-api-secret"],
algorithm,
priceProvider,
Composer.Instance.GetExportedValueByTypeName<IDataAggregator>(Config.Get("data-aggregator", "QuantConnect.Lean.Engine.DataFeeds.AggregationManager"), forceTypeNameOnExisting: false),
job);
Composer.Instance.AddPart<IDataQueueHandler>(brokerage);
Expand Down

0 comments on commit a8190ae

Please sign in to comment.