Skip to content

Commit

Permalink
Fix price
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsamson committed Mar 12, 2016
1 parent 2ab4a1d commit 91dd57a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions web/elm/src/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Html exposing (..)
import Html.Attributes exposing (href, class)
import Actions exposing (..)
import Models exposing (..)
import String

type alias ViewModel =
{ ticker : String
Expand Down Expand Up @@ -69,11 +70,20 @@ tickerTable address model =
[]
[ td [] [ text model.ticker ]
, td [] [ text model.venue ]
, td [] [ text (toString model.bid) ]
, td [] [ text (toString model.ask) ]
, td [] [ text (toString model.price) ]
, td [] [ text (formatPrice model.bid) ]
, td [] [ text (formatPrice model.ask) ]
, td [] [ text (formatPrice model.price) ]
, td [] [ text ((toString model.bidSize) ++ " / " ++ (toString model.bidDepth)) ]
, td [] [ text ((toString model.askSize) ++ " / " ++ (toString model.askDepth)) ]
]
]
]

formatPrice : Int -> String
formatPrice price =
let
priceStr = toString price
cents = String.right 2 priceStr
dollars = String.slice 0 -2 priceStr
in
"$" ++ dollars ++ "." ++ cents

0 comments on commit 91dd57a

Please sign in to comment.