Returns list of 1,000 most recent spot market data points represented as SpotPriceHistory
    objects. Note: The most recent object/data point will be first in the list.

    :rtype: list[SpotPriceHistory]
492477
def _get_spot_history(ctx, instance_type):
    

    one_week_ago = datetime.datetime.now() - datetime.timedelta(days=7)
    spot_data = ctx.ec2.get_spot_price_history(start_time=one_week_ago.isoformat(),
                                               instance_type=instance_type,
                                               product_description="Linux/UNIX")
    spot_data.sort(key=attrgetter("timestamp"), reverse=True)
    return spot_data
67052
def history(self, dates=None, linreg_since=None, lin_reg_days=20):
        '''
        
        '''
        dates = dates or self.get_dates_range()
        vals = [self.on_date(dt, only_count=True) for dt in dates]
        ret = Series(vals, index=dates)
        if linreg_since is not None:
            ret = self._linreg_future(ret, linreg_since, lin_reg_days)
        return ret.sort_index()
1137031
def _points(self, x_pos):
        
        for series_group in (self.series, self.secondary_series):
            accumulation = [0] * self._len
            for serie in series_group[::-1 if self.stack_from_top else 1]:
                accumulation = list(map(sum, zip(accumulation, serie.values)))
                serie.points = [(x_pos[i], v)
                                for i, v in enumerate(accumulation)]
                if serie.points and self.interpolate:
                    serie.interpolated = self._interpolate(x_pos, accumulation)
                else:
                    serie.interpolated = []
1289470
def get_data_point(self, n):
        
        # loop over the columns and pop the data
        point = []
        for k in self.ckeys: point.append(self[k][n])
        return point
4127
def prices(self):
        
        # if accessing and stale - update first
        if self._needupdate or self.now != self.parent.now:
            self.update(self.root.now)
        return self._prices.loc[:self.now]
886562
def markets(self):
        '''
        
        '''
        with self.client.connect(*self.bestip):
            data = self.client.get_markets()
            return self.client.to_df(data)

        return None
198753
def value(self):
        
        val = (round(i / 1000, 3) for i in self.__serial_price(1))
        return list(val)
256938
def current_hold_price(self):
        
        
        def weights(x):
            n=len(x)
            res=1
            while res>0 or res<0:
                res=sum(x[:n]['amount'])
                n=n-1
            
            x=x[n+1:]     
            
            if sum(x['amount']) != 0:
                return np.average(
                    x['price'],
                    weights=x['amount'],
                    returned=True
                )
            else:
                return np.nan
        return self.history_table.set_index(
            'datetime',
            drop=False
        ).sort_index().groupby('code').apply(weights).dropna()
736204
def fetch_points_of_sales(self, ticket=None):
        
        ticket = ticket or self.get_or_create_ticket('wsfe')

        client = clients.get_client('wsfe', self.is_sandboxed)
        response = client.service.FEParamGetPtosVenta(
            serializers.serialize_ticket(ticket),
        )
        check_response(response)

        results = []
        for pos_data in response.ResultGet.PtoVenta:
            results.append(PointOfSales.objects.update_or_create(
                number=pos_data.Nro,
                issuance_type=pos_data.EmisionTipo,
                owner=self,
                defaults={
                    'blocked': pos_data.Bloqueado == 'N',
                    'drop_date': parsers.parse_date(pos_data.FchBaja),
                }
            ))

        return results
1359668
def get_last_traded_dt(self, asset, dt, data_frequency):
        
        return self._get_pricing_reader(data_frequency).get_last_traded_dt(
            asset, dt)
1343554
def _collectOffAxisPoints(self):
        
        offAxis = {}
        for l, (value, deltaName) in self.items():
            location = Location(l)
            name = location.isOnAxis()
            if name is None or name is False:
                offAxis[l] = 1
        return list(offAxis.keys())
1192299
def get_points(self):
        
        if hasattr(self, 'points'):
            points = self.crdmap.to_data(self.points)
        else:
            points = []
        return points
403211
def points(self):
        
        if not self._points:
            self._points = MetricPoints(self.api_client)
        return self._points
292817
def list(self, request, *args, **kwargs):
        
        return super(PriceListItemViewSet, self).list(request, *args, **kwargs)
734172
def to_twodim_list(self):
        
        if self._timestampFormat is None:
            return self._timeseriesData

        datalist = []
        append   = datalist.append
        convert  = TimeSeries.convert_epoch_to_timestamp
        for entry in self._timeseriesData:
            append([convert(entry[0], self._timestampFormat), entry[1:]])

        return datalist
873562
def openTrades(self) -> List[Trade]:
        
        return [v for v in self.wrapper.trades.values()
                if v.orderStatus.status not in OrderStatus.DoneStates]
1291949
def get_prices(self) -> List[PriceModel]:
        
        # return self.security.prices.order_by(Price.date)
        from pricedb.dal import Price

        pricedb = PriceDbApplication()
        repo = pricedb.get_price_repository()
        query = (repo.query(Price)
            .filter(Price.namespace == self.security.namespace)
            .filter(Price.symbol == self.security.mnemonic)
            .orderby_desc(Price.date)
        )
        return query.all()