出價以繁榮API代碼例子QuickSnipe.java

為今年我的ProsperDays介紹我展示出價以繁榮API的意志… ? 我建立了剪斷Java節目的一個快和骯髒的出價。? (這個節目沒準備好黃金時間作為出價的阻擊的工具,但是它是否是非常接近和一非常有效的演示。? 我說的原因它沒準備好是它缺乏記憶,意味它在同一個目錄在隨後通行證將出價。)

我認為API出價是第1步在一個勇敢的新的世界繁榮借貸。? 一,它容易地考慮到習慣模型。

如此這126線節目做什麼?

它詢問活躍AA-C信用等級目錄… ? 如果目錄通過我延長相信過濾器(硬編碼) ?并且極小值繁榮計算了ROI價值(引起?繁榮,并且地板通過作為參量) ?并且極小的時間餘留在拍賣它將安置一個檢驗測試出價的或一個真正的出價。

什麼是這個代碼的延長的信用要求? 短的答復…非常緊緊。

  • 0當前DQ
  • 0-1在前6個月詢問
  • 0公眾紀錄在為時10年
  • 0 DQ在為時7年
  • 銀行卡運用在3%和80%之間

這Java代碼(我對貢獻了這個代碼 SourceForge繁榮API ?項目).? 它要求Java2WSDL和開放來源工具引起的API類由亞帕基印第安人基礎。

包裹prosper.api;   

進口java.math.BigDecimal;
進口java.math.MathContext;
進口java.rmi.RemoteException;
進口java.sql。時間戳;
進口java.util。日曆;
進口java.util。Iterator;
進口java.util.TreeMap;   

進口javax.xml.rpc.ServiceException;   

進口com.prosper.services.ProsperAPI.DefinitionResult;
進口com.prosper.services.ProsperAPI.Field;
進口com.prosper.services.ProsperAPI.Listing;
進口com.prosper.services.ProsperAPI.ProsperAPILocator;
進口com.prosper.services.ProsperAPI.ProsperAPISoap;
進口com.prosper.services.ProsperAPI.ProsperObject;
進口com.prosper.services.ProsperAPI.ProsperObjectResult;   

公開類QuickSnipe
 {
	私有串m_Username;
	私有串m_Password;
	私有雙重m_MinROI;
	私有int m_HoursToGo;
	私有布爾m_PlaceBids;
	私有ProsperAPISoap m_APISoap;   

	公開QuickSnipe (串用戶名、串密碼、雙重minROI、int hoursToGo,布爾placeBids)投擲ServiceException
	{
		m_Username =用戶名;
		m_Password =密碼;
		m_MinROI = minROI;
		m_PlaceBids = placeBids;
		m_HoursToGo = hoursToGo;
		m_APISoap = (新的ProsperAPILocator ()).getProsperAPISoap ();
	}
	/**
	 * @param args
	 *
	公開靜止空隙主要(串[] args)
	{
		如果(args.length! =5)
		{
			System.err.println (「用法: QuickSnipe用戶名密碼minROI hoursToGo PlaceBids ");
			回歸;
		}
		嘗試
		{
			QuickSnipe qs =新的QuickSnipe (args [0], args [1], Double.parseDouble (args [2]), Integer.parseInt (args [3]), Boolean.parseBoolean (args [4]));
			qs.snipe ();
		}
		抓住(例外e)
		{
			e.printStackTrace (System.err);
		}
	}   

	私有空隙阻擊()投擲例外
	{
		DefinitionResult res = m_APISoap.log (m_Username, m_Password);

		串象徵= res.getMessage ();
		ProsperObjectResult por = m_APISoap.query(token, "listing", getFieldsString("listing",true), "status=2 and (creditgrade=7 or creditgrade=6 or creditgrade=5 or creditgrade=4)");
		ProsperObject[] pos = por.getProsperObjects();
		TreeMap<Calendar,Listing> timeLeftListings = new TreeMap<Calendar,Listing>();
		for (int i=0; i<pos.length; i++)
		{
			Listing l = (Listing)pos[i];
			Calendar end = (Calendar)l.getStartDate().clone();
			end.add(Calendar.HOUR, (l.getDuration()*24));
			long millisToGo = end.getTimeInMillis() - System.currentTimeMillis();
			if (l.getNowDelinquent()==0  //my required extended credit and ROI
					&& (millisToGo/1000/60/60)<=m_HoursToGo
					&& l.getInquiriesLast6Months()<2
					&& l.getPublicRecordsLast10Years()==0
					&& l.getDelinquenciesLast7Years()==0
					&& l.getBankcardUtilization().doubleValue()<=.8
					&& l.getBankcardUtilization().doubleValue()>=.03
					&& ((l.getBidMaximumRate().doubleValue()+l.getROINetDefaultRate().doubleValue()+l.getROIInterestAndFeesRate().doubleValue()+l.getROIServicingFeeRate().doubleValue())>=m_MinROI)
					)
			{
				timeLeftListings.put(end, l);
			}
		}
		boolean pause = false;
		for (Iterator<listing> i = timeLeftListings.values().iterator(); i.hasNext(); )
		{
			if (pause)  // you have to pause to avoid bid throttling
				{try {Thread.sleep(6000);}catch (Exception ignore){}}
			Listing l = i.next();
			Timestamp startts = new Timestamp(l.getStartDate().getTimeInMillis());
			Calendar end = (Calendar)l.getStartDate().clone();
			end.add(Calendar.HOUR, (l.getDuration()*24));
			Timestamp endts = new Timestamp(end.getTimeInMillis());
			long hoursToGo = (end.getTimeInMillis() - System.currentTimeMillis())/1000/60/60;
			System.err.println("\n"+startts+" + "+l.getDuration()+" days = "+endts+" | Hours To Go: "+hoursToGo);
			System.err.println("Bid on Listing: "+l.getListingNumber()+"\nAt Rate: "+(m_MinROI-l.getROINetDefaultRate().doubleValue()-l.getROIInterestAndFeesRate().doubleValue()-l.getROIServicingFeeRate().doubleValue()));
			res = m_APISoap.bid(token, l.getListingNumber(), new BigDecimal(50,new MathContext(4)), new BigDecimal(m_MinROI-l.getROINetDefaultRate().doubleValue()-l.getROIInterestAndFeesRate().doubleValue()-l.getROIServicingFeeRate().doubleValue(),new MathContext(4)), m_PlaceBids);
			pause = true;
			System.err.println("Bid Message: "+res.getMessage());
		}
		m_APISoap.logout(token);
	}   

	private String getFieldsString(String type, boolean authenticated) throws RemoteException
	{
		DefinitionResult res = m_APISoap.describe(null, type);
		Field[] fields = res.getDefinition().getFields();
		int count = 0;
		String s="";
		for (int i=0; i<fields.length; i++)
		{
			if (authenticated || !fields[i].isAuthenticated())
			{
				if (count!=0)
				{
					s+= ",";
				}
				s+= fields[i].getName();
				count++;
			}
		}
		return s;
	}
}
Related Stores If you liked this article, vote for it on del.icio.us and stumbleupon.


Categories:

Prosper.com



2 comments ↓
#1 Ben on 02.27.08 at 9:25 pm

Cool, thanks for sharing! I’ll have to get my jdk installed again at home and give it a shot.

#2 Prosper Roundup — The Week After Edition on 03.02.08 at 4:59 pm

[...] RateLadder on Prosper Days 2008?as well as the source code for the tool demonstrated at Prosper Days: QuickSnipe [...]

Leave a Comment

Email Updates