Pololen Bitcoin Lending Bot

A Decentralized Bitcoin Lending Bot for Poloniex
What It Does

URGENT: If you are a current user and suddenly are unable to connect to Poloniex please upgrade to Pololen Poloniex changed some server security settings which required an update with Pololen. Please review the FAQ for update instructions and always back up your wallet file prior to upgrading.

Pololen is a full featured, lightweight application for lending Bitcoin (only) on the Poloniex exchange, requiring no installer and capable of running off a USB drive if portability is required. It's designed to be both anonymous and decentralized. Once configured with the Poloniex API keys, Pololen will check the users account each minute, monitoring the current offer book and placing offers at a user configurable depth within the book as funds become available in the lending account.

Pololen also tracks rates for the last 15 days, building a database of points to accurately calculate the mean loan rate as well as the average deviation from the mean allowing it to accurately define when calculated rates are outliers. With user configurable settings Pololen allows the user to set a limit, in deviations, of how low they will allow a bid. Pololen also allows the user to maximize earnings by extending the duration of loans based on how many deviations they are from the mean. In human speak, this is a "sliding scale" of loan durations in which the higher the rate, the longer the duration. These settings are completely configurable by the user and will show the user the result of each change they make based on the current mean and deviation. By making these changes based on deviation and mean, rather than hard and fast numbers, the settings will follow the market as it ebbs and flows.

To avoid "Polo Pogo" and further maximize earnings Pololen uses a step down technique as loan rates drop. Rather than drop offered rates into the hole when a large amount of funds become available and rates plummet, Pololen will drop it's target rate slowly toward the market rate, giving the market time to stabilize and work it's way back up toward more profitable rates.

Rate Drop Protection
Variable Duration
Rate Averaging
Pololen uses adjustable rate drop protection that ensures that your loans are issued at the highest rate possible, avoiding the "PoloPogo" when rates drop for a minute or two and quickly return to previous levels.
Pololen offers user specified mechanics to automatically attempt to extend loans for longer duration while the market is higher than average, allowing you to possibly hold loans at higher rates for longer periods, maximizing profits.
Pololen collects and analyzes the last two weeks of market rates, determining mean and average deviation. As new rates are determined Pololen analyzes the rate to determine if it is an outlier and acts accordingly.
Why Decentralize?
You own the bitcoin. How much you have and what you do with it is no one's business but yours. Pololen doesn't require your email address, or your home address, or anything else that could possibly identify you to a third party. All relevant data is held local on your computer with the exception of the requests made to Poloniex to instruct it to lend funds. Any payments made are made via the blockchain. 

Options and Features
By default Pololen lends all the funds in the user's lending account. As there is no way for the lender to end a loan prematurely, the bank function was added to allow the user the ability to stop loaning a set number of funds, but not have to completely stop lending. Once the user puts a number in the box (say, ".5" for example) Pololen will stop making loans until the lending account reaches that amount. After the account reaches that value all funds in the account over the bank amount will continue to be offered as loans. This keeps as many funds as possible lent out while still allowing the user access to needed funds as loans mature.

Rate Drop Protection
Pololen applies rate drop protection in an attempt to keep your loan offers higher. The recommended rate drops slower than the market rate to allow the market to move back up to meet it. The rate in which the recommended rate will drop is now user adjustable from super slow (less loans, higher rates) to so fast it matches the market (more loans, lower rates.)

Variable Duration
Variable duration allows Pololen to maximize earnings by extending loans for longer than two days depending on how many deviations the loan is from the average. While not required, these settings allow the user to possibly pick up longer, higher rate loans during an uptick in the market and possibly hold those loans after the market settles to more average rates. While not guaranteed to hold a loan for any length of time, the fact is you most definitely won't hold it for more than two days if it's only offered for two days. What lender out there wouldn't want to hold a loan at 0.8% or 1% for 40 days in the current market? When using variable duration the user sets three parameters. The first is the maximum amount of time the user will allow their funds to be lent for. The second is how many rate deviations below the mean the user is willing to post a loan for. The third is the amount of deviations the user would like to have before adding a day to the duration. This sounds confusing, no doubt, but when making changes to these settings you'll be able to see the effect those changes will have at the current calculated market rates.

