Giter VIP home page Giter VIP logo

Comments (6)

cedricporter avatar cedricporter commented on July 16, 2024

请问可以提供下具体代码吗?

from rqalpha.

smilingpoplar avatar smilingpoplar commented on July 16, 2024

@cedricporter 比如跑:
rqalpha run -f examples/multi_rsi.py -s 2006-08-01 -e 2016-08-08 -o result.pkl --plot

或者下面二八轮动的代码:

def init(context):
  context.stocks = ['000300.XSHG', '000905.XSHG', '000012.XSHG']

def handle_bar(context, bar_dict):
  [hs, zz, gz] = context.stocks
  history20 = history(20, '1d', 'close')
  hsIncrease = history20[hs][-1] - history20[hs][0]
  zzIncrease = history20[zz][-1] - history20[zz][0]
  positions = context.portfolio.positions
  [hsQuality, zzQuality, gzQuality] = [positions[hs].quantity, positions[zz].quantity, positions[gz].quantity]
  if hsIncrease < 0 and zzIncrease < 0:
    if hsQuality > 0: order_target_percent(hs, 0)
    if zzQuality > 0: order_target_percent(zz, 0)
    order_target_percent(gz, 1)
  elif hsIncrease < zzIncrease:
    if hsQuality > 0: order_target_percent(hs, 0)
    if gzQuality > 0: order_target_percent(gz, 0)
    order_target_percent(zz, 1)
  else:
    if zzQuality > 0: order_target_percent(zz, 0)
    if gzQuality > 0: order_target_percent(gz, 0)
    order_target_percent(hs, 1)
  logger.info("positions hs300: " + str(hsQuality) + ", zz500: " + str(zzQuality) + ", gz: " + str(gzQuality))

from rqalpha.

cedricporter avatar cedricporter commented on July 16, 2024

rqalpha run -f examples/multi_rsi.py -s 2006-08-01 -e 2016-08-08 -o result.pkl --plot 这个是一样的,不一样的话,可能是你本地的data bundle有点老,可以rqalpha update_bundle更新下。

qq20160811-0

二八轮动是因为购买了指数。而指数在 ricequant.com 的 lotsize 是1, rqalpha的 lotsize 是 100,因为钱不够开不了仓。后续会将 rqalpha 购买指数时的 lotsize 修改为 1。

from rqalpha.

smilingpoplar avatar smilingpoplar commented on July 16, 2024

@cedricporter 嗯,运行multi_rsi.py是一样了。

lotsize是啥?我可以在哪儿改?

from rqalpha.

cedricporter avatar cedricporter commented on July 16, 2024

指数的 lotsize 刚刚修改好了,您可以更新下 pip install -U rqalpha

from rqalpha.

smilingpoplar avatar smilingpoplar commented on July 16, 2024

@cedricporter 好了,👍

from rqalpha.

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.