python - 尝试使用 Quantopian 期货票据交易下订单时出错
问题描述
因此,我现在开始学习期货交易的 Quantopian,但遇到了无法进行纸面交易的问题。该错误表示它无法在order
方法中指定符号。我希望有人能给我一个答案,以帮助我了解正在发生的事情。
def initialize(context):
# Dow Jones E-Mini Continuous Future
context.future = continuous_future('YM')
schedule_function(daily_func, date_rules.every_day(), time_rules.market_open())
def daily_func(context, data):
ym_active = data.history(context.future, 'price', 50, '1m')
log.info(ym_active)
sma_50 = ym_active.mean()
sma_20 = ym_active[-20:].mean()
if sma_20 > sma_50:
#I am running into a problem where it says that I have to specify the contract.
order(context.future, 1, style=MarketOrder)
elif sma_20 < sma_50:
#I am running into a problem here too.
order(context.future, -1, style=MarketOrder)
解决方案
推荐阅读
- vuetify.js - Vuetify - how to make sticky elements?
- amazon-web-services - 为什么使用 Terraform 解析我的 dynamo_db_table_name 时会出错?
- jmeter - 如何性能测试分析服务
- c++ - 从基于迭代器的 for 循环转换后,如何在 map::find() 中调用方法?
- python - Python 脚本依赖于另一个 .exe。是否可以将两者合并为一个.exe?
- c# - EF Core 3.0 存储过程:多个参数
- html - In a HTML email signature is there way to conditionally hide content?
- facebook-javascript-sdk - Fetch conversions with FB Marketing API
- mysql - MYSQL 5 在存储在列中的点周围创建一个信封
- nginx - HLS 没有拉取 m3u8 文件