Thursday, August 29, 2013

ZKB Json parsing in Java

Json parsing in Java using gson:

   While looking into pulling kill data using zkillboard's API, I had some trouble learning how to parse Json.  This is partially because its the first time that I was using Json, and partially because I am still new to Java as a whole.  Below is an example of how to parse kill data from ZKB.

    Some notes on parsing data from ZKB:
  • You need ~15 second program pause after every call to ZKB.  This is not reflected in this code as it parses a single page of the call.
  • Please see the ZKB Api page for more information on how to make the calls you want.

package com.JEves.test;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;

import com.btr.proxy.search.ProxySearch;
import com.btr.proxy.search.ProxySearch.Strategy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;

public class SimpleKbParser   implements JsonDeserializer {

 public String m_value;
 /**
  * @param args
  */
 @SuppressWarnings("deprecation")
 public static void main(String[] args) {
  ProxySearch proxySearch = new ProxySearch();
  proxySearch.addStrategy(Strategy.OS_DEFAULT); 
  proxySearch.addStrategy(Strategy.JAVA); 
  proxySearch.addStrategy(Strategy.BROWSER); 
  ProxySelector proxySelector = proxySearch.getProxySelector(); 

  if(proxySelector != null) {
   ProxySelector.setDefault(proxySelector); 
   URI home = URI.create("http://www.google.com"); 
   //System.out.println("ProxySelector: " + proxySelector); 
   //System.out.println("URI: " + home); 
   List proxyList = proxySelector.select(home); 
   if (proxyList != null && !proxyList.isEmpty()) { 
    for (Proxy proxy : proxyList) { 
     //System.out.println(proxy); 
     SocketAddress address = proxy.address(); 
     if (address instanceof InetSocketAddress) { 
      String host = ((InetSocketAddress) address).getHostName(); 
      String port = Integer.toString(((InetSocketAddress) address).getPort()); 
      System.setProperty("http.proxyHost", host); 
      System.setProperty("http.proxyPort", port); 
     } 
    } 
   }
  }
  URLConnection.setDefaultRequestProperty("Accept-Encoding", "gzip, deflate");
  URLConnection.setDefaultRequestProperty("User-Agent", "Valkrr Dragonsworn");
  BufferedReader reader;
  String itemUrl = "http://zkillboard.com/api/kills/regionID/10000002/";
  try {
   GsonBuilder gsonBuilder = new GsonBuilder();
      gsonBuilder.registerTypeAdapter(SimpleKbParser.class, new SimpleKbParser());
      Gson gson = gsonBuilder.create();
   reader = new BufferedReader(new InputStreamReader(new URL(itemUrl).openStream()));
   SimpleKbParser[] kills = gson.fromJson(reader, SimpleKbParser[].class);
   for(int i = 0; i < kills.length; i++) {
    System.out.println("Kill: " + i);
    System.out.println(kills[i].m_value + "\n");
   }
  }
  catch(Exception e) {
   e.printStackTrace();
  }
 }

 @Override
 public SimpleKbParser deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
  SimpleKbParser ret = new SimpleKbParser();
  int killID = ((JsonObject) json).get("killID").getAsInt();
  int solarSystemID = ((JsonObject) json).get("solarSystemID").getAsInt();
  String killTime = ((JsonObject) json).get("killTime").getAsString();
  int moonID = ((JsonObject) json).get("moonID").getAsInt();
  ret.m_value += "killID: " + killID;
  ret.m_value += "\nsolarSystemID: " + solarSystemID;
  ret.m_value += "\nkillTime: " + killTime;
  ret.m_value += "\nmoonID: " + moonID;
  return ret;
 }

}

I will go through the above class section by section.  I am assuming you will be copying this into an editor so I will be referring to line numbers.

Lines 1-23:

   Your basic setup and import steps.

