private void btnUpdate_Click(object sender, EventArgs e)
        {
            int gatewayId = getGatewayId(txtExchange.Text);
            int productTypeId = getProductTypeId(cbProductType.SelectedItem.ToString());
            uint maxPos = 0;
            uint maxLongShort = 0;

            if(gatewayId != -1 && productTypeId != -1 && uint.TryParse(txtMaxPosition.Text, out maxPos) && uint.TryParse(txtMaxLongShort.Text, out maxLongShort))
            {
                foreach (TTUSAPI.DataObjects.AccountGroup acctGroup in m_accountGroups.Values) // Loop through downloaded account groups
                {
                    if (acctGroup.Name == cbAccount.SelectedItem.ToString())
                    {
                        TTUSAPI.DataObjects.AccountGroupProfile acctGroupProfile = new TTUSAPI.DataObjects.AccountGroupProfile(acctGroup);

                        TTUSAPI.DataObjects.AccountGroupProductLimitProfile productLimit;
                        bool productLimitSet = false;
                        foreach (TTUSAPI.DataObjects.AccountGroupProductLimit prodLimit in acctGroupProfile.ProductLimits.Values) //Loop through product limits associated with the account
                        {
                            //Replace account product limits that match ones in the update file
                            if (prodLimit.GatewayID == gatewayId && prodLimit.ProductTypeID == productTypeId && prodLimit.Product.ToUpper().Equals(txtProduct.Text.ToUpper()))
                            {
                                productLimit = new TTUSAPI.DataObjects.AccountGroupProductLimitProfile(prodLimit); //Create copy of Product Limit
                                productLimit.MaxPositionPerContract = maxPos; //Set Maximum Position
                                productLimit.MaxProductLongShort = maxLongShort; // Set Maximum Long/Short Position
                                acctGroupProfile.AddProductLimit(productLimit); //Add product limit to account
                                productLimitSet = true;
                                break;
                            }
                        }
                        //Create new product limits if they don't currently exist for the account
                        if (productLimitSet == false)
                        {
                            productLimit = new TTUSAPI.DataObjects.AccountGroupProductLimitProfile(); //Create new Product Limit
                            //Assign values to product limit from update file object
                            productLimit.GatewayID = gatewayId;
                            productLimit.Product = txtProduct.Text;
                            productLimit.ProductTypeID = productTypeId;
                            productLimit.MaxPositionPerContract = maxPos;
                            productLimit.MaxProductLongShort = maxLongShort;
                            productLimit.AllowTradingOutrights = true;
                            productLimit.AllowTradingSpreads = true;
                            acctGroupProfile.AddProductLimit(productLimit); //Add product limit to account
                        }

                        ResultStatus res = m_TTUSAPI.UpdateAccountGroup(acctGroupProfile); //Send updates to TTUS Server
                        if (res.Result == ResultType.SentToServer) //On Success
                        {
                            UpdateStatusBar("Updated account " + acctGroup.Name);
                        }
                        else if (res.Result == ResultType.ValuesUnchanged) //No Change
                        {
                            UpdateStatusBar("Account " + acctGroup.Name + " unchanged");
                        }
                        else //On Failure
                        {
                            UpdateStatusBar("Failed to update account " + acctGroup.Name + ", " + res.ErrorMessage);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int  gatewayId     = getGatewayId(txtExchange.Text);
            int  productTypeId = getProductTypeId(cbProductType.SelectedItem.ToString());
            uint maxPos        = 0;
            uint maxLongShort  = 0;

            if (gatewayId != -1 && productTypeId != -1 && uint.TryParse(txtMaxPosition.Text, out maxPos) && uint.TryParse(txtMaxLongShort.Text, out maxLongShort))
            {
                foreach (TTUSAPI.DataObjects.AccountGroup acctGroup in m_accountGroups.Values) // Loop through downloaded account groups
                {
                    if (acctGroup.Name == cbAccount.SelectedItem.ToString())
                    {
                        TTUSAPI.DataObjects.AccountGroupProfile acctGroupProfile = new TTUSAPI.DataObjects.AccountGroupProfile(acctGroup);

                        TTUSAPI.DataObjects.AccountGroupProductLimitProfile productLimit;
                        bool productLimitSet = false;
                        foreach (TTUSAPI.DataObjects.AccountGroupProductLimit prodLimit in acctGroupProfile.ProductLimits.Values) //Loop through product limits associated with the account
                        {
                            //Replace account product limits that match ones in the update file
                            if (prodLimit.GatewayID == gatewayId && prodLimit.ProductTypeID == productTypeId && prodLimit.Product.ToUpper().Equals(txtProduct.Text.ToUpper()))
                            {
                                productLimit = new TTUSAPI.DataObjects.AccountGroupProductLimitProfile(prodLimit); //Create copy of Product Limit
                                productLimit.MaxPositionPerContract = maxPos;                                      //Set Maximum Position
                                productLimit.MaxProductLongShort    = maxLongShort;                                // Set Maximum Long/Short Position
                                acctGroupProfile.AddProductLimit(productLimit);                                    //Add product limit to account
                                productLimitSet = true;
                                break;
                            }
                        }
                        //Create new product limits if they don't currently exist for the account
                        if (productLimitSet == false)
                        {
                            productLimit = new TTUSAPI.DataObjects.AccountGroupProductLimitProfile(); //Create new Product Limit
                            //Assign values to product limit from update file object
                            productLimit.GatewayID              = gatewayId;
                            productLimit.Product                = txtProduct.Text;
                            productLimit.ProductTypeID          = productTypeId;
                            productLimit.MaxPositionPerContract = maxPos;
                            productLimit.MaxProductLongShort    = maxLongShort;
                            productLimit.AllowTradingOutrights  = true;
                            productLimit.AllowTradingSpreads    = true;
                            acctGroupProfile.AddProductLimit(productLimit); //Add product limit to account
                        }

                        ResultStatus res = m_TTUSAPI.UpdateAccountGroup(acctGroupProfile); //Send updates to TTUS Server
                        if (res.Result == ResultType.SentToServer)                         //On Success
                        {
                            UpdateStatusBar("Updated account " + acctGroup.Name);
                        }
                        else if (res.Result == ResultType.ValuesUnchanged) //No Change
                        {
                            UpdateStatusBar("Account " + acctGroup.Name + " unchanged");
                        }
                        else //On Failure
                        {
                            UpdateStatusBar("Failed to update account " + acctGroup.Name + ", " + res.ErrorMessage);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //          TTUSAPI.DataObjects.AccountGroup acctGroup;

//            if (gatewayId != -1 && productTypeId != -1 && uint.TryParse(txtMaxPosition.Text, out maxPos) && uint.TryParse(txtMaxLongShort.Text, out maxLongShort))
//           {
            foreach (TTUSAPI.DataObjects.AccountGroup acctGroup in m_accountGroups.Values) // Loop through downloaded account groups
            {
                // Clients should type in Group name to search for
                if (acctGroup.Name.ToUpper() == txtAccountGroupName.Text.ToUpper())
                {
                    TTUSAPI.DataObjects.AccountGroupProfile acctGroupProfile = new TTUSAPI.DataObjects.AccountGroupProfile(acctGroup);

                    TTUSAPI.DataObjects.AccountGroupProductLimitProfile productLimit;
                    //bool productLimitSet = false;
                    //foreach (TTUSAPI.DataObjects.AccountGroupProductLimit prodLimit in acctGroupProfile.ProductLimits.Values) //Loop through product limits associated with the account
                    //{
                    //    //Replace account product limits that match ones in the update file
                    //    if (prodLimit.GatewayID == gatewayId && prodLimit.ProductTypeID == productTypeId && prodLimit.Product.ToUpper().Equals("ES"))
                    //    {
                    //        productLimit = new TTUSAPI.DataObjects.AccountGroupProductLimitProfile(prodLimit); //Create copy of Product Limit
                    //        productLimit.MaxPositionPerContract = maxPos; //Set Maximum Position
                    //        productLimit.MaxProductLongShort = maxLongShort; // Set Maximum Long/Short Position
                    //        acctGroupProfile.AddProductLimit(productLimit); //Add product limit to account
                    //        productLimitSet = true;
                    //        break;
                    //    }
                    //}
                    //Create new product limits if they don't currently exist for the account
                    //if (productLimitSet == false)
                    //{

                    // Loop through Markets
                    foreach (TTUSAPI.DataObjects.MarketProductCatalog marketPC in m_MarketProductCatalogs.Values)
                    {
                        // Loop through GWs
                        foreach (TTUSAPI.DataObjects.GatewayProductCatalog gwPC in marketPC.GatewayProductCatalogs.Values)
                        {
                            // Loop through Product Types
                            foreach (TTUSAPI.DataObjects.ProductCatalog productTypes in gwPC.ProductCatalogs.Values)
                            {
                                // Do only for Futures
                                if (productTypes.ProductType.ProductTypeID == 1)
                                {
                                    // Loop through Products
                                    foreach (TTUSAPI.DataObjects.Product prod in productTypes.Products.Values)
                                    {
                                        productLimit = new TTUSAPI.DataObjects.AccountGroupProductLimitProfile(); //Create new Product Limit

                                        //Assign values to product limit from update file object
                                        productLimit.GatewayID             = gwPC.Gateway.GatewayID;
                                        productLimit.Product               = prod.Name;
                                        productLimit.ProductTypeID         = 1; // Insert for Futures
                                        productLimit.MaxOutrightsOrderQty  = 1;
                                        productLimit.MaxSpreadsOrderQty    = 1;
                                        productLimit.AllowTradingOutrights = true;
                                        productLimit.AllowTradingSpreads   = true;

                                        //Add product limit to account group
                                        acctGroupProfile.AddProductLimit(productLimit);

                                        ResultStatus res = m_TTUSAPI.UpdateAccountGroup(acctGroupProfile); //Send updates to TTUS Server
                                        if (res.Result == ResultType.SentToServer)                         //On Success
                                        {
                                            UpdateStatusBar("Updated account Group; " + acctGroup.Name);
                                        }
                                        else if (res.Result == ResultType.ValuesUnchanged) //No Change
                                        {
                                            UpdateStatusBar("Account Group; " + acctGroup.Name + " unchanged");
                                        }
                                        else //On Failure
                                        {
                                            UpdateStatusBar("Failed to update account Group; " + acctGroup.Name + ", " + res.ErrorMessage);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }