Exemplo n.º 1
0
        public void ReportPositionClosed(Messaging.Protobuf.Position position)
        {
            PositionsClosedCount++;
            PipsTotal   += position.Pips;
            ProfitTotal += position.GrossProfit;
            StateManager.SetInitialStateAsync(new Dictionary <string, object>
            {
                { RuleConfiguration.PIPSTOTAL, PipsTotal },
                { RuleConfiguration.PROFITTOTAL, ProfitTotal },
                { RuleConfiguration.POSITIONCLOSEDCOUNT, ProfitTotal }
            }
                                              );
            StrategyExecutionReport.Add(position.CloseTime + "," + position.Label + "," + "*" + "," + "OnPositionClosed");

            //Add the Rules to the TradeResult report to see which rules executed prior to a position closing
            TradeExecutionReport.Add(position.Label + ","
                                     + position.SymbolCode + ","
                                     + position.EntryTime + ","
                                     + position.CloseTime + ","
                                     + position.EntryPrice + ","
                                     + position.ClosePrice + ","
                                     + position.Pips + ","
                                     + position.StopLossPrice + ","
                                     + position.TakeProfitPrice + ","
                                     + position.GrossProfit);
        }
Exemplo n.º 2
0
 public static bool ParseOpenPosition(cAlgo.API.Position p, out Messaging.Protobuf.Position position, Messaging.Protobuf.Position.Types.StateChange stateChange = Messaging.Protobuf.Position.Types.StateChange.None)
 {
     try
     {
         position = new Messaging.Protobuf.Position()
         {
             Id              = p.Id,
             Label           = p.Label,
             Pips            = p.Pips,
             EntryTime       = p.EntryTime.ToBinary(),
             SymbolCode      = p.SymbolCode,
             StopLossPrice   = (double)p.StopLoss,
             TakeProfitPrice = (double)p.TakeProfit,
             Volume          = p.Volume,
             TradeType       = ParsePositionTradeType(p.TradeType),
             GrossProfit     = p.GrossProfit,
             StateChange     = stateChange
         };
     }
     catch (Exception e)
     {
         Console.WriteLine("FAILED to parse Position: " + e.ToString());
         position = null;
         return(false);
     }
     return(true);
 }
Exemplo n.º 3
0
 public void ReportPositionOpened(Messaging.Protobuf.Position position)
 {
     PositionsOpenedCount++;
     StateManager.SetInitialStateAsync(new Dictionary <string, object>
     {
         { RuleConfiguration.POSITIONSOPENEDCOUNT, PipsTotal }
     }
                                       );
     StrategyExecutionReport.Add(position.EntryTime + "," + position.Label + "," + "*" + "," + "OnPositionOpened");
 }
Exemplo n.º 4
0
        public void ReportPositionClosed(Messaging.Protobuf.Position position)
        {
            PipsTotal   += position.Pips;
            ProfitTotal += position.GrossProfit;


            StrategyExecutionReport.Add(position.CloseTime + "," + position.Label + "," + "*" + "," + "OnPositionClosed");

            //Add the Rules to the TradeResult report to see which rules executed prior to a position closing
            TradeExecutionReport.Add(position.Label + ","
                                     + position.SymbolCode + ","
                                     + position.EntryTime + ","
                                     + position.CloseTime + ","
                                     + position.EntryPrice + ","
                                     + position.ClosePrice + ","
                                     + position.Pips + ","
                                     + position.StopLossPrice + ","
                                     + position.TakeProfitPrice + ","
                                     + position.GrossProfit);
        }
Exemplo n.º 5
0
 public void ReportPositionModified(Messaging.Protobuf.Position position, string timestamp)
 {
     StrategyExecutionReport.Add(timestamp + "," + position.Label + "," + "*" + "," + "OnPositionModified");
 }
Exemplo n.º 6
0
 public void ReportPositionOpened(Messaging.Protobuf.Position position)
 {
     PositionsOpenedCount++;
     StrategyExecutionReport.Add(position.EntryTime + "," + position.Label + "," + "*" + "," + "OnPositionOpened");
 }
Exemplo n.º 7
0
 public static bool ParseClosedPosition(cAlgo.API.Position _position, double closePrice, DateTime closeTime, out Messaging.Protobuf.Position position)
 {
     if (ParseOpenPosition(_position, out position, Messaging.Protobuf.Position.Types.StateChange.Closed))
     {
         position.ClosePrice = closePrice;
         position.CloseTime  = closeTime.ToBinary();
         return(true);
     }
     return(false);
 }