def test_extract_pos(self): index_dup = [ Timestamp('2015-06-08', tz='UTC'), Timestamp('2015-06-08', tz='UTC'), Timestamp('2015-06-09', tz='UTC'), Timestamp('2015-06-09', tz='UTC') ] index = [ Timestamp('2015-06-08', tz='UTC'), Timestamp('2015-06-09', tz='UTC') ] positions = DataFrame( { 'amount': [100., 200., 300., 400.], 'last_sale_price': [10., 20., 30., 40.], 'sid': [1, 2, 1, 2] }, index=index_dup) cash = Series([100., 200.], index=index) result = extract_pos(positions, cash) expected = DataFrame(OrderedDict([(1, [100. * 10., 300. * 30.]), (2, [200. * 20., 400. * 40.]), ('cash', [100., 200.])]), index=index) expected.index.name = 'index' assert_frame_equal(result, expected)
def test_extract_pos(self): index_dup = [Timestamp('2015-06-08', tz='UTC'), Timestamp('2015-06-08', tz='UTC'), Timestamp('2015-06-09', tz='UTC'), Timestamp('2015-06-09', tz='UTC')] index = [Timestamp('2015-06-08', tz='UTC'), Timestamp('2015-06-09', tz='UTC')] positions = DataFrame( {'amount': [100., 200., 300., 400.], 'last_sale_price': [10., 20., 30., 40.], 'sid': [1, 2, 1, 2]}, index=index_dup ) cash = Series([100., 200.], index=index) result = extract_pos(positions, cash) expected = DataFrame(OrderedDict([ (1, [100.*10., 300.*30.]), (2, [200.*20., 400.*40.]), ('cash', [100., 200.])]), index=index ) expected.index.name = 'index' assert_frame_equal(result, expected)
def test_extract_pos(self): index_dup = [ Timestamp("2015-06-08", tz="UTC"), Timestamp("2015-06-08", tz="UTC"), Timestamp("2015-06-09", tz="UTC"), Timestamp("2015-06-09", tz="UTC"), ] index = [Timestamp("2015-06-08", tz="UTC"), Timestamp("2015-06-09", tz="UTC")] positions = DataFrame( {"amount": [100.0, 200.0, 300.0, 400.0], "last_sale_price": [10.0, 20.0, 30.0, 40.0], "sid": [1, 2, 1, 2]}, index=index_dup, ) cash = Series([100.0, 200.0], index=index) result = extract_pos(positions, cash) expected = DataFrame( OrderedDict( [(1, [100.0 * 10.0, 300.0 * 30.0]), (2, [200.0 * 20.0, 400.0 * 40.0]), ("cash", [100.0, 200.0])] ), index=index, ) expected.index.name = "index" expected.columns.name = "sid" assert_frame_equal(result, expected)
def test_extract_pos(self): index_dup = [ Timestamp("2015-06-08", tz="UTC"), Timestamp("2015-06-08", tz="UTC"), Timestamp("2015-06-09", tz="UTC"), Timestamp("2015-06-09", tz="UTC"), ] index = [ Timestamp("2015-06-08", tz="UTC"), Timestamp("2015-06-09", tz="UTC"), ] positions = DataFrame( { "amount": [100.0, 200.0, 300.0, 400.0], "last_sale_price": [10.0, 20.0, 30.0, 40.0], "sid": [1, 2, 1, 2], }, index=index_dup, ) cash = Series([100.0, 200.0], index=index) result = extract_pos(positions, cash) expected = DataFrame( OrderedDict( [ (1, [100.0 * 10.0, 300.0 * 30.0]), (2, [200.0 * 20.0, 400.0 * 40.0]), ("cash", [100.0, 200.0]), ] ), index=index, ) expected.index.name = "index" expected.columns.name = "sid" assert_frame_equal(result, expected)