コード例 #1
0
def lookup_driver_asset(driver):
    session = Session()
    asset = session.query(Asset).filter(Asset.id == driver.asset_id).first()
    if hasattr(asset, 'expiry'):
        # pre-load asset expiry for Derivative type assets
        asset.expiry
    session.close()
    return asset
コード例 #2
0
def get_forward_rate_assets(discount_curve):
    asset_class_id = discount_curve.asset_class_id
    max_expiration_date = max((ei.expiry.expiration_date for ei in discount_curve.expiry_impls)) + timedelta(days=180)
    session = Session()
    assets = session.query(Future)\
        .join(Expiry)\
        .filter(Future.asset_class_id == asset_class_id)\
        .filter(Expiry.expiration_date <= max_expiration_date)\
        .filter(Expiry.expiration_date >= datetime.today())\
        .options(subqueryload(Future.expiry))\
        .order_by(Expiry.expiration_date)\
        .all()
    session.close()
    return assets
コード例 #3
0
ファイル: tests.py プロジェクト: tombnorwood/valuesserver
def values_server_creation():
    session = Session()
    vs = create_values_server("HoneyBadger")
    session.add(vs)
    portfolio_creation(session, vs)
    session.commit()
    session.close()
コード例 #4
0
ファイル: server.py プロジェクト: tombnorwood/valuesserver
def run_values_server(name, zmq_context):
    session = Session()
    session.expire_on_commit = False
    vs = load_values_server(name, session)
    log.info("server loaded")
    start_values_server(vs, zmq_context, session)
    session.commit()
    log.info("server initialization complete")
    subscribe_to_all_feeds(vs)
    api_server = APIServer(ValuesServerAPI(vs), zmq_context, 9000)
    api_server.start()
    vs.feed_server_proxy.join_child_greenlets()
    session.close()