From 1e4ad2808848c60bcf75d636d1f4eec0a2e971fb Mon Sep 17 00:00:00 2001 From: Michael Harding Date: Tue, 5 Jun 2018 10:03:10 -0400 Subject: [PATCH] SPARK-1201: Security column in Secutity Limits --- src/web/ui/src/Accounts/View.fs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/web/ui/src/Accounts/View.fs b/src/web/ui/src/Accounts/View.fs index 0b60fbd65..14949fe16 100644 --- a/src/web/ui/src/Accounts/View.fs +++ b/src/web/ui/src/Accounts/View.fs @@ -330,6 +330,7 @@ let securityLimits model dispatch = { content = str "Exchange"; className = ""; isHeader = true } { content = str "Security Type"; className = ""; isHeader = true } { content = str "Symbol"; className = ""; isHeader = true } + { content = str "Security"; className = ""; isHeader = true } { content = str "Max Net Long Position"; className = ""; isHeader = true } { content = str "Max Net Short Position"; className = ""; isHeader = true } ] @@ -339,6 +340,25 @@ let securityLimits model dispatch = let symbolArray = Array.concat [| [| model.AllValueDisplay |]; Array.map (fun a -> a.symbol ) model.mdRelayProductData |] + let getSecurityMap (limit:AccountSecurityPositionLimitUnit) = + let allOption = { + product = { + exchange = bts.api.Venue.UNSET + ``type`` = bts.api.SecurityType.UNSET + symbol = model.AllValueDisplay + }; + names = (JSMap.add "0" model.AllValueDisplay JSMap.empty) + }:ExpirationNameList + + Array.concat [ [| allOption |]; model.mdRelayExpNameData] + |> Array.filter (fun (x:bts.co2.ExpirationNameList) -> ( + ((x.product.exchange = limit.security.exchange) || (x.product.exchange = bts.api.Venue.UNSET)) + && ((x.product.``type`` = limit.security.securityType) || (x.product.``type`` = bts.api.SecurityType.UNSET)) + && ((x.product.symbol = limit.security.securitySymbol) || (x.product.symbol = model.AllValueDisplay)) + ) + ) + |> Seq.map (fun x -> x.names ) |> JSMap.concat + let modifyRow (oldRow:AccountSecurityPositionLimitUnit) (newRow:AccountSecurityPositionLimitUnit) = let i = Array.findIndex (fun l -> oldRow = l) model.scratch.securityPositionLimits let left = Array.append (model.scratch.securityPositionLimits.[..i-1]) [| newRow |] @@ -361,6 +381,9 @@ let securityLimits model dispatch = | true -> model.AllValue modifyRow oldRow { oldRow with security = { oldRow.security with securitySymbol = v } } + let changeSecurityId (oldRow:AccountSecurityPositionLimitUnit) (value:string) = + modifyRow oldRow { oldRow with security = { oldRow.security with securityId = (uint32 value) } } + let changeLongPositionLimit (oldRow:AccountSecurityPositionLimitUnit) (value:string) = modifyRow oldRow { oldRow with longPositionLimit = (uint32 value) } @@ -399,6 +422,15 @@ let securityLimits model dispatch = className = "" isHeader = false } + { content = Fields.mapSelect + "" + (JSMap.toMap (getSecurityMap limit)) + None + (Some (sprintf "%i" limit.security.securityId)) + ((changeSecurityId limit) >> SecurityLimits >> dispatch) + className = "" + isHeader = false + } { content = Fields.text "" (sprintf "%i" limit.longPositionLimit)