Skip to content

Commit ea612ad

Browse files
committed
Fix regression tests
1 parent 100046d commit ea612ad

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

Algorithm.CSharp/ManuallySetMarketHoursAndSymbolPropertiesDatabaseEntriesAlgorithm.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using System;
1717
using System.Collections.Generic;
1818
using QuantConnect.Interfaces;
19+
using QuantConnect.Securities;
1920

2021
namespace QuantConnect.Algorithm.CSharp
2122
{
@@ -54,7 +55,7 @@ public override void Initialize()
5455
throw new RegressionTestException("Expected the SPY CFD market hours to be the same as the underlying equity market hours.");
5556
}
5657

57-
if (!ReferenceEquals(spyCfd.SymbolProperties, equitySymbolProperties))
58+
if (!SymbolPropertiesAreEquivalent(spyCfd.SymbolProperties, equitySymbolProperties))
5859
{
5960
throw new RegressionTestException("Expected the SPY CFD symbol properties to be the same as the underlying equity symbol properties.");
6061
}
@@ -74,12 +75,25 @@ public override void Initialize()
7475
throw new RegressionTestException("Expected the AUDUSD CFD market hours to be the same as the underlying forex market hours.");
7576
}
7677

77-
if (!ReferenceEquals(audUsdCfd.SymbolProperties, audUsdForexSymbolProperties))
78+
if (!SymbolPropertiesAreEquivalent(audUsdCfd.SymbolProperties, audUsdForexSymbolProperties))
7879
{
7980
throw new RegressionTestException("Expected the AUDUSD CFD symbol properties to be the same as the underlying forex symbol properties.");
8081
}
8182
}
8283

84+
private static bool SymbolPropertiesAreEquivalent(SymbolProperties a, SymbolProperties b)
85+
{
86+
return a.Description == b.Description &&
87+
a.QuoteCurrency == b.QuoteCurrency &&
88+
a.ContractMultiplier == b.ContractMultiplier &&
89+
a.MinimumPriceVariation == b.MinimumPriceVariation &&
90+
a.LotSize == b.LotSize &&
91+
a.MarketTicker == b.MarketTicker &&
92+
a.MinimumOrderSize == b.MinimumOrderSize &&
93+
a.PriceMagnifier == b.PriceMagnifier &&
94+
a.StrikeMultiplier == b.StrikeMultiplier;
95+
}
96+
8397
/// <summary>
8498
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
8599
/// </summary>

Algorithm.Python/ManuallySetMarketHoursAndSymbolPropertiesDatabaseEntriesAlgorithm.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def initialize(self):
5151
if json.JsonConvert.serialize_object(spy_cfd.exchange.hours) != json.JsonConvert.serialize_object(equity_market_hours_entry.exchange_hours):
5252
raise AssertionError("Expected the SPY CFD market hours to be the same as the underlying equity market hours.")
5353

54-
if json.JsonConvert.serialize_object(spy_cfd.symbol_properties) != json.JsonConvert.serialize_object(equity_symbol_properties):
54+
if not self.symbol_properties_are_equivalent(spy_cfd.symbol_properties, equity_symbol_properties):
5555
raise AssertionError("Expected the SPY CFD symbol properties to be the same as the underlying equity symbol properties.")
5656

5757
# We can also do it for a specific ticker
@@ -66,5 +66,16 @@ def initialize(self):
6666
if json.JsonConvert.serialize_object(aud_usd_cfd.exchange.hours) != json.JsonConvert.serialize_object(aud_usd_forex_market_hours_entry.exchange_hours):
6767
raise AssertionError("Expected the AUDUSD CFD market hours to be the same as the underlying forex market hours.")
6868

69-
if json.JsonConvert.serialize_object(aud_usd_cfd.symbol_properties) != json.JsonConvert.serialize_object(aud_usd_forex_symbol_properties):
69+
if not self.symbol_properties_are_equivalent(aud_usd_cfd.symbol_properties, aud_usd_forex_symbol_properties):
7070
raise AssertionError("Expected the AUDUSD CFD symbol properties to be the same as the underlying forex symbol properties.")
71+
72+
def symbol_properties_are_equivalent(self, a, b):
73+
return (a.description == b.description and
74+
a.quote_currency == b.quote_currency and
75+
a.contract_multiplier == b.contract_multiplier and
76+
a.minimum_price_variation == b.minimum_price_variation and
77+
a.lot_size == b.lot_size and
78+
a.market_ticker == b.market_ticker and
79+
a.minimum_order_size == b.minimum_order_size and
80+
a.price_magnifier == b.price_magnifier and
81+
a.strike_multiplier == b.strike_multiplier)

0 commit comments

Comments
 (0)