private static void Main(string[] args)
        {
            var shares    = 0;
            var tradeType = TradeType.Buy;

            do
            {
                var console = string.Empty;
                while (string.IsNullOrEmpty(console))
                {
                    Console.WriteLine("Enter Ticker Symbol, Number of Shares to Trade, and Trade TradeType (B/S)");
                    Console.WriteLine("Example: HP,200,S   [Enter Q to quit]");
                    Console.Write("Enter Trade: ");
                    console = Console.ReadLine();
                }
                //TODO, put in validation for input

                //Strip out the white spaces
                console = Regex.Replace(console, @"\s+", "");
                if (console.ToLower().Equals("q"))
                {
                    break;
                }
                var tradeInfo = console.Split(',');

                var ticker = tradeInfo[0];
                int i;
                if (int.TryParse(tradeInfo[1], out i))
                {
                    shares = i;
                }

                if (tradeInfo[2].ToLower().Equals("b"))
                {
                    tradeType = TradeType.Buy;
                }
                else if (tradeInfo[2].ToLower().Equals("s"))
                {
                    tradeType = TradeType.Sell;
                }

                Console.WriteLine("I will now try to {0} {1} shares of {2}", tradeType, shares, ticker);

                //Call the static object, Trading System. TradingSystem will return the response
                //message of the Trade.
                Trade responseTradeMessage = TradingSystem.Trade(ticker, shares, tradeType);

                Console.WriteLine("The following is the result of your trade:\n");
                //Convert the response Trade message into a JSON string and show it
                var startColor = Console.ForegroundColor;
                //Make the console text RED upon failure
                if (responseTradeMessage.TradeStatus.Equals(TradeStatus.Fail))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                Console.WriteLine(JsonConvert.SerializeObject(responseTradeMessage, Newtonsoft.Json.Formatting.Indented));
                Console.ForegroundColor = startColor;
            } while (true);
        }
示例#2
0
        static async Task MainAsync()
        {
            // Config
            Config config = new Config()
            {
                Reload                  = false,
                DataDirectory           = @"..\..\..\..\data\",
                QuandlApiKey            = "",
                GoogleCookies           = "",
                ImportantWords          = new string[] { "debt", "color", "stocks", "economics", "inflation", "restaurant", "portfolio", "metals", "housing", "dow jones", "revenue", "sell", "bonds", "risk", "car", "credit", "markets", "return", "unemployment", "leverage", "chance", "nasdaq", "money", "society", "war", "religion", "cancer", "growth", "investment", "hedge", "marriage", "transaction", "cash", "economy", "derivatives", "headlines", "profit", "loss", "office", "forex", "finance", "fed", "banking", "stock market", "fine", "crisis", "happy", "gains", "invest", "house" },
                BestNCompanies          = 100,
                NormalizationWindowSize = int.MaxValue,
                DataFrom                = new DateTime(1995, 1, 1),
                ValidFrom               = 0.7,
                TestFrom                = 0.85,
                Predict                 = 30,
                Random                  = new Random()
            };

            // Prepare data
            DataManager dataManager = new DataManager(config);
            await dataManager.PrepareData();

            // Make prediction
            RnnManager rnnManager = new RnnManager(config);

            rnnManager.Predict();

            // Decode prediction
            dataManager.DecodePrediction();

            // Make trades
            TradingSystem tradingSystem = new TradingSystem(config);

            tradingSystem.Trade();
        }
 public void OverTradeLimitTest()
 {
     TradingSystem.Trade("Endava", 500, TradeType.Buy);
 }
 public void BuyTest()
 {
     TradingSystem.Trade("Endava", 125, TradeType.Buy);
 }