Exemplo n.º 1
0
        private static void ConditionSamples(EClientSocket client, int nextOrderId)
        {
            //! [order_conditioning_activate]
            Order mkt = OrderSamples.MarketOrder("BUY", 100);

            //Order will become active if conditioning criteria is met
            mkt.ConditionsCancelOrder = true;
            mkt.Conditions.Add(OrderSamples.PriceCondition(208813720, "SMART", 600, false, false));
            mkt.Conditions.Add(OrderSamples.ExecutionCondition("EUR.USD", "CASH", "IDEALPRO", true));
            mkt.Conditions.Add(OrderSamples.MarginCondition(30, true, false));
            mkt.Conditions.Add(OrderSamples.PercentageChangeCondition(15.0, 208813720, "SMART", true, true));
            mkt.Conditions.Add(OrderSamples.TimeCondition("20160118 23:59:59", true, false));
            mkt.Conditions.Add(OrderSamples.VolumeCondition(208813720, "SMART", false, 100, true));
            client.placeOrder(nextOrderId++, ContractSamples.EuropeanStock(), mkt);
            //! [order_conditioning_activate]

            //Conditions can make the order active or cancel it. Only LMT orders can be conditionally canceled.
            //! [order_conditioning_cancel]
            Order lmt = OrderSamples.LimitOrder("BUY", 100, 20);

            //The active order will be cancelled if conditioning criteria is met
            lmt.ConditionsCancelOrder = true;
            lmt.Conditions.Add(OrderSamples.PriceCondition(208813720, "SMART", 600, false, false));
            client.placeOrder(nextOrderId++, ContractSamples.EuropeanStock(), lmt);
            //! [order_conditioning_cancel]
        }
Exemplo n.º 2
0
        private static void marketDepthOperations(EClientSocket client)
        {
            /*** Requesting the Deep Book ***/
            //! [reqmarketdepth]
            client.reqMarketDepth(2001, ContractSamples.EurGbpFx(), 5, false, null);
            //! [reqmarketdepth]
            Thread.Sleep(2000);
            /*** Canceling the Deep Book request ***/
            //! [cancelmktdepth]
            client.cancelMktDepth(2001, false);
            //! [cancelmktdepth]

            /*** Requesting the Deep Book ***/
            //! [reqmarketdepth]
            client.reqMarketDepth(2002, ContractSamples.EuropeanStock(), 5, true, null);
            //! [reqmarketdepth]
            Thread.Sleep(5000);
            /*** Canceling the Deep Book request ***/
            //! [cancelmktdepth]
            client.cancelMktDepth(2002, true);
            //! [cancelmktdepth]

            /*** Requesting Market Depth Exchanges ***/
            Thread.Sleep(2000);
            //! [reqMktDepthExchanges]
            client.reqMktDepthExchanges();
            //! [reqMktDepthExchanges]
        }
Exemplo n.º 3
0
        private static void newsOperations(EClientSocket client)
        {
            /*** Requesting news ticks ***/
            //! [reqNewsTicks]
            client.reqMktData(12001, ContractSamples.USStockAtSmart(), "mdoff,292", false, false, null);
            //! [reqNewsTicks]

            Thread.Sleep(5000);

            /*** Canceling news ticks ***/
            //! [cancelNewsTicks]
            client.cancelMktData(12001);
            //! [cancelNewsTicks]

            // Requesting news providers
            Thread.Sleep(2000);
            //! [reqNewsProviders]
            client.reqNewsProviders();
            //! [reqNewsProviders]

            // Requesting news article
            Thread.Sleep(2000);
            //! [reqNewsArticle]
            client.reqNewsArticle(12002, "BZ", "BZ$04507322", null);
            //! [reqNewsArticle]

            // Requesting historical news
            Thread.Sleep(2000);
            //! [reqHistoricalNews]
            client.reqHistoricalNews(12003, 8314, "BZ+FLY", "", "", 10, null);
            //! [reqHistoricalNews]
        }
Exemplo n.º 4
0
 private static void whatIfSamples(EClientSocket client, int nextOrderId)
 {
     /*** Placing what-if order ***/
     //! [whatiforder]
     client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), OrderSamples.WhatIfLimitOrder("BUY", 200, 120));
     //! [whatiforder]
 }
