def initdb(): """Remove all content from database and initializes it with default values """ resetdb() conn = Historical(app_site()) date = d.today() - timedelta(days=45) keys = conn.get('keys') content = [conn.process(v, keys) for v in conn.get('init_values')] [conn.post(values) for values in content] post_all(conn, keys) price = conn.get_first_price(conn.securities, date) conn.post(conn.process(price, keys)) print 'Database initialized'
def popdb(): """Remove all content from database, initializes it, and populates it with sample data """ initdb() conn = Historical(app_site()) date = d.today() - timedelta(days=30) keys = conn.get('keys') content = [conn.process(v, keys) for v in conn.get('pop_values')] [conn.post(values) for values in content] post_all(conn, keys) price = conn.get_first_price(conn.securities, date) conn.post(conn.process(price, keys)) print 'Database populated'
def popdb(): """Remove all content from database, initializes it, and populates it with sample data """ initdb() conn = Historical(app_site()) date = d.today() - timedelta(days=30) keys = conn.get('keys') content = [conn.process(v, keys) for v in conn.get('pop_values')] [conn.post(values) for values in content] post_all(conn, keys) price = conn.get_first_price(conn.securities, date) conn.post(conn.process(price, keys)) print 'Database populated'
def initdb(): """Remove all content from database and initializes it with default values """ resetdb() conn = Historical(app_site()) date = d.today() - timedelta(days=45) keys = conn.get('keys') content = [conn.process(v, keys) for v in conn.get('init_values')] [conn.post(values) for values in content] post_all(conn, keys) price = conn.get_first_price(conn.securities, date) conn.post(conn.process(price, keys)) print 'Database initialized'
def popprices(sym=None, start=None, end=None, extra=None): """Add prices (and optionally dividends or splits) to securities in the database """ with app.app_context(): conn = Historical(app_site()) keys = conn.get('keys') sym = sym.split(',') if sym else None values = conn.get_price_list(sym, start, end, extra) conn.post(conn.process(values, keys)) print 'Prices table populated'
def popprices(sym=None, start=None, end=None, extra=None): """Add prices (and optionally dividends or splits) to securities in the database """ with app.app_context(): conn = Historical(app_site()) keys = conn.get('keys') sym = sym.split(',') if sym else None values = conn.get_price_list(sym, start, end, extra) conn.post(conn.process(values, keys)) print 'Prices table populated'
def initdb(): """Removes all content from database and initializes it with default values """ with app.app_context(): resetdb() site = portify(url_for('api', _external=True)) conn = Historical(site) values = get_init_values() conn.post(conn.process(values)) post_all(conn) print 'Database initialized'
def popdb(): """Removes all content from database and populates it with sample data """ with app.app_context(): initdb() site = portify(url_for('api', _external=True)) conn = Historical(site) values = get_pop_values() conn.post(conn.process(values)) post_all(conn) print 'Database populated'
def popprices(sym=None, start=None, end=None, extra=None): """Add price quotes """ with app.app_context(): site = portify(url_for('api', _external=True)) conn = Historical(site) sym = sym.split(',') if sym else None divs = True if (extra and extra.startswith('d')) else False splits = True if (extra and extra.startswith('s')) else False values = conn.get_prices(sym, start, end, extra) table = 'event' if (divs or splits) else 'price' keys = conn.event_keys if (divs or splits) else conn.price_keys conn.post(conn.process(values, table, keys)) print 'Prices table populated'