コード例 #1
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public IList <BetfairE.AvailabilityInfo> GetDetailAvailableMktDepth(int exchangeId, int marketId, int selectionId)
        {
            BetfairE.BFExchangeService service = serviceExchanges[exchangeId];

            BetfairE.GetDetailedAvailableMktDepthReq detailReq = new BetfairE.GetDetailedAvailableMktDepthReq();
            detailReq.header      = headerExchange;
            detailReq.marketId    = marketId;
            detailReq.selectionId = selectionId;

            BetfairE.GetDetailedAvailableMktDepthResp detailResp = service.getDetailAvailableMktDepth(detailReq);
            ResetSessionToken(detailResp.header);

            if (detailResp.errorCode == BetfairE.GetDetailedAvailMktDepthErrorEnum.OK)
            {
                return(detailResp.priceItems);
            }
            else if (detailResp.errorCode == BetfairE.GetDetailedAvailMktDepthErrorEnum.NO_RESULTS)
            {
                return(new BetfairE.AvailabilityInfo[0]);
            }
            else if (ExchangeThrottleException.WasThrottled(detailResp))
            {
                throw new ExchangeThrottleException("getDetailAvailableMktDepth", detailResp);
            }
            else
            {
                throw new ExchangeException("getDetailAvailableMktDepth", detailResp);
            }
        }
コード例 #2
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public IList <BetfairE.PlaceBetsResult> PlaceBets(int exchangeId, IEnumerable <BetfairE.PlaceBets> bets)
        {
            if (IsExchangeLocked(exchangeId))
            {
                throw new ExchangeException("placeBets", string.Format("Exchange {0} is locked for placement ({1}.LockExchange has been called)", exchangeId, GetType().FullName), null);
            }
            BetfairE.BFExchangeService service = serviceExchanges[exchangeId];

            BetfairE.PlaceBetsReq placeBetsReq = new BetfairE.PlaceBetsReq();
            placeBetsReq.header = headerExchange;
            placeBetsReq.bets   = new List <BetfairE.PlaceBets>(bets).ToArray();

            BetfairE.PlaceBetsResp placeBetsResp = service.placeBets(placeBetsReq);
            ResetSessionToken(placeBetsResp.header);

            if (placeBetsResp.errorCode != BetfairE.PlaceBetsErrorEnum.OK)
            {
                if (ExchangeThrottleException.WasThrottled(placeBetsResp))
                {
                    throw new ExchangeThrottleException("placeBets", placeBetsResp);
                }
                else
                {
                    throw new ExchangeException("placeBets", placeBetsResp);
                }
            }
            return(placeBetsResp.betResults);
        }
コード例 #3
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public BetfairE.MarketPrices GetMarketPrices(int exchangeId, int marketId)
        {
            BetfairE.BFExchangeService service = serviceExchanges[exchangeId];

            BetfairE.GetMarketPricesCompressedReq pricesReq = new BetfairE.GetMarketPricesCompressedReq();
            pricesReq.header       = headerExchange;
            pricesReq.currencyCode = currency;
            pricesReq.marketId     = marketId;

            BetfairE.GetMarketPricesCompressedResp pricesResp = service.getMarketPricesCompressed(pricesReq);
            ResetSessionToken(pricesResp.header);

            if (pricesResp.errorCode == BetfairE.GetMarketPricesErrorEnum.OK)
            {
                return(DecompressMarketPrices(pricesResp.marketPrices));
            }
            else if (ExchangeThrottleException.WasThrottled(pricesResp))
            {
                throw new ExchangeThrottleException("getMarketPricesCompressed", pricesResp);
            }
            else
            {
                throw new ExchangeException("getMarketPricesCompressed", pricesResp);
            }
        }