Max Loan Amount
If you have a large chunk of bitcoin to split into smaller orders you can set a max loan amount. Setting this amount to, say, 0.5 will ensure that loans are issued for a maximum amount of 0.5 bitcoin. Note that this increases the risk of orphaned loan offers so you should monitor your open loan offers closely while using this. This option should never be used if you are manually lending high above the market rate. In that instance you should lend all BTC available in your account. 

Offer Minutes
By default Pololen will cancel a loan offer when it detects a change in rates. You can force Pololen to keep offers open for a minimum amount of time by entering the minutes to keep the loan open in Offer Minutes. For instance, if you enter a 20 in this field it will keep an offer open for a minimum of 20 minutes before closing it. Pololen will continue to monitor the market each minute and will continue to issue additional loans for the offer time you specify.

Manual Offering
Any open offers in your account will show in the open offers tab. From this tab you can both cancel existing offers and create new offers. However, while Pololen is running it is automatically trying to lend all funds in your account. If you want to keep some funds available for manual offering you should use the bank function to set a minimum balance to be maintained in your account. Manual offering allows you to split your loans into smaller chunks, if that's your preffered method of lending. Enter the amount to lend, rate, and duration and Pololen will split into into smaller loan offers for you.

Manual Override
Pololen gives you the ability to override the variable duration settings allowing the bot to run in a more traditional mode. 

Pololen records all loans closed on CSV files saved by month. In addition to the information that can be downloaded from Poloniex, Pololen will also stamp the data with the value of the earned amount for the loan in USD based on the current value of bitcoin. This is tremendously helpful when comparing current and prior values. Files are stored in the "Records" folder in the same folder as the application.

Pololen includes several charts to help the user see what's happening in the market. The market chart shows the rates over the last 15 days as well as showing mean + deviation and mean - deviation to indicate where the "Average" lending rates are over that 15 day period. The hourly chart shows the last three hours of rate data by minute indicating market rate, Pololen's recommended rate, as well as the minimum rate, your manual rate (if any), and any loan offers that are placed.

Automatically Move To lending Account
When this option is checked Pololen will automatically move any BTC that appears in your exchange account to your lending account and lend it out. If you are an active trader DO NOT TURN ON THIS OPTION. However, if you have funds being delivered to your exchange account and want to automatically lend those funds, turning on this option in the deviation calculations tab will move the BTC automatically and lend it out.

OS Requirements
Microsoft .NET 4.5.2 Library
A Poloniex lending account 
API Access to Poloniex (DO NOT turn on trading and DO NOT turn on withdrawal.)
A Windows computer, Windows 7 or above, to run Pololen preferably 24/7.
And, of course, An internet connection

API Requirements
The user will need to create an API Key for Pololen on the Poloniex website. The key should NOT allow trading and most certainly should NOT allow withdrawal. While you can restrict the API to a certain IP address, you will experience problems if you are operating from a location with a dynamic IP - or you install the application on a USB and run it from more than one location. For that reason please only restrict to a single IP address if you understand what it means to do so. Only the minimum permissions are required to run Pololen. DO NOT turn on trading and DO NOT turn on withdrawal. Please do not attempt to reuse an existing API. It can cause errors. Also, please only run one copy of Pololen on a given account and turn off any other BTC lending bots you may have.

I want to upgrade but how do I do it?
If you have an existing version and want to upgrade, download the file linked below and extract the folder to whatever location you would like. Then, to be on the safe side, backup your existing folder.
Copy the following files from your old folder to the newly downloaded one:
Points.dat (overwriting the file that came with the download)
Then copy the entire Records folder from your current folder into the newly downloaded folder.
You can now let 'er rip. 

If you do not have a full copy of current market rates please go to the API tab and click save. You will be prompted to download current market rates. Once this is done the application will be synced to the market.

My browser / antivirus / etc says this might be dangerous?
Those items work by reputation. Files that are not downloaded frequently have no reputation so they are oftentimes quarantined or blocked in some fashion. That doesn't mean there's anything bad in there - it just means that your software is trying to keep you from downloading a strange file from the internet which is what it is supposed to do. I would recommend that first you go to our thread on  bitcointalk.org and see what other users have to say. From there you can make a determination of our reputation within the community. If you feel that we're safe to do business with then you should always check the MD5 hash of any file you download in which it is provided. The MD5 hash ensures that the file you download is the exact same file that we placed there for you to download and has not been modified by a third party.

