April 2019
Intermediate to advanced
426 pages
11h 13m
English
The Position class helps us keep track of our current market position and account balance for a traded instrument, and is written as follows:
class Position(object): def __init__(self, symbol=''): self.symbol = symbol self.buys = self.sells = self.net = 0 self.rpnl = 0 self.position_value = 0
The number of units bought, sold, and net are declared as buys, sells, and net variables, respectively. The rpnl variable stores the recently realized profits and losses for the symbol. Note that the position_value variable starts with a value of zero. When securities are bought, the value of the securities is debited from this account. When securities are sold, the value of the securities is credited into this ...
Read now
Unlock full access