Exemplo n.º 1
0
        public OrderObject prepareParamsFromLoginRules(string instrument)
        {
            OrderObject              orderObject = new OrderObject();
            O2GLoginRules            loginRules  = _session.Session.getLoginRules();
            O2GResponseReaderFactory factory     = _session.Session.getResponseReaderFactory();
            // Gets first account from login.
            O2GResponse accountsResponse = loginRules.getTableRefeshResponse(O2GTable.Accounts);
            O2GAccountsTableResponseReader accountsReader = factory.createAccountsTableReader(accountsResponse);
            O2GAccountRow account = accountsReader.getRow(0);

            orderObject.AccountID = account.AccountID;
            // Store base iAmount
            orderObject.BaseAmount = account.BaseUnitSize;

            O2GResponse offerResponse = loginRules.getTableRefeshResponse(O2GTable.Offers);
            O2GOffersTableResponseReader offersReader = factory.createOffersTableReader(offerResponse);

            for (int i = 0; i < offersReader.Count; i++)
            {
                O2GOfferRow offer = offersReader.getRow(i);
                if (instrument.Equals(offer.Instrument))
                {
                    orderObject.OfferID   = offer.OfferID;
                    orderObject.Ask       = offer.Ask;
                    orderObject.Bid       = offer.Bid;
                    orderObject.PointSize = offer.PointSize;
                    orderObject.Symbol    = new Symbol(instrument);
                    break;
                }
            }

            return(orderObject);
        }
Exemplo n.º 2
0
        public bool ExistsPositionFor(string symbol)
        {
            O2GResponseReaderFactory factory = session.Session.getResponseReaderFactory();
            // Gets first account from login.
            O2GLoginRules loginRules = session.Session.getLoginRules();
            O2GResponse   response   = loginRules.getTableRefeshResponse(O2GTable.ClosedTrades);

            O2GTradesTableResponseReader tradesReader = factory.createTradesTableReader(response);

            for (int i = 0; i < tradesReader.Count; i++)
            {
                O2GTradeRow tradeRow = tradesReader.getRow(i);
                Console.WriteLine("Trades---");
                Console.WriteLine(tradeRow.OpenQuoteID);
                Console.WriteLine(tradeRow.OfferID);
            }

            return(false);
        }