コード例 #1
0
        /// <summary>
        /// Gets current average back and lay bets for every runner
        /// </summary>
        /// <returns></returns>
        public AsynBetStatus[] GetCurrBets()
        {
            AsynBetStatus[] retVal = new AsynBetStatus[currBets.Count()];

            for (int i = 0; i < currBets.Count(); i++)
            {
                retVal[i]           = new AsynBetStatus();
                retVal[i].bAmount   = currBets[i].bAmount;
                retVal[i].bAvgPrice = currBets[i].bAvgPrice;
                retVal[i].lAvgPrice = currBets[i].lAvgPrice;
                retVal[i].lAmount   = currBets[i].lAmount;
                retVal[i].selId     = currBets[i].selId;
            }
            return(retVal);
        }
コード例 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="username">Bf username</param>
        /// <param name="password">Bf password</param>
        /// <param name="marketId"> Market id</param>
        /// <param name="checkTimeMilliseconds">Time between checks of market</param>
        /// <param name="noOfRunners">Number of runners in the market</param>
        public ProfitAndLossAsync(String username, String password, int marketId, int checkTimeMilliseconds, int noOfRunners)
        {
            noOr     = noOfRunners;
            Username = username;
            Password = password;
            MarketId = marketId;
            CheckTimeMilliseconds = checkTimeMilliseconds;
            currBets = new AsynBetStatus[noOfRunners];

            for (int i = 0; i < noOfRunners; i++)
            {
                currBets[i]         = new AsynBetStatus();
                currBets[i].bAmount = currBets[i].bAvgPrice = currBets[i].lAmount = currBets[i].lAvgPrice = 0;
                currBets[i].selId   = 0;
            }
        }
コード例 #3
0
        public void Start()
        {
            Api = new BetFairApi();
            Api.LoginNonFree(Username, Password);
            Api.ManualySetMarketId(MarketId);
            //Random rnd = new Random();
            MarketRunners[] runners = Api.GetMarketRunners();

            for (int i = 0; i < noOr; i++)
            {
                retVal[i]           = new AsynBetStatus();
                retVal[i].bAmount   = 0;
                retVal[i].bAvgPrice = 0;
                retVal[i].lAmount   = 0;
                retVal[i].lAvgPrice = 0;
                retVal[i].selId     = runners[i].SelectionId;
            }

            while (true)
            {
                try
                {
                    //CurrentPL[] retVal = Api.GetCurrentMatchedPL();
                    AsynBetStatus[] retVal = GetCurrPlManual();

                    Report Rpt = new Report(delegate()
                    {
                        for (int i = 0; i < retVal.Count(); i++)
                        {
                            PALC.currBets[i].bAmount   = retVal[i].bAmount;
                            PALC.currBets[i].bAvgPrice = retVal[i].bAvgPrice;
                            PALC.currBets[i].lAmount   = retVal[i].lAmount;
                            PALC.currBets[i].lAvgPrice = retVal[i].lAvgPrice;
                            PALC.currBets[i].selId     = retVal[i].selId;
                        }
                    });

                    Rpt.Invoke();
                }
                catch { }

                System.Threading.Thread.Sleep(CheckTimeMs);
            }
        }