Giter Club home page Giter Club logo

Comments (1)

sjhermanek avatar sjhermanek commented on July 17, 2024

I got this to run (after some hacking around) by adding two assets to the same strategy as such:

  # Add price events to strategy. This means that for every lapse of resolution, we will be calling the price_event function once, for each symbol (pair, secondary) defined.
  strategy.add_price_event(price_event, secondary, resolution=resolution)
  strategy.add_price_event(price_event, pair, resolution=resolution, init=init, teardown=teardown)

And then in price_event

if (symbol == pair):
    variables['history'].append(price)
    variables[secondary]['history'].append(interface.get_price(secondary))
else:
    return

... # Rest of your logic

There was a bit of fiddling around in the init - make sure to call it only once.

variables['history'] = interface.history(pair, 1200, resolution, end_date=state.time, return_as='deque')['close']
variables[secondary] = {}
variables[secondary]["history"] = interface.history(secondary, 1200, resolution, end_date=state.time, return_as='deque')['close']

... # Rest of your logic

(Make sure to set secondary to global context)

from blankly.

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.