Code Monkey home page Code Monkey logo

Comments (4)

a8d7e8 avatar a8d7e8 commented on July 17, 2024

See if nothize#1 is related.

from ib.

dsouzae avatar dsouzae commented on July 17, 2024

Hello Gareth,

Not sure if you have resolved this issue yet, hopefully the following is helpful.

The InstrumentManager is not documented how it works. I am not sure of the history of it, but it looks to be used for testing the code. It is used to get one result based on test code.

My guess is the channel inside mgr is no longer reading the reply channel.

manager.go has a full documentation about how managers are supposed to work. Depending on your goal, you might need to implement your own manager.

Or you can start will the following code (hopefully it works, my environment is not setup market data):

func main() {
    options := ib.EngineOptions{}
    engine, err := ib.NewEngine(options)
    if err != nil {
        log.Fatal(err)
    }

    rc := make(chan ib.Reply)

    req := &ib.RequestMarketData{}
    req.Contract = ib.Contract{
        Symbol:       "USD",
        SecurityType: "CASH",
        Exchange:     "IDEALPRO",
        Currency:     "ZAR"}

    req.SetID(engine.NextRequestID())

    engine.Send(req)

    for {
        select {
        case r := <-rc:
            fmt.Println(r)
            switch r.(type) {
            case *ib.TickPrice:
                tick := r.(*ib.TickPrice)
                switch tick.Type {
                case ib.TickLast:
                    fmt.Printf("%v: Last %v", tick.ID(), tick.Price)
                case ib.TickBid:
                    fmt.Printf("%v: Bid %v", tick.ID(), tick.Price)
                case ib.TickAsk:
                    fmt.Printf("%v: Ask %v", tick.ID(), tick.Price)
                }
            }
        }
    }
}

from ib.

LuSaxy avatar LuSaxy commented on July 17, 2024

Thank you so much for getting back to me. I ended up solving the issue.

the code opens up 2 responses from the IB workstation. 1 when on the engine. and then another when i created the instrument manager (which i thought would have gone to the engine one). then in my select case statement i was only doing the drain for the engine channel that is created and never drained the instrument manager channel <- if that makes sense :)

so in my code above if i add notify:=mgr.Refresh() and then just listen for notify:

 engine,_:=ib.NewEngine(ib.EngineOptions{})
rc := make(chan ib.Reply)



mgr,_:=ib.NewInstrumentManager(engine, ib.Contract{
	Symbol:       "USD",
	SecurityType: "CASH",
	Exchange:     "IDEALPRO",
	Currency:     "ZAR",
})
s:=ib.RequestMarketDataType{
	MarketDataType: 1,
}
    
    notify:=mgr.Refresh()
engine.Send(&s)
engine.SubscribeAll(rc)

for {
	select {
       case <-notify:
                fmt.Println(mgr.Ask())   
	case r := <-rc:
		//whatever you want to do with engine responses
		
	}
}

from ib.

dsouzae avatar dsouzae commented on July 17, 2024

Your code with Refresh looks to be the correct solution over mine.

from ib.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.