mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-04 12:45:06 +08:00
to account for minimum price variation. On an order to buy, between .05 below to .95 above a penny, use that penny. On an order to sell, between .05 above to .95 below a penny, use that penny.
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
from nose_parameterized import parameterized
|
|
from unittest import TestCase
|
|
|
|
from zipline.finance.blotter import round_for_minimum_price_variation
|
|
|
|
|
|
class BlotterTestCase(TestCase):
|
|
|
|
@parameterized.expand([(0.00, 0.00),
|
|
(0.01, 0.01),
|
|
(0.0005, 0.00),
|
|
(1.006, 1.00),
|
|
(1.0095, 1.01),
|
|
(1.00949, 1.00),
|
|
(1.0005, 1.00)])
|
|
def test_round_for_minimum_price_variation_buy(self, price, expected):
|
|
result = round_for_minimum_price_variation(price, is_buy=True)
|
|
self.assertEqual(result, expected)
|
|
|
|
@parameterized.expand([(0.00, 0.00),
|
|
(0.01, 0.01),
|
|
(0.0005, 0.00),
|
|
(1.006, 1.01),
|
|
(1.0005, 1.00),
|
|
(1.00051, 1.01),
|
|
(1.0095, 1.01)])
|
|
def test_round_for_minimum_price_variation_sell(self, price, expected):
|
|
result = round_for_minimum_price_variation(price, is_buy=False)
|
|
self.assertEqual(result, expected)
|