New to both python and Quant. I've been looking at this for hours/referencing google for syntax related to lists and initialization. Totally stumped.
import pandas as pd
import numpy as np
tpos = ['sold', 'sold', 'sold', 'sold', 'sold'];
context.t = sid(6653);
def handle_data(context, data):
MA3D = data.history(context.t, 'price', 3, '1d').mean()
MA3M = data.history(context.t, 'price', 3, '1m').mean()
boughts = tpos.count('bought');
solds = tpos.count('sold');
if boughts < 5: ###buy
if MA3M <= MA3D:
tpos = 'bought'
context.bp = data.current(context.t, 'price')
if solds < 5:
if data.current(context.t, 'price') > context.bp:
tpos = 'sold'
My goal is basically to develop a simple algo which trades a few sets of a specific stock at a time based on price. I'm aware this isn't a winning strategy. This algo is only intended as a means of studying success of simple buy sell stategies as a basis for developing future quant algos.