Friday, January 17, 2014

Expanding Your Empire

I have given a lot of thought lately as to why I experienced such amazing profits relative to my liquid capital when I first started trading and how poorly those profits scaled with an increase in capital.  The principal seems sound: what I can do with 100 mil, I should be able to do twice as well with 200 mil.  Why was this seemingly extremely simple concept not translating from a sound idea on paper into a working theory in EVE?  I began to look at exactly what I had been doing to increase my involvement in the market as I grew in wealth and how I could change that to increase my profits and I believe I have figured it out.

Previously, the way I had increased my stake in the market was to increase my investing in a blanket fashion.  Whereas before, I might have been investing 10 mil an item into 10 items, I was now investing 20 mil an item into 10 items.  This pattern continued with slight variations; although I did invest in more items, I continuously put more ISK into the amount I was investing per item as my wealth increased.

That is the reason my profits were increasing at a snail's pace: the correct way to grow as a trader is not to increase amount invested per item, but rather amount of items invested in.

Had I gone from investing 10 mil an item into 10 items to 10 mil an item into 20 items, my profits would have approached, if not achieved, a level twice as high as they previously had been.  The reasoning behind this is simple, once you think about it: if it takes an hour to move 10 units of X at a profit of 1 mil/unit, and I have invested enough ISK to purchase 10 units of X, I should make 10 mil ISK/hour off of X.  If I invest enough ISK to purchase 20 units of X, I should still make 10 mil ISK/hour, but this time for 2 hours.  However, if I invest in 10 units of X and 10 units of a near-identical item Y, I should make 20 mil ISK/hour, 10 from X and 10 from Y.

Though it seems as though investing in double the amount of an item and then going twice as long between updating orders is a sound idea, you have to consider that the real world is not the perfect example I included above, and in reality, there are other people like you, sitting in a station, spinning their ship, and updating their orders to stay on top.  When you invest in an item, you are much more likely to be undercut than you are to have your order completely filled.  Each order I place on the market is generally undercut at least 10 times before being fulfilled completely.  By investing in more items, in addition to having the chance to make more ISK per time, you also have the opportunity to avoid being undercut; if you are trading in item X and you are undercut, you immediately lose the ability to profit, whereas if you are trading in X, Y, and Z, and X is undercut, you continue to profit off of Y and Z.

I have been practicing this method of expansion very stringently the past few days, but today I kicked it into overdrive, and the results were very satisfying.  Today alone, I went from about 2.65 bil to 2.85 bil, a profit of about 200 million ISK.  That's a return of about 7.5%, which isn't bad for one day's investing.  However, this practice comes with a price: with my skills, I have a maximum of 113 orders on the market at any given time.  For the majority of my trading today, I did not have more than 20 remaining orders available to me.  This level of expansion means that in the near future, I may be required to train up my skills in order to be able to make more market orders (or make another market alt to put in a different hub, or both).

All I know is, since beginning to use this strategy, I've noticed definite increases in my profits, so unless something changes in the future or I discover a better method, this is the method I will continue to use as I grow my empire, and it is the method I will recommend to others in their expansion as well.  Good luck increasing the size of your empire and fly safe o7

Monday, January 13, 2014

Of Code and ISK Part II: I Just Wanna Tend the Coffers

After my last post, Of Code and ISK, I received some feedback indicating that although I accomplished what I had in mind, I could have done so much more.  For those of you who don't feel like reading my other post, I assembled a sequence of programs that would allow me to scan the entire market of a station, export all orders to a CSV file, read those orders, perform some analytics, and spit out a list of items that would be profitable to trade.  The downside to this method was that it would take a matter of hours to scan the entire market of a station.

Some of the comments I received led me to the EMDR, or EVE Market Data Relay.  I had been adverse to using this tool previously fearing many a spoofed order or inaccurate data, not to mention difficulty implementing it into my code.

I was so wrong.

I spent a few hours today tweaking my code and have managed to truncate my entire line of software to an HTML file and two Python files (one of which does nothing more than host a local HTTP server to make accessing the HTML file easier).  All I have to do is run both Python files, navigate to my server in the IGB, and refresh the view once in a while to see the latest data on my screen.

For the webpage, I took advantage of the fact that the IGB supports HTML5 by using a button that runs a XMLHttpRequest function to pull my file into a table I have in the page.  This table uses the jQuery Tablesorter to keep everything organized, allowing me to easily read and interpret the data.

I have to say, I am very impressed with how easy to use EMDR was and how much nicer this is compared to my previous method.  I will include some samples of my code to make life a little easier for those of you who wish to make something similar.  This is the Javascript code to parse a file (outputhtml.txt) which is stored in the same directory as index.html and set the contents of the div with id='main' to the contents of the file.
 function doStuff () {
            var oReq = new XMLHttpRequest();
            oReq.onload = reqListener;
  "get", "outputhtml.txt", true);
