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

cache more frame type bars and do real-time calc with lua #58

Open
zillionare opened this issue Jul 15, 2022 · 0 comments
Open

cache more frame type bars and do real-time calc with lua #58

zillionare opened this issue Jul 15, 2022 · 0 comments
Assignees

Comments

@zillionare
Copy link
Owner

Now we have only cache 1m bar in redis, and to get unclosed bars of 1w, we have to:

  1. fetch week bars from persistent db
  2. fetch day bars from persistent db for unclosed week
  3. fetch 1m bars for today, and resample it into day bars
  4. resample all these day bars into unclosed week bar
  5. concatenate closed week bars with unclosed week bar

The whole process is tedious and not performant. If we have cached all 5m, 15m, 30m, 60m, 1d, 1w, 1M bars in redis, the performance will be much better.

To do this, we need to develop a lua script:

  1. called every time upon arrival of 1m bars
  2. update latest 5m (and others) bars by merging existed bar and latest 1m bar
  3. start new entry for frames in (5m, 15m, 30m, 60m) at the begin of each frame type (could be parameter passed through by python)
  4. clear cache after calibration, re-calc unclosed bar of week/month frame using latest closed day bars (python)
  5. clear cached bars for week/month after this frame is closed, after calibration time.
zillionare pushed a commit that referenced this issue Jul 24, 2022
1. add lua script and wrappers under scripts
2. load_lua_script during app.init
3. rebuild unclosed bars during app.init
4. realtime calc unclosed bars after 1m bars is fetched and cached
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants