public IFSymbolExecute MarketInShort() { var l1 = ExecuteGetL1(); if (l1.Symbol == null) { Error(String.Format("Cannot get Lv1 for {0}", Symbol)); } if (GetStatus() == Fstatus.Error) { return(this); } var curOpenPos = api.GetOpenPositionForSymbol(Symbol); if (curOpenPos.Volume != 0 && curOpenPos.Side == "B") { api.FlattenSymbol(Symbol); } var remaining = GetRemainingShareFromOpenPos(curOpenPos); if (remaining > 0) { api.CancelSellOrdersForSymbol(Symbol); var sellPrice = l1.BidPrice; api.ExecuteOrder("Sell", Symbol, sellPrice, remaining); FLog.AddFormLogMessage(String.Format("Market In @{0}", sellPrice)); } return(this); }
public IFSymbolExecute OfferAtPrice(double price) { var curOpenPos = api.GetOpenPositionForSymbol(Symbol); if (curOpenPos.Volume != 0 && curOpenPos.Side == "B") { api.FlattenSymbol(Symbol); } var remaining = GetRemainingShareFromOpenPos(curOpenPos); api.CancelSellOrdersForSymbol(Symbol); api.ExecuteOrder("Sell", Symbol, price, remaining); FLog.AddFormLogMessage(String.Format("Offer In @{0}", price)); return(this); }
// Update Share Size for Exit public IFSymbol SetExitSharePercentage(int percent) { FLog.AddFormLogMessage(String.Format("Set the share size to {0} percent for {1}", percent, Symbol)); var curOpenPos = api.GetOpenPositionForSymbol(Symbol); if (curOpenPos.Volume == 0) { return(this); } var newShare = initopenPos.Volume * percent / 100; ShareSize = Math.Abs(newShare); return(this); }
public IFSymbolExecute ExitMarket() { var l1 = ExecuteGetL1(); if (l1.Symbol == null) { Error(String.Format("Cannot get Lv1 for {0}", Symbol)); } if (GetStatus() == Fstatus.Error) { return(this); } var curOpenPos = api.GetOpenPositionForSymbol(Symbol); var remaining = GetRemainingShareForExit(curOpenPos); if (remaining == 0) { return(this); } if (CurrentPositionType == FPositionType.Long) { var sellPrice = l1.BidPrice; api.ExecuteOrder("Sell", Symbol, sellPrice, remaining); FLog.AddFormLogMessage(String.Format("Market Out @{0} for {1} shares", sellPrice, remaining)); } else if (CurrentPositionType == FPositionType.Short) { var buyPrice = l1.AskPrice; api.ExecuteOrder("Buy", Symbol, buyPrice, remaining); FLog.AddFormLogMessage(String.Format("Market Out @{0} for {1}", buyPrice, remaining)); } return(this); }
//private void Filled(string message) //{ // FLog.AddFormLogMessage(message); // Result.Filled(message); //} private void Error(string message) { FLog.AddFormLogMessage(message); Result.Error(message); }
public IFSymbolExecute FlatPosition() { FLog.AddFormLogMessage(String.Format("Executing Flat for {0},", Symbol)); api.FlattenSymbol(Symbol); return(this); }