diff --git a/backtester/backtester.py b/backtester/backtester.py index 25806cf..7ea690c 100644 --- a/backtester/backtester.py +++ b/backtester/backtester.py @@ -12,8 +12,6 @@ from .strategy import Strategy class Backtest: """Backtest runner class.""" def __init__(self, allocation, initial_capital=1_000_000, shares_per_contract=100): - assert isinstance(allocation, dict) - assets = ('stocks', 'options', 'cash') total_allocation = sum(allocation.get(a, 0.0) for a in assets) @@ -35,7 +33,6 @@ class Backtest: @stocks.setter def stocks(self, stocks): - assert all(isinstance(stock, Stock) for stock in stocks), 'Invalid stocks' assert np.isclose(sum(stock.percentage for stock in stocks), 1.0, atol=0.000001), 'Stock percentages must sum to 1.0' self._stocks = list(stocks) @@ -47,7 +44,6 @@ class Backtest: @options_strategy.setter def options_strategy(self, strat): - assert isinstance(strat, Strategy) self._options_strategy = strat @property @@ -56,7 +52,6 @@ class Backtest: @stocks_data.setter def stocks_data(self, data): - assert isinstance(data, TiingoData) self._stocks_schema = data.schema self._stocks_data = data @@ -66,7 +61,6 @@ class Backtest: @options_data.setter def options_data(self, data): - assert isinstance(data, HistoricalOptionsData) self._options_schema = data.schema self._options_data = data diff --git a/backtester/datahandler/historical_options_data.py b/backtester/datahandler/historical_options_data.py index 25aceb8..9c02f15 100644 --- a/backtester/datahandler/historical_options_data.py +++ b/backtester/datahandler/historical_options_data.py @@ -6,9 +6,7 @@ from .schema import Schema class HistoricalOptionsData: """Historical Options Data container class.""" def __init__(self, file, schema=None, **params): - if schema: - assert isinstance(schema, Schema) - else: + if schema is None: self.schema = HistoricalOptionsData.default_schema() file_extension = os.path.splitext(file)[1] diff --git a/backtester/datahandler/tiingo_data.py b/backtester/datahandler/tiingo_data.py index 0f35d6e..7b48846 100644 --- a/backtester/datahandler/tiingo_data.py +++ b/backtester/datahandler/tiingo_data.py @@ -6,9 +6,7 @@ import pandas as pd class TiingoData: """Tiingo (stocks & indeces) Data container class.""" def __init__(self, file, schema=None, **params): - if schema: - assert isinstance(schema, Schema) - else: + if schema is None: self.schema = TiingoData.default_schema() file_extension = os.path.splitext(file)[1] diff --git a/backtester/strategy/strategy.py b/backtester/strategy/strategy.py index 84d4036..61cc9df 100644 --- a/backtester/strategy/strategy.py +++ b/backtester/strategy/strategy.py @@ -2,9 +2,6 @@ import math import numpy as np -from ..datahandler import Schema -from .strategy_leg import StrategyLeg - class Strategy: """Options strategy class. @@ -12,7 +9,6 @@ class Strategy: entry and exit conditions. """ def __init__(self, schema): - assert isinstance(schema, Schema) self.schema = schema self.legs = [] self.conditions = [] @@ -20,7 +16,6 @@ class Strategy: def add_leg(self, leg): """Adds leg to the strategy""" - assert isinstance(leg, StrategyLeg) assert self.schema == leg.schema leg.name = "leg_{}".format(len(self.legs) + 1) self.legs.append(leg) diff --git a/backtester/strategy/strategy_leg.py b/backtester/strategy/strategy_leg.py index 355058a..4afd659 100644 --- a/backtester/strategy/strategy_leg.py +++ b/backtester/strategy/strategy_leg.py @@ -1,14 +1,9 @@ from backtester.enums import Type, Direction -from backtester.datahandler import Schema class StrategyLeg: """Strategy Leg data class""" def __init__(self, name, schema, option_type=Type.CALL, direction=Direction.BUY): - assert isinstance(schema, Schema) - assert isinstance(option_type, Type) - assert isinstance(direction, Direction) - self.name = name self.schema = schema self.type = option_type