コード例 #4
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public IList <BetfairE.VolumeInfo> GetMarketTradedVolume(int exchangeId, int marketId, int selectionId)
        {
            BetfairE.BFExchangeService service = serviceExchanges[exchangeId];

            BetfairE.GetMarketTradedVolumeReq volumeReq = new BetfairE.GetMarketTradedVolumeReq();
            volumeReq.header       = headerExchange;
            volumeReq.currencyCode = currency;
            volumeReq.marketId     = marketId;
            volumeReq.selectionId  = selectionId;
            volumeReq.asianLineId  = 0;

            BetfairE.GetMarketTradedVolumeResp volumeResp = service.getMarketTradedVolume(volumeReq);
            ResetSessionToken(volumeResp.header);

            if (volumeResp.errorCode == BetfairE.GetMarketTradedVolumeErrorEnum.OK)
            {
                return(volumeResp.priceItems);
            }
            else if (volumeResp.errorCode == BetfairE.GetMarketTradedVolumeErrorEnum.NO_RESULTS)
            {
                return(new BetfairE.VolumeInfo[0]);
            }
            else if (ExchangeThrottleException.WasThrottled(volumeResp))
            {
                throw new ExchangeThrottleException("getMarketTradedVolume", volumeResp);
            }
            else
            {
                throw new ExchangeException("getMarketTradedVolume", volumeResp);
            }
        }
コード例 #5
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public BetfairE.Market GetMarket(int exchangeId, int marketId)
        {
            BetfairE.BFExchangeService service = serviceExchanges[exchangeId];

            BetfairE.GetMarketReq marketReq = new BetfairE.GetMarketReq();
            marketReq.header             = headerExchange;
            marketReq.marketId           = marketId;
            marketReq.locale             = string.Empty;
            marketReq.includeCouponLinks = false;

            BetfairE.GetMarketResp marketResp = service.getMarket(marketReq);
            ResetSessionToken(marketResp.header);

            if (marketResp.errorCode == BetfairE.GetMarketErrorEnum.OK)
            {
                return(marketResp.market);
            }
            else if (ExchangeThrottleException.WasThrottled(marketResp))
            {
                throw new ExchangeThrottleException("getMarket", marketResp);
            }
            else
            {
                throw new ExchangeException("getMarket", marketResp);
            }
        }
コード例 #6
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public EventInfo GetEvents(int eventId)
        {
            EventInfo info = new EventInfo();

            BetfairG.GetEventsReq eventsReq = new BetfairG.GetEventsReq();
            eventsReq.header        = headerGlobal;
            eventsReq.eventParentId = eventId;

            BetfairG.GetEventsResp eventsResp = serviceGlobal.getEvents(eventsReq);
            ResetSessionToken(eventsResp.header);

            if (eventsResp.errorCode == BetfairG.GetEventsErrorEnum.OK)
            {
                info.Events           = eventsResp.eventItems;
                info.MarketsSummaries = eventsResp.marketItems;
                return(info);
            }
            else if (eventsResp.errorCode == BetfairG.GetEventsErrorEnum.NO_RESULTS)
            {
                info.Events           = new BetfairG.BFEvent[0];
                info.MarketsSummaries = new BetfairG.MarketSummary[0];
                return(info);
            }
            else if (ExchangeThrottleException.WasThrottled(eventsResp))
            {
                throw new ExchangeThrottleException("getEvents", eventsResp);
            }
            else
            {
                throw new ExchangeException("getEvents", eventsResp);
            }
        }
コード例 #7
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public IList <BetfairG.EventType> GetAllEventTypes()
        {
            BetfairG.GetEventTypesReq eventTypesReq = new BetfairG.GetEventTypesReq();
            eventTypesReq.header = headerGlobal;

            BetfairG.GetEventTypesResp eventTypesResp = serviceGlobal.getAllEventTypes(eventTypesReq);
            ResetSessionToken(eventTypesResp.header);

            if (eventTypesResp.errorCode == BetfairG.GetEventsErrorEnum.OK)
            {
                return(eventTypesResp.eventTypeItems);
            }
            else if (eventTypesResp.errorCode == BetfairG.GetEventsErrorEnum.NO_RESULTS)
            {
                return(new BetfairG.EventType[0]);
            }
            else if (ExchangeThrottleException.WasThrottled(eventTypesResp))
            {
                throw new ExchangeThrottleException("getAllEventTypes", eventTypesResp);
            }
            else
            {
                throw new ExchangeException("getAllEventTypes", eventTypesResp);
            }
        }
