Fermé

Write some Software

Correcting a Run time Erro in code (Quantopian Algorithm): NameError: global name 'vwap' is not defined

...

Below the code :

from [url removed, login to view] import attach_pipeline, pipeline_output

from [url removed, login to view] import Pipeline

from datetime import timedelta

def initialize(context):

context.aapl= sid(24)

schedule_function(my_rebalance, date_rules.every_day(), time_rules.market_close(minutes=3))

def compute_weights(context, data):

hist = [url removed, login to view]([url removed, login to view], 'price', 30, '1d')

vwap_hist = [url removed, login to view]([url removed, login to view], ['price', 'volume'], 10, '1d')[:-1]

vwap = (vwap_hist['price'] * vwap_hist['volume']).sum() / vwap_hist['volume'].sum()

def my_rebalance(context,data):

if data.can_trade([url removed, login to view]):

if [url removed, login to view]([url removed, login to view], 'price') < vwap*0.995:

order_target_value(sid(24), -50)

elif [url removed, login to view]([url removed, login to view], 'price') > vwap*1.005:

order_target_value(sid(24), +50)

Compétences : Analyses financières, Marchés Financiers, Programmation, Python

Voir plus : software write mq4, software write chip epson, useful software write book, software write web specs, free software write user guide, software write edid, free software write company profile, software write websites idea, visual basic write function, software write book images, write function 2005, software write books, software write protection, free software write book, write function will return larger integers, software write book, access 2007 vba write function, write script date picker control, write function net, write function takes positive integer returns leading digit, write function vbnet, software write protect software, software write technical manual

Concernant l'employeur :
( 4 commentaires ) Allston, Ireland

N° du projet : #12668930