Code Monkey home page Code Monkey logo

Comments (3)

dsouzae avatar dsouzae commented on July 17, 2024 3

Can you post what you have implement? Make sure you subscribe to get a response for request ID or all responses.

I have example code available here for other types of requests:
https://github.com/dsouzae/ibstockcli

I do not have an example for RequestRealtimeBars, but I will see if I can get a working example ready for tomorrow.

from ib.

lumosxgh avatar lumosxgh commented on July 17, 2024

Thank you @dsouzae, your repo really helped me out. I would suggest anyone looking for examples to check out the code for the same.

from ib.

dsouzae avatar dsouzae commented on July 17, 2024

I have pushed some changes in the ibstockcli. Here are some details.

Make sure you either call SubscribeAll(...) or Subscribe(...,id) with the request id to get the responses on your reply change.

Make the request:

func doRequestRealTimeBars(mgr *IBManager, symbol string) {
       request := ib.RequestRealTimeBars{
               Contract:   NewContract(symbol),
               BarSize:    5,
               WhatToShow: ib.RealTimeTrades,
               UseRTH:     true,
       }

       id := mgr.NextOrderID()
       request.SetID(id)
       mgr.realtimeMap[id] = symbol

       mgr.engine.Send(&request)

       log.Printf("%s: Sending RealTime Bars For %s", mgr.label, symbol)
}

I added a map to save the request id to get the symbol string.

In your engineLoop add support to output realtime bars. Also using the map to get the symbol name:

case (*ib.RealtimeBars):
        r := r.(*ib.RealtimeBars)

        symbol, ok := ibmanager.realtimeMap[r.ID()]
        if !ok {
                symbol = "???"
        }

        log.Printf("%10s: %v - Open: %10.2f Close: %10.2f Low %10.2f High %10.2f Volume %10.2f Count %10v WAP %10.2f\n",
                symbol,
                time.Unix(r.Time, 0).Format("15:04:05"),
                r.Open,
                r.Close,
                r.Low,
                r.High,
                r.Volume,
                r.Count,
                r.WAP)

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.