#Quantopian Algorithm ordertarget
7062 단어 QuantopianPython
order_target
order_target는 order와 마찬가지로 주식과 주식 수를 지정하는 청약 함수지만, 이때 주식 수는 포트폴리오에 보유하고자 하는 주식 수를 뜻한다. 이미 지정된 주식 수를 보유하면 신규 매수가 늘거나 늘어나지 않는다.
알고리즘 예
(주문 방법 이외에 #Quantopian Algorithm order-Qita의 설명을 참조하십시오)
def initialize(context):
context.security = sid(24)
schedule_function(rebalance,
date_rule=date_rules.every_day(),
time_rule=time_rules.market_close(minutes = 1))
def rebalance(context, data):
price_history = data.history(
context.security,
fields='price',
bar_count=5,
frequency='1d'
)
average_price = price_history.mean()
current_price = data.current(context.security, 'price')
if data.can_trade(context.security):
if current_price > (1.01 * average_price):
# 成り行きでAAPLを100株買う.しかし,既に持っていたら買わない.
order_target(context.security, 100)
log.info("Buying %s" % (context.security.symbol))
elif current_price < average_price:
order_target(context.security, 0)
log.info("Selling %s" % (context.security.symbol))
record(current_price=current_price, average_price=average_price)
메모지
상기
full backtest
확인일지, 예를 들어 2017/05/09~13 부합조건current_price > (1.01 * average_price)
을 통해 AAPL을 장기 주문하였으나 Transaction Detail을 보면 알 수 있듯이 2017/05/09만 거래되었습니다.로그 이미지
Transaction Detail 이미지
주문을 하기 전에 위치를 확인하지 않고 원하는 주식 수만 남겨 두니 정말 가볍군요.
다음에는 order_target_value입니다.
기타 주문 방법
#Quantopian Algorithm order
#Quantopian Algorithm ordervalue
#Quantopian Algorithm orderpercent
#Quantopian Algorithm ordertarget_value
Reference
이 문제에 관하여(#Quantopian Algorithm ordertarget), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/shinseitaro/items/f1ea0245bba1e7ccc82d텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)