Last active
July 10, 2018 03:23
-
-
Save yoshyoshi/73f130026c25a7dcdb9d6909b1990277 to your computer and use it in GitHub Desktop.
read data CSV files and process into trading indicators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import talib | |
rawDataLocation = "<your folder location>" | |
storageLocation = "<your folder location>" | |
assetsToProcess = ["SPY"] | |
# Data types for the CSV format of the previous post | |
# ISO8601 date-time string should be read using |S24 due to its standard length | |
dtypeList = ["|S24",np.float64,np.float64,np.float64,np.float64,np.float64] | |
iteratorPos = 0 # Tracks position in list of symbols to download | |
assetListLen = len(assetsToProcess) | |
while iteratorPos < assetListLen: | |
symbol = assetsToProcess[iteratorPos] | |
raw_data = np.genfromtxt(rawDataLocation + '{0}.csv'.format(symbol), delimiter=',',names=True,dtype=dtypeList) | |
close_list = raw_data["close"] | |
SMA20 = talib.SMA(close_list,20) | |
RSI14 = talib.RSI(close_list,14) | |
# Add your own function to store or process data as needed | |
iteratorPos += 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment