@@ -3,12 +3,12 @@ package main
33import (
44 "flag"
55 "fmt"
6+ "github.com/robaho/fixed"
67 "log"
78 "time"
89
910 . "github.com/robaho/go-trader/pkg/common"
1011 "github.com/robaho/go-trader/pkg/connector"
11- "github.com/shopspring/decimal"
1212)
1313
1414type algoState int
@@ -27,9 +27,9 @@ var exchange ExchangeConnector
2727type MyAlgo struct {
2828 symbol string
2929 instrument Instrument
30- entryPrice decimal. Decimal
31- offset decimal. Decimal
32- totalProfit decimal. Decimal
30+ entryPrice fixed. Fixed
31+ offset fixed. Fixed
32+ totalProfit fixed. Fixed
3333 state algoState
3434 runs int
3535 nextEntry time.Time
@@ -86,7 +86,7 @@ func (a *MyAlgo) OnFill(fill *Fill) {
8686 if a .state == waitSell {
8787 profit := fill .Price .Sub (a .entryPrice )
8888 fmt .Println ("exited market at " , fill .Price )
89- if profit .GreaterThan (decimal . Zero ) {
89+ if profit .GreaterThan (fixed . ZERO ) {
9090 fmt .Println ("!!!! winner " , profit )
9191 } else {
9292 fmt .Println ("____ loser " , profit )
@@ -118,7 +118,7 @@ func main() {
118118 flag .Parse ()
119119
120120 callback .symbol = * symbol
121- callback .offset = decimal . NewFromFloat (* offset )
121+ callback .offset = fixed . NewF (* offset )
122122
123123 p , err := NewProperties (* props )
124124 if err != nil {
@@ -133,7 +133,7 @@ func main() {
133133 panic ("exchange is not connected" )
134134 }
135135
136- err : = exchange .DownloadInstruments ()
136+ err = exchange .DownloadInstruments ()
137137 if err != nil {
138138 panic (err )
139139 }
@@ -148,7 +148,7 @@ func main() {
148148 for {
149149 time .Sleep (time .Duration (10 ) * time .Second )
150150 tp := callback .totalProfit
151- if tp .LessThan (decimal . Zero ) {
151+ if tp .LessThan (fixed . ZERO ) {
152152 fmt .Println ("<<<<< total profit" , tp )
153153 } else {
154154 fmt .Println (">>>>> total profit" , tp )
0 commit comments