twistml.targets package

Submodules

twistml.targets.rawstockdata module

Contains functions to extract useful target vectors from raw stock

data .csv files.

<extended summary>

<routine listings>

<see also>

<notes>

<references>

<examples>

Author:

Matthias Manhertz

Copyright:
  1. Matthias Manhertz 2015
Licence:

MIT

class twistml.targets.rawstockdata.StockCsvReader(filepath, pricecolumn, datecolumn, dateformat='%Y-%m-%d', delimiter=', ')

Reads daily stock prices from a .csv file.

read()

Reads the .csv file an returns a dict mapping stock price to datetime.

dict[datetime,float]
A dictionary where the datetime stamps from the .csv file are the keys and the corresponding stock prices are the values.
twistml.targets.rawstockdata.get_daily_changes(prices, fromdate, todate, dateformat='%Y-%m-%d', return_classes=False, ignore_neutral_days=True, logger=None)

Returns the relative change for each date in a range.

<Extended Summary>

prices : dict[datetime, float]
A dictionary that has datetime stamps as keys and the stock prices as values. (Can be generated from a .csv file using the StockCsvReader class.)
fromdate : str
Start of the daterange for which to get the stock prize changes as a string in dateformat.
todate : str
End of the daterange for which to get the stock prize changes as a string in dateformat.
dateformat : str, optional
The dateformat as used by datetime.strftime and datetime.strptime. (See python documentation for details.)
return_classes : bool, optional
If True, the returned changes will be 1 for days with positive price change and -1 for days with negative price change, instead of continous values. (If ignore_neutral_days is False 0 will be returned for days without price change.) (default is False)
ignore_neutral_days : bool, optional
Days that have no change in stock price are treated as nonexistant. This almost exclusively removes weekends and bank holidays, but may on occasion remove a legitimate datapoint. (default is True)
logger : logging.Logger, optional
A logger object, used to display / log console output (default is None, which implies quiet execution).
daily_changes : dict[datetime, float]
A dictionary mapping the percentage change in stockprice to a datetime. This does not include dates for which no change can be computed (either because the date itself or the day before are not part of the prices dict).

<Notes>

<References>

<Examples>

Module contents

<package summary>

<extended summary>

<module listings>

Author:

Matthias Manhertz

Copyright:
  1. Matthias Manhertz 2015
Licence:

MIT