Ejemplo n.º 1
0
def row_to_record (row):
    """
    Converts row of CSV file to COT_Record data object

    Arguments:
    - `row`: - array of CSV values
    """
    sym = name_to_symbol (row[0])
    if sym == None:
        return None
    return COT_Record (symbol = sym,
                       date = utils.parseIsoDate (row[2]),
                       oi = long (row[7]),
                       pos_non_comm_long = long (row[8]),
                       pos_non_comm_short = long (row[9]),
                       pos_non_comm_spread = long (row[10]),
                       pos_comm_long = long (row[11]),
                       pos_comm_short = long (row[12]),
                       pos_non_rep_long = long (row[15]),
                       pos_non_rep_short = long (row[16]),
                       count_non_comm_long = long (row[78]),
                       count_non_comm_short = long (row[79]),
                       count_non_comm_spread = long (row[80]),
                       count_comm_long = long (row[81]),
                       count_comm_short = long (row[82]))
Ejemplo n.º 2
0
def row_to_record(row):
    """
    Converts row of CSV file to COT_Record data object

    Arguments:
    - `row`: - array of CSV values
    """
    sym = name_to_symbol(row[0])
    if sym == None:
        return None
    return COT_Record(symbol=sym,
                      date=utils.parseIsoDate(row[2]),
                      oi=long(row[7]),
                      pos_non_comm_long=long(row[8]),
                      pos_non_comm_short=long(row[9]),
                      pos_non_comm_spread=long(row[10]),
                      pos_comm_long=long(row[11]),
                      pos_comm_short=long(row[12]),
                      pos_non_rep_long=long(row[15]),
                      pos_non_rep_short=long(row[16]),
                      count_non_comm_long=long(row[78]),
                      count_non_comm_short=long(row[79]),
                      count_non_comm_spread=long(row[80]),
                      count_comm_long=long(row[81]),
                      count_comm_short=long(row[82]))
Ejemplo n.º 3
0
 def get (self):
     # download http://cftc.gov/dea/newcot/deacit.txt, and check first line and third CSV value
     try:
         res = fetch_cftc_file ("/dea/newcot/deacit.txt")
         for row in csv.reader ([res.split ('\n')[0]], delimiter=',', quotechar='"'):
             if row[2] == '':
                 return None
             return utils.parseIsoDate (row[2])
     except:
         pass
     return None
Ejemplo n.º 4
0
 def get(self):
     # download http://cftc.gov/dea/newcot/deacit.txt, and check first line and third CSV value
     try:
         res = fetch_cftc_file("/dea/newcot/deacit.txt")
         for row in csv.reader([res.split('\n')[0]],
                               delimiter=',',
                               quotechar='"'):
             if row[2] == '':
                 return None
             return utils.parseIsoDate(row[2])
     except:
         pass
     return None