예제 #1
0
        static void Main(string[] args)
        {
            string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ODBCDataConnectionString"].ConnectionString;

            Program.da = new SqlServerAccesssODBC(connectionString);


            Persona oPersona = new Persona(9, "Carlos", "Cadtro");

            Persona.Truncate();

            oPersona.Save();
            oPersona.id        = 1;
            oPersona.nombre    = "Edwin";
            oPersona.apellidos = "Jimenez";
            oPersona.Save();
            oPersona.Delete();
            DataTable result = Persona.Select();

            foreach (DataRow item in result.Rows)
            {
                Console.WriteLine("------------------------");
                Console.WriteLine(item["Nombre"]);
                Console.WriteLine(item["Apellidos"]);
                Console.WriteLine("------------------------");
            }
            Console.ReadLine();
        }
예제 #2
0
 public void delete(string ID)
 {
     using (DBAccess.DBAccess db = new DBAccess.DBAccess())
     {
         string[,] param =   {
                                 {"@ID", ID}
                             };
         db.ExecuteNonQuery("sprDeleteCustomer", param);
     }
 }
예제 #3
0
        static void Main()
        {
            Application.EnableVisualStyles();

            string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Pg"].ConnectionString;

            Program.da = new PgAccess(connectionString);

            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
예제 #4
0
 public void add(ModelCustomer MC)
 {
     using (DBAccess.DBAccess db = new DBAccess.DBAccess())
     {
         string[,] param =   {
                                 {"@NAME", MC.Name},
                                 {"@ADDRESS", MC.Address}
                             };
         db.ExecuteNonQuery("sprInsertCustomer", param);
     }
 }
예제 #5
0
        public BacktestEngine(EWrapperImpl wrapper, DBAccess.DBAccess db, XmlNode config)
        {
            _wrapper = wrapper;
            _db      = db;
            _tm      = ThreadManager.instance;
            lock (_lock)
            {
                _wrapper.nextOrderId = DBAccess.DBAccess.instance.getMaxOrderId() + 1;
            }
            _config    = config;
            _account   = config["Account"].InnerText;
            _startDate = DateTime.Parse(config["StartDate"].InnerText);
            string endDateStr = config["EndDate"].InnerText;

            if (endDateStr == "Today")
            {
                _endDate = DateTime.Today;
            }
            else
            {
                _endDate = DateTime.Parse(endDateStr);
            }
            _barType            = config["BarType"].InnerText;
            _minBarSize         = Int32.Parse(config["MinBarSize"].InnerText);
            _slippage           = Int32.Parse(config["Slippage"].InnerText);
            _limitIncludeTouch  = Boolean.Parse(config["LimitIncludeTouch"].InnerText);
            _source             = config["MarketDataSource"].InnerText;
            _reportFolder       = config["ReportFolder"].InnerText;
            _interval           = new TimeSpan(0, 0, _minBarSize);
            _mktData            = new Dictionary <int, Bar[]>();
            _currMktIndices     = new Dictionary <int, int>();
            _barIds             = new List <int>();
            _barTickerMap       = new Dictionary <int, int>();
            _tickTickerMap      = new Dictionary <int, int>();
            _mktTimeZoneMap     = new Dictionary <int, TimeZoneInfo>();
            _contractBarMap     = new Dictionary <int, int>();
            _orderContractMap   = new Dictionary <int, Contract>();
            _barSlippageMap     = new Dictionary <int, double>();
            _currTime           = _startDate;
            _currd              = _currTime.Date;
            _liveOrders         = new SortedDictionary <int, Order>();
            _ocaGroups          = new Dictionary <string, List <int> >();
            _childOrders        = new Dictionary <int, List <int> >();
            _executions         = new SortedDictionary <int, Execution>();
            _timeEventHandlers  = new SortedDictionary <int, List <onTime> >();
            _timeEventRefreshed = new Dictionary <int, bool>();
            _isDone             = new Dictionary <int, bool>();
            _sleepId            = 0;
            _sleepEvents        = new Dictionary <int, AutoResetEvent>();
            _nextBarEvent       = new ManualResetEvent(true);
        }
예제 #6
0
 public ModelCustomer getCustomerByID(string ID)
 {
     using (DBAccess.DBAccess db = new DBAccess.DBAccess())
     {
         string[,] param = { { "@Id", ID } };
         using (SqlDataReader rdr = db.ExecuteReader("sprSelectCustomerByID", param))
         {
             ModelCustomer item = new ModelCustomer();
             while (rdr.Read())
             {
                 item.Id = Convert.ToInt32(rdr["Id"]);
                 item.Name = rdr["Name"].ToString();
                 item.Address = rdr["Address"].ToString();
             }
             return item;
         }
     }
 }
예제 #7
0
        public DataTable getAllCustomer(string strWhere, string strOrderBy)
        {
            using (DBAccess.DBAccess db = new DBAccess.DBAccess())
            {
                if (strOrderBy == "") { strOrderBy = " ORDER BY Id"; }

                string[,] param =   {
                                        { "@strWhere", strWhere },
                                        { "@strOrderBy", strOrderBy }
                                    };
                using (SqlDataReader rdr = db.ExecuteReader("sprSelectAllCustomer", param))
                {
                    DataTable DT = new DataTable();
                    DT.Load(rdr);
                    return DT;
                }
            }
        }
예제 #8
0
 public int updateFlag(string ID)
 {
     using (DBAccess.DBAccess db = new DBAccess.DBAccess())
     {
         string[,] param = { { "@ID", ID } };
         int UpdateFlag = Convert.ToInt32(db.ExecuteScalar("sprCustomerFlag", param));
         return UpdateFlag;
     }
 }
예제 #9
0
 public void update(ModelCustomer MC)
 {
     using (DBAccess.DBAccess db = new DBAccess.DBAccess())
     {
         string[,] param =   {
                                 {"@ID", MC.Id.ToString()},
                                 {"@NAME", MC.Name},
                                 {"@ADDRESS", MC.Address}
                             };
         db.ExecuteNonQuery("sprUpdateCustomer", param);
     }
 }
예제 #10
0
        static void Main()
        {
            DBAccess db = DBUtils.getDB();
            //Console.WriteLine(db.getNextEventTime("EIA Report", new DateTime(2018,1,1)));
            //DBUtils.createAllTables();
            //Console.WriteLine(db.getContract(8991549).Symbol);
            //Console.WriteLine(db.getModelParameters(1, new DateTime(2015,12,4)));
            //DataTable dt = db.getHistoricalData(1, new DateTime(2013, 1, 1), new DateTime(2015, 1, 1), "close");
            //for(int i=0; i < dt.Rows.Count; ++i)
            //{
            //    for (int j = 0; j < dt.Columns.Count; ++j)
            //        Console.Write(dt.Rows[i][j].ToString() + "\t");
            //    Console.WriteLine();
            //}
            //string xml = File.ReadAllText(getXmlPath("model_parameters.xml"));
            //db.runNonQuery("insert into model_parameters values (2, 1, '2015-12-02', '" + xml + "')");
            //db.createCombos();
            //db.createOrders();
            //db.createContracts();
            //db.createCommissions();
            //db.createExecutions();
            //db.createAccounts();
            //db.createStrategies();
            //db.createModelParameters();
            //db.createPositions();
            //db.createErrors();
            //db.createSystemLog();
            //db.createEvents();
            //db.createNearbyContracts();
            //String query = @"select * from test";
            //DataTable dt = db.runQuery(query);
            //Console.WriteLine("Hello");
            //Console.WriteLine(dt.ToString());
            //String model_xml = File.ReadAllText(getXmlPath("modelPairStatArb.xml"));
            //int model_id = db.addModel(-1, "Test IWM/IWB Pair Stat Arb", model_xml, "Testing Russells Pair Trading 100/0.01");
            //List<string> ret = db.getStrategyInfo(1);
            //List<Contract> ret = db.getPairContracts(-1);
            //Console.WriteLine(ret[0].ToString());
            //Console.WriteLine(ret[1].ToString());

            //String model_xml = File.ReadAllText(getXmlPath("modelFixedReversion.xml"));
            //int model_id = db.addModel(-1, "BT_Settlement_Reversion", model_xml, "Brent Settlement Reversion");
            //String strategy_xml = File.ReadAllText(getXmlPath("strategyFixedReversion.xml"));
            //db.addStrategy("Fixed", "BT_Settlement_Reversion", strategy_xml, "Brent Settlement Reversion");

            //String strategy_xml = File.ReadAllText(getXmlPath("RussellsDailyDownloader.xml"));
            //db.addStrategy("MarketDataDownloader", "Russells_100d_100d", strategy_xml, "Russells family 100D daily data");

            //String strategy_xml = File.ReadAllText(getXmlPath("BrentDataDownloader.xml"));
            //db.addStrategy("MarketDataDownloader", "BD_201609_60_7d", strategy_xml, "Brent Sep - Nov 2016 1 min 7d download");

            //String strategy_xml = File.ReadAllText(getXmlPath("BrentNearbyDataDownloader_Dec14-Nov15.xml"));
            //db.addStrategy("MarketDataDownloader", "BD_Dec14-Nov15Contracts_60_120d", strategy_xml, "Brent multi contracts multi endDates ");

            //String strategy_xml = File.ReadAllText(getXmlPath("XAUUSDDownloader.xml"));
            //db.addStrategy("MarketDataDownloader", "XAUUSD-1Min-16D-endingToday", strategy_xml, "XAUUSD spot gold 16D ending Today");

            //String strategy_xml = File.ReadAllText(getXmlPath("NZDUSDDownloader.xml"));
            //db.addStrategy("MarketDataDownloader", "NZDUSD-1Min-1500D-ending20161130", strategy_xml, "NZDUSD spot 1500D ending 20161122");


            //String strategy_xml = File.ReadAllText(getXmlPath("SGXDataDownloader.xml"));
            //db.addStrategy("MarketDataDownloader", "SGX_201609_60_7d", strategy_xml, "SGX Futures Sep 2016 1 min 7d download");

            //String model_xml = File.ReadAllText(getXmlPath("modelEventReversion.xml"));
            //int model_id = db.addModel(-1, "EIA", model_xml, "Brent EIA Event");
            //String strategy_xml = File.ReadAllText(getXmlPath("strategyEventReversion.xml"));
            //db.addStrategy("EventReversion", "EIA", strategy_xml, "Brent EIA Event");

            //String model_xml = File.ReadAllText(getXmlPath("modelSgxSwitch.xml"));
            //int model_id = db.addModel(134421928, "STW_201609", model_xml, "STW 201609 SGX Switch");
            //String strategy_xml = File.ReadAllText(getXmlPath("strategySgxSwitch.xml"));
            //db.addStrategy("SgxSwitch", "STW_201609", strategy_xml, "STW 201609 SGX Switch");

            //nearby contract example usage
            //int conId = db.addNearbyContract("COIL", "FUT", "IPE", "ICE Brent Crude Nearby_1 Roll_2d");
            //db.setNearbyContractSchedule(conId, 1, 2); //create nearby1 synthetic contract, where indexoffset = 2, i.e roll 2 days before actual expiry
            //int barId = db.addBarDataId(conId, "trades", 60, "IB", "");
            //db.exportBarsToFile(barId, new DateTime(2016, 9, 15), new DateTime(2016, 10, 15), getMktDataPath("test"));

            //DBUtils.generatePnLReport("MyAccount", new DateTime(2016, 12, 1), DateTime.Today, "C:\\MyReportFolder");
        }