예제 #1
0
from portfolio import PortfoliosHolder
from quandl_streams import get_live
from simple_files import FileHolder


__author__ = 'Andy Fundinger - [email protected]'

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    cob_date = sys.argv[1]

    portfolios = PortfoliosHolder('portfolio')
    funds = FundsHolder('funds')
    model = FileHolder('model')
    results = FileHolder('results')
    market = get_live(get_file("sys"), model)

    risk_by_fund = DataFrame(
        ((fund.name, fund.price(market, model, cob_date), fund.hVar(market, model, cob_date)) for fund in funds),
        columns=['fund_name', 'price', 'hVar'])
    risk_by_fund['normalized_hVar'] = risk_by_fund['hVar'] / risk_by_fund['price']

    results['risk_by_fund'] = risk_by_fund

    risk_by_portfolio = DataFrame(((portfolio.name, portfolio.price(funds, market, model, cob_date),
                                    portfolio.hVar(funds, market, model, cob_date)) for portfolio in portfolios),
                                  columns=['portfolio_name', 'price', 'hVar'])
    risk_by_portfolio['normalized_hVar'] = risk_by_portfolio['hVar'] / risk_by_portfolio['price']

    results['risk_by_portfolio'] = risk_by_portfolio
예제 #2
0
    return Dingus("{coll_name}_env".format(coll_name=coll_name))


def get_file(coll_name):
    return FileHolder(coll_name)


if __name__ == "__main__":
    print(repr(get_dummy("test")))

    dummyCollection = get_dummy("market1")
    print(repr(dummyCollection))
    print(repr(dummyCollection.news))
    print(repr(dummyCollection.news['IBM']))
    print(repr(dummyCollection.news['IBM']['5-14-2010']))

    print(repr(dummyCollection.fx.usd_eur['High (est)']['2010-05-14']))
    print(repr(dummyCollection.fx.usd_eur['Low (est)']['2010-05-14']))
    print(repr(dummyCollection.fx.usd_eur.Rate['2010-05-14']))

    fileCollection = get_file("market1")
    print(repr(fileCollection))
    print(repr(fileCollection.news))
    print(repr(fileCollection.news['IBM']))
    print(repr(fileCollection.news['IBM']['5-14-2010']))

    liveCollection = get_live(get_file("sys"))
    print(repr(liveCollection.fx.usd_eur['High (est)']['2010-05-14']))
    print(repr(liveCollection.fx.usd_eur['Low (est)']['2010-05-14']))
    print(repr(liveCollection.fx.usd_eur.Rate['2010-05-14']))
예제 #3
0
 def test_market(self):
     live_coll = get_live(get_file("sys"), FileHolder('model'))
     usdEurAsset = live_coll.fx['usd_eur']
     assert isinstance(usdEurAsset, QuandlAsset)
     assert len(usdEurAsset)
     assert live_coll.fx.usd_eur is usdEurAsset
예제 #4
0
 def setUp(self):
     self.portfolios = PortfoliosHolder('portfolio')
     self.funds = FundsHolder('funds')
     self.model = FileHolder('model')
     self.market = get_live(get_file("sys"), self.model)