Optimal dynamic basis trading