Daily profit and loss

I am looking for a code snippet that would help me calculate daily profit and loss using realized and unrealized profit. Thanks.