Exemplo n.º 5
0
        private static void TestAlgoSamples(EClientSocket client, int nextOrderId)
        {
            //! [algo_base_order]
            Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);

            //! [algo_base_order]

            //! [arrivalpx]
            AvailableAlgoParams.FillArrivalPriceParams(baseOrder, 0.1, "Aggressive", "09:00:00 CET", "16:00:00 CET", true, true);
            client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
            //! [arrivalpx]

            Thread.Sleep(500);

            //! [darkice]
            AvailableAlgoParams.FillDarkIceParams(baseOrder, 10, "09:00:00 CET", "16:00:00 CET", true);
            client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
            //! [darkice]

            Thread.Sleep(500);

            //! [ad]
            AvailableAlgoParams.FillAccumulateDistributeParams(baseOrder, 10, 60, true, true, 1, true, true, "09:00:00 CET", "16:00:00 CET");
            client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
            //! [ad]

            Thread.Sleep(500);

            //! [twap]
            AvailableAlgoParams.FillTwapParams(baseOrder, "Marketable", "09:00:00 CET", "16:00:00 CET", true);
            client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
            //! [twap]

            Thread.Sleep(500);

            //! [vwap]
            AvailableAlgoParams.FillVwapParams(baseOrder, 0.2, "09:00:00 CET", "16:00:00 CET", true, true);
            client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
            //! [vwap]

            Thread.Sleep(500);

            //! [balanceimpactrisk]
            AvailableAlgoParams.FillBalanceImpactRiskParams(baseOrder, 0.1, "Aggressive", true);
            client.placeOrder(nextOrderId++, ContractSamples.USOptionContract(), baseOrder);
            //! [balanceimpactrisk]

            Thread.Sleep(500);

            //! [minimpact]
            AvailableAlgoParams.FillMinImpactParams(baseOrder, 0.3);
            client.placeOrder(nextOrderId++, ContractSamples.USOptionContract(), baseOrder);
            //! [minimpact]

            //! [adaptive]
            AvailableAlgoParams.FillAdaptiveParams(baseOrder, "Normal");
            client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
            //! [adaptive]
        }
Exemplo n.º 6
0
 private static void contractOperations(EClientSocket client)
 {
     client.reqContractDetails(209, ContractSamples.EurGbpFx());
     Thread.Sleep(2000);
     //! [reqcontractdetails]
     client.reqContractDetails(210, ContractSamples.OptionForQuery());
     //! [reqcontractdetails]
 }
Exemplo n.º 7
0
 private static void historicalTicks(EClientSocket client)
 {
     //! [reqhistoricalticks]
     client.reqHistoricalTicks(18001, ContractSamples.USStockAtSmart(), "20170712 21:39:33", null, 10, "TRADES", 1, true, null);
     client.reqHistoricalTicks(18002, ContractSamples.USStockAtSmart(), "20170712 21:39:33", null, 10, "BID_ASK", 1, true, null);
     client.reqHistoricalTicks(18003, ContractSamples.USStockAtSmart(), "20170712 21:39:33", null, 10, "MIDPOINT", 1, true, null);
     //! [reqhistoricalticks]
 }
Exemplo n.º 8
0
 private static void histogramData(EClientSocket client)
 {
     //! [reqHistogramData]
     client.reqHistogramData(15001, ContractSamples.USStockWithPrimaryExch(), false, "1 week");
     //! [reqHistogramData]
     Thread.Sleep(2000);
     //! [cancelHistogramData]
     client.cancelHistogramData(15001);
     //! [cancelHistogramData]
 }
Exemplo n.º 9
0
 private static void headTimestamp(EClientSocket client)
 {
     //! [reqHeadTimeStamp]
     client.reqHeadTimestamp(14001, ContractSamples.USStock(), "TRADES", 1, 1);
     //! [reqHeadTimeStamp]
     Thread.Sleep(1000);
     //! [cancelHeadTimestamp]
     client.cancelHeadTimestamp(14001);
     //! [cancelHeadTimestamp]
 }
