コード例 #1
0
 public void GetTradeOrderCommand(IMarketModelSimulation data_set_slice)
 {
     if (data_set_slice.OpenOrders.Count == 0)
     {
         data_set_slice.ProcessOrderCommand(new TradingOrderCommand(TradingOrderType.Long, 100000.0, data_set_slice.CurrentBid, 0));
     }
 }
コード例 #2
0
 public void GetTradeOrderCommand(IMarketModelSimulation market_model)
 {
     //double[] features = new double[history_count];
     //for (int index = 0; index < history_count; index++)
     //{
     //    features[index] = market_model.Second1[-index].CloseBid;
     //}
     //double [] likelyhoods = model.GetLikelihoods(features);
 }
コード例 #3
0
 public MarketResult(double start_cash, PriceSet price_set, IMarketModelSimulation market, IReadOnlyList <double> cash, IReadOnlyList <double> equity)
 {
     this.StartCash = start_cash;
     this.EndCash   = market.Cash;
     this.PriceSet  = price_set;
     this.Market    = market;
     this.Cash      = cash;
     this.Equity    = equity;
 }
コード例 #4
0
 public void GetTradeOrderCommand(IMarketModelSimulation market)
 {
     if ((market.OpenOrders.Count == 0) && (run_lenght < market.Second1.HistoryCount))
     {
         double gain = market.CurrentBid - market.Second1.GetHistory(run_lenght).CloseBid;
         if (gain_threshold < gain)
         {
             market.ProcessOrderCommand(new TradingOrderCommand(TradingOrderType.Long, 100000, market.CurrentAsk, 0, market.CurrentAsk - gain, market.CurrentBid + gain));
         }
     }
 }
コード例 #5
0
 public void GetTradeOrderCommand(IMarketModelSimulation market_model)
 {
     if (market_model.OpenOrders.Count == 0)
     {
         OpenFirst(market_model);
     }
     else
     {
         CheckSwap(market_model);
     }
 }
コード例 #6
0
        public void OpenFirst(IMarketModelSimulation market_model)
        {
            //Long short criterion
            double upper_limit = market_model.CurrentAsk + 0;
            double lower_limit = market_model.CurrentAsk - 0;

            if (BuyLong())
            {
                market_model.ProcessOrderCommand(new TradingOrderCommand(TradingOrderType.Long, market_model.CurrentAsk, InitialVolume, this.Slippage, lower_limit, upper_limit));
            }
            else
            {
                market_model.ProcessOrderCommand(new TradingOrderCommand(TradingOrderType.Short, market_model.CurrentBid, InitialVolume, this.Slippage, upper_limit, lower_limit));
            }
        }
コード例 #7
0
        public void GetTradeOrderCommand(IMarketModelSimulation market)
        {
            if (market.Second1.HistoryCount < run_length)
            {
                return;
            }
            //Long side: Bid is rising
            if (market.Second1.GetHistory(1).CloseBid < market.Second1.GetHistory(0).CloseBid)
            {
                bool make_trade = true;
                for (int index = 1; index < run_length; index++)
                {
                    if (market.Second1.GetHistory(index + 1).CloseBid >= market.Second1.GetHistory(index).CloseBid)
                    {
                        make_trade = false;
                    }
                }

                if (make_trade)
                {
                    Long(market);
                }
            }

            //Short side: Ask is going doen
            if (market.Second1.GetHistory(0).CloseAsk < market.Second1.GetHistory(1).CloseAsk)
            {
                bool make_trade = true;
                for (int index = 1; index < run_length; index++)
                {
                    if (market.Second1.GetHistory(index).CloseAsk >= market.Second1.GetHistory(index + 1).CloseAsk)
                    {
                        make_trade = false;
                    }
                }

                if (make_trade)
                {
                    Short(market);
                }
            }
        }
コード例 #8
0
        public void GetTradeOrderCommand(IMarketModelSimulation market)
        {
            if ((market.OpenOrders.Count == 0) && (run_lenght_long < market.Second1.HistoryCount))
            {
                double gain_long = market.CurrentBid - market.Second1.GetHistory(run_lenght_long).CloseAsk;
                if (gain_threshold_long < gain_long)
                {
                    market.ProcessOrderCommand(new TradingOrderCommand(TradingOrderType.Long, TradingConstants.LOT, market.CurrentAsk, 0, market.CurrentAsk - gain_long, market.CurrentBid + gain_long));
                }
            }

            if ((market.OpenOrders.Count == 0) && (run_lenght_short < market.Second1.HistoryCount))
            {
                double gain_short = market.CurrentAsk - market.Second1.GetHistory(run_lenght_short).CloseBid;
                if (gain_short < gain_threshold_short)
                {
                    market.ProcessOrderCommand(new TradingOrderCommand(TradingOrderType.Short, TradingConstants.LOT, market.CurrentBid, 0, market.CurrentBid - gain_short, market.CurrentAsk + gain_short));
                }
            }
        }
