コード例 #1
0
        public static Order BuildOrder(IEnumerable<Loan> loansToBuy)
        {
            Order order = new Order();
            order.aid = 1302864;
            List<LoanForOrder> loansToOrder = new List<LoanForOrder>();

            foreach (Loan loan in loansToBuy)
            {
                LoanForOrder buyLoan = new LoanForOrder();
                buyLoan.loanId = loan.id;
                buyLoan.requestedAmount = 25.0;
                buyLoan.portfolioId = null;

                loansToOrder.Add(buyLoan);
            }
            order.orders = loansToOrder;
            return order;
        }
コード例 #2
0
        private static void Main(string[] args)
        {
            // Url for retrieving the latest listing of loans
                var latestLoansUrl = "https://api.lendingclub.com/api/investor/v1/loans/listing";

                // Url to retrieve the detailed list of notes owned
                var detailedNotesOwnedUrl = "https://api.lendingclub.com/api/investor/v1/accounts/1302864/detailednotes";

                // Url to retrieve account summary, which contains value of outstanding principal
                var accountSummaryUrl = "https://api.lendingclub.com/api/investor/v1/accounts/1302864/summary";

                // Url to submit a request to buy loans
                var submitOrderUrl = "https://api.lendingclub.com/api/investor/v1/accounts/1302864/orders";

                // Store the Account object to get balance and outstanding principal.
                Account myAccount = new Account();
                myAccount = getAccountFromJson(RetrieveJsonString(accountSummaryUrl));
                // Variable for storing cash balance available.
                double accountBalance = myAccount.availableCash;

                // We only need to search for loans if we have at least $25 to buy one.
                if (accountBalance >= 25)
                {
                    var stopwatch = new Stopwatch();
                    stopwatch.Start();
                    int numberOfLoansToBuy = (int) (accountBalance/25);

                    while (stopwatch.ElapsedMilliseconds < 90000)
                    {
                     Thread.Sleep(500);

                        // Total outstanding principal of account. Used to get value each state should be limited to.
                        //double outstandingPrincipal = myAccount.outstandingPrincipal;
                        // Limit for a state is 3% of total outstanding principal.
                        //double statePrincipalLimit = .03*outstandingPrincipal;

                        // List of notes I own. Used to determine which states I should invest in.
                        //NotesOwned myNotesOwned = getLoansOwnedFromJson(RetrieveJsonString(detailedNotesOwnedUrl));

                        // Retrieve the latest offering of loans on the platform.
                        NewLoans latestListedLoans = getNewLoansFromJson(RetrieveJsonString(latestLoansUrl));

                        // Filter the new loans based off of my criteria.
                        var filteredLoans = filterNewLoans(latestListedLoans.loans, numberOfLoansToBuy);

                        // Create a new order to purchase the filtered loans.
                        Order order = new Order();
                        order = BuildOrder(filteredLoans);

                        string output = JsonConvert.SerializeObject(order);
                        Console.WriteLine(submitOrder(submitOrderUrl, output));
                    }
                    Console.ReadLine();
                }
        }