Exemplo n.º 10
0
        private static void BracketSample(EClientSocket client, int nextOrderId)
        {
            //BRACKET ORDER
            //! [bracketsubmit]
            List <Order> bracket = OrderSamples.BracketOrder(nextOrderId++, "BUY", 100, 30, 40, 20);

            foreach (Order o in bracket)
            {
                client.placeOrder(o.OrderId, ContractSamples.EuropeanStock(), o);
            }
            //! [bracketsubmit]
        }
Exemplo n.º 11
0
        private static void marketRuleOperations(EClientSocket client)
        {
            client.reqContractDetails(17001, ContractSamples.USStock());
            client.reqContractDetails(17002, ContractSamples.Bond());

            Thread.Sleep(2000);

            //! [reqmarketrule]
            client.reqMarketRule(26);
            client.reqMarketRule(240);
            //! [reqmarketrule]
        }
Exemplo n.º 12
0
 private static void fundamentals(EClientSocket client)
 {
     /*** Requesting Fundamentals ***/
     //! [reqfundamentaldata]
     client.reqFundamentalData(8001, ContractSamples.USStock(), "ReportsFinSummary", null);
     //! [reqfundamentaldata]
     Thread.Sleep(2000);
     /*** Canceling fundamentals request ***/
     //! [cancelfundamentaldata]
     client.cancelFundamentalData(8001);
     //! [cancelfundamentaldata]
 }
Exemplo n.º 13
0
 private static void marketDepthOperations(EClientSocket client)
 {
     /*** Requesting the Deep Book ***/
     //! [reqmarketdepth]
     client.reqMarketDepth(2001, ContractSamples.EurGbpFx(), 5, null);
     //! [reqmarketdepth]
     Thread.Sleep(2000);
     /*** Canceling the Deep Book request ***/
     //! [cancelmktdepth]
     client.cancelMktDepth(2001);
     //! [cancelmktdepth]
 }
Exemplo n.º 14
0
 private static void realTimeBars(EClientSocket client)
 {
     /*** Requesting real time bars ***/
     //! [reqrealtimebars]
     client.reqRealTimeBars(3001, ContractSamples.EurGbpFx(), 5, "MIDPOINT", true, null);
     //! [reqrealtimebars]
     Thread.Sleep(2000);
     /*** Canceling real time bars ***/
     //! [cancelrealtimebars]
     client.cancelRealTimeBars(3001);
     //! [cancelrealtimebars]
 }
Exemplo n.º 15
0
        private static void continuousFuturesOperations(EClientSocket client)
        {
            client.reqContractDetails(18001, ContractSamples.ContFut());

            //! [reqhistoricaldatacontfut]
            String queryTime = DateTime.Now.ToString("yyyyMMdd HH:mm:ss");

            client.reqHistoricalData(18002, ContractSamples.ContFut(), queryTime, "1 Y", "1 month", "TRADES", 0, 1, false, null);
            Thread.Sleep(10000);
            client.cancelHistoricalData(18002);
            //! [reqhistoricaldatacontfut]
        }
Exemplo n.º 16
0
        private static void contractOperations(EClientSocket client)
        {
            //! [reqcontractdetails]
            client.reqContractDetails(209, ContractSamples.OptionForQuery());
            client.reqContractDetails(210, ContractSamples.EurGbpFx());
            client.reqContractDetails(211, ContractSamples.Bond());
            client.reqContractDetails(212, ContractSamples.FuturesOnOptions());
            //! [reqcontractdetails]

            Thread.Sleep(2000);
            //! [reqmatchingsymbols]
            client.reqMatchingSymbols(211, "IB");
            //! [reqmatchingsymbols]
        }
Exemplo n.º 17
0
        private static void historicalDataRequests(EClientSocket client)
        {
            /*** Requesting historical data ***/
            //! [reqhistoricaldata]
            String queryTime = DateTime.Now.AddMonths(-6).ToString("yyyyMMdd HH:mm:ss");

            client.reqHistoricalData(4001, ContractSamples.EurGbpFx(), queryTime, "1 M", "1 day", "MIDPOINT", 1, 1, false, null);
            client.reqHistoricalData(4002, ContractSamples.EuropeanStock(), queryTime, "10 D", "1 min", "TRADES", 1, 1, false, null);
            //! [reqhistoricaldata]
            Thread.Sleep(2000);
            /*** Canceling historical data requests ***/
            client.cancelHistoricalData(4001);
            client.cancelHistoricalData(4002);
        }
