trader/core/portfolio/portfolio.py
def process_position(self, timestamp, action, ticker, quantity, price,
                         commission):
        """
        Handles any new position or modification to
        a current position, by calling the respective
        _add_position and _modify_position methods.

        Hence, this single method will be called by the
        PortfolioHandler to update the Portfolio itself.
        """
        action = action.name
        if action == 'long':
            self.capital -= ((quantity * price) + commission)
        elif action == 'short':
            self.capital += ((quantity * price) - commission)

        if ticker not in self.positions:
            self.__add_position(
                timestamp, action, ticker, quantity,
                price, commission
            )
        else:
            self.__modify_position(
                timestamp, action, ticker, quantity,
                price, commission
            )
        self.update_portfolio()
        print('Processed position: {}'.format(ticker))
        print('portoflio capital: {}'.format(self.capital))
        print('equity: {}'.format(self.equity))
        print('closed_positions: {}'.format(self.closed_positions))

        Handles any new position or modification to
        a current position, by calling the respective
        _add_position and _modify_position methods.

        Hence, this single method will be called by the
        PortfolioHandler to update the Portfolio itself.
        
Handles any new position or modification to
a current position, by calling the respective
_add_position and _modify_position methods.

Hence, this single method will be called by the
PortfolioHandler to update the Portfolio itself.
Handles any new position or modification to a current position by calling the respective _add_position and _modify_position methods . Hence this single method will be called by the PortfolioHandler to update the Portfolio itself .
def process_position(self, timestamp, action, ticker, quantity, price,
                         commission):
        action = action.name
        if action == 'long':
            self.capital -= ((quantity * price) + commission)
        elif action == 'short':
            self.capital += ((quantity * price) - commission)
        if ticker not in self.positions:
            self.__add_position(
                timestamp, action, ticker, quantity,
                price, commission
            )
        else:
            self.__modify_position(
                timestamp, action, ticker, quantity,
                price, commission
            )
        self.update_portfolio()
        print('Processed position: {}'.format(ticker))
        print('portoflio capital: {}'.format(self.capital))
        print('equity: {}'.format(self.equity))
        print('closed_positions: {}'.format(self.closed_positions))
def process_position ( self , timestamp , action , ticker , quantity , price , commission ) : action = action . name if action == 'long' : self . capital -= ( ( quantity * price ) + commission ) elif action == 'short' : self . capital += ( ( quantity * price ) - commission ) if ticker not in self . positions : self . __add_position ( timestamp , action , ticker , quantity , price , commission ) else : self . __modify_position ( timestamp , action , ticker , quantity , price , commission ) self . update_portfolio ( ) print ( 'Processed position: {}' . format ( ticker ) ) print ( 'portoflio capital: {}' . format ( self . capital ) ) print ( 'equity: {}' . format ( self . equity ) ) print ( 'closed_positions: {}' . format ( self . closed_positions ) )
Handles any new position or modification to
a current position, by calling the respective
_add_position and _modify_position methods.
Handles any new position or modification to a current position by calling the respective _add_position and _modify_position methods .
"""
        Handles any new position or modification to
        a current position, by calling the respective
        _add_position and _modify_position methods.

        Hence, this single method will be called by the
        PortfolioHandler to update the Portfolio itself.
        """
self
timestamp
action
ticker
quantity
price
commission