-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
55 lines (44 loc) · 891 Bytes
/
main.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
package main
import (
"flag"
"fmt"
"os"
)
const (
symbolUSD = "USD"
symbolETH = "ETH"
symbolBTC = "BTC"
tradingPairETHUSD = "ETHUSD"
tradingPairBTCUSD = "BTCUSD"
)
func main() {
fileName := flag.String("filename", "history.csv", "trade history csv")
flag.Parse()
btcMarketData, err := GetBTCMarketData()
if err != nil {
panic(err)
}
ethMarketData, err := GetETHMarketData()
if err != nil {
panic(err)
}
cr := NewCompositeReport(btcMarketData, ethMarketData)
lots, err := ParseTrades(*fileName)
if err != nil {
panic(err)
}
for _, lot := range lots {
cr.Add(lot)
}
fmt.Printf("%s\n", cr)
for key, report := range cr.Reports {
if len(report.Calculations) > 0 {
fd, err := os.OpenFile(key+".csv", os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
panic(err)
}
report.WriteCalculations(fd)
fd.Close()
}
}
}