Exemplo n.º 18
0
        private static void tickOptionComputationOperations(EClientSocket client)
        {
            /*** Requesting real time market data ***/
            //! [reqmktdata]
            client.reqMktData(2001, ContractSamples.FuturesOnOptions(), string.Empty, false, false, null);
            //! [reqmktdata]

            Thread.Sleep(10000);

            /*** Canceling the market data subscription ***/
            //! [cancelmktdata]
            client.cancelMktData(2001);
            //! [cancelmktdata]
        }
Exemplo n.º 19
0
        private static void smartComponents(EClientSocket client)
        {
            client.reqMktData(13001, ContractSamples.USStockAtSmart(), "", false, false, null);

            while (string.IsNullOrWhiteSpace(testImpl.BboExchange))
            {
                Thread.Sleep(1000);
            }

            client.cancelMktData(13001);
            //! [reqsmartcomponents]
            client.reqSmartComponents(13002, testImpl.BboExchange);
            //! [reqsmartcomponents]
        }
Exemplo n.º 20
0
        private static void OcaSample(EClientSocket client, int nextOrderId)
        {
            //OCA ORDER
            //! [ocasubmit]
            List <Order> ocaOrders = new List <Order>();

            ocaOrders.Add(OrderSamples.LimitOrder("BUY", 1, 10));
            ocaOrders.Add(OrderSamples.LimitOrder("BUY", 1, 11));
            ocaOrders.Add(OrderSamples.LimitOrder("BUY", 1, 12));
            OrderSamples.OneCancelsAll("TestOCA_" + nextOrderId, ocaOrders, 2);
            foreach (Order o in ocaOrders)
            {
                client.placeOrder(nextOrderId++, ContractSamples.USStock(), o);
            }
            //! [ocasubmit]
        }
Exemplo n.º 21
0
        private static void HedgeSample(EClientSocket client, int nextOrderId)
        {
            //F Hedge order
            //! [hedgesubmit]
            //Parent order on a contract which currency differs from your base currency
            Order parent = OrderSamples.LimitOrder("BUY", 100, 10);

            parent.OrderId = nextOrderId++;
            //Hedge on the currency conversion
            Order hedge = OrderSamples.MarketFHedge(parent.OrderId, "BUY");

            //Place the parent first...
            client.placeOrder(parent.OrderId, ContractSamples.EuropeanStock(), parent);
            //Then the hedge order
            client.placeOrder(nextOrderId++, ContractSamples.EurGbpFx(), hedge);
            //! [hedgesubmit]
        }
