Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

改成moddule形式 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions go_src/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module xtp.go

go 1.14

require (
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
github.com/urfave/cli v1.22.4
)
15 changes: 15 additions & 0 deletions go_src/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA=
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
45 changes: 22 additions & 23 deletions go_src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,27 @@ import (
"os"
"os/signal"

"sync"
"github.com/urfave/cli"
"github.com/op/go-logging"

. "github.com/leochan007/xtp.go/go_src/defs"
. "github.com/leochan007/xtp.go/go_src/xtp_wrapper"
"sync"
. "xtp.go/defs"
. "xtp.go/xtp_wrapper"
)

type StockMap map[string]string

var (
log = logging.MustGetLogger("go_xtp_trader")
log = logging.MustGetLogger("go_xtp_trader")
Stocks = make(StockMap)
wg sync.WaitGroup
c chan os.Signal
wg sync.WaitGroup
c chan os.Signal
)

func waitForSignal() {
LOOP:
LOOP:
for {
select {
case <-c:
case <-c:
break LOOP
default:
}
Expand All @@ -37,9 +36,9 @@ func waitForSignal() {
}

func main() {

c = make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill)
signal.Notify(c, os.Interrupt, os.Kill)

var quotehost string
var quoteport int
Expand All @@ -55,7 +54,7 @@ func main() {
app := cli.NewApp()
app.UseShortOptionHandling = true
app.Version = "0.0.1"
app.Flags = []cli.Flag {
app.Flags = []cli.Flag{
cli.StringFlag{Name: "quotehost, q", Destination: &quotehost},
cli.IntFlag{Name: "quoteport, p", Destination: &quoteport},
cli.StringFlag{Name: "traderhost, r", Destination: &traderhost},
Expand Down Expand Up @@ -83,18 +82,18 @@ func main() {
folder := "xtp_con"

/*
trader_api := GoCreateLCTraderApi(1, folder)
trader_spi := GoCreateLCTraderSpi()
trader_api := GoCreateLCTraderApi(1, folder)
trader_spi := GoCreateLCTraderSpi()

Go_trader_apiRegisterSpi(trader_api, trader_spi)
Go_trader_apiRegisterSpi(trader_api, trader_spi)

session_id := Go_trader_apiLogin(trader_api, traderhost, traderport, username, password, softKey)
session_id := Go_trader_apiLogin(trader_api, traderhost, traderport, username, password, softKey)

if session_id != 0 {
fmt.Println("--- trader login OK.")
} else {
fmt.Println("--- trader failed.")
}
if session_id != 0 {
fmt.Println("--- trader login OK.")
} else {
fmt.Println("--- trader failed.")
}
*/

quote_api := GoCreateLCQuoteApi(1, folder)
Expand All @@ -103,7 +102,7 @@ func main() {
Go_quote_apiRegisterSpi(quote_api, quote_spi)

Stocks["000001"] = "000001"

loginResult := Go_quote_apiLogin(quote_api, quotehost, quoteport, username, password)

if loginResult == 0 {
Expand All @@ -118,7 +117,7 @@ func main() {
wg.Wait()

return nil
}
}

err := app.Run(os.Args)

Expand Down
2 changes: 1 addition & 1 deletion go_src/strategies/strategy_base.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package strategies

import (
. "leochan007/xtp.go/go_src/defs"
. "xtp.go/defs"
)

type IStrategy interface {
Expand Down
4 changes: 2 additions & 2 deletions go_src/xtp_wrapper/event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import "C"
import (
"fmt"

. "github.com/leochan007/xtp.go/go_src/defs"
. "github.com/leochan007/xtp.go/go_src/queue"
. "xtp.go/defs"
. "xtp.go/queue"
)

func query_handle() {
Expand Down
4 changes: 2 additions & 2 deletions go_src/xtp_wrapper/xtp_quote_spi.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import "C"

import (

. "github.com/leochan007/xtp.go/go_src/defs"
. "github.com/leochan007/xtp.go/go_src/queue"
. "xtp.go/defs"
. "xtp.go/queue"

"unsafe"
)
Expand Down
2 changes: 1 addition & 1 deletion go_src/xtp_wrapper/xtp_trader_spi.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
//"os"
"unsafe"

. "github.com/leochan007/xtp.go/go_src/queue"
. "xtp.go/queue"
)

//export Go_trader_apiOnError
Expand Down