Git Product home page Git Product logo

Comments (7)

ranaroussi avatar ranaroussi commented on May 18, 2024

Well, it should in theory, but I took a different approach here in favor of efficiency...

The way this works now is that it resamples data to the strategy resolution on every new tick that is received, so if there's a 5 second gap between ticks, you won't get bar events during that time.

However, when the new tick is received the self.bars / instrument.bars / instrument.get_bars() should get you the full bar history for every second - even if the quote has not changed.

The idea behind this decision was that if nothing's happening in the market, its likely that the strategy shouldn't take any action - but when something is happening (a tick received), you'll have access to the full data for calculating moving averages, etc.

I'm still thinking if there's an elegant way (or a reason) to have the bar event fire every second that doesn't involves without using threads and without putting unnecessary strain on the system.

from qtpylib.

ranaroussi avatar ranaroussi commented on May 18, 2024

Ok... couldn't help it :)

If you'll add "force_resolution" = True to your strategy initializer, you'll get a bar every resolution - regardless of whether or not new ticks were received.

Version 1.5.27 released.

from qtpylib.

jkleint avatar jkleint commented on May 18, 2024

Unfortunately it's still skipping beats with force_resolution=True. I'll see if I can fix it.

$ python sec_test.py 
bar 1478895960 2016-11-11 20:26:00
bar 1478895961 2016-11-11 20:26:01
bar 1478895962 2016-11-11 20:26:02
bar 1478895964 2016-11-11 20:26:04
bar 1478895965 2016-11-11 20:26:05
bar 1478895966 2016-11-11 20:26:06
bar 1478895967 2016-11-11 20:26:07
bar 1478895969 2016-11-11 20:26:09
bar 1478895970 2016-11-11 20:26:10
bar 1478895971 2016-11-11 20:26:11
bar 1478895973 2016-11-11 20:26:13
bar 1478895975 2016-11-11 20:26:15
bar 1478895976 2016-11-11 20:26:16

from qtpylib.

jkleint avatar jkleint commented on May 18, 2024

So I tracked the issue down to Algo._tick_handler(); it's not a thread/timing issue, it's how _tick_handler decides if it's got a new bar:

    if len(bar.index) > self.tick_bar_count > 0:
        self._bar_handler(bar)

Which I think is saying if this bar has more bars than the last bar, call the bar handler? I don't really understand this section, but len(bar.index) and self.tick_bar_count are often the same, so it doesn't fire a bar.

from qtpylib.

ranaroussi avatar ranaroussi commented on May 18, 2024

Hopefully fixed in v. 1.5.29

from qtpylib.

jkleint avatar jkleint commented on May 18, 2024

Thanks, much better. It still skips seconds after running for a while, but I can probably live with it.

from qtpylib.

 avatar commented on May 18, 2024

I see the same issue. It skips seconds after running for a while.

from qtpylib.

Related Issues (20)

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.