Beispiel #1
0
def main():
    # Parse command line flags into FLAGS.
    flags.ArgParser().parse_args(namespace=FLAGS)
    # Set logging level
    logging.basicConfig(level=logging.INFO)
    # Run
    RunData()
def main():
  # Parse command line flags into FLAGS.
  flags.ArgParser().parse_args(namespace=FLAGS)

  logging.basicConfig(level=logging.INFO)

  input_csv = FLAGS.input_csv.split(',')
  output_directory = FLAGS.output_directory

  if not input_csv or not output_directory:
    logging.fatal('--input_csv and --output_directory are required.')

  Generate(input_csv, output_directory)
Beispiel #3
0
def main():
    # Parse command line flags into FLAGS.
    flags.ArgParser().parse_args(namespace=FLAGS)

    logging.basicConfig(level=logging.INFO)
    directory = './data/test'
    # stock = Stock('600789', '鲁抗医药', '医药', '2001-01-01')
    # stock = Stock('000977', '浪潮信息', '医药', '2001-01-01')
    stock = Stock('300652', 'N雷迪克', '制造业', '2017-05-16')
    # stock = Stock('300039', '上海凯宝', '医药', '2011-01-01')
    # stock = Stock('000621', '*ST比特', 'Unknown', '2011-01-01')
    fetcher = NeteaseSeasonFetcher(directory)
    fetcher.Fetch(stock)
Beispiel #4
0
def main():
    # Parse command line flags into FLAGS.
    flags.ArgParser().parse_args(namespace=FLAGS)

    logging.basicConfig(level=logging.INFO)
    directory = './data/test'
    stock = Stock('000977', '浪潮信息', '医药', '2001-01-01')
    insighter = DataInsights(directory)
    insight = insighter.DoStats(stock)

    header = insight.columns()
    writer = csv.DictWriter(sys.stdout, fieldnames=header)
    writer.writeheader()
    writer.writerow(insight.data())
Beispiel #5
0
import csv
import datetime
import logging
import os
import sys

import flags
import batch_data_fetcher
import data_fetcher
import data_insights
import date_util
import stock_info

FLAGS = flags.FLAGS
flags.ArgParser().add_argument('--data_directory',
                               default='./data',
                               help='The base directory of output.')
flags.ArgParser().add_argument(
    '--insight_stocks',
    default='',
    help='Comma seperated stock codes to do insights.')
flags.ArgParser().add_argument(
    '--annual',
    default=False,
    action='store_true',
    help='Whether to run seasonal(default) or annual data.')
flags.ArgParser().add_argument('--insight_output',
                               default=None,
                               help='The output of insight data.')

Beispiel #6
0
def main():
  # Parse command line flags into FLAGS.
  flags.ArgParser().parse_args(namespace=FLAGS)
  logging.basicConfig(level=logging.INFO)

  LoadAllStocks()
Beispiel #7
0
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-

import argparse
import csv
import logging
import os
import re
import sys

import flags

FLAGS = flags.FLAGS
flags.ArgParser().add_argument(
    '--stock_list',
    default='',
    help='Comma separated stock list files.')


class Stock(object):
  def __init__(self, code, name, industry, ipo_date):
    self.__code = code
    self.__name = name
    self.__industry = industry
    self.__ipo_date = ipo_date

  def code(self):
    return self.__code

  def name(self):
    return self.__name
# -*- coding: utf-8 -*-

"""Generate all stocklist based on the csv downloaded."""

import argparse
import csv
import datetime
import logging
import os
import sys

import flags

FLAGS = flags.FLAGS
flags.ArgParser().add_argument(
    '--input_csv',
    default='data/stocklist_shanghai.csv,data/stocklist_shenzhen.csv',
    help='The input csv files to generate the final stocklist.')
flags.ArgParser().add_argument(
    '--portfolio_list',
    default='data/portfolio.csv',
    help='The input portfolio csv.')
flags.ArgParser().add_argument(
    '--output_directory',
    default='data',
    help='The directory to output stocklist csv.')


def Generate(input_csv_list, output_directory):
  # The mapping from input column to output column
  mapping = {
      u'A股代码'.encode('gbk'): u'A股代码'.encode('utf8'),
Beispiel #9
0
import numpy
import os
import re
import sys
from scipy import stats

import flags
import date_util
import stock_info

Stock = stock_info.Stock

FLAGS = flags.FLAGS
flags.ArgParser().add_argument(
    '--insight_season',
    help=
    'The season to do insights: YYYY-03-31, YYYY-06-30, YYYY-09-30, YYYY-12-31'
)


class InsightData(object):
    """ Contains {metrics_name -> value} and the order to output metrics."""
    def __init__(self):
        self._columns = []  # the data can be output in columns order
        self._data = {}

    def AddColumns(self, cols):
        for c in cols:
            assert not c in self._columns  # no duplicate columns
        self._columns += cols
        return self
Beispiel #10
0
import csv
import datetime
import logging
import os
import re
import sys
import urllib2

import flags
import date_util
import stock_info

FLAGS = flags.FLAGS
flags.ArgParser().add_argument(
    '--force_refetch',
    default=False,
    action='store_true',
    help='If set, always refetch the raw data even if it already exists.')
flags.ArgParser().add_argument(
    '--refetch_price',
    default=False,
    action='store_true',
    help='If set, always refetch the price data even if it already exists.')
flags.ArgParser().add_argument(
    '--force_refine',
    default=False,
    action='store_true',
    help='If set, always refine the raw data even if the result already exists.'
)

Stock = stock_info.Stock