File tree 5 files changed +9
-9
lines changed
5 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -22,4 +22,4 @@ build :
22
22
23
23
doc :
24
24
@echo " Generating godoc documentation..."
25
- @godoc -http=:6060 &
25
+ @go doc -http=:6060
Original file line number Diff line number Diff line change 1
1
module github.com/quick-trade/xoney
2
2
3
- go 1.21.6
3
+ go 1.22.0
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ func CurrentWeights(portfolio common.BaseDistribution) toolkit.PortfolioWeights
54
54
weights [currency ] = toolkit .BaseWeight (amount / totalCapital )
55
55
}
56
56
57
- dist , err := toolkit .NewPortfolioWeights (weights )
57
+ dist , err := toolkit .NewPortfolioWeights (weights , 0 )
58
58
if err != nil {
59
59
panic (err )
60
60
}
@@ -246,7 +246,7 @@ func TestRebalanceMarketOrders(t *testing.T) {
246
246
}
247
247
248
248
// Create new PortfolioWeights with desired weights
249
- portfolioWeights , err := toolkit .NewPortfolioWeights (desiredWeights )
249
+ portfolioWeights , err := toolkit .NewPortfolioWeights (desiredWeights , 0 )
250
250
if err != nil {
251
251
t .Fatalf ("Error creating portfolio weights: %v" , err )
252
252
}
Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ type GridGenerator interface {
227
227
Next (candle data.Candle ) ([]GridLevel , error ) // new levels can be nil
228
228
}
229
229
230
- type GridBot struct {
230
+ type GridBot struct { // TODO: debug
231
231
grid grid
232
232
strategy GridGenerator
233
233
instrument data.Instrument
Original file line number Diff line number Diff line change @@ -19,22 +19,22 @@ type (
19
19
PortfolioWeights map [data.Currency ]BaseWeight
20
20
)
21
21
22
- func NewPortfolioWeights (distribution map [data.Currency ]BaseWeight ) (* PortfolioWeights , error ) {
22
+ func NewPortfolioWeights (distribution map [data.Currency ]BaseWeight , epsilon float64 ) (* PortfolioWeights , error ) {
23
23
weights := PortfolioWeights (distribution )
24
- if err := weights .isValid (); err != nil {
24
+ if err := weights .isValid (epsilon ); err != nil {
25
25
return nil , err
26
26
}
27
27
return & weights , nil
28
28
}
29
29
30
- func (f PortfolioWeights ) isValid () error {
30
+ func (f PortfolioWeights ) isValid (epsilon float64 ) error {
31
31
sumWeights := 0.0
32
32
33
33
for _ , weight := range f {
34
34
sumWeights += math .Abs (float64 (weight ))
35
35
}
36
36
37
- if sumWeights != 1 {
37
+ if math . Abs ( sumWeights - 1 ) > epsilon {
38
38
return errors .NewInvalidWeightsError (sumWeights )
39
39
}
40
40
You can’t perform that action at this time.
0 commit comments