Line 25:

   public class SimpleKbParser   implements JsonDeserializer<SimpleKbParser> {

  JsonDeserializer is what makes the magic easy an quick.  This basically allows you to have your storage class get 1 element at a time from the series of elements and have to worry about parsing just that one element.  

Lines 33-57:

   I do part of my programming behind a firewall and the other part outside of a firewall.  This piece of code allows the script to auto detect the correct proxy type and use that by default. This requires proxy-vole to be linked to the project, so if you are not worried about firewalls, remove these lines along with lines 15 and 16.

Lines 58-75:

   An extremely basic program for grabbing and printing kill data.

   The key line here is line 67:
      SimpleKbParser[] kills = gson.fromJson(reader, SimpleKbParser[].class);
    This line tells gson that you want to parse the BufferedReader with your json in it into an array of SimpleKbParser objects.

Lines 79-90:

   Here is the function overloaded from JsonDeserializer.  For this example I just pulled some of the simple information out of the json and added it to a member string to be later printed.  Depending on what you are trying to do with this information, you will have to decide what information you want.

int killID = ((JsonObject) json).get("killID").getAsInt();

   You have to cast the JsonElement json to JsonObject, then run the get(Element Tag) which returns a JsonElement.  You run the getAs<Type>() function on the resulting JsonElement to get the value in a usable format.

JsonArray attackers = ((JsonObject) json).get("attackers").getAsJsonArray();
for(int i = 0; i < attackers.size(); i++) {
   JsonObject attacker = attackers.get(i).getAsJsonObject();
}

   For array data inside a json element, you cast as above, but you get it as a JsonArray type.  You can then iterate over that array, getting each object as a JsonObject to make getting values easier.


Summary:

   So, we learned how to get ZKB data into our programs in just a few dozen lines of actual code, less that 100 total lines.  There are some things not covered here to keep it simple, line how to effectively iterate over pages in a query and pretty much any error checking.  All of the coding is done in Eclipse build v21.1.0 using the ADT install package.  Other compilers might have compiler specific requirements that could prevent the above code from compiling.

   My source code can be found at Rapid Assembly.  This include git source repository and an occasional executable of my tool.  I have not made much use of the zkillboard parser yet, but I have plans to do so as part of a product selection GUI.

The Increasingly poor decisions of an Eve Industrialist

The Increasingly poor decisions of an Eve Industrialist:

Product Selection:


   I recently moved my main into faction warfare.  This has been widely regarded as a bad idea.  So I become a war target, and in my noobish innocence I figured I would be safe in my miltias high-sec space... and I was forcefully corrected on this misconception by a war target Machariel sitting outside the dead end  system that I used to do invention out of... to the tune of 500 M isk.

https://zkillboard.com/detail/32099354/

   So Red Frog Freight and I have become very good friends.  For 4.5M I can have 800K m3 of freight moved 11 jumps.  I am sold.  Try to combine as much as possible into a single contract to make the most of it.

   So, my main is now in Black Rise doing Caldari faction warfare with several million skill points in industry just wasting away, so I decide to try some T1 industry.  I buy a Thrasher BPO (ME 10, PE 10) and a Moa BPO (ME 22, PE 15).  Both are doctrine ships in my alliance.  I build 30 Moas and 100 Thrashers and put them up for sale in Black Rise, and ~25 days later, 6 Moas and 5 Thrashers have sold.  FML.  There is 380M tied up for a month for no good reason.



  In this time I spent about a billion isk on PvP ships stocking up doctrine ships I have yet to really use.  I have lost a couple to frigate hot drops in plexes, but have yet to manage to kill anything.  A carebear in PvP is like a seal trying to play fight club in the shark tank, its going to have a bad time.

  I have been working on product selection programs for a while now, both for T1, which is much easier, and T2, which is complicated by meta items and decryptors in the invention process.  My tool told me to look a Covert Ops Cloaking Devices.  So I loaded them up in my tool, and they were showing 6 day build times and 400-500K isk/hour/manufacturing line and 50% profit.  That comes out to something in the neighborhood of 2.6B in profit/month.


   I bought a researched BPO (100,15) for 250M and a copy blank from NPC for 100M.  Then I spent over 500M to buy enough materials to invent 10 T2 BPCs and build an additional 100 units of Prototype Cloaking Device.  Then I went to install my blank to make invention copies, when I noticed the real problem.  Not only does it take 277.78 days to make 20 100 run copies needed for normal invention, but there are additional materials required to make those copies.  The above image shows the copy time, but includes the cost of copy materials.  So this caused me to add copy time to the display of my tool, and also to take the greater of the copy or build time to determine ISK / hour.


   Looking at it with copy time determining isk/hr, it now looks like a much worse product.  You still have > 50% profit, but now with only 100K isk/hr, which comes out to somewhere around 672M isk/month.  There are so many easier ways to make that kind of isk, this is only 200M isk above Scorch M, which has a negligible effort.  So what about using decoders?

  Just reducing the number of runs on the T1 copy to minimum almost doubles your isk/hr.


  Inventing on Augmentation decryptors brings your isk/hr sky rocketing back into an area that I am willing to work with.  You are still making 50% profit, or 100% Return on investment(ROI).  5 day copy time, ~70 copies to make 20 T2 BPCs assuming level 4 invention skills.  As it sits right now, I am sitting on this material, after making 200 units of Prototype Cloaking Device, trying to decide how far down the rabbit hole I want to go.


And then you add another inventor into the mix...

   So, after all of that fun, I have another inventor coming up on completing the invention training plan in less than 3 weeks.  With an 12-16 day lead time on high sec copy slots, its time to select the products for her.  So I spent some time in the last week working on my invention profiteer, see my previous post for more info.  I came up with 3 products, each with ~50% profit and a 1.5-2 day adjusted build time.  Those products I will keep to my self, as I do not want to encourage more competition.

   Below is a chart of the 90 day history of build cost (red) verses sell price (blue) for my 3 inventors.  It will probably take a couple of months to get this into full swing and find a good balance.  My main will have 6-7 day build times, my new inventor will have 1.5 -2 day build times, and my old inventor has 1-2 day build times.  I spent an additional 30 million on BPO blanks for copying for my main and new inventor.



Plans:

    I know in the early posts of this blog, I talked about doing a high-sec T2 inventor in only NPC stations, but that is quickly becoming impractical.  The problem is not invention or manufacturing slots, if you move around and are flexible enough you can find a sweet spot to do that in that will allow you to have near 100% efficiency. The problem is that you need ~105% or more of the T1 BPCs to make T2 BPCs.  You will find that in most high sec areas, you are looking at 8-30 days lead time until your copy starts.  Another trap you run into is that some of the copy slots have costs an order of magnitude higher than the rest.  Normally, my copy costs are in the 140K-280K isk range for full runs and 20 copies, and I'm fine with that.  But you sometimes find a line that will cost you 2.5M isk for the same thing, which I am not ok with.

   So, I need to look into dropping a couple of POSs.  2 Medium POSs will allow me to run up to 8 inventors, doing copying, inventing, and manufacturing at the POS.  This will also run me ~440M isk/month, or almost a PLEX.  I can't afford to do that until I have my other 2 invention lines established.  Not only that, but I don't have any characters with faction standing above 5, so I will have to hire a standings service to be able to drop the POSs.  POS cost is also another problem, to drop 2 medium towers will cost nearly a billion ISK, with only 4 equipment arrays and 1 each of mobile and advanced mobile labs.  This is the minimum needed for 2 characters.  The second tower is so that I don't have to worry about a standings service when I outgrow the first.  I also need to start doing missions on one of my invention characters so that I can boost my corp faction standings myself.

  This is all not mentioning the fact that I have been neglecting my faction warfare duties.  I need to have time to be bad at PvP and run plexes.  Oh well, it keeps Eve interesting :)