How can I get in touch with you?
I don't post my email on the website, but you can PM me at bitcointalk.org (barcodeguy) or if you have Pololen you'll find my email on the front when you launch it.

Is this application part of Poloniex?
Nope - this application is a private endeavor to help lenders earn fees on Poloniex. This app is not part of, endorsed, or in any way affiliated with Poloniex.

It seems to be running, but it's not lending?

Not lending can be caused by two issues. Either you're out of credits, which the application will tell you, or you have less then 0.01 in your lending account. Poloniex will not allow you to lend less than 0.01 BTC, so the application won't try to lend it.

Where can we talk about this thing?
We've got a thread over on bitcointalk.org

How do I set a minimum lending rate?

Pololen is designed to work in deviations from average, not with hard and fast numbers. That said, go to the Deviation Calculations tab and change the value for Minimum Lending Rate. The minimum rate will show in the text underneath. Note that this is based on deviations so the minimum will change as the market changes. This can be completely overridden and the application run in a more basic mode by selecting manual override. In that tab you can set a minimum rate and a firm duration.

I'm seeing some errors. Are they normal?
Pololen works with a number of APIs. In the normal course of operations these APIs, or the network between, will have issues from time to time and errors are not unusual. Here's some error messages you may see from time to time and what they mean.

  • Prior thread is still running - This means that Poloniex couldn't finish it's cycle in one minute. Typically this is due to slow responses from the API it's calling, or network congestion. It should try again in another minute.
  • Error getting past history - This means that Pololen attempted to get history from Poloniex and no history was returned. This happens when the Poloniex servers are overtaxed. It will try again on it's next scheduled history pull.
  • Please check your API settings - This happens when Poloniex doesn't seem to recognize your API. If you are setting it up for the first time please double check it's settings to ensure they are correct. Otherwise it's likely a transient error and it will correct itself on the next cycle.
  • Error getting BTC pricing - This means that the API that returns the current BTC price in USD failed to return data. This is transient and typically corrects on the next cycle.
  • Out of grace period - This means your credits are below -0.001 and they need to be refilled before the bot will continue lending.
  • Your grace period will end soon - This means that your credits are below 0 but higher than -0.001. Pololen will continue to lend your bitcoin until your credits get below -0.001
  • Excess Rate Drop Detected - This is not an error exactly. It's an indicator to tell you that the market dropped excessively. Pololen will gradually allow it's rate to drop toward the market rate.
  • Error Placing Order - This means that Pololen attempted to place your bitcoin order, but Poloniex did not accept your order. This is typically a transient error and Pololen will lend your funds on the next cycle.

What's all this mean and deviation stuff? I'd rather not have to do math.
Well, In terms what it is - in my opinion it's the best way to lend in a moving market. Rather than saying to do something when the market is a defined rate, I think it's better to do something when the market is, or is not, average. You don't need to do a bunch of math though - the output in the deviation calculations tab will show you the exact effect that the changes you are making will have based on the current market.

You keep saying based on the current market. What does that mean?
When you first run Pololen it comes with data to simulate the market. However that data is a simulation that is guaranteed to show an average of 0.1% with a deviation of 0.05%. Over the course of the next two weeks Pololen will record market data and fill in this "sample" data with the real thing. Once a couple of weeks have gone by it will be tuned to the market. It will then base it's decisions on true market data with the settings that you have selected in the "Deviation Calculations" tab.

How come it only lends BTC? Do you hate alts?
That's a great question. First off, I love alts - some better than others, of course. The application was written for BTC only as that's all I lend. It may not always be that way. I'm thinking about how I can add select coins to it while still keeping it fast and light. Please don't take this as I am definitely adding other coins - I very well may not. The key, really, is my time plus other user's desire to have them plus if I can find a good reliable way to do it without it being slower or less reliable.

