Skip to content

Commit d1f38e5

Browse files
version 0.16.7
1 parent e01cd69 commit d1f38e5

File tree

10 files changed

+732
-35
lines changed

10 files changed

+732
-35
lines changed

DONE_TO_DO.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Release notes
22

3+
## Version 0.16.6
4+
Created classses for individual futures contracts, and included example of how to use Quandl to get them
5+
36
## Version 0.16.5
47
Updated .csv data and moved to seperate section - now stored under Github LFS
58

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ For a longer explanation of the motivation and point of this project see my [blo
3838

3939
[User guide](docs/userguide.md)
4040

41+
[Working with futures data](/docs/futures.md)
4142

4243
## Dependencies
4344

44-
Python 3.x, pandas, matplotlib, pyyaml, numpy, scipy
45+
Python 3.x, pandas, matplotlib, pyyaml, numpy, scipy, quandl
46+
4547
See [requirements.txt](requirements.txt) for full details.
4648

4749
Make sure you get the python3 versions of the relevant packages, i.e. use:

docs/futures.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
TBC
2+
3+
(QUANDL code is [here](/examples/futuresdata/quandldata.py) )

docs/userguide.md

+17
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,14 @@ brokers and quandl data in the future.
592592
If you want to use a different set of data values (eg equity EP ratios,
593593
interest rates...) you'll need to [create your own Data object](#create_data).
594594

595+
*WORK IN PROGRESS*
596+
I'm currently working on including support so that you can:
597+
598+
- Get futures data from Quandl
599+
- Store it individually in a database
600+
- Stitch contracts together to make an adjusted price
601+
602+
See [working with futures data](/docs/futures.md)
595603

596604
## How do I... Save my work
597605

@@ -658,6 +666,15 @@ particular **source** (for example .csv files, databases and so on).
658666
Only one kind of specific data object is provided with the system in the
659667
current version - `csvFutures`.
660668

669+
*WORK IN PROGRESS*
670+
I'm currently working on including support so that you can:
671+
672+
- Get futures data from Quandl
673+
- Store it individually in a database
674+
- Stitch contracts together to make an adjusted price
675+
676+
See [working with futures data](/docs/futures.md)
677+
661678
#### Generic data objects
662679

663680
You can get use data objects directly:

examples/futuresdata/quandldata.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
Here is an example of how we get individual futures price data from quandl
3+
"""
4+
5+
from sysdata.futuresdata import listOfFuturesContracts
6+
from sysdata.quandl.futures import quandl_get_futures_contract_historic_data, listOfQuandlFuturesContracts
7+
8+
import quandl
9+
import datetime
10+
11+
instrument_code = "EDOLLAR"
12+
first_date = datetime.datetime(2000,1,1)
13+
last_date = datetime.datetime(2002,1,1)
14+
rollcycle_string = "HMUZ"
15+
16+
#quandl.ApiConfig.api_key = 'your key here'
17+
list_of_contracts = listOfFuturesContracts.series_of_contracts_within_daterange(instrument_code, first_date,
18+
last_date, rollcycle_string)
19+
20+
list_of_quandl_contracts = listOfQuandlFuturesContracts(list_of_contracts)
21+
22+
q_data = dict([(contract.ident(), quandl_get_futures_contract_historic_data(contract)) for contract in list_of_quandl_contracts])

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ matplotlib>=1.4.3
33
pyyaml>=3.11
44
numpy>=1.13.3
55
scipy>=1.0.0
6+
quandl>=3.3.0

syscore/dateutils.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,25 @@
3232

3333
UNIXTIME_IN_YEAR = UNIXTIME_CONVERTER * SECONDS_IN_YEAR
3434

35+
MONTH_LIST = ["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"]
36+
37+
38+
def month_from_contract_letter(contract_letter):
39+
"""
40+
Returns month number (1 is January) from contract letter
41+
42+
:param contract_letter:
43+
:return:
44+
"""
45+
46+
try:
47+
month_number = MONTH_LIST.index(contract_letter)
48+
except ValueError:
49+
return None
50+
51+
return month_number+1
52+
53+
3554
def contract_month_from_number(month_number):
3655
"""
3756
Returns standard month letters used in futures land
@@ -40,7 +59,6 @@ def contract_month_from_number(month_number):
4059
:return: str
4160
"""
4261

43-
MONTH_LIST=["F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"]
4462
return MONTH_LIST[month_number-1]
4563

4664
def expiry_date(expiry_ident):

0 commit comments

Comments
 (0)