Monday, August 26, 2013

Top Invention Products: Modules

Top Invention Products: Modules

   I have another inventor coming up on fully trained and I need to decide what products to invent on her.  So I have been working on a script to give me insight into the best products, in both ISK/hr and volume.  What I came up with was an industrial index, expressed by the following formula:

   Industrial Index = ((Sell Price - (Build cost + Invent Cost + Copy Cost(materials))) / (Greater of Build or copy Time rounded up to the next 12 hour increment)) * (lesser of 1 or (20 % daily sales volume / Volume Produced/day by 1 mfg line);

   What this means is that its estimating the isk/hr based on the actual time it will take most people to flip jobs.  Most people cannot keep a 16 hour line going at 16 hours, so we round up to 24 hours to calculate isk/hr.  The sales volume component makes sure that you are not thoroughly out producing the market.  What I am sharing with you today are the top 50 modules (no decoders or meta items considered) to produce based on numbers on 8/25/13.  There are some products, like 125mm Gatling AutoCannon II that when investigated clearly show they are in a bubble.  There are also a lot of products which had no volume on that day.  But given the amount of time it takes to run this, ~20 seconds / day / product configuration, I don't see me running a 90 day comparison of all products any time soon.

   I will be doing a series of posts that give the same kind of information for different market groups.

   And without further ado, here is the top 50 modules per Industrial Index, sorted ASCII-betically.

100MN Afterburner II
125mm Gatling AutoCannon II
1MN Afterburner II
1MN Microwarpdrive II
200mm AutoCannon II
200mm Reinforced Steel Plates II
800mm Reinforced Steel Plates II
Adaptive Nano Plating II
Cap Recharger II
Capacitor Flux Coil II
Capacitor Power Relay II
Co-Processor II
Cruise Missile Launcher II
Damage Control II
Drone Damage Amplifier II
Drone Link Augmentor II
Dual 180mm AutoCannon II
Energized Adaptive Nano Membrane II
Expanded Cargohold II
Explosive Plating II
Heavy Capacitor Booster II
Heavy Ion Blaster II
Heavy Neutron Blaster II
Inertia Stabilizers II
Large Remote Armor Repair System II
Light Electron Blaster II
Light Ion Blaster II
Light Missile Launcher II
Light Neutron Blaster II
Magnetic Field Stabilizer II
Medium Armor Repairer II
Medium Capacitor Booster II
Medium Shield Booster II
Medium Shield Extender II
Mining Laser Upgrade II
Nanofiber Internal Structure II
Overdrive Injector System II
Power Diagnostic System II
Rapid Light Missile Launcher II
Relic Analyzer II
Remote Sensor Booster II
Rocket Launcher II
Scan Pinpointing Array II
Sensor Booster II
Shield Power Relay II
Small Armor Repairer II
Small Energy Neutralizer II
Survey Scanner II
Warp Core Stabilizer II
Warp Scrambler II


Monday, July 15, 2013

June Monthly Update

June Monthly Update:


Later is better than never...

  • 414 million profit from 2.63 billion in sales.
    • 1.6 billion in material costs.
    • 29 million in manufacturing related costs (Maufacturing slots, Invention slots, copy slots, PE research slots, and ME research slots.)
    • 218 million in skills.
      • I decided to "Buy ALL THE SKILLS!!!" and hit the limit of 50 skills in training...
    • 40 million on Transaction taxes, upping skills to reduce this.
    • 28 million in brokers fees, again upping skills to reduce this.
    • 92 million in new BPO's.
      • I bought 1 each of Data Analyzer I Blueprint and Relic Analyzer I Blueprint, both 25 ME/25PE, for 25 mil each thinking I might get into the T2 Analyzers, but the market crashed.
      • Bought a bunch of frigate/indy BPO's from NPC's and have been using spare slots on my 2 copy toons to do ME/PE research on them.
    • 147 mil was spent on Personal stuff.  This includes Itty V's with T2 mods and T1 rigs for several characters.  It also includes my new Anathema for playing with scanning on my main.
As you can see, pretty steady month, no surprises.



Product sales breakdown.  My alt is starting to dominate the show with better products.  Need to investigate better product selection for my main.  Also, looking at bringing another inventor online in another couple of months.

Below is the Sell price vs Build cost of my mains entire kit:

And below, is a similar graph for my alt:

Plans:
  • I am splitting my main off of the corp wallet and he is going back to buying/selling all of his own product.  This is in preparation of joining a corp.  He is keeping the money from his current cycle, and maybe buying his next kit out of the corp wallet, but after that, he will have to work on his own capitol.
  • Working out of NPC stations, I need to get more agile in being able to move things from one station to another to take advantage of open slots.  My current home, when both my toons are done, there is usually a 2 hour wait on invention slots and a 30 minute - 8 day wait on manufacturing slots.
    • Looks like whomever I am sharing the station with either increased the number of people or changed their product line up to include 8 day manufacturing runs :(
  • With ~ 30 million in station costs, not to mention the 400K in contract costs moving things back and forth, it's about time I break down and start doing the math on getting a POS placed in high-sec.  My standings are nowhere near high enough to do it, so I will have to use a standings service to game the system.
    • POS will allow me to take the 2 copy toons that I currently have and move them into full inventors.
    • It will also remove the ~8 day delay in starting copy jobs that I now face in empire NPC stations.
    • It will also give me a couple of ME/PE slots without the 30+ day wait time.
    • Not sure if I will bother with doing manufacturing in the POS.
  • One of my copy alts will need to start doing T1 component manufacturing for my main inventors.  This will cut up to 6 days off the wait to start manufacturing my next T2 cycle
    • Most likely this will mean remaining 1 cycle or more ahead of my T2 cycles.
    • I will have to look closely at the available Component BPO's and find several to fill this toons manufacturing slots with component and T1 work.
    • Will need a report to constantly make sure that prices don't fluctuate from being profitable.

TL;DR
     Made another months profit.  Main is looking for corp.  Looking to make mo money.

Wednesday, June 5, 2013

Early Odyssey Profiteer Charts

Early Odyssey Profiteer Charts:

   One of the projects that I am working on is an attempt to fish out good products, both in profitability and velocity, from the chaff of available products.  I use a custom app to generate CSV's full of price/Material Efficiency.  I thought I would give you some graph pr0n and have them available for comparison to later graphs as the industry shake-up in odyssey settles out.  One note, is all prices and sales volume are from http://eve-marketdata.com/ and are limited to the forge.  Its also averaged out over the last 7 days to even out price/volume spikes.

   This will be a huge wall of graphs.  Also, please understand that these are Profitability * adjusted velocity.  This means that those products that have a huge profit, but not many sell, are ranked lower than those that have less profit but sell more.  Its also adjusted by how many you can produce in a given time period.  The value is calculated something along the lines of ((20% of Jita Sales Volume/day) / (How many units are produced in 1 day with PE 0 in high sec station with all 5 skills) * (Profit/hour for that ME value).  This gives you a rough idea of what the "Profitability velocity" of the item is.

   Just a note that this is far from the end of the work needed to select products.











Monday, June 3, 2013

May Financial Report

May Financial Report:

Highlights:
  • Sold 2.36 B ISK, bought 1.63 B ISK, for a total profit of ~730 M ISK (~31% Profit, or ~45% ROI).
    • Manufacturing accounts for 2.1 B ISK in sales and 1.38 B ISK in costs.
    • I sold a Raven (148 M ISK) and 2 Gnosis (~112 M ISK each) to make up the remaining income.
    • I bought an additional 187 M ISK in BPO's for my alt (A R.A.M. set and a Caldari T2 set)
  • Got product to market from my alt late this month, around the 24th.  Should increase my revenue next month if I can get her on a steady schedule.
  • Holding off on investing another ~300 million in component BPO's for my alt, using some from my main in the mean time.
  • I was using www.myeveapi.com to extract my wallet journal and transaction data, but late this month it stopped working for my journal, so I am looking for another source to easily extract this information.    What that means for this report is that taxes and other costs are underrepresented, but it should only be a couple of million low.

Category Breakdown of May:

  • No surprises here, Manufacturing kits/sales make up the lions share of money made/spent.
  • Spent about 3.5 million on copy slots and 5.6 million on invention.
Sales Breakdown for May (With products removed :):

  • All 4 lines that start early in the month are from my main.  I missed getting my last product to market, so it looks a little low at the end of the month.
  • Of the products that I selected for my alt, 2 are not showing the expected velocity.  Looks like all 4 are going to be competitive markets.

And finally the Manufacturing report:

  • I invested in another mfg cycle even though I am not complete on the current one.  This is an OCD make the graph pr0n look pretty thing.


   All in all, pretty good month.  I lost a week of play time when my credit card got stolen days before my main account was due.  We got most of the money back, but I had to wait for new cards to be issued.  My alt only had a partial kit make it to market.  I need to look into what she's doing, because looking into the sales graphs, you can see that 2 of the products (purple and dark blue) are selling good.  But the other 2 products (light green and pink) are not selling as well.
   For the next month I will be investing in some components to level out my costs during the first couple of months of Odyssey.  Also need to look into filling out some researched component BPO's on my alt to allow some flexibility.  Still looking for some filler product for both toons to keep their manufacturing lines full, but May was very tight on cash until the last week or so.
   I need to setup some planetary interactions on my main and start using some research agents for both of my toons.  Not sure if I want to add PI skills to my alt.  With my alt's training almost complete, I need to carefully consider what to do with the training time on my second account, especially in light of needing more copy slots to keep up with my invention slots.

Lessons learned:

  • When creating an alt, make sure that you have all the BPO's, researched and not, that they need before starting.
  • 500 M ISK is not enough to start a high-sec T2 manufacturing business without a lot of hiccups.  You need 500 M ISK or more just for kits.  You will probably spend at least that much again buying researched BPO's to make it efficient.
  • Noting the bullet above, have ~1.5 billion ISK available for any new alt.  500 M ISK for implants/skills, 500 M ISK for BPO's, and 500 M ISK for kit costs. (See Locke's Everything You Never Wanted to Know: Making an Industrial Alt for more information on making an industrial alt.)
  • All the bullets above being said, I am probably trying to buy too large of kits.  I am doing 4 products at 200 units/product.  Cutting that in half for each kit will be helpful.  Also, my main is doing products with components from all 4 races, and my alt is doing components from 2 different races.  Selecting products in the same race might be a better idea.
  • Product selection is difficult...and probably the biggest and most important time sink you will find.  Study your intended market and spend the time needed to determine what the true velocity of your product is. (If you don't know what I mean by velocity see Metrics, again from Locke.)
  • Because of the bullet above, I will be narrowing the focus of my alt, unfortunately, in high-sec station invention, this is not an agile process, you're looking 20+ days out to see the first cycle of your adjusted copy jobs come out of the oven (I have been averaging ~10 days/copy job, but I sometimes have to move 10+ jumps to find those stations with only 5 day queues).
  • For my main, I had to train another character to do nothing but copy for him.  I will have to do the same thing for my alt, once I finish with the last of the training.  I have them setup for 8 slots of copying, that's enough for for 800 modules every 10-14 days/character.  Trying to maintain 8 slots of copy and still do invention makes for a nightmare schedule.  28 days or so for an 11th slot/character...doesn't seem worth it yet, not with another 3 character slots on my current account still open.
  • Need to find a good way to utilize a potential 10 manufacturing slots / copy character.  Depending on how component profits come out in Odyssey, that's one option.  I would like to start producing some ships, but the T1 ship market is pretty upside down.  There are a few T1 products that look interesting, especially if I have the capital to keep them in sale orders in trade hubs, but that is probably a couple of months out.

Wednesday, May 1, 2013

Chart Fu

Chart Fu

   Just updated my script to make a shopping list, and added a plot for cost.  Just thought that I would make a short post for posterity.