import HQuant.LoadHistory import HQuant.History import Data.Time import Data.Time.Clock import qualified Finance.Quote.Yahoo as Yahoo start :: Day start = fromGregorian 2010 1 1 :: Day buy h shares = Order (historyUTCTime h) shares (adjclose h) sell h shares = Order (historyUTCTime h) (negate shares) (adjclose h) orderPrice (Order _ shares price) = negate$price * (fromIntegral shares) --buy price multiplier shares = price * multiplier * shares --sell price multiplier shares = price * multiplier * (negate$shares) profit o1 o2 = (orderPrice o1) + (orderPrice o2) main :: IO () main = do let longShares = 60 * 1 let shotShared = 100 * 1 gld <- readHistory "GLD" gdx <- readHistory "GDX" let o1 = buy ( head gld) longShares let c1 = sell (head $reverse gld) longShares let o2 = sell (head gdx) shotShared let c2 = buy (head $reverse gdx) shotShared print o1 print c1 print o2 print c2 print $ orderPrice o1 print $ orderPrice o2 let p1 =profit o1 c1 let p2 =profit o2 c2 print p1 print p2 print $p1+p2