def get_prices(self): time_frame = TimeFrame.from_value(self.time_frame) # Get the latest price point if TimeInterval.CURRENT.equals(time_frame.time_interval): prices = self._get_prices_current() # Get the latest minute prices elif TimeInterval.MINUTES_ONE.equals(time_frame.time_interval): prices = self._get_prices_one_minute() # Get the latest 15 minute prices elif TimeInterval.MINUTES_FIFTEEN.equals(time_frame.time_interval): prices = self._get_prices_fifteen_minutes() # Get the latest hourly prices elif TimeInterval.HOURS_ONE.equals(time_frame.time_interval): prices = self._get_prices_one_hour() # Get the latest four hour prices elif TimeInterval.HOURS_FOUR.equals(time_frame.time_interval): prices = self._get_prices_four_hour() # Get the latest daily prices elif TimeInterval.DAYS_ONE.equals(time_frame.time_interval): prices = self._get_prices_one_day() return prices.all()
def of(market: str, target_symbol: str, trading_symbol: str, time_frame): asset_price_history = SQLLiteAssetPriceHistory.query.filter_by( market=market, target_symbol=target_symbol, trading_symbol=trading_symbol, time_frame=TimeFrame.from_value(time_frame).value).first() if not asset_price_history: asset_price_history = SQLLiteAssetPriceHistory( market=market, target_symbol=target_symbol, trading_symbol=trading_symbol, time_frame=TimeFrame.from_value(time_frame).value) asset_price_history.get_prices() asset_price_history.save(db) return asset_price_history
def get_delta(self, obj): return PerformanceService \ .of_metric( obj, PerformanceMetric.DELTA, TimeFrame.from_value( self.context.get("time_frame", TimeFrame.ONE_DAY.value) ) )
def get_performance(self, obj): return PerformanceService\ .of_metric( obj, PerformanceMetric.OVERALL_PERFORMANCE, TimeFrame.from_value( self.context.get("time_frame", TimeFrame.ONE_DAY.value) ) )
def __init__(self, asset_prices_array, time_frame): self.asset_prices = [] self.intervals = TimeFrame.from_value(time_frame).intervals for zipped_asset_prices in zip(*asset_prices_array): self.asset_prices.insert(0, zipped_asset_prices) self.size = len(self.intervals) self.front = self.size - 1
def __init__(self, portfolio, time_frame: TimeFrame): self.time_frame = TimeFrame.from_value(time_frame).value self.portfolio = portfolio # Retrieve snapshots self.snapshots = self._retrieve_snapshots(portfolio, time_frame) self.asset_prices = self._retrieve_asset_price_histories( self._retrieve_unique_symbols(), self.time_frame ) self.current_snapshot = None self.current_date = None self.index = 0 self.intervals = IntervalsQueue(self.time_frame)
def __init__(self, time_frame): self.intervals = TimeFrame.from_value(time_frame).intervals self.size = len(self.intervals) self.front = self.size - 1
def __init__(self, market, target_symbol, trading_symbol, time_frame): self.market = market self.target_symbol = target_symbol self.trading_symbol = trading_symbol self.time_frame = TimeFrame.from_value(time_frame).value