コード例 #1
0
ファイル: Bet.cs プロジェクト: qkostal/program
 /// <summary>
 /// Does the list contain the following Runner
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Contains(Bet item)
 {
     lock (List.SyncRoot)
     {
         return List.Contains(item);
     }
 }
コード例 #2
0
ファイル: Betfair.API.cs プロジェクト: sjdweb/lignite
        /// <summary>
        /// The API PlaceBets service allows you to place multiple (1 to 60) bets on
        /// a single Market. There is an instance of PlaceBetsResp returned in the
        /// output for each instance of PlaceBets in the input. The success or failure
        /// of the individual bet placement operation is indicated by the Success Boolean.
        /// Note: To bet on an event, you need to have sufficient funds available
        /// in the relevant local wallet to cover your entire liability. If you want
        /// to bet on the Australian exchange server and you do not have sufficient funds
        /// in your Australian wallet to cover the liability, you must first transfer funds
        /// into that wallet from your UK wallet by using the transferFunds service
        /// (see Chapter 56). Also, your wallet must be active
        /// (and not, for example, suspended for any reason) at the time you place the bet.
        /// </summary>
        /// <param name="bets">The bets.</param>
        /// <returns></returns>
        public List <Bet> PlaceBets(List <Bet> bets)
        {
            const string serviceName = "PlaceBets";

            Console.WriteLine("{0}$ API_SERVICE {1}", DateTime.Now, serviceName);

            var errorMessages = new List <string>();

            for (int x = 0; x < bets.Count; x++)
            {
                if (!bets[x].betRequestprocessed && bets[x].betId == 0)
                {
                    Bet bet     = bets[x];
                    var request = new PlaceBetsReq
                    {
                        header = ((BetfairExchangeAPI.APIRequestHeader)GetHeader(false)),
                        bets   = new PlaceBets[1]
                    };

                    request.bets[0] = new PlaceBets();

                    bets[x].betRequestprocessed = true;

                    request.bets[0].asianLineId = bet.asianLineId;

                    switch (bet.betCategory)
                    {
                    case BetCategoryOptions.EXCHANGE:
                        request.bets[0].betCategoryType = BetCategoryTypeEnum.E;
                        break;

                    case BetCategoryOptions.LIMIT_ON_CLOSE:
                        request.bets[0].betCategoryType = BetCategoryTypeEnum.L;
                        break;

                    default:
                        request.bets[0].betCategoryType = bet.betCategory == BetCategoryOptions.MARKET_ON_CLOSE ? BetCategoryTypeEnum.M : BetCategoryTypeEnum.NONE;
                        break;
                    }

                    switch (bet.betPersistence)
                    {
                    case BetPersistenceOptions.IN_PLAY_PERSISTENCE:
                        request.bets[0].betPersistenceType = BetPersistenceTypeEnum.IP;
                        break;

                    case BetPersistenceOptions.UNMATCHED_FILL_WITH_SP:
                        request.bets[0].betPersistenceType = BetPersistenceTypeEnum.SP;
                        break;

                    default:
                        request.bets[0].betPersistenceType = BetPersistenceTypeEnum.NONE;
                        break;
                    }

                    request.bets[0].betType = bet.betType == BetTypeOptions.L ? BetTypeEnum.L : BetTypeEnum.B;

                    request.bets[0].bspLiability = bet.bspLiability;
                    request.bets[0].marketId     = bet.marketId;
                    request.bets[0].price        = bet.price;
                    request.bets[0].selectionId  = bet.selectionId;
                    request.bets[0].size         = bet.size;

                    var response = _bfExchangeService[bet.exchangeId].placeBets(request);

                    if (response.betResults[0] != null && response.betResults[0].betId > 0)
                    {
                        bets[x].betId = response.betResults[0].betId;
                    }

                    try
                    {
                        bets[x].success             = response.betResults[0].success;
                        bets[x].systemBetCreateDate = DateTime.Now.ToUniversalTime();

                        ValidateAPIResponse(serviceName, Convert.ToString(response.header.errorCode),
                                            Convert.ToString(response.errorCode), response.header.sessionToken);

                        if (response.betResults[0].sizeMatched > 0)
                        {
                            bets[x].size = response.betResults[0].sizeMatched;
                        }

                        bets[x].customUserBetNote = response.betResults[0].resultCode.ToString();
                    }
                    catch (Exception ex)
                    {
                        errorMessages.Add(ex.Message);
                    }
                }
            }

            foreach (string message in errorMessages)
            {
                Console.WriteLine("{0}$ API_SERVICE {1} :{2} ", DateTime.Now, serviceName, message);
            }

            return(bets);
        }
コード例 #3
0
ファイル: Bet.cs プロジェクト: qkostal/program
 /// <summary>
 /// Add a Price to the IList
 /// </summary>
 /// <param name="item">The item.</param>
 public virtual void Add(Bet item)
 {
     lock (List.SyncRoot)
     {
         //forward our Add method on to
         //CollectionBase.IList.Add
         List.Add(item);
     }
 }
コード例 #4
0
ファイル: SelectionView.cs プロジェクト: qkostal/program
        /// <summary>
        /// Handles the MouseClick event of the selectionPriceButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void selectionPriceButton_MouseClick(object sender, EventArgs e)
        {
            if (sender.GetType() != typeof (SelectionPriceButton) || SelectionData == null) return;

            var button = ((SelectionPriceButton) sender);

            if(button.IsSpButton)
            {
                // todo: implement
            }
            else
            {
                var bet = new Bet
                              {
                                  betCategory = BetCategoryOptions.EXCHANGE,
                                  betPersistence = BetPersistenceOptions.NONE,
                                  betType = button.ButtonType,
                                  price = button.PriceItem.price,
                                  selectionId = SelectionData.selectionId,
                                  exchangeId = ExchangeId,
                                  marketId = MarketId,
                                  asianLineId = SelectionData.asianLineId
                              };

                eventController.InvokeShowBetPlacementControl(this, new ShowPlaceBetControlEventArgs { SenderUID = UniqueInstanceID, Bet = bet, ExchangeId = ExchangeId, MarketId = MarketId, SelectionName = SelectionData.name });
            }
        }