(self)
| 920 | self.assertEqual(result.ix[i]['num_positions'], expected) |
| 921 | |
| 922 | def test_noop_orders(self): |
| 923 | asset = self.asset_finder.retrieve_asset(1) |
| 924 | |
| 925 | # Algorithm that tries to buy with extremely low stops/limits and tries |
| 926 | # to sell with extremely high versions of same. Should not end up with |
| 927 | # any positions for reasonable data. |
| 928 | def handle_data(algo, data): |
| 929 | |
| 930 | ######## |
| 931 | # Buys # |
| 932 | ######## |
| 933 | |
| 934 | # Buy with low limit, shouldn't trigger. |
| 935 | algo.order(asset, 100, limit_price=1) |
| 936 | |
| 937 | # But with high stop, shouldn't trigger |
| 938 | algo.order(asset, 100, stop_price=10000000) |
| 939 | |
| 940 | # Buy with high limit (should trigger) but also high stop (should |
| 941 | # prevent trigger). |
| 942 | algo.order(asset, 100, limit_price=10000000, stop_price=10000000) |
| 943 | |
| 944 | # Buy with low stop (should trigger), but also low limit (should |
| 945 | # prevent trigger). |
| 946 | algo.order(asset, 100, limit_price=1, stop_price=1) |
| 947 | |
| 948 | ######### |
| 949 | # Sells # |
| 950 | ######### |
| 951 | |
| 952 | # Sell with high limit, shouldn't trigger. |
| 953 | algo.order(asset, -100, limit_price=1000000) |
| 954 | |
| 955 | # Sell with low stop, shouldn't trigger. |
| 956 | algo.order(asset, -100, stop_price=1) |
| 957 | |
| 958 | # Sell with low limit (should trigger), but also high stop (should |
| 959 | # prevent trigger). |
| 960 | algo.order(asset, -100, limit_price=1000000, stop_price=1000000) |
| 961 | |
| 962 | # Sell with low limit (should trigger), but also low stop (should |
| 963 | # prevent trigger). |
| 964 | algo.order(asset, -100, limit_price=1, stop_price=1) |
| 965 | |
| 966 | ################### |
| 967 | # Rounding Checks # |
| 968 | ################### |
| 969 | algo.order(asset, 100, limit_price=.00000001) |
| 970 | algo.order(asset, -100, stop_price=.00000001) |
| 971 | |
| 972 | daily_stats = self.run_algorithm(handle_data=handle_data) |
| 973 | |
| 974 | # Verify that positions are empty for all dates. |
| 975 | empty_positions = daily_stats.positions.map(lambda x: len(x) == 0) |
| 976 | self.assertTrue(empty_positions.all()) |
| 977 | |
| 978 | def test_position_weights(self): |
| 979 | sids = (1, 133, 1000) |
nothing calls this directly
no test coverage detected