Where are you looking?
PnL is calculated depending on the direction of the trade.
As long as the trade is in progress the PnL reported will be the entry vs ask for Long and entry vs bid for short.
Once you exit it will be entry price vs exit price.
If you are referring to this little chart on the daily results table...
That is a fifteen minute snapshot of the PnL, it does appear closer to the entry vs the last.
I am not sure exactly how or when it is calculated, that would require the developers taking a look at the source code.
from cloudquant.interfaces import Strategy
class AccountPnL(Strategy):
@classmethod
def is_symbol_qualified(cls, symbol, md, service, account):
return symbol in ['AAPL','MSFT']
def on_start(self, md, order, service, account):
if self.symbol == 'AAPL':
order.send(self.symbol, 'buy', 100, type='MOO')
if self.symbol == 'MSFT':
order.send(self.symbol, 'sell', 100, type='MOO')
def on_minute_bar(self, event, md, order, service, account, bar):
# def on_trade(self, event, md, order, service, account):
myshares = account[self.symbol].position.shares
entry_price = account[self.symbol].position.entry_price
if myshares > 0: # Long Pnl will be calculated from entry vs ask
print("{} {:<6} LONG Last Price {:8.2f} Ask Price {:8.2f} Entry Price {:8.2f} Shares {:8.2f} Entry PnL {:8.2f}".format(service.time_to_string(event.timestamp,"%H:%M:%S"),self.symbol,md.L1.last,md.L1.ask,entry_price,myshares,account[self.symbol].unrealized_pl.entry_pl))
if myshares < 0: # Short PnL will be calculated from the entry vs bid
print("{} {:<6} SHORT Last Price {:8.2f} Bid Price {:8.2f} Entry Price {:8.2f} Shares {:8.2f} Entry PnL {:8.2f}".format(service.time_to_string(event.timestamp,"%H:%M:%S"),self.symbol,md.L1.last,md.L1.bid,entry_price,myshares,account[self.symbol].unrealized_pl.entry_pl))
If you are referring to this little chart on the daily results table...
Yes, exactly this chart. I find it very useful to analyze intraday drawdowns and such, but not sure if it is calculated with bid/ask or some last/close of the bar. Hence the question.
Comments
Where are you looking?
PnL is calculated depending on the direction of the trade.
As long as the trade is in progress the PnL reported will be the entry vs ask for Long and entry vs bid for short.
Once you exit it will be entry price vs exit price.
If you are referring to this little chart on the daily results table...

That is a fifteen minute snapshot of the PnL, it does appear closer to the entry vs the last.
I am not sure exactly how or when it is calculated, that would require the developers taking a look at the source code.
Yes, exactly this chart. I find it very useful to analyze intraday drawdowns and such, but not sure if it is calculated with bid/ask or some last/close of the bar. Hence the question.