Esempio n. 1
0
        static void Main(string[] args)
        {
            AccountInfo account = new AccountInfo();

            account.InvestorName      = System.Configuration.ConfigurationManager.AppSettings["InvestorName"];
            account.BrokerID          = System.Configuration.ConfigurationManager.AppSettings["BrokerID"];
            account.InvestorID        = System.Configuration.ConfigurationManager.AppSettings["InvestorID"];
            account.Password          = System.Configuration.ConfigurationManager.AppSettings["Password"];
            account.MarketDataAddress = System.Configuration.ConfigurationManager.AppSettings["MarketDataAddress"];
            account.TradeAddress      = System.Configuration.ConfigurationManager.AppSettings["TradeAddress"];

            TradeFramework framework = new TradeFramework(account);

            string instrumentID = System.Configuration.ConfigurationManager.AppSettings["InstrumentID"];

            var input = GetPrice();

            while (input.ToLower() != "exit")
            {
                double price;
                if (double.TryParse(input, out price))
                {
                    var trader = new Trader(instrumentID, price, framework);
                    trader.Run();
                }
                input = GetPrice();
            }
        }
Esempio n. 2
0
        public OrderPlacer(TradeFramework framework)
        {
            this.frame = framework;

            this.frame.CtpTrader.OnRspOrderInsert    += CtpTrader_OnRspOrderInsert;
            this.frame.CtpTrader.OnErrRtnOrderInsert += CtpTrader_OnErrRtnOrderInsert;
            this.frame.CtpTrader.OnRspOrderAction    += CtpTrader_OnRspOrderAction;
            this.frame.CtpTrader.OnErrRtnOrderAction += CtpTrader_OnErrRtnOrderAction;
        }
Esempio n. 3
0
        public Trader(string instrumentID, double targetPrice, TradeFramework framework)
        {
            if (framework == null)
            {
                throw new ArgumentNullException();
            }
            this.Volume       = 1;
            this.instrumentID = instrumentID;
            this.targetPrice  = targetPrice;
            this.frame        = framework;

            this.frame.Subscribe(this, instrumentID);
            this.instrument = this.frame.GetInstrument(instrumentID);
        }