コード例 #1
0
    def save_portfolio(self, datetime, portfolio, perf_tracker, recorded_vars):
        '''
        Store in Rethinkdb a zipline.Portfolio object
        '''
        if perf_tracker.progress != 0.0 and self.table:

            metrics = perf_tracker.to_dict()
            metrics.update({
                'date': datetime,
                'recorded': recorded_vars,
                'portfolio': dbutils.portfolio_to_dict(portfolio)
            })

            log.debug('Saving metrics in database')
            log.debug(rdb.table(self.table).insert(metrics).run(self.session))
コード例 #2
0
ファイル: influx.py プロジェクト: OspreyX/insights
    def save_portfolio(self, datetime, portfolio):
        '''
        Store in Rethinkdb a zipline.Portfolio object
        '''
        log.debug('Saving portfolio in database')
        pf = dbutils.portfolio_to_dict(portfolio)
        pf.pop('positions')
        data = [{
            "name": self.name,
            "time": datetime.strftime("%Y-%m-%d %H:%M"),
            "columns": pf.keys(),
            "points": [pf.values()]}]
        # Timestamp type is not json serializable
        data[0]['points'][0][-1] = pf['start_date'].__str__()

        self.session.write_points(data)
コード例 #3
0
    def save_portfolio(self, datetime, portfolio):
        '''
        Store in Rethinkdb a zipline.Portfolio object
        '''
        log.debug('Saving portfolio in database')
        pf = dbutils.portfolio_to_dict(portfolio)
        pf.pop('positions')
        data = [{
            "name": self.name,
            "time": datetime.strftime("%Y-%m-%d %H:%M"),
            "columns": pf.keys(),
            "points": [pf.values()]
        }]
        # Timestamp type is not json serializable
        data[0]['points'][0][-1] = pf['start_date'].__str__()

        self.session.write_points(data)
コード例 #4
0
ファイル: rethink.py プロジェクト: OspreyX/insights
    def save_portfolio(self, datetime, portfolio, perf_tracker, recorded_vars):
        '''
        Store in Rethinkdb a zipline.Portfolio object
        '''
        if perf_tracker.progress != 0.0 and self.table:

            metrics = perf_tracker.to_dict()
            metrics.update({
                'date': datetime,
                'recorded': recorded_vars,
                'portfolio': dbutils.portfolio_to_dict(portfolio)
            })

            log.debug('Saving metrics in database')
            log.debug(
                rdb.table(self.table)
                   .insert(metrics)
                   .run(self.session)
            )