function reqListener () {
            document.getElementById('main').innerHTML = this.responseText;

If you wish to use EMDR in your Python program, check out the data format guide so you know what you're dealing with.  In case their example didn't make it clear, you're going to be dealing with a series of dictionaries.  In the case of orders, each dictionary will have a key ('rowsets') which contains an array of dictionaries, each of a different item or region.  Simply configure your calculations and have the program output your results to a text file.  Be sure to format them properly in HTML for easy importation into your webpage.  I will also include a method for outputting your data in HTML while linking the name of each item to its market details:
<a href='javascript:void(0)' onclick='CCPEVE.showMarketDetails("+str(itemid)+")'>"+ "</a>"
Finally, a screenshot of my site.  It's nice, clean, and simple, and can be sorted by any column.

And with that, feel free to ask any questions you may have and I will do my best to answer them.  Thanks for reading and fly safe o7 

Friday, January 10, 2014

Of Code and ISK

One of the great things about EVE Online is that a very large portion of the people who play it work in the field of IT.  This results in a huge amount of third party tools (EVEMon, EVE Mentat, Elinor, EVE-Central, most alliance's websites, and the list goes on and on...) as well as a great deal of support for developer's from CCP's end.  The possibilities are nigh endless in terms of the applications that can be developed with some code know-how, some hard work, plenty of Googling, and a vision.

It all starts with an idea.  As most of my readers will know, one of my favorite/main activities in EVE is station trading, which is where I make much of my ISK (and try to put in as little effort as possible).  However, when it comes to the things I've tried coding to make station trading more profitable, I've put in many hours of effort, but I dare say that sometimes, I've enjoyed them more than EVE (looking at you, siege fleets).  One of the most difficult parts of station trading is deciding which items you'll be trading to turn a profit.  A lot of factors must be considered when making the decision, such as the stability of the item, the volume traded, the profit margin, the cost, etc.  The end result is that although a profitable item is not hard to find, one that will give consistent and high returns can be.  Then it hit me: why don't I make a program that will tell me what items offer the highest margins and meet my criteria for items that I want to trade?

I'm no code genius, but I have limited experience in web design (HTML, CSS, PHP, and Javascript/jQuery), as well as software development (Python and some C#).  My original plan was to design my program in a way that allowed the entire thing to be operated from the IGB in EVE.  The program would first scan the market (every item) to put them in the cache, then scrape the cache, calculate the margin for each item, filter the items through some criteria, and finally output the results to a web page that would be readable in the IGB.  My hopes were dashed as I quickly found that such a system would be much more trouble than it is worth.

To begin with, I needed a webpage that I could load in the IGB that would scan the market to load every item into the cache.  Rather than start from scratch, I butchered my code from the order scanner page of masterpiece of EVE market software known as EVE Mentat.  Using that as a starting point, I now had an HTML page that would open the market details for every item in my list.  To make life easier, I set up a simple HTTP server with this script (courtesy of stackoverflow).  Simply save that as a .py file in the same directory as your HTML file (which you should name index.html) and run it.  You can access the file by going to in the IGB.

Now I found myself with a webpage capable of scanning the market, but no item IDs for which to scan.  I downloaded a data dump (which was from Incarna, so I'm probably missing some items but they shouldn't be too big of a deal) from the EVE forums here and through the magic of MySQL pulled out a list of every item in the database which exists on the market (some items can't be purchased on the market, but a quick Google search taught me how to select only those that can be).  This data was placed in the HTML page I had made earlier and when I ran it, it worked!  However, the import turned up over 6000 items, meaning that with a 3 second interval (the minimum I'd need to use to avoid going over the maximum number of market requests I could make, which would make the script continue to run without actually pulling more data), it would take hours upon hours to scan the market.  I solved this by just letting it run while I slept.

At this stage, I was left with the market data for (almost) every item on the market in my cache.  What to do from here?  I used the dumper tool from EVE-Central to scrape the cache and export the market orders for every item into one CSV file.  This process unsurprisingly took quite a while.  However, it also meant that much of the hard part was done, as Python was undoubtedly my strongest language of all those I had used so far, and all that remained was to use it to process the data into a user-friendly format.  Some quick code calculations yielded a script which analyzed the orders for every item, threw out those with no data or those with only one type (buy or sell) of order, calculated the % profit margin for each item (taking my skills into account), and threw away any item with less than 30 mil worth of potential profit currently on the market.  Entity's Reverence library provided me with the means to pull the names for the items from their item IDs.  The results were exported to another HTML file in the form of a table, which using some jQuery magic, gave me the ability to sort the data by column.  I included columns for volume and margin, so I could play with the data as I wished.  I also made each item's name into a link that would open the market data for that item, to make checking on/trading desirable items easier.

I am fairly happy with the end result, and it's not hard to see why; I now have an easy to use table that contains data on most of the items worth station trading.  I only actually went through the list for a few minutes, but in those few minutes I found at least two new items to invest in with profit margins in the thousands of percents that looked very promising.

For the time being, I do not think I will be releasing this file.  Though I love helping the community, which gives me indirect competition, I have never released any of the items I am trading in because I would like to avoid directly competing with my readers as much as possible.  Releasing this file to the masses would make my life absolute hell whenever I try to station trade.  However, I spent about two days making this program, and I did not have available to me (most of) a step by step guide on how to do so.  Anyone with a simple background in code or the ability to Google should be able to recreate a lot of what I've done here simply based on reading the above guide.  Though I probably shouldn't, I have a soft spot for helping people out, so if you have any questions, leave a comment or PM me on reddit (/u/toxicity959) and I will see if I can help you work through whatever problems you may have encountered.

Thanks for reading my blog and keep on developing!  Fly safe o7