Exemplo n.º 22
0
        private static void testConnectDisconnect(EWrapperImpl wrapper)
        {
            //Order order = OrderSamples.LimitOrder();
            //Contract contract = ContractSamples.getOption();

            //wrapper.ClientSocket.reqMktData(1, ContractSamples.getOption(), "", false);
            //wrapper.ClientSocket.reqMktData(3, ContractSamples.getEuropeanStock(), "", false);
            //wrapper.ClientSocket.reqGlobalCancel();
            //wrapper.ClientSocket.reqCurrentTime();
            //wrapper.ClientSocket.reqMktData(1, ContractSamples.getForex(), "", false);
            //wrapper.ClientSocket.calculateImpliedVolatility(2, ContractSamples.getOption(), 10, 345);
            //wrapper.ClientSocket.calculateOptionPrice(3, ContractSamples.getOption(), 4.69, 345);
            //wrapper.ClientSocket.reqAccountSummary(1, "All", AccountSummaryTags.GetAllTags());
            //wrapper.ClientSocket.reqAccountUpdates(true, "DU150462");
            //wrapper.ClientSocket.reqAllOpenOrders();
            //wrapper.ClientSocket.reqAutoOpenOrders(true);
            //wrapper.ClientSocket.reqOpenOrders();
            //wrapper.ClientSocket.placeOrder(wrapper.NextOrderId, ContractSamples.getForex(), order);

            wrapper.ClientSocket.placeOrder(wrapper.NextOrderId, ContractSamples.getComboContract(), OrderSamples.LimitOrderForComboWithLegPrice());

            //wrapper.ClientSocket.reqContractDetails(1, ContractSamples.getForex());
            //wrapper.ClientSocket.reqExecutions(1, new ExecutionFilter());
            //wrapper.ClientSocket.reqMktData(2, ContractSamples.getForex(), "", false);
            //wrapper.ClientSocket.reqFundamentalData(1, ContractSamples.getEuropeanStock(), "snapshot");
            //wrapper.ClientSocket.reqHistoricalData(1, ContractSamples.getEurUsdForex(), "20130722 23:59:59", "1 D", "1 hour", "MIDPOINT", 1, 1);
            //wrapper.ClientSocket.cancelHistoricalData(1);
            //wrapper.ClientSocket.reqFundamentalData(2, ContractSamples.getEuropeanStock(), "snapshot");
            //wrapper.ClientSocket.reqIds(-1);
            //wrapper.ClientSocket.reqManagedAccts();
            //wrapper.ClientSocket.reqMarketDataType(1);
            //wrapper.ClientSocket.reqMarketDepth(1, ContractSamples.getForex(), 5);
            //wrapper.ClientSocket.reqNewsBulletins(true);
            //wrapper.ClientSocket.reqPositions();
            //wrapper.ClientSocket.reqRealTimeBars(1, ContractSamples.getForex(), -1, "MIDPOINT", true);
            //wrapper.ClientSocket.reqScannerParameters();
            //wrapper.ClientSocket.exerciseOptions(1, ContractSamples.getOption(), 1, 20, null, 1);
            //wrapper.ClientSocket.reqScannerSubscription(1, GetScannerSubscription());
            //wrapper.ClientSocket.requestFA(Constants.FaProfiles);

            //NOT WORKING (ALSO CHECKED WITH JAVA 969)
            wrapper.ClientSocket.setServerLogLevel(1);
            Thread.Sleep(500000);
        }
Exemplo n.º 23
0
        private static void tickByTickOperations(EClientSocket client)
        {
            /*** Requesting tick-by-tick data (only refresh) ***/
            //! [reqtickbytick]
            client.reqTickByTickData(19001, ContractSamples.USStockAtSmart(), "Last");
            client.reqTickByTickData(19002, ContractSamples.USStockAtSmart(), "AllLast");
            client.reqTickByTickData(19003, ContractSamples.USStockAtSmart(), "BidAsk");
            client.reqTickByTickData(19004, ContractSamples.EurGbpFx(), "MidPoint");
            //! [reqtickbytick]

            Thread.Sleep(10000);

            //! [canceltickbytick]
            client.cancelTickByTickData(19001);
            client.cancelTickByTickData(19002);
            client.cancelTickByTickData(19003);
            client.cancelTickByTickData(19004);
            //! [canceltickbytick]
        }
Exemplo n.º 24
0
        private static void tickDataOperations(EClientSocket client)
        {
            /*** Requesting real time market data ***/
            //Thread.Sleep(1000);
            //! [reqmktdata]
            client.reqMktData(1001, ContractSamples.StockComboContract(), string.Empty, false, null);
            //! [reqmktdata]
            //! [reqmktdata_snapshot]
            client.reqMktData(1003, ContractSamples.FutureComboContract(), string.Empty, true, null);
            //! [reqmktdata_snapshot]

            //! [reqmktdata_genticks]
            //Requesting RTVolume (Time & Sales), shortable and Fundamental Ratios generic ticks
            client.reqMktData(1004, ContractSamples.USStock(), "233,236,258", false, null);
            //! [reqmktdata_genticks]

            //! [reqmktdata_contractnews]
            client.reqMktData(1005, ContractSamples.USStock(), "mdoff,292:BZ", false, null);
            client.reqMktData(1006, ContractSamples.USStock(), "mdoff,292:BT", false, null);
            client.reqMktData(1007, ContractSamples.USStock(), "mdoff,292:FLY", false, null);
            client.reqMktData(1008, ContractSamples.USStock(), "mdoff,292:MT", false, null);
            //! [reqmktdata_contractnews]
            //! [reqmktdata_broadtapenews]
            client.reqMktData(1009, ContractSamples.BTbroadtapeNewsFeed(), "mdoff,292", false, null);
            client.reqMktData(1010, ContractSamples.BZbroadtapeNewsFeed(), "mdoff,292", false, null);
            client.reqMktData(1011, ContractSamples.FLYbroadtapeNewsFeed(), "mdoff,292", false, null);
            client.reqMktData(1012, ContractSamples.MTbroadtapeNewsFeed(), "mdoff,292", false, null);
            //! [reqmktdata_broadtapenews]

            //! [reqoptiondatagenticks]
            //Requesting data for an option contract will return the greek values
            client.reqMktData(1002, ContractSamples.OptionWithLocalSymbol(), string.Empty, false, null);
            //! [reqoptiondatagenticks]

            Thread.Sleep(10000);
            /*** Canceling the market data subscription ***/
            //! [cancelmktdata]
            client.cancelMktData(1001);
            client.cancelMktData(1002);
            client.cancelMktData(1003);
            //! [cancelmktdata]
        }
