Files
quantconnect--lean/Tests/Engine/Setup/BacktestingSetupHandlerTests.cs
Roman Yavnikov 50ccec9a01 feat: gdax -> coinbase (#7633)
* feat: gdax -> coinbase

* feat: defaultBrokerageModel gdax -> coinbase

* refactor: coinbaseBrokerageModel
fix: gdax test

* feat: add coinbase market hours

* feat: symbolPropDB gdax -> coinbase

* fix: gdax to coinbase tests

* fix: coinbase Fees data

* remove: gdax market-hours

* revert: stopMarket order Type by date + test

* fix: coinbase test (fee was changed)
revert: old test with stopMarket gdax
fix: pandas padding

* refactor: gdaxLiveTrading -> CoinbaseLiveTrading
remove: gdax configs

* remove: old gdax testdata files

* refactor: gdax route -> coinbase route
feat: add deprecated gdax info
feat: some string "gdax" -> "coinbase"

* fix: style brackets

* fix: config coinbase data-queue-handler

* revert: public StablePairsGDAX collection

* rename: GdaxBrokerageModel to CoinbaseBrokerageModel in tests
rename: gdax -> coinbase in DefaultMarketMap
rename: gdaxBrokerageModelTest to Coinbase...

* revert: coinbase changes in toolbox (deprecated)

* remove: override Clone() in GDAX\Coinbase-OrderProperties

* typo: ops missing brackets

* rename: Market.Gdax -> Coinbase in Test
remove: ref on gdax

* test: compatibility of GDAXOrderProperties

* fix: coinbase brokerageName enum number

* feat: readonly to stablePairs Gdax/Coinbase
remove: GetFeeModel() in GDAXBrokerageModel {}

* test: gdax market name compatible with coinbase

* rename: config to old ones

* feat: coinbase CanUpdateOrder()

* rename: plus to commit 4135c91

* feat: coinbase fee model + test

* fix: stable fees data

* update: coinbase symbol-properties-database.csv

* fix:  validation of MinimumOrderSize in SubmitOrder()

* feat: gdax -> coinbase

* feat: defaultBrokerageModel gdax -> coinbase

* refactor: coinbaseBrokerageModel
fix: gdax test

* feat: add coinbase market hours

* feat: symbolPropDB gdax -> coinbase

* fix: gdax to coinbase tests

* fix: coinbase Fees data

* remove: gdax market-hours

* revert: stopMarket order Type by date + test

* fix: coinbase test (fee was changed)
revert: old test with stopMarket gdax
fix: pandas padding

* refactor: gdaxLiveTrading -> CoinbaseLiveTrading
remove: gdax configs

* remove: old gdax testdata files

* refactor: gdax route -> coinbase route
feat: add deprecated gdax info
feat: some string "gdax" -> "coinbase"

* fix: style brackets

* fix: config coinbase data-queue-handler

* revert: public StablePairsGDAX collection

* rename: GdaxBrokerageModel to CoinbaseBrokerageModel in tests
rename: gdax -> coinbase in DefaultMarketMap
rename: gdaxBrokerageModelTest to Coinbase...

* revert: coinbase changes in toolbox (deprecated)

* remove: override Clone() in GDAX\Coinbase-OrderProperties

* typo: ops missing brackets

* rename: Market.Gdax -> Coinbase in Test
remove: ref on gdax

* test: compatibility of GDAXOrderProperties

* fix: coinbase brokerageName enum number

* feat: readonly to stablePairs Gdax/Coinbase
remove: GetFeeModel() in GDAXBrokerageModel {}

* test: gdax market name compatible with coinbase

* rename: config to old ones

* feat: coinbase CanUpdateOrder()

* rename: plus to commit 4135c91

* feat: coinbase fee model + test

* fix: stable fees data

* update: coinbase symbol-properties-database.csv

* fix:  validation of MinimumOrderSize in SubmitOrder()

* fix: skipped gdax name to coinbase

* feature: visible Symbol prop in DefaultOrderBook
2024-01-05 16:57:19 -03:00

91 lines
3.3 KiB
C#

/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.Linq;
using NUnit.Framework;
using QuantConnect.Util;
using QuantConnect.Packets;
using QuantConnect.Interfaces;
using QuantConnect.Lean.Engine.Setup;
using QuantConnect.Lean.Engine.RealTime;
using QuantConnect.Lean.Engine.DataFeeds;
using QuantConnect.Tests.Engine.DataFeeds;
using QuantConnect.Algorithm.Framework.Selection;
namespace QuantConnect.Tests.Engine.Setup
{
[TestFixture]
public class BacktestingSetupHandlerTests
{
private IAlgorithm _algorithm;
private DataManager _dataManager;
[OneTimeSetUp]
public void Setup()
{
_algorithm = new TestAlgorithmThrowsOnInitialize();
_dataManager = new DataManagerStub(_algorithm);
_algorithm.SubscriptionManager.SetDataManager(_dataManager);
}
[OneTimeTearDown]
public void TearDown()
{
_dataManager.RemoveAllSubscriptions();
}
[Test]
public void HandlesErrorOnInitializeCorrectly()
{
using var setupHandler = new BacktestingSetupHandler();
var packet = new BacktestNodePacket();
packet.Controls.RamAllocation = 1024 * 4;
var realTimeHandler = new BacktestingRealTimeHandler();
var resultHandler = new TestResultHandler();
Assert.IsFalse(setupHandler.Setup(new SetupHandlerParameters(_dataManager.UniverseSelection, _algorithm, null, packet,
resultHandler, null, realTimeHandler, TestGlobals.DataCacheProvider, TestGlobals.MapFileProvider)));
resultHandler.Exit();
realTimeHandler.Exit();
setupHandler.DisposeSafely();
Assert.AreEqual(1, setupHandler.Errors.Count);
Assert.IsTrue(setupHandler.Errors[0].InnerException.Message.Equals("Some failure", StringComparison.OrdinalIgnoreCase));
}
internal class TestAlgorithmThrowsOnInitialize : AlgorithmStub
{
public override void Initialize()
{
SetAccountCurrency("USDT");
SetStartDate(2018, 08, 17);
SetEndDate(2021, 11, 15);
// this will fail later because due to default crypto market being Coinbase there is no conversion rate route
var symbols = new[] { "ADAUSDT", "BNBUSDT", "BTCUSDT", "ETHUSDT", "LTCUSDT", "SOLUSDT" }
.Select(ticker => QuantConnect.Symbol.Create(ticker, SecurityType.Crypto, Market.Binance));
SetUniverseSelection(new ManualUniverseSelectionModel(symbols));
SetBenchmark("BTCUSDT");
throw new Exception("Some failure");
}
}
}
}