Exemple #1
0
 public Broker(EClientSocket clientSocket, SimpleLogger log, Parameters @params, Slack slack)
 {
     this.log          = log;
     this.@params      = @params;
     this.clientSocket = clientSocket;
     this.slack        = slack;
 }
 public Controller(EClientSocket clientSocket, SimpleLogger log, Parameters @params, Strategy strategy, Broker broker, Positions positions, FuturesContract futures, Prices prices, Transactions transactions, Slack slack)
 {
     this.@params      = @params;
     this.log          = log;
     this.clientSocket = clientSocket;
     this.strategy     = strategy;
     this.broker       = broker;
     this.futures      = futures;
     this.prices       = prices;
     this.transactions = transactions;
     this.slack        = slack;
 }
Exemple #3
0
        public void openOrder(int orderId, Contract contract, Order order, OrderState orderState)
        {
            String str = ("OpenOrder. Id:" + orderId + ", Symbol:" + contract.Symbol + ", SecType:" + contract.SecType + " Exchange:" + contract.Exchange + " Action:" + order.Action + ", OrderType:" + order.OrderType + ", Price:" + order.LmtPrice + " Quantity:" + order.TotalQuantity + ", OrderState:" + orderState.Status);

            log.Broker(str);

            if (orderState.Status.Contains("Submitted") || orderState.Status.Contains("Cancel"))
            {
                OrderDetails.OrderStatusList.DataList.Add(str);
            }

            OpenOrder.OpenOrderList.DataList.Add(str);

            if (orderState.Status.Contains("Filled") && !OpenOrder.MessageOrderList.DataList.Contains(orderId))
            {
                Slack slack = new Slack();
                slack.SendMessageToSlack($"[*{str}*");
                OpenOrder.MessageOrderList.DataList.Add(orderId);
            }
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            EWrapperImpl  ibClient     = new EWrapperImpl();
            EClientSocket clientSocket = ibClient.ClientSocket;


            Console.ForegroundColor = ConsoleColor.DarkGreen;
            string logo = @"
 /$$$$$$$  /$$                     /$$        /$$$$$$                      /$$   /$$               /$$       /$$$$$$                        
| $$__  $$| $$                    | $$       /$$__  $$                    |__/  | $$              | $$      |_  $$_/                        
| $$  \ $$| $$  /$$$$$$   /$$$$$$$| $$   /$$| $$  \__/  /$$$$$$   /$$$$$$  /$$ /$$$$$$    /$$$$$$ | $$        | $$   /$$$$$$$   /$$$$$$$    
| $$$$$$$ | $$ /$$__  $$ /$$_____/| $$  /$$/| $$       |____  $$ /$$__  $$| $$|_  $$_/   |____  $$| $$        | $$  | $$__  $$ /$$_____/    
| $$__  $$| $$| $$  \ $$| $$      | $$$$$$/ | $$        /$$$$$$$| $$  \ $$| $$  | $$      /$$$$$$$| $$        | $$  | $$  \ $$| $$          
| $$  \ $$| $$| $$  | $$| $$      | $$_  $$ | $$    $$ /$$__  $$| $$  | $$| $$  | $$ /$$ /$$__  $$| $$        | $$  | $$  | $$| $$          
| $$$$$$$/| $$|  $$$$$$/|  $$$$$$$| $$ \  $$|  $$$$$$/|  $$$$$$$| $$$$$$$/| $$  |  $$$$/|  $$$$$$$| $$       /$$$$$$| $$  | $$|  $$$$$$$ /$$
|_______/ |__/ \______/  \_______/|__/  \__/ \______/  \_______/| $$____/ |__/   \___/   \_______/|__/      |______/|__/  |__/ \_______/|__/
                                                                | $$                                                                        
                                                                | $$                                                                        
                                                                |__/                                                                        

                            ";

            Console.WriteLine(logo);
            Console.ResetColor();

            Console.Write("BlockShift Trading App");
            Console.Write("\n");
            Console.Write("DISCLAIMER: USING THIS SOFTWARE AT MY OWN RISK\n");
            Console.Write("\n");

            try
            {
                ConsoleWindow.QuickEditMode(false);

                Parameters @params = new Parameters(Path.Combine(Environment.CurrentDirectory, "config.conf"));

                SimpleLogger log = new SimpleLogger();

                Slack slack = new Slack(@params);

                Prices prices = new Prices(log, @params);

                FuturesContract futures = new FuturesContract(@params);

                Strategy strategy = new Strategy(log);

                Broker broker = new Broker(clientSocket, log, @params, slack);

                Positions positions = new Positions(log, @params, slack);

                Transactions transactions = new Transactions(log);

                Controller ctl = new Controller(clientSocket, log, @params, strategy, broker, positions, futures, prices, transactions, slack);

                broker.ConnectionToBroker(strategy, positions);

                ctl.Run();
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message.ToString());
                Console.Write(ex.StackTrace.ToString());
            }


            Console.ReadLine();
        }
Exemple #5
0
 public Positions(SimpleLogger log, Parameters @params, Slack slack)
 {
     this.log     = log;
     this.@params = @params;
     this.slack   = slack;
 }