I hate lending bots. I think they lower rates and add a lot of chaff to the offer book. Why is this one different?
Another great question and I can understand why you would feel this way. First off Pololen doesn't create offers less than the lowest offer, ever, and it's usually quite a bit higher. It will never spam the order book with a bunch of small offers that lower the rates. Second, when the market drops Pololen drops it's recommended rate incrementally to slowly match the market. It tries very hard not to issue a loan at the lowest rate. Instead it tries to meet the market again on the upswing. The primary purpose is to try to get the user the best possible rate. The secondary purpose is to not drop a bunch of loans at low rates that drive the market down further.

What is this moving funds option that's been added?
When this option is checked any BTC that is in your Exchange account is automatically moved over to your lending account. Obviously, if you trade, you DO NOT want to check this option. However if you have funds that automatically move into your account and always move them to lending this will do that automatically saving you the trouble of having to log in and do it.
Download and Install
Download Version
Download Link:   http://poloniexbitcoinlendingbot.com/download/Pololen-Current.zip
MD5: 91D7CE0D35CD96AF2EA03410E13CFDDB
SHA-256: 1DF2EAB939308A488F8D04154C4F2B390B573446BA6A55EFAF462F2C84B6684B

First Time Setup (See FAQ if upgrading from an existing version)
After downloading the zip archive and verifying the MD5 open it and drag the Pololen folder wherever you would like on your computer. 

Let your antivirus do any scanning, sandboxing, etc. it needs to do to be satisfied. Some heuristic scanners don't like this application as they seem to think it is "something new" but they can't seem to figure out what. 

*CRITICAL NOTE: The first time you run the application it will generate two dat files within it's folder. Once those files are created they cannot be regenerated and the application will not run without them, even if you download a new copy. Keep them backed up.

Double Click "Pololen" within the folder.

If prompted, please allow the application to access servers outside of your firewall.

