<jupyter_start><jupyter_text>Weekend Trend Trader This notebook outlines experiments in getting my weekend trend trader code implemented.<jupyter_code>import pandas as pd
import pandas.io.data as web
import datetime<jupyter_output><empty_output><jupyter_text>Get Daily price data for Caltex.<jupyter_code># date ranges
end = datetime.date(2015, 1, 26)
start = end + datetime.timedelta(weeks=-21)
start
# Get daily price data for Caltex
ctx = web.DataReader('ctx.ax', 'yahoo', start, end)
ctx<jupyter_output><empty_output><jupyter_text>Transform to WeeklyNot sure if there is a better way of doing this? So far this is the best I have found. The Pandas API doco is rather poor in this area.<jupyter_code># resample to weekly ohlc data starting on Monday
weekly = pd.DataFrame()
weekly["Open"] = ctx['Open'].resample('W-FRI', how='first')
weekly["High"] = ctx['High'].resample('W-FRI', how='max')
weekly["Low"] = ctx['Low'].resample('W-FRI', how='min')
weekly["Close"] = ctx['Close'].resample('W-FRI', how='last')
weekly["Volume"] = ctx['Volume'].resample('W-FRI', how='mean')
weekly
# Work out 20 week Rate of Change in price.
round((weekly["Close"][-1] - weekly["Close"][-21]) / weekly["Close"][-21], 2)
# Work out 20 week high of closing prices
weekly["Close"][-21:-1]
weekly["Close"][-21:-1].max()<jupyter_output><empty_output><jupyter_text>All Ords Moving AverageTo enter trade, 10 week moving average of All Ords must be greater than last week.<jupyter_code># date ranges
end = datetime.date(2015, 1, 26)
start = end + datetime.timedelta(weeks=-12)
all_ords = web.DataReader('^AORD', 'yahoo', start, end)
all_ords
weekly_ords = pd.DataFrame()
weekly_ords["Close"] = all_ords["Close"].resample("W-FRI", how="last")
weekly_ords
# 10 week moving average
pd.rolling_mean(weekly_ords["Close"], 10)
weekly_ords.plot()
nums = pd.Series([1,2,3,4,5,6,7,8,9,10,11])
pd.rolling_mean(nums,5)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15838996340825928, 'fraction_numerical': 0.028227914270778882, 'mean_word_length': 6.717741935483871, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '33019', 'license': 'MIT', 'n_tokens_mistral': 707, 'n_tokens_neox': 669, 'n_words': 180, 'path': 'Trend-Trader.ipynb', 'repo_name': 'eldritchideen/weekly-trend-trader', 'size': '1913'}