Exemplo n.º 25
0
        private static void rerouteCFDOperations(EClientSocket client)
        {
            //! [reqmktdatacfd]
            client.reqMktData(16001, ContractSamples.USStockCFD(), string.Empty, false, false, null);
            Thread.Sleep(1000);
            client.reqMktData(16002, ContractSamples.EuropeanStockCFD(), string.Empty, false, false, null);
            Thread.Sleep(1000);
            client.reqMktData(16003, ContractSamples.CashCFD(), string.Empty, false, false, null);
            Thread.Sleep(1000);
            //! [reqmktdatacfd]

            //! [reqmktdepthcfd]
            client.reqMarketDepth(16004, ContractSamples.USStockCFD(), 10, false, null);
            Thread.Sleep(1000);
            client.reqMarketDepth(16005, ContractSamples.EuropeanStockCFD(), 10, false, null);
            Thread.Sleep(1000);
            client.reqMarketDepth(16006, ContractSamples.CashCFD(), 10, false, null);
            Thread.Sleep(1000);
            //! [reqmktdepthcfd]
        }
Exemplo n.º 26
0
        private static void historicalDataRequests(EClientSocket client)
        {
            //Console.WriteLine(account.Email);

            /*** Requesting historical data ***/
            //! [reqhistoricaldata]
            if (tradeConfig.Historical)
            {
                String queryTime = DateTime.Now.ToString("yyyyMMdd HH:mm:ss");
                foreach (StockConfig sc in tradeConfig.Stocks)
                {
                    client.reqHistoricalData(sc.Id, ContractSamples.GetContract(sc.Symbol), queryTime, "9 M", "1 min", "MIDPOINT", 1, 1, false, null);
                }
                //client.reqHistoricalData(1002, ContractSamples.USStock2(), queryTime, "9 M", "1 min", "MIDPOINT", 1, 1, false, null);
                //! [reqhistoricaldata]
                //Thread.Sleep(2000);
                /*** Canceling historical data requests ***/
                //client.cancelHistoricalData(1001);
            }
        }
Exemplo n.º 27
0
        private static void realTimeBars(EClientSocket client)
        {
            /*** Requesting real time bars ***/
            if (tradeConfig.Realtime)
            {
                #region Realtime with today's RSI
                String queryTime = DateTime.Now.ToString("yyyyMMdd HH:mm:ss");
                foreach (StockConfig sc in tradeConfig.Stocks)
                {
                    client.reqHistoricalData(sc.Id, ContractSamples.GetContract(sc.Symbol), queryTime, "1 D", "1 min", "MIDPOINT", 1, 1, false, null);
                }
                //client.reqHistoricalData(1001, ContractSamples.USStock(), queryTime, "1 D", "1 min", "MIDPOINT", 1, 1, false, null);
                Thread.Sleep(10000);
                //client.cancelHistoricalData(1001);
                foreach (StockConfig sc in tradeConfig.Stocks)
                {
                    client.reqRealTimeBars(sc.Id, ContractSamples.GetContract(sc.Symbol), 5, "MIDPOINT", true, null);
                }
                //client.reqRealTimeBars(1001, ContractSamples.USStock(), 5, "MIDPOINT", true, null);
                #endregion
            }
            if (tradeConfig.AfterRTH)
            {
                #region After RTH trading
                foreach (StockConfig sc in tradeConfig.Stocks)
                {
                    client.reqRealTimeBars(sc.Id, ContractSamples.GetContract(sc.Symbol), 5, "MIDPOINT", false, null);
                }
                //client.reqRealTimeBars(1001, ContractSamples.USStock(), 5, "MIDPOINT", false, null);
                #endregion
            }

            //client.reqRealTimeBars(1002, ContractSamples.USOptionContract2(), 5, "MIDPOINT", true, null);

            //! [reqrealtimebars]
            //Thread.Sleep(2000);
            /*** Canceling real time bars ***/
            //! [cancelrealtimebars]
            //client.cancelRealTimeBars(3001);
            //! [cancelrealtimebars]
        }