コード例 #9
0
        public void TrailingStopLoss(IMarketModelSimulation market_model, double stoplossTrail)
        {
            if (market_model.OpenOrders.Count > 0)
            {
                List <int> openOrders = new List <int>(market_model.OpenOrders.Keys);
                foreach (int selectedOrder in openOrders)
                {
                    var tradingOrder = market_model.OpenOrders[selectedOrder];

                    if (tradingOrder.OrderType == TradingOrderType.Long &&
                        stoplossTrail < market_model.CurrentBid - tradingOrder.StopLoss)
                    {
                        market_model.ModifyOrder(selectedOrder, market_model.CurrentBid - stoplossTrail, tradingOrder.TakeProfit);
                    }
                    if (tradingOrder.OrderType == TradingOrderType.Short &&
                        stoplossTrail < tradingOrder.StopLoss - market_model.CurrentAsk)
                    {
                        market_model.ModifyOrder(selectedOrder, market_model.CurrentAsk + stoplossTrail, tradingOrder.TakeProfit);
                    }
                }
            }
        }
コード例 #10
0
        public void GetTradeOrderCommand(IMarketModelSimulation market_model)
        {
            Tuple <double[], bool> indicator_0_Tuple      = indicator_0.Compute(market_model);
            Tuple <double[], bool> indicator_0_Tuple_Prev = indicator_0_Tuple;

            if (indicator_0_Tuple.Item2 && market_model.OpenOrders.Count == 0)
            {
                //   if (market_model.CurrentAsk < indicator_0_Tuple.Item1[2] && market_model.Second1[-1].CloseAsk < indicator_0_Tuple_Prev.Item1[2])

                if (threshold_long < indicator_0_Tuple.Item1[7])
                {
                    market_model.ProcessOrderCommand(new TradingOrderCommand(TradingOrderType.Long, TradingConstants.LOT, market_model.CurrentAsk, 0
                                                                             , market_model.CurrentAsk - stop_loss * TradingConstants.POINT, market_model.CurrentAsk + take_profit * TradingConstants.POINT));
                }
                if (threshold_short > indicator_0_Tuple.Item1[7])
                {
                    market_model.ProcessOrderCommand(new TradingOrderCommand(TradingOrderType.Short, TradingConstants.LOT, market_model.CurrentBid, 0
                                                                             , market_model.CurrentBid + stop_loss * TradingConstants.POINT, market_model.CurrentBid - take_profit * TradingConstants.POINT));
                }
            }

            TrailingStopLoss(market_model, TradingConstants.POINT * 150);
        }
コード例 #11
0
 public void GetTradeOrderCommand(IMarketModelSimulation market_model)
 {
     //float expected_value = 0;
     //float desnisty_sum = 0;
     //for (int raster_index = 0; raster_index < this.raster.Length; raster_index++)
     //{
     //    float expected_density =  this.expectation_function.Compute(new Tuple<MarketModel,float>(data_set_slice, this.raster[raster_index]));
     //    desnisty_sum += expected_density;
     //    expected_value += this.raster[raster_index] * expected_density;
     //}
     //expected_value  /= desnisty_sum;
     //if(this.threshold_buy < expected_value)
     //{
     //    return new TradeOrderCommand(this.symbol, TradeOrderType.Long);
     //}
     //else if(expected_value < threshold_sell)
     //{
     //    return new TradeOrderCommand(this.symbol, TradeOrderType.Short);
     //}
     //else
     //{
     //    return new TradeOrderCommand(this.symbol, TradeOrderType.Hold);
     //}
 }
コード例 #12
0
 public void GetTradeOrderCommand(IMarketModelSimulation market)
 {
     Tuple <double[], bool> tuple = indicator.Compute(market);
 }
コード例 #13
0
 public void Short(IMarketModelSimulation market)
 {
     market.ProcessOrderCommand(new TradingOrderCommand(TradingOrderType.Short, 1, market.CurrentBid, 2, market.CurrentAsk + margin * TradingConstants.POINT, market.CurrentBid - margin * TradingConstants.POINT));
 }