Guest User

Untitled

a guest
Jul 14th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.79 KB | None | 0 0
  1. %returns the quicksale and slowsale value of a material based on a parse of
  2. %market dump
  3. %Input: Material (using space not underscore for something like Dark
  4. %Ochre), Region (eg Heimatar), station (numerical ID), filelocation, eg
  5. %C:\Users\Alex\Documents\EVE\logs\Marketlogs\
  6. %
  7. %Output: [Quicksale,Slowsale]
  8. %
  9. %Example
  10. %[Veldspar_quicksale,Veldspar_slowsale]=marketparse('Veldspar', 'Heimatar',
  11. %60004588, 'C:\Users\Alex\Documents\EVE\logs\Marketlogs\')
  12.  
  13.  
  14. function[quicksale,slowsale] = marketparse(material, region, station, filelocation)
  15. %material='Veldspar';
  16. %region='Heimatar';
  17. %station=60004588;
  18. %filelocation='C:\Users\Alex\Documents\EVE\logs\Marketlogs\';
  19.  
  20. filelist=struct2cell(dir(strcat(filelocation,region,'-',material,'*')));
  21. filelist_size=size(filelist);
  22.  
  23. timestamp_values=zeros(filelist_size(2));
  24. for (counter=1:filelist_size(2))
  25.     timestamp_values(counter)=filelist{5,counter};
  26. end
  27.  
  28. timestamp=max(timestamp_values(:,:));
  29. current_timestamp=filelist{5,1};
  30.  
  31. while (current_timestamp ~= timestamp)
  32.     filelist_size=size(filelist);
  33.     filelistb={filelist{1,2:filelist_size(2)};filelist{2,2:filelist_size(2)};filelist{3,2:filelist_size(2)};filelist{4,2:filelist_size(2)};filelist{5,2:filelist_size(2)}};
  34.     filelist=filelistb;
  35.     clear filelistb
  36.     current_timestamp=filelist{5,1};
  37. end
  38.  
  39. filelist=strcat(filelocation,char(filelist{1,1}));
  40. fid=fopen(filelist);
  41. trash=fgetl(fid);
  42. market=textscan(fid,'%f,%f,%f,%f,%f,%f,%f,%s %f:%f:%f,%f,%f,%f,%f,%f,%s');
  43. market_price=market{1,1};
  44. market_string=market{1,8};
  45. market_station=market{1,13};
  46.  
  47. counter=1;
  48. while (counter<max(size(market_price)))
  49.     if (market_station(counter) ~= station)
  50.         if (counter==1)
  51.             market_price=market_price(2:max(size(market_price)));
  52.             market_string={market_string{2:max(size(market_string))}}';
  53.             market_station=market_station(2:max(size(market_station)));
  54.         else
  55.             if (counter==max(size(market_price)))
  56.                 market_price=market_price(1:counter-1);
  57.                 market_string={market_string{1:counter-1}}';
  58.                 market_station=market_station(1:counter-1);
  59.             else
  60.                 market_price=[market_price(1:counter-1);market_price(counter+1:max(size(market_price)))];
  61.                 market_string={market_string{1:counter-1},market_string{counter+1:max(size(market_string))}}';
  62.                 market_station=[market_station(1:counter-1);market_station(counter+1:max(size(market_station)))];
  63.             end
  64.         end
  65.     else
  66.         counter=counter+1;
  67.     end
  68. end
  69.  
  70.  
  71.  
  72. number_of_values=max(size(market_price));
  73. counter=0;
  74. sellers=0;
  75.  
  76. while (counter<number_of_values)
  77.     counter=counter+1;
  78.     test_value=(market_string{counter}=='F');
  79.     if (test_value(1)==1)
  80.         sellers=sellers+1;
  81.     end
  82. end
  83.  
  84. counter=0;
  85. buyers=0;
  86. while (counter<number_of_values)
  87.     counter=counter+1;
  88.     test_value=(market_string{counter}=='T');
  89.     if (test_value(1)==1)
  90.         buyers=buyers+1;
  91.     end
  92. end
  93.  
  94. counter=0;
  95. counter2=1;
  96.  
  97. if (sellers==0)
  98.     slowsale=0;
  99. else
  100.     slowsale_vector=zeros(1,sellers);
  101.     while (counter<number_of_values)
  102.         counter=counter+1;
  103.         test_value=market_string{counter}=='F';
  104.         if (test_value(1)==1)
  105.             slowsale_vector(counter2)=market_price(counter);
  106.             counter2=counter2+1;
  107.         end
  108.     end
  109.     slowsale=min(slowsale_vector);
  110. end
  111.  
  112. counter=0;
  113. counter2=1;
  114.  
  115. if (buyers==0)
  116.     quicksale=0;
  117. else
  118.     quicksale_vector=zeros(1,sellers);
  119.     while (counter<number_of_values)
  120.         counter=counter+1;
  121.         test_value=market_string{counter}=='T';
  122.         if (test_value(1)==1)
  123.             quicksale_vector(counter2)=market_price(counter);
  124.             counter2=counter2+1;
  125.         end
  126.     end
  127.     quicksale=max(quicksale_vector);
  128. end
Add Comment
Please, Sign In to add comment