public void testStopOnCloseWorks() { close(15); close(0); hasOrders(symbol().buy("buy stuff", market(), 100, fillOrKill())); fill(0, 10); // bought 100 at 10, so stop should be at 0 noOrders(); close(5); hasOrders(position().exit("TrailingStoppage", stop(0), oneBar())); close(15); AreEqual(5, O.the(symbolSystem.dynamicExitsOnClose)[0]); AreEqual(0, O.the(symbolSystem.dynamicExitsOnClose)[1]); AreEqual(0, O.the(symbolSystem.dynamicExitsOnClose)[2]); hasOrders(position().exit("TrailingStoppage", stop(5), oneBar())); close(0); hasOrders(Order.ANY, position().exit("get out", market(), fillOrKill())); fill(1, 0); noOrders(); close(-5); hasOrders(symbol().sell("sell stuff", market(), 100, fillOrKill())); fill(0, -10); noOrders(); close(-5); hasOrders(position().exit("TrailingStoppage", stop(0), oneBar())); close(-15); hasOrders(position().exit("TrailingStoppage", stop(-5), oneBar())); }
public void testObjectiveExit() { processBar(15, 15, 15, 15); processBar(0, 0, 0, 0); hasOrders(symbol().buy("buy stuff", market(), 100, fillOrKill())); fill(0, 10); // bought 100 at 10, so exit should be at 20 AreEqual(20, O.the(symbolSystem.dynamicExits)[0]); hasOrders(position().exit("ObjectiveReached", limit(20), oneBar())); processBar(5, 5, 5, 5); hasOrders(position().exit("ObjectiveReached", limit(20), oneBar())); processBar(15, 15, 15, 15); AreEqual(20, O.the(symbolSystem.dynamicExits)[0]); hasOrders(position().exit("ObjectiveReached", limit(20), oneBar())); processBar(0, 0, 0, 0); hasOrders(Order.ANY, position().exit("get out", market(), fillOrKill())); fill(1, 0); noOrders(); processBar(-5, -5, -5, -5); hasOrders(symbol().sell("sell stuff", market(), 100, fillOrKill())); fill(0, -10); hasOrders(position().exit("ObjectiveReached", limit(-20), oneBar())); processBar(-5, -5, -5, -5); hasOrders(position().exit("ObjectiveReached", limit(-20), oneBar())); processBar(-15, -15, -15, -15); hasOrders(position().exit("ObjectiveReached", limit(-20), oneBar())); }
public void testStopWorks() { processBar(15, 15, 15, 15); processBar(0, 0, 0, 0); hasOrders(symbol().buy("buy stuff", market(), 100, fillOrKill())); fill(0, 20); // bought 100 at 20, so stop should be at 10 AreEqual(10, O.the(symbolSystem.dynamicExits)[0]); hasOrders(position().exit("TrailingStoppage", stop(10), oneBar())); processBar(5, 5, 5, 5); hasOrders(position().exit("TrailingStoppage", stop(10), oneBar())); processBar(15, 15, 15, 15); AreEqual(10, O.the(symbolSystem.dynamicExits)[0]); AreEqual(10, O.the(symbolSystem.dynamicExits)[1]); AreEqual(10, O.the(symbolSystem.dynamicExits)[2]); hasOrders(position().exit("TrailingStoppage", stop(10), oneBar())); processBar(0, 0, 0, 0); hasOrders(Order.ANY, position().exit("get out", market(), fillOrKill())); fill(1, 0); noOrders(); processBar(-5, -5, -5, -5); hasOrders(symbol().sell("sell stuff", market(), 100, fillOrKill())); fill(0, -100); hasOrders(position().exit("TrailingStoppage", stop(-90), oneBar())); processBar(-95, -95, -95, -95); hasOrders(position().exit("TrailingStoppage", stop(-90), oneBar())); processBar(-92, -92, -92, -92); hasOrders(position().exit("TrailingStoppage", stop(-90), oneBar())); }
void addPoints(string fileName) { var csv = new QFile(fileName).csv(); Collection c = csv.records(); foreach (var record in O.list <List>(c)) { addPoint(Double.Parse(O.the(O.list <string>(record)))); } }
public static string testName() { var frames = new StackTrace(false).GetFrames(); if (frames == null) { throw Bomb.toss("no frames on stack?"); } foreach (var frame in frames) { var mb = frame.GetMethod(); var attributes = mb.GetCustomAttributes(typeof(TestAttribute), true); if (O.isEmpty(attributes)) { continue; } return(((TestAttribute)O.the(attributes)).Description); } throw Bomb.toss("no test attribute found on current test!"); }