/
schema.go
133 lines (117 loc) · 4.33 KB
/
schema.go
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package client
import (
"encoding/json"
"fmt"
"github.com/shopspring/decimal"
"github.com/sirupsen/logrus"
)
type FugleAPIResponse struct {
APIVersion string `json:"api_version"`
StatusCode int `json:"status_code"`
Data FugleAPIData `json:"data"`
}
type FugleAPIData struct {
Info FugleAPIInfo `json:"info"`
Chart map[string]FugleAPIChartPrice `json:"chart"`
Quote FugleAPIQuote `json:"quote"`
Meta FugleAPIMeta `json:"meta"`
Dealts []FugleAPIDealts `json:"dealts"`
}
type FugleAPIInfo struct {
Date string `json:"date"`
Mode string `json:"mode"`
SymbolID string `json:"symbolId"`
CountryCode string `json:"countryCode"`
Timezone string `json:"timeZone"`
LastUpdatedAt string `json:"lastUpdatedAt"`
}
type FugleAPIChartPrice struct {
Open decimal.Decimal `json:"open"`
High decimal.Decimal `json:"high"`
Low decimal.Decimal `json:"low"`
Close decimal.Decimal `json:"close"`
Volume decimal.Decimal `json:"volume"`
Unit decimal.Decimal `json:"unit"`
}
type FugleAPIQuote struct {
Iscurbing bool `json:"isCurbing"`
Iscurbingrise bool `json:"isCurbingRise"`
Iscurbingfall bool `json:"isCurbingFall"`
Istrial bool `json:"isTrial"`
Isopendelayed bool `json:"isOpenDelayed"`
Isclosedelayed bool `json:"isCloseDelayed"`
Ishalting bool `json:"isHalting"`
Isclosed bool `json:"isClosed"`
Total FugleAPITotal `json:"total"`
Trial FugleAPITrial `json:"trial"`
Trade FugleAPITrade `json:"trade"`
Order FugleAPIOrder `json:"order"`
PriceHigh FugleAPIQuotePrice `json:"priceHigh"`
PriceLow FugleAPIQuotePrice `json:"priceLow"`
PriceOpen FugleAPIQuotePrice `json:"priceOpen"`
}
type FugleAPITotal struct {
At string `json:"at"`
Unit decimal.Decimal `json:"unit"`
Volume decimal.Decimal `json:"volume"`
}
type FugleAPITrial struct {
At string `json:"at"`
Price decimal.Decimal `json:"price"`
Unit decimal.Decimal `json:"unit"`
Volume decimal.Decimal `json:"volume"`
}
type FugleAPITrade struct {
At string `json:"at"`
Price decimal.Decimal `json:"price"`
Unit decimal.Decimal `json:"unit"`
Volume decimal.Decimal `json:"volume"`
Serial decimal.Decimal `json:"serial"`
}
type FugleAPIOrder struct {
At string `json:"at"`
Bestbids []FugleAPIBestPrice `json:"bestBids"`
Bestasks []FugleAPIBestPrice `json:"bestAsks"`
}
type FugleAPIBestPrice struct {
Price decimal.Decimal `json:"price"`
Unit decimal.Decimal `json:"unit"`
Volume decimal.Decimal `json:"volume"`
}
type FugleAPIQuotePrice struct {
Price decimal.Decimal `json:"price"`
At string `json:"at"`
}
type FugleAPIMeta struct {
Isindex bool `json:"isIndex"`
Namezhtw string `json:"nameZhTw"`
Industryzhtw string `json:"industryZhTw"`
Pricereference decimal.Decimal `json:"priceReference"`
Pricehighlimit decimal.Decimal `json:"priceHighLimit"`
Pricelowlimit decimal.Decimal `json:"priceLowLimit"`
Candaybuysell bool `json:"canDayBuySell"`
Candaysellbuy bool `json:"canDaySellBuy"`
Canshortmargin bool `json:"canShortMargin"`
Canshortlend bool `json:"canShortLend"`
Volumeperunit int `json:"volumePerUnit"`
Currency string `json:"currency"`
Isterminated bool `json:"isTerminated"`
Issuspended bool `json:"isSuspended"`
Iswarrant bool `json:"isWarrant"`
Typezhtw string `json:"typeZhTw"`
Abnormal string `json:"abnormal"`
IsUnusuallyRecommended bool `json:"isUnusuallyRecommended"`
}
type FugleAPIDealts struct {
At string `json:"at"`
Price decimal.Decimal `json:"price"`
Unit decimal.Decimal `json:"unit"`
Serial decimal.Decimal `json:"serial"`
}
func (resp *FugleAPIResponse) PrettyPrint() {
buffer, err := json.MarshalIndent(resp, "", " ")
if err != nil {
logrus.Infoln(err.Error())
}
fmt.Println(string(buffer))
}