
P&L UI Test

Turn merge with md off since we want to control the md

ExchangeSim {
   value {merge_with_md:false}
}

clear your fills database:
	rm ~/sparkdata/data/databases/fills/*

and you may also want to clear your orders for a clean slate:
	rm ~/sparkdata/data/databases/orders/*


Throughout the test we'll refer to accounts ACC A and ACC A1. These specific accounts aren't necessary, but rather that we have fills in multiple distinct accounts.

Bring up the pnl form (empty) .
Bring up a SIM:SI ladder form, pick your favorite expiration. It should be completely empty since we're controlling the md, and the ACC A account should be selected in the account drop down list.
Bring up an order ticket for your corresponding ladder
	place a buy order with price 14.000 and qty 10
		your ladder should populate now
	place a sell order with price 14.010 at qty 10
		this will give you a valid Midpoint for you PnL Price in the PnL
Sell a 1 lot at your bid (14.000)
	The Start Net Pos should be 0
	Start Pnl should be 0
	Day Long and Day Short should be 1 (we crossed our own bid)
	Day PnL should be 0
	Total Net Pos should be 0 (buy 1 - sell 1)
	Total PnL should be 0 (we have no position)
	PnL Price should be at the midpoint of your bid and ask (14.000 + 14.010)/2 = 14.005.
Improve the bid
	Under ACC A1 account (this is important for the next step), enter a 10 lot bid at 14.005
	Observe the PnL Price reflect the current Midpoint (14.0075)
	Switch back to ACC A
Sell a 1 lot at the current bid
	You should now have rows for both the ACC A and ACC A1 account
	ACC A
		Day Long 1
		Day Short 2
		Day PnL -12.5
			(14.005 [fill price] - 14.0075 [driver price]) * 1 [qty] * 5000 [cash per point] = -12.50
		Total Net Pos -1
		Total PnL = -12.5
		PnL Price = 14.0075
	ACC A1
		Day Long 1
		Day Short 0
		Day PnL 12.5
			(14.0075 - 14.005) * 1 * 5000
Move the market
	Move your working sell order up to 14.020
	The PnL Price should update to 14.0125  ((14.020 + 14.005) /2)
	The Day and Total PnLs should update to according to the same calculation as earlier
		ACC A: -37.5
		ACC A1: 37.5
Check the Totals Footer
	Day Long: 2
	Day Short: 2
	Day PnL: 0
	PnL: 0
Force the SOD process to aggregate the fills
	Configure your sod time to be after your last fill and before now.
	Note that SODTime is currently expressed in UTC, so you'll have to make the appropriate conversion.
	
	Here is a sample config:
	
SODTime{
   value {
      sod_hh: 15
      sod_mm: 00
   }
}
	
	Restart sparkd and the SOD process should consolidate your day fills so...
	
	ACC A: 
		Start Net Pos -1
		Start PnL -12.5
			(14.005 - 14.0125) * 2 * 5000 = -75
			(14.0125 - 14.000) * 1 * 5000 = 62.5
			-75 + 62.5 = -12.5
		Day Long 0
		Day Short 0
		Day PnL 0
		Total Net Pos -1
		Total PnL -12.5
		PnL Price 14.0125
	ACC A1: 
		Start Net Pos 1
		Start PnL 37.5
		Day Long 0
		Day Short 0
		Day PnL 0
		Total Net Pos 1
		Total PnL 37.5
			(14.0125 - 14.005) * 1 * 5000
		PnL Price 14.0125

Sell a 1 lot as the current bid in ACC A
	ACC A:
		Start Net Pos -1 (no change)
		Start PnL -12.5 (no change)
		Day Long 0
		Day Short 1
		Day PnL -37.5
		Total Net Pos -2
		Total PnL -50
		PnL Price 14.0125
	ACC A1: 
		Start Net Pos 1 (no change)
		Start PnL 37.5 (no change)
		Day Long 1
		Day Short 0
		Day PnL 37.5
		Total Net Pos 2
		Total PnL 75
		PnL Price 14.0125	


Test sorting and filtering
