-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
77 lines (68 loc) · 1.64 KB
/
main.go
File metadata and controls
77 lines (68 loc) · 1.64 KB
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
/*
* @Description: Do not edit
* @Author: taowentao
* @Date: 2021-06-24 20:03:02
* @LastEditors: taowentao
* @LastEditTime: 2021-07-25 17:04:09
*/
package main
import (
"fmt"
"fund_analyze/module"
"fund_analyze/ttjj"
"fund_analyze/util"
"sort"
"time"
)
//我的信息
var my_info *module.MyInfo
//005913
var f_fund *module.FundInfo
func init() {
util.Init()
my_info = new(module.MyInfo)
my_info.Init(300000)
f_fund = new(module.FundInfo)
saleFee := []module.SaleFee{
{Day: 7, Fee: 1.5 / 100},
}
f_fund.Init("001593", 0.15/100, saleFee)
}
//每天的操作
func day_op(day time.Time, acc_net float64) {
//计算收益率
//2015.07.28买入
bt, _ := time.Parse("2006-01-02", "2015-07-28")
if day.Before(bt) {
return
}
if len(my_info.MyFunds) == 0 {
my_info.PurchaseFund(day, f_fund, 100)
}
fund := my_info.MyFunds["001593"]
y, _ := fund.Yield(day)
fmt.Printf("date:%s, acc: %f, yield: %.2f%%\n", day.Format("2006-1-2"), acc_net, y*100)
}
func main() {
fmt.Println("day,value")
days_info, err := ttjj.GetFundDaysInfo("001593")
if err != nil {
fmt.Print(err)
}
f_fund.DaysInfo = days_info
// day, _ := time.ParseInLocation("2006-1-2", "2020-07-01", time.Local)
// info, err := days_info.GetFundDayInfo(day)
// fmt.Println(info)
//排序
var times []int
for k := range days_info.DaysInfo {
times = append(times, int(k))
}
sort.Ints(times)
for _, t := range times {
v := days_info.DaysInfo[uint32(t)]
day := util.ParseDaysToTime(v.Date)
// fmt.Println(day.Format("2006-1-2"), ",", v.AccumulatedNet)
day_op(day, v.AccumulatedNet)
}
}