コード例 #8
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public IList <BetfairE.Bet> GetCurrentBets(
            int exchangeId, int marketId, BetfairE.BetStatusEnum status,
            BetfairE.BetsOrderByEnum orderBy, ref int record, int records)
        {
            BetfairE.BFExchangeService service = serviceExchanges[exchangeId];

            BetfairE.GetCurrentBetsReq betsReq = new BetfairE.GetCurrentBetsReq();
            betsReq.header             = headerExchange;
            betsReq.marketId           = marketId;
            betsReq.betStatus          = status;
            betsReq.detailed           = true;
            betsReq.orderBy            = orderBy;
            betsReq.recordCount        = records;
            betsReq.startRecord        = record;
            betsReq.noTotalRecordCount = true;

            BetfairE.GetCurrentBetsResp betsResp = service.getCurrentBets(betsReq);
            ResetSessionToken(betsResp.header);

            if (betsResp.errorCode == BetfairE.GetCurrentBetsErrorEnum.OK)
            {
                record = (betsResp.bets.Length < records) ? 0 : (record + records);
                return(betsResp.bets);
            }
            else if (betsResp.errorCode == BetfairE.GetCurrentBetsErrorEnum.INVALID_START_RECORD)
            {
                record = 0;
                return(new BetfairE.Bet[0]);
            }
            else if (betsResp.errorCode == BetfairE.GetCurrentBetsErrorEnum.NO_RESULTS)
            {
                record = 0;
                return(new BetfairE.Bet[0]);
            }
            else if (ExchangeThrottleException.WasThrottled(betsResp))
            {
                throw new ExchangeThrottleException("getCurrentBets", betsResp);
            }
            else
            {
                record = 0;
                throw new ExchangeException("getCurrentBets", betsResp);
            }
        }
コード例 #9
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public void Logout()
        {
            BetfairG.LogoutReq logoutReq = new BetfairG.LogoutReq();
            logoutReq.header = headerGlobal;

            BetfairG.LogoutResp logoutResp = serviceGlobal.logout(logoutReq);
            ResetSessionToken(logoutResp.header);

            if (logoutResp.errorCode == BetfairG.LogoutErrorEnum.OK)
            {
                headerGlobal.sessionToken   = null;
                headerExchange.sessionToken = null;
            }
            else if (ExchangeThrottleException.WasThrottled(logoutResp))
            {
                throw new ExchangeThrottleException("logout", logoutResp);
            }
            else
            {
                throw new ExchangeException("logout", logoutResp);
            }
        }
コード例 #10
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public void Login(string username, string password)
        {
            BetfairG.LoginReq loginReq = new BetfairG.LoginReq();
            loginReq.username  = username;
            loginReq.password  = password;
            loginReq.productId = 82;

            BetfairG.LoginResp loginResp = serviceGlobal.login(loginReq);
            ResetSessionToken(loginResp.header);

            if (loginResp.errorCode == BetfairG.LoginErrorEnum.OK)
            {
                currency = loginResp.currency;
            }
            else if (ExchangeThrottleException.WasThrottled(loginResp))
            {
                throw new ExchangeThrottleException("login", loginResp);
            }
            else
            {
                throw new ExchangeException("login", loginResp);
            }
        }
コード例 #11
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public IList <BetfairE.CancelBetsResult> CancelBets(int exchangeId, IList <BetfairE.CancelBets> bets)
        {
            BetfairE.BFExchangeService service = serviceExchanges[exchangeId];

            BetfairE.CancelBetsReq cancelBetsReq = new BetfairE.CancelBetsReq();
            cancelBetsReq.header = headerExchange;
            cancelBetsReq.bets   = new List <BetfairE.CancelBets>(bets).ToArray();

            BetfairE.CancelBetsResp cancelBetsResp = service.cancelBets(cancelBetsReq);
            ResetSessionToken(cancelBetsResp.header);

            if (cancelBetsResp.errorCode != BetfairE.CancelBetsErrorEnum.OK)
            {
                if (ExchangeThrottleException.WasThrottled(cancelBetsResp))
                {
                    throw new ExchangeThrottleException("cancelBets", cancelBetsResp);
                }
                else
                {
                    throw new ExchangeException("cancelBets", cancelBetsResp);
                }
            }
            return(cancelBetsResp.betResults);
        }