Go to Poloniex and create a new API key. Do NOT turn on trading and do NOT turn on withdrawal. (Don't EVER turn on withdrawal, no matter who is asking!) Copy the API value and key into the text boxes on the API tab on Pololen and click the save button. When you click the save button you will be given the opportunity to update rates. This is highly recommended as it will instantly sync Pololen to the current market. If you want to lend with manual settings, go to the manual override tab and enter your settings.

Once the application is running go to the deviation calculations tab. Mess around with the settings in here and view the results in the text box underneath. This will show you what your current mean and deviation values are, as well as your minimum loan rate and how long a loan will be issued based on your settings and the supplied data. You should review this tab daily as the application runs to help get a feel for what it's doing.

Click the monitor lending account checkbox and, if you're not there already, go to the operation log tab. Within a minute or so Pololen will start pulling market rates and loaning your Bitcoin if you have any available within your Poloniex lending account. If you don't have any money in your lending account Pololen will still run, collecting data from the market and settling on the rate and duration it would recommend for any BTC that might be found in your account. It may be of benefit to watch this (I personally find it quite addictive) even when you have no funds in the account just to watch how it recommends rates, durations, and steps down as rates drop. Leave Pololen running as much as possible, 24/7 preferably, so it can collect market data and issue loans as funds become available in your lending account.
Pololen will let you earn up to 0.02 BTC in interest before it asks for payment. Payment is 5% of interest earned. IE, for each 0.02 BTC you earn in interest, you need to send 0.001 in BTC to keep the application lending. If you decide to keep running the application after you've reached 0.02 in interest please go to the API tab and click Generate. This will generate a unique Bitcoin address for you to pay the 5%. I stress this address is for software payments only and I recommend that you only add enough to the address for a couple of weeks at a time. Once you apply credits to the bot the bot will be locked to your API. All credits applied will be applied only to the API you are using moving forward. It's important that you don't delete your API in Poloniex after adding credits.
Thanks to the following for their API services or DLLs:
NBitcoin Library
Newtonsoft Json Library
Change Log
06-01-2017 - Application is changed to run in en-US mode on all locals. 
06-02-2017 - Updated total generation to ensure it only includes BTC. 
06-02-2017 - Updated report generation to only report BTC loan returns. 
06-07-2017 - Added functionality for automatically moving funds from exchange to lending. New build Updated link and MD5
06-07-2017 - Added FAQ section
06-13-2017 - Created this webpage

06-17-2017 - Refactored order of operations in lending cycle to minimize time between loan cancel and loan post.
06-17-2017 - Refactored order of operations in history cycle to make sure that credit check takes precedence over other history tasks.
06-17-2017 - Modified handling of USD retrieval so if the API has an error the last value is used, not a zero value
06-17-2017 - Added manual override capability to allow the bot to run in a more traditional mode.
06-17-2017 - Changed nomenclature on API tab to better line up with Poloniex site's nomenclature.

06-18-2017 - Updated the UI to use percent rather than multiplier (ie 0.1234% rather than 0.00123400)
06-18-2017 - Fixed bug where a rate at a percent that was even (ie no decimal point) would show a high value.
06-18-2017 - Added Max Loan Rate to give the user a way to break up large funds into small loans.
06-18-2017 - Added a tab to show open offers to the user.
06-18-2017 - Added a method for the user to manually place offers.
06-18-2017 - Added saving to the top level items - ie DepthBTC, bank, and Max to ensure they load if the user closes and opens the app
06-18-2017 - Added a version check for Pololen to check current version every 12 hours and prompt the user if a new version is available.

06-18-2017 - Modified deviation minimum rate to be negative or positive values
06-18-2017 - Added exception handling to cancel loan orders. If Poloniex returns an error current build shows an ugly exception box.
06-18-2017 - Updated manual lending to allow the user to split up offers into smaller chunks.
06-19-2017 - Added status indicator
06-19-2017 - Modified manual offer behavior to stop auto lending while the offer dialog is open
06-19-2017 - Added status bar to Manual Lend Window
06-19-2017 - Added status bar to main window
06-19-2017 - Added ability to interact with the server to get a single line message from the server
06-19-2017 - Updated hourly chart to be three hours
06-19-2017 - Updated hourly chart to show minimum rate (based on deviation.)
06-19-2017 - Updated hourly chart to show manual rate (if lending manually)
06-19-2017 - Updated hourly chart to show points where an offer was placed
06-19-2017 - Added slider to set the rate that step down protection will drop to meet the market.
06-19-2017 - Changed missing wallet functionality to rebuild a wallet if needed with negative credits.

06-21-2017 - Added rate to title bar text.
06-21-2017 - Added tool tips to show rates on charts.
06-21-2017 - Added average range to three hour range (This is 2 week average.)
06-21-2017 - Modified charts to use a transparent range rather than two lines to show average. It just looks better.
                       But wait - there's more. I'm colorblind so it may look terrible.
06-21-2017 - Made admin changes to keep a rates list updated. Client applications can download new rates by clicking "Save"on the API tab.
                       The idea is that new users can download rates when adding their API, but existing users are free to use as well
                       if they need to refresh.
06-23-2017 - Updated deviation drop down for minimum rate to range from -25 to +25 rather then -10 to +10 as used previously.
                       This gives a lot more room for the user to maneuver as the deviations get smaller.

06-28-2017 - Added rate tracking for loan offers so the bot will not cancel an offer if the rate has not changed.
06-28-2017 - Updated offer tracking to better handle multiple offers.
06-28-2017 - Added a minimum time to keep offers posted. The bot won't cancel an offer until the next cycle after the duration has expired.
06-30-2017 - Locked API to credits. Once credits are delivered they are locked to a single API
06-30-2017 - Fixed bug in which saving API caused the app to always download points, even if cancel was clicked.

07-07-2017 - Added Open Loans Tab to show all open BTC loans
07-07-2017 - Removed editing from Open Offers and recent closings tables.
07-07-2017 - Added stats page to include Funds on Loan, Funds On Offer, Total Funds (Combination of the last two), Unrealized Fees
                       (Gross profit based on fees from Open Loans), Available Credits, and Estimated Credits in Days (the amount of time that
                       the user can estimate their current dredit load will keep the bot lending.)
07-07-2017 - Modifed alert that shows for missing API to ensure that the application will not cycle without an API entered.
08-02-2017 - Fixed bug in wich an exception was thrown when Offer Minutes text box has no text.

01-18-2018 - Fixed connection issue after Poloniex server upgrade. Was unable to connect to the server.