
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 and sim fix (to prevent recent orders/fills from sim being resurrected):
	rm ~/sparkdata/data/databases/fills/*
	rm -rf /home/bts/sparkdata/data/jetfix/sim
    rm -rf /home/bts/sparkdata/data/exchange_sim

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 (just prices, no sizes) 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
	place a sell order with price 14.010 at qty 10 this will give you a valid Midpoint for your 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 displayed as 14.010)
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 (displayed as 14.010)
	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) (displayed as 14.015)
	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 relative to the server's local time, which in the case of DEV will likely be UTC, so you'll need to supply the appropriate UTC time.
	https://time.is/UTC

	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...
(note: you will need to move the market and put it back to facilliate a change in MD to get a PnL price)

	ACC A:
		Start Net Pos -1
		Start PnL blank
		Day Long 0
		Day Short 0
		Day PnL 0
		Total Net Pos -1
		Total PnL -37.5
		PnL Price 14.0125 (displayed as 14.015)
	ACC A1:
		Start Net Pos 1
		Start PnL blank
		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 (displayed as 14.015)

Sell a 1 lot at the current bid in ACC A
	ACC A:
		Start Net Pos -1 (no change)
		Start PnL -37.5
		Day Long 0
		Day Short 1
		Day PnL -37.5
		Total Net Pos -2
		Total PnL -75
		PnL Price 14.0125 (displayed as 14.015)
	ACC A1:
		Start Net Pos 1 (no change)
		Start PnL 37.5
		Day Long 1
		Day Short 0
		Day PnL 37.5
		Total Net Pos 2
		Total PnL 75
		PnL Price 14.0125 (displayed as 14.015)
		
Buy a 1 lot at the current bid in ACCA via Trading -> Manual Fills
	Click the '+' menu icon from the toolbar along the left side of the window to bring up the Add New popup
	Click on the blank security button to launch the security picker and pick your security
	Specify account as ACC A
	Specify side as Buy
	Specify qty as 1
	Specify price at 14.005
	Click OK to state the fill
	Click the Save icon to publish it out
	
	The manual fill will be published as part of the Day PnL so ACC A should reflect as follows:
	
	ACC A:
		Start Net Pos -1 (no change) 
		Start PnL -37.5
		Day Long 1
		Day Short 1
		Day PnL 0
		Total Net Pos -1
		Total PnL -37.5
		PnL Price 14.0125 (displayed as 14.015)	

Enter a manual fill in a complely different security of your choosing
	Verify a new row is show in the pnl for the appropriate security
	Verify the net pos is accurate
	For extra credit, create a market in that security and verify the Start PnL and Total PnL reflect appropriately


Test sorting and filtering