コード例 #12
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public IList <BetfairE.UpdateBetsResult> UpdateBets(int exchangeId, IEnumerable <BetfairE.UpdateBets> bets)
        {
            BetfairE.BFExchangeService service = serviceExchanges[exchangeId];

            BetfairE.UpdateBetsReq updateBetsReq = new BetfairE.UpdateBetsReq();
            updateBetsReq.header = headerExchange;
            updateBetsReq.bets   = new List <BetfairE.UpdateBets>(bets).ToArray();

            BetfairE.UpdateBetsResp updateBetsResp = service.updateBets(updateBetsReq);
            ResetSessionToken(updateBetsResp.header);

            if (updateBetsResp.errorCode != BetfairE.UpdateBetsErrorEnum.OK)
            {
                if (ExchangeThrottleException.WasThrottled(updateBetsResp))
                {
                    throw new ExchangeThrottleException("updateBets", updateBetsResp);
                }
                else
                {
                    throw new ExchangeException("updateBets", updateBetsResp);
                }
            }
            return(updateBetsResp.betResults);
        }
コード例 #13
0
ファイル: Exchange.cs プロジェクト: w1r2p1/BetFairBot-1
        public IList <BetfairE.Bet> GetBetHistory(
            int exchangeId, int marketId, BetfairE.BetStatusEnum status,
            DateTime from, DateTime to,
            ICollection <int> eventTypeIds, ICollection <BetfairE.MarketTypeEnum> marketTypes,
            BetfairE.BetsOrderByEnum orderBy, ref int record, int records)
        {
            int?[] nullableEventTypeIds = null;
            if (eventTypeIds != null)
            {
                int index = 0;
                nullableEventTypeIds = new int?[eventTypeIds.Count];
                foreach (int eventTypeId in eventTypeIds)
                {
                    nullableEventTypeIds[index++] = eventTypeId;
                }
            }

            BetfairE.MarketTypeEnum?[] nullableMarketTypes = null;
            if (marketTypes != null)
            {
                int index = 0;
                nullableMarketTypes = new BetfairE.MarketTypeEnum?[marketTypes.Count];
                foreach (BetfairE.MarketTypeEnum marketType in marketTypes)
                {
                    nullableMarketTypes[index++] = marketType;
                }
            }

            BetfairE.BFExchangeService service = serviceExchanges[exchangeId];

            BetfairE.GetBetHistoryReq betsReq = new BetfairE.GetBetHistoryReq();
            betsReq.header              = headerExchange;
            betsReq.detailed            = true;
            betsReq.marketId            = marketId;
            betsReq.betTypesIncluded    = status;
            betsReq.placedDateFrom      = from;
            betsReq.placedDateTo        = to;
            betsReq.eventTypeIds        = nullableEventTypeIds;
            betsReq.marketTypesIncluded = nullableMarketTypes;
            betsReq.sortBetsBy          = orderBy;
            betsReq.recordCount         = records;
            betsReq.startRecord         = record;

            BetfairE.GetBetHistoryResp betsResp = service.getBetHistory(betsReq);
            ResetSessionToken(betsResp.header);

            if (betsResp.errorCode == BetfairE.GetBetHistoryErrorEnum.OK)
            {
                record = (betsResp.betHistoryItems.Length < records) ? 0 : (record + records);
                return(betsResp.betHistoryItems);
            }
            else if (betsResp.errorCode == BetfairE.GetBetHistoryErrorEnum.INVALID_START_RECORD)
            {
                record = 0;
                return(new BetfairE.Bet[0]);
            }
            else if (betsResp.errorCode == BetfairE.GetBetHistoryErrorEnum.NO_RESULTS)
            {
                record = 0;
                return(new BetfairE.Bet[0]);
            }
            else if (ExchangeThrottleException.WasThrottled(betsResp))
            {
                throw new ExchangeThrottleException("getBetHistory", betsResp);
            }
            else
            {
                record = 0;
                throw new ExchangeException("getBetHistory", betsResp);
            }
        }