/
Model.hs
105 lines (91 loc) · 3.78 KB
/
Model.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{-
This file is part of Tractor.
Tractor is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Tractor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Tractor. If not, see <http://www.gnu.org/licenses/>.
-}
{- |
Module : Model
Description : A schema of Table
Copyright : (c) 2017 Akihiro Yamamoto
License : AGPLv3
Maintainer : https://github.com/ak1211
Stability : unstable
Portability : POSIX
株価データベースのモデル
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE LambdaCase #-}
module Model where
import Data.Text (Text)
import qualified Database.Persist.TH as DB
import Data.ByteString.Char8 (ByteString)
import Data.Time (UTCTime)
import TickerSymbol as Import
import TimeFrame as Import
import TechnicalIndicators as Import
DB.share [DB.mkPersist DB.sqlSettings, DB.mkMigrate "migrateQuotes"] [DB.persistLowerCase|
-- | 株式銘柄テーブル
Portfolio
ticker TickerSymbol -- ^ ティッカー
caption Text Maybe -- ^ 銘柄名
updateAt UTCTime Maybe -- ^ 価格情報を取り込んだ日付時間
deriving Show
-- | 初値, 高値, 安値, 終値, 出来高, 売買代金テーブル
Ohlcvt
ticker TickerSymbol -- ^ ティッカー
tf TimeFrame -- ^ 時間枠
at UTCTime -- ^ 日付時間
open Double Maybe -- ^ 初値
high Double Maybe -- ^ 高値
low Double Maybe -- ^ 安値
close Double Maybe -- ^ 終値
volume Double Maybe -- ^ 出来高
turnover Double Maybe -- ^ 売買代金
source Text Maybe -- ^ 情報の入手元
deriving Show
-- | テクニカル指標テーブル
TechInds
ohlcvt OhlcvtId -- ^ 紐付け
ind TechnicalInds -- ^ テクニカル指標
val Double -- ^ 値
deriving Show
|]
DB.share [DB.mkPersist DB.sqlSettings, DB.mkMigrate "migrateLogTable"] [DB.persistLowerCase|
-- | HTTP通信記録用データーベース
-- urlのページにHTTP通信をした時の返答
Loghttp
url String -- ^ ページのURL
scheme String -- ^ スキーム
userInfo String -- ^ オーソリティ
host String -- ^ オーソリティ
port String -- ^ オーソリティ
path String -- ^ パス
query String -- ^ クエリ
fragment String -- ^ フラグメント
--
reqCookie String -- ^ 要求クッキー
reqBody String -- ^ 要求ボディ
--
respDatetime UTCTime -- ^ 返答時間
respStatus String -- ^ 返答HTTP status code
respVersion String -- ^ 返答HTTP version
respHeader String -- ^ 返答ヘッダ
respCookie String -- ^ 返答クッキー
respBody ByteString -- ^ 返答ボディ(HTML)
deriving Show
|]