Exemple #1
0
 public void TestAgentCreationInvalidArguments()
 {
     List <String> Coins = new List <String> {
         "ETH", "BTC", "BCH", "NEO"
     };
     TradingAgent agent = new TradingAgent(-100.0d, Coins);
 }
Exemple #2
0
        public void TestAgentCreationValidArguments()
        {
            List <String> Coins = new List <String> {
                "ETH", "BTC", "BCH", "NEO"
            };
            TradingAgent agent = new TradingAgent(100.0d, Coins);

            Assert.NotNull(agent);
        }
Exemple #3
0
        public void TestKucoinClient()
        {
            List <String> coins = new List <String> {
                "ETH", "BTC", "BCH", "NEO"
            };
            TradingAgent agent = new TradingAgent(100.0d, coins);

            KuCoinApi.NetCore.KuCoinApiClient kucoinClient = agent.GetKucoinClient();
            Assert.NotNull(kucoinClient);
        }
Exemple #4
0
        public void TestBuyingPower()
        {
            List <String> Coins = new List <String> {
                "ETH", "BTC", "BCH", "NEO"
            };
            double        testBuyingPower = 100.0d;
            TradingAgent  agent           = new TradingAgent(testBuyingPower, Coins);
            List <String> agentCoins      = agent.GetCoinTypes();

            Assert.Equal(testBuyingPower, agent.GetBuyingPower());
        }
Exemple #5
0
        public void TestDecideTransaction()
        {
            List <String> coins = new List <String> {
                "ETH", "BTC", "BCH", "NEO"
            };
            TradingAgent agent = new TradingAgent(100.0d, coins);

            KuCoinApi.NetCore.KuCoinApiClient kucoinClient = agent.GetKucoinClient();
            KuCoinApi.NetCore.Entities.Tick[] ticks        = kucoinClient.GetTicks();

            agent.GetCoinInfo(ticks, coins);
            agent.DecideTransaction();
            // Buying power has changed due to buy transaction being carried out.
            Assert.NotEqual(100.0d, agent.GetBuyingPower());
        }
Exemple #6
0
        public void TestAgentCoinsInput()
        {
            List <String> Coins = new List <String> {
                "ETH", "BTC", "BCH", "NEO"
            };
            TradingAgent  agent      = new TradingAgent(100.0d, Coins);
            List <String> agentCoins = agent.GetCoinTypes();

            Assert.NotEmpty(agentCoins);

            Coins      = new List <String> {
            };
            agent      = new TradingAgent(100.0d, Coins);
            agentCoins = agent.GetCoinTypes();
            Assert.Empty(agentCoins);
        }
Exemple #7
0
        private static PortfolioManager Get(string symbol)
        {
            //Initialize
            TradingPortfolio np = new TradingPortfolio();

            //ADD INITIAL SECURITIES
            ForexSecurity security = new ForexSecurity(symbol);

            security.LotSize  = 100000;     //Lots
            security.PipSize  = 0.0001M;    //PipSize in 4 decimal places
            security.TickSize = 0.00001M;   //Size of one tick
            security.PipValue = 1M;         //PipValue, if unable to calculate to base currency
            security.Digits   = 5;

            var account = new SimAccount("SIMULATED", "Sim account for backtesting", 10000, 100, "SIM");

            np.SetAccount(account);
            np.Securities.AddSecurity(security);

            //ADD AGENT AND INJECT TEMPLATES
            np.InjectAgent <ExampleTradingAgent>();

            //Set streams
            TradingAgent agent = (TradingAgent)np.Agents[0];

            agent.AgentId   = 115230;
            agent.TimeFrame = TimeSpan.FromSeconds(TimeFrameInSeconds);
            OHLCBarStream ls = new OHLCBarStream(np.Securities[symbol], np.Agents[0].TimeFrame);

            agent.SetDefaultStream(ls);
            ls.Initialize();
            agent.Initialize();
            agent.Start();

            SimpleBacktester.OnMessage  += SimpleBacktester_OnMessage;
            SimpleBacktester.OnProgress += SimpleBacktester_OnProgress;

            return(np);
        }