Пример #1
0
def test_three_years_test(tmpdir):
    p = tmpdir.join("hello.txt")
    three_years_back_plus_day = date.today() - timedelta(days=1094)
    three_years_back = date.today() - timedelta(days=1095)
    three_years_back_minus_day = date.today() - timedelta(days=1096)
    year_ago = date.today() - timedelta(days=365)
    p.write("{ date: '2013-01-10', ticker: 'tsla', quantity: 2, price: 123.4, account: 'acct1', owner: 'alice' }\n" +
            "{ date: '2013-01-11', ticker: 'tsla', quantity: 2, price: 123.4, account: 'acct1', owner: 'bob' }\n" +
            "{ date: '" + str(date.today()) + "', ticker: 'tsla', quantity: 7, price: 123.4, account: 'acct1', owner: 'alice' }\n" +
            "{ date: '" + str(three_years_back_plus_day) + "', ticker: 'plus', quantity: 8, price: 123.4, account: 'acct1', owner: 'alice' }\n" +
            "{ date: '" + str(three_years_back) + "', ticker: 'presne3', quantity: 9, price: 123.4, account: 'acct1', owner: 'alice' }\n" +
            "{ date: '" + str(three_years_back_minus_day) + "', ticker: 'minus', quantity: 10, price: 123.4, account: 'acct1', owner: 'alice' }\n" +
            "{ date: '" + str(year_ago) + "', ticker: 'year_ago', quantity: 10, price: 123.4, account: 'acct1', owner: 'alice' }\n")
    res = str(st.three_years_test(p.dirname + "/" + p.basename))
    assert "tsla        4" in res
    assert "presne3     9" in res
    assert "minus      10" in res
    assert "year_ago" not in res
Пример #2
0
## This is how the lambda is done
# ds['total_czk'] = ds.total_value.apply(lambda x: x * cv.getUSDCZK())

## Bezny check
print "Akcie v USD"
print "Dne: " + str(date.today())
print str(st.worth_at_date('../transactions/us_stocks', date.today()))
print "V czk:"
print str(st.worth_at_date_czk('../transactions/us_stocks', date.today()))

print "Investovane penize"
print mn.invested(rt.read_file('../transactions/czk'))

print "Prodat lze"
print str(st.three_years_test('../transactions/us_stocks'))

print "Zhodnoceni"
print "Honza"
print str(rp.appreciation(rt.read_file('../transactions/czk'), '../transactions/us_stocks', 'jd'))
print "Deni"
print str(rp.appreciation(rt.read_file('../transactions/czk'), '../transactions/us_stocks', 'deni'))
print "Mama"
print str(rp.appreciation(rt.read_file('../transactions/czk'), '../transactions/us_stocks', 'mama'))
print "Terka"
print str(rp.appreciation(rt.read_file('../transactions/czk'), '../transactions/us_stocks', 'terka'))
print "Laura"
print str(rp.appreciation(rt.read_file('../transactions/czk'), '../transactions/us_stocks', 'laura'))


## Takhle nejak pracovat s datama