コード例 #1
0
 public OrderLive(OrderLiveType bookType, MarketAction orderType, double amount, double rate)
 {
     this.bookType  = bookType;
     this.orderType = orderType;
     this.amount    = amount;
     this.rate      = rate;
 }
コード例 #2
0
ファイル: YahooHelper.cs プロジェクト: zonquan/decision-trees
 private static YahooTreeData BuildYahooTreeData(YahooNormalized record, MarketAction action)
 {
     return new YahooTreeData
     {
         Spread = record.High - record.Low,
         Volatility = record.Volatility,
         Change = record.Change,
         Action = action
     };
 }
コード例 #3
0
 private static YahooTreeData BuildYahooTreeData(YahooNormalized record, MarketAction action)
 {
     return(new YahooTreeData
     {
         Spread = record.High - record.Low,
         Volatility = record.Volatility,
         Change = record.Change,
         Action = action
     });
 }
コード例 #4
0
 private void SaveLogRecord(double bought, double sold, double profit, MarketAction executedAction, MarketAction correctAction)
 {
     TradeLog.Add(new TradeLogRecord
     {
         QuantityBought = bought,
         QuantitySold   = sold,
         Profit         = profit,
         ExecutedAction = executedAction,
         CorrectAction  = correctAction
     });
 }
コード例 #5
0
        /// <summary>
        /// Displays simulation result
        /// </summary>
        /// <param name="result"></param>
        private void DisplaySimulationResult(SimulationResult result)
        {
            foreach (var point in chartCtrl.Series[Constants.PriceSerieName].Points)
            {
                MarketAction action = result.Actions.Where(x => x.Date == (point.Tag as OHLC).Date).FirstOrDefault();

                if (action != null)
                {
                    point.MarkerImage = action.ActionType == ActionType.Bid ? "MaxMarker.bmp" : "MinMarker.bmp";

                    point.MarkerImageTransparentColor = Color.White;
                }
                else if (!string.IsNullOrEmpty(point.MarkerImage))
                {
                    point.MarkerImage = string.Empty;
                }
            }
        }
コード例 #6
0
        public OrderLive(string bookType, string orderType, string amount, string rate)
        {
            if (bookType == "orderBookModify")
            {
                this.bookType = OrderLiveType.Modify;
            }
            else if (bookType == "orderBookRemove")
            {
                this.bookType = OrderLiveType.Remove;
            }
            else if (bookType == "newTrade")
            {
                this.bookType = OrderLiveType.Add;
            }
            else
            {
                throw new Exception("Unknown BookOrder type: " + bookType);
            }

            if (orderType == "ask" || orderType == "sell")
            {
                this.orderType = MarketAction.Sell;
            }
            else if (orderType == "bid" || orderType == "buy")
            {
                this.orderType = MarketAction.Buy;
            }
            else
            {
                throw new Exception("Unknown order type: " + orderType);
            }

            if (string.IsNullOrEmpty(amount))
            {
                this.amount = 0;
            }
            else
            {
                this.amount = double.Parse(amount, System.Globalization.CultureInfo.InvariantCulture);
            }

            this.rate = double.Parse(rate, System.Globalization.CultureInfo.InvariantCulture);
        }
コード例 #7
0
        public void PlaceBid(ForexTreeData record, MarketAction action)
        {
            switch (action)
            {
            case MarketAction.Buy:
                ExecuteBuy(record);
                break;

            case MarketAction.Sell:
                ExecuteSell(record);
                break;

            case MarketAction.Hold:
                SaveLogRecord(0.0, 0.0, 0.0, MarketAction.Hold, record.Action);
                break;

            default:
                throw new BllException("Incorrect market action.");
            }
        }
        double DetermineSafeExposureAmount(OrderBook orderBook, MarketAction action, double currentHoard, double currentSpeculables)
        {
            int fingersCrossedExposureDivider = 5;

            switch (action)
            {
            case MarketAction.BUY:
                transaction firstBuy = orderBook.BuyOrders.FirstOrDefault();

                try
                {
                    double secondFirstGiven = orderBook.BuyOrders[1].GivenAmount;
                    return(Math.Abs(secondFirstGiven - firstBuy.GivenAmount));
                }

                catch (Exception)
                {
                    return(firstBuy.GivenAmount);
                }

            case MarketAction.SELL:
                transaction lastSell = orderBook.SellOrders.LastOrDefault();

                try
                {
                    double secondLastReceived = orderBook.BuyOrders[1].ReceivedAmount;
                    return(Math.Abs(secondLastReceived - lastSell.ReceivedAmount));
                }

                catch (Exception)
                {
                    return(lastSell.ReceivedAmount);
                }

            default:
                return(0);    //required by compiler
            }
        }
コード例 #9
0
 public void PlaceBid(ForexTreeData record, MarketAction action)
 {
     switch (action)
     {
         case MarketAction.Buy:
             ExecuteBuy(record);
             break;
         case MarketAction.Sell:
             ExecuteSell(record);
             break;
         case MarketAction.Hold:
             SaveLogRecord(0.0, 0.0, 0.0, MarketAction.Hold, record.Action);
             break;
         default:
             throw new BllException("Incorrect market action.");
     }
 }
コード例 #10
0
 private void SaveLogRecord(double bought, double sold, double profit, MarketAction executedAction, MarketAction correctAction)
 {
     TradeLog.Add(new TradeLogRecord
     {
         QuantityBought = bought,
         QuantitySold = sold,
         Profit = profit,
         ExecutedAction = executedAction,
         CorrectAction = correctAction
     });
 }
コード例 #11
0
 private string GetContentPartialViewName(MarketAction forAction)
 {
     return(string.Format("_{0}", Enum.GetName(forAction.GetType(), forAction)));
 }
コード例 #12
0
 public MarketParameters()
 {
     Action = MarketAction.NotSet;
 }
コード例 #13
0
 public MarketFilter()
 {
     Action = MarketAction.NotSet;
 }
コード例 #14
0
 public Verdict(MarketAction verdict, double percentageToCommit)
 {
     this.action          = verdict;
     this.ammounttocommit = percentageToCommit;
 }
コード例 #15
0
 public MarketParameters()
 {
     Action = MarketAction.NotSet;
 }
コード例 #16
0
 public MarketFilter()
 {
     Action = MarketAction.NotSet;
 }