
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/*

If your Ladder is not centered on at 2500 after entering your first order you may need to clear other databases
  rm ~/sparkdata/data/databases/*

Throughout the test we'll refer to accounts BTS1 and BTS2. 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 ladder form. It should be completely empty since we're controlling the md.  For this exercise we'll be using ES.
Bring up an order ticket for your corresponding ladder
	place a buy order with price 2500 and qty 100
	your ladder should populate now
Sell a 1 lot at your bid
	The Start of Day (SOD) position should be 0
	Buy qty and Sell qty should be 1 (we crossed our own bid)
	Net Pos should be 0 (buy 1 - sell 1)
	PnL should be 0 (since we have a 0 net position)
	PnL Price should be the level of your bid.
	AvgBuy and Avg Sell should both represent the level at which you entered the buy and sell order
Improve the bid
	Under BTS2 account (this is important for the next step), enter a 100 lot bid at 2500.25
	Observe the PnL Price reflect the current bid
	Switch back to BTS1
Sell a 1 lot at the current bid
	You should now have rows for both the BTS1 and BTS2 account
	BTS1
		Sell Qty 2
		Net Pos -1
		PnL 0
		Avg Buy 2500.0
		Avg Sell 2500.13
Improve the Bid
	Enter a 100 lot bid at 2500.50
	The PnL Price should reflect the current Bid (2500.5)
	The PnL for BTS1 account should show -12.5
		Fill 1: 25    = (2500.5 - 2500) * 1 * 50
		Fill 2: -25   = (2500 - 2500.5) * 1 * 50
		Fill 3: -12.5 = (2500.25 - 2500.5) * 1 * 50
    The PnL for BTS2 account should show 12.5 by a similar calculation as above (but there is only 1 fill)
Go to bed and wake up the next day
	The SOD for BTS1 should show a -1
	The SOD for BTS2 should show a 1
	Buy Qty for all should show 0
	Sell Qty for all should show 0
	Net Pos should be the same as SOD at the moment
The simulator might not work for orders left up overnight
	If your ladder shows no working orders, place a buy order with price 2500 and qty 100
Sell a 1 lot as the current bid
	The SOD should still show -1
	The Buy and Sell Qty should show 1 (we crossed ourselves)
	The net position will still say -1
	Now switch to BTS2
Sell a 5 lot at the current bid
	The SOD should still show -1
	BTS1 Buy qty should show 6 (1 (crossed) + 5 (BTS2))
	BTS1 Sell Qty should show 1
	Net Pos should show 4 (-1 (SOD) + 6 (Buys) -1 (Sells))
	BTS1 PnL should show 12.5

Test sorting and filtering