Exemplo n.º 28
0
        private static void tickByTickOperations(EClientSocket client)
        {
            /*** Requesting tick-by-tick data (only refresh) ***/
            //! [reqtickbytick]
            client.reqTickByTickData(19001, ContractSamples.USStockAtSmart(), "Last", 0, false);
            client.reqTickByTickData(19002, ContractSamples.USStockAtSmart(), "AllLast", 0, false);
            client.reqTickByTickData(19003, ContractSamples.USStockAtSmart(), "BidAsk", 0, true);
            client.reqTickByTickData(19004, ContractSamples.EurGbpFx(), "MidPoint", 0, false);
            //! [reqtickbytick]

            Thread.Sleep(10000);

            //! [canceltickbytick]
            client.cancelTickByTickData(19001);
            client.cancelTickByTickData(19002);
            client.cancelTickByTickData(19003);
            client.cancelTickByTickData(19004);
            //! [canceltickbytick]

            Thread.Sleep(5000);

            /*** Requesting tick-by-tick data (historical + refresh) ***/
            //! [reqtickbytick]
            client.reqTickByTickData(19005, ContractSamples.EuropeanStock(), "Last", 10, false);
            client.reqTickByTickData(19006, ContractSamples.EuropeanStock(), "AllLast", 10, false);
            client.reqTickByTickData(19007, ContractSamples.EuropeanStock(), "BidAsk", 10, false);
            client.reqTickByTickData(19008, ContractSamples.EurGbpFx(), "MidPoint", 10, true);
            //! [reqtickbytick]

            Thread.Sleep(10000);

            //! [canceltickbytick]
            client.cancelTickByTickData(19005);
            client.cancelTickByTickData(19006);
            client.cancelTickByTickData(19007);
            client.cancelTickByTickData(19008);
            //! [canceltickbytick]
        }
        public static int Main(string[] args)
        {
            RequestContractDetails testImpl = new RequestContractDetails();

            testImpl.ClientSocket.eConnect("127.0.0.1", 7496, 0);
            while (testImpl.NextOrderId <= 0)
            {
            }

            //We can request the whole option's chain by giving a brief description of the contract
            //i.e. we only specify symbol, currency, secType and exchange (SMART)
            Contract optionContract = ContractSamples.OptionForQuery();

            testImpl.ClientSocket.reqContractDetails(1, optionContract);

            while (!testImpl.isFinished)
            {
            }
            Thread.Sleep(10000);
            Console.WriteLine("Disconnecting...");
            testImpl.ClientSocket.eDisconnect();
            return(0);
        }
Exemplo n.º 30
0
        private static void optionsOperations(EClientSocket client)
        {
            //! [reqsecdefoptparams]
            client.reqSecDefOptParams(0, "IBM", "", "STK", 8314);
            //! [reqsecdefoptparams]

            /*** Calculating implied volatility ***/
            //! [calculateimpliedvolatility]
            client.calculateImpliedVolatility(5001, ContractSamples.OptionAtBOX(), 5, 85, null);
            //! [calculateimpliedvolatility]
            /*** Canceling implied volatility ***/
            client.cancelCalculateImpliedVolatility(5001);
            /*** Calculating option's price ***/
            //! [calculateoptionprice]
            client.calculateOptionPrice(5002, ContractSamples.OptionAtBOX(), 0.22, 85, null);
            //! [calculateoptionprice]
            /*** Canceling option's price calculation ***/
            client.cancelCalculateOptionPrice(5002);
            /*** Exercising options ***/
            //! [exercise_options]
            client.exerciseOptions(5003, ContractSamples.OptionWithTradingClass(), 1, 1, null, 1);
            //! [exercise_options]
        }