This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func findShortestEdgeFromNode(node Node) Edge { | |
minimumEdge := MaxEdge | |
for _, edge := range Edges { | |
if edge.Node1.Name != node.Name || EdgeContains(UsedEdges, edge) { | |
continue | |
} | |
if edge.Length.LessThan(minimumEdge.Length) && !NodeContains(VisitedNodes, edge.Node2) { | |
log.Trace.Println("\nReplaced minimumEdge with shorter edge " + edge.String()) | |
minimumEdge = edge | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ProcessEdges(node Node) { | |
if NodeContains(VisitedNodes, node) { | |
return | |
} | |
EdgeCount += 1 | |
VisitedNodes = append(VisitedNodes, node) | |
edge := findShortestEdgeFromNode(node) | |
RouteEdges = append(RouteEdges, edge) | |
TotalDistance = TotalDistance.Add(edge.Length) | |
NextNode = Nodes[edge.Node2.Name] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func CalculateEdges(listEdges bool) string { | |
var sbldr = strings.Builder{} | |
for _, co := range Nodes { | |
for _, ci := range Nodes { | |
if co.Name == ci.Name { | |
log.Trace.Println("Skipping " + co.Name + " and " + ci.Name) | |
continue | |
} | |
diffXSq := co.XCoord.Sub(ci.XCoord).Abs().Pow(decimal.NewFromInt(2)) | |
diffYSq := co.YCoord.Sub(ci.YCoord).Abs().Pow(decimal.NewFromInt(2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func GenNodes() string { | |
var sbldr = strings.Builder{} | |
for _, node := range NodeNames { | |
x := decimal.NewFromInt(int64(rand.Intn(GridMax-GridMin) + GridMin)) | |
y := decimal.NewFromInt(int64(rand.Intn(GridMax-GridMin) + GridMin)) | |
if !colocation(x, y) { | |
Nodes[node] = *NewNode(node, x, y) | |
} else { | |
log.Error.Println("Found colocated instance") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func FindOriginNode(listNodes bool) string { | |
originDist := float64(100 * 100) | |
for _, node := range Nodes { | |
sqd, _ := node.XCoord.Pow(decimal.NewFromInt(2)).Add(node.YCoord.Pow(decimal.NewFromInt(2))).Float64() | |
d := math.Sqrt(sqd) | |
if d < originDist { | |
originDist = d | |
OriginNode = node | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func GenNodesFixed() string { | |
var sbldr = strings.Builder{} | |
xray := []float64{100, 56.84, 1.87, 30, 92.66, 81.67, 16, 9.04, 72.8, 97.2, 40.11, 0.1, 46.24, 98.88, 67.12, 5.81, 20.79, 86.21, 89.11, 24.49, 3.91, 62.91, 99.62, 50.66, 0.56, 35.82, 95.56} | |
yray := []float64{50, 99.53, 63.55, 4.17, 23.92, 88.69, 86.66, 21.33, 5.5, 66.5, 99.01, 46.9, 0.14, 39.46, 96.98, 73.39, 9.42, 15.52, 81.15, 93, 30.61, 1.69, 56.18, 100, 57.49, 2.05, 29.4} | |
i := 0 | |
for _, node := range NodeNames { | |
x := decimal.NewFromFloat(xray[i]) | |
y := decimal.NewFromFloat(yray[i]) | |
Nodes[node] = *NewNode(node, x, y) | |
i++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Processing 6 input files. | |
Processing Btc | |
Buy recommendation 0.04 Btc at price 6627.16, cost $270.13 on 2019-12-18 | |
Sell Recommendation 0.07 Btc at price 9592.18, earn $669.88 on 2020-02-06 | |
Cash available $1480.27, Btc available 0.21, portfolio total $2890.86 | |
Buy recommendations 9, Sale recommendations 15 | |
Processing Eth | |
Sell Recommendation 159.62 Eth at price 193.34, earn $30861.1 on 2019-10-10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==> HistoryAnalysisBTC.txt <== | |
Sell Recommendation 0.07 Btc at price 9592.18, earn $669.88 on 2020-02-06 | |
After trade, cash available $1480.27, Btc available 0.21, portfolio total $3489.92 | |
Buy recommendations 9, Sale recommendations 15 | |
==> HistoryAnalysisETH.txt <== | |
Buy recommendation 135.1 Eth at price 132.72, cost $17930.83 on 2019-12-17 | |
After trade, cash available $53792.5, Eth available 613.96, portfolio total $135279.32 | |
Buy recommendations 13, Sale recommendations 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Initial Cash $1000, Initial Eth 0, Initial Portfolio value $1000 | |
Buy recommendation 286.03 Eth at price 0.87, cost $250 on 2015-09-14 | |
After trade, cash available $750, Crypto available 286.03, portfolio total $1000 | |
Buy recommendation 321.58 Eth at price 0.58, cost $187.5 on 2015-09-28 | |
After trade, cash available $562.5, Crypto available 607.61, portfolio total $916.77 | |
Buy recommendation 319.77 Eth at price 0.44, cost $140.62 on 2015-10-21 | |
After trade, cash available $421.88, Crypto available 927.38, portfolio total $829.71 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Analyzer() { | |
readCsvFile() | |
macd := NewMacd() | |
rsi := NewRsi() | |
trend := NewTrend() | |
obv := NewObv() | |
priceClose, err := decimal.NewFromString("0") | |
volume, err := decimal.NewFromString("0") | |
check(err) | |
rsiB := false |
NewerOlder