Comments (6)
请问可以提供下具体代码吗?
from rqalpha.
@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.
rqalpha run -f examples/multi_rsi.py -s 2006-08-01 -e 2016-08-08 -o result.pkl --plot
这个是一样的,不一样的话,可能是你本地的data bundle有点老,可以rqalpha update_bundle
更新下。
二八轮动是因为购买了指数。而指数在 ricequant.com 的 lotsize 是1, rqalpha的 lotsize 是 100,因为钱不够开不了仓。后续会将 rqalpha 购买指数时的 lotsize 修改为 1。
from rqalpha.
@cedricporter 嗯,运行multi_rsi.py
是一样了。
lotsize
是啥?我可以在哪儿改?
from rqalpha.
指数的 lotsize 刚刚修改好了,您可以更新下 pip install -U rqalpha
from rqalpha.
@cedricporter 好了,👍
from rqalpha.
Related Issues (20)
- 为什么instrument设计order_book_id 和 trading_code, ctp交易的时候 order_book_id 和交易所代码不一致,无法subscribe HOT 1
- open_auction中发布的股票卖单,非一字跌停时,被拒单。 HOT 2
- 集合竞价发限价单,可以加滑点吗?
- 如何启用融资功能? HOT 1
- futures.get_dominant_price接口特性需求 HOT 2
- 1分钟线期货回测出错 HOT 2
- open_auction()中发出的买单经常会以低于开盘价成交,有时则不会。 HOT 1
- 分钟线回测,下个bar内部满足条件未成交 HOT 6
- [FEATURE] 限价(LIMIT_ORDER)的交易逻辑问题 HOT 2
- QQ群加不了 HOT 2
- Matcher并没有真正地考虑算法单特定目标的执行情况? HOT 1
- 什么时候支持python3.12,3.12版本性能提升很大啊 HOT 4
- mac无法安装mod HOT 1
- 发现一枚warning,类型提示有问题
- 发现一枚bug HOT 4
- 关于账户(Account)资金计算逻辑的一个疑问 HOT 2
- 希望收益曲线可以支持对数坐标轴
- Postion类中self._prev_close和self._last_price如何赋值? HOT 1
- 回测结果显示出现错乱
- rqalpha支持计算多周期指标吗
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rqalpha.