# Search some help to finish a programm which analyse the all order in eve universe

**URL:** <https://forums.eveonline.com/t/search-some-help-to-finish-a-programm-which-analyse-the-all-order-in-eve-universe/66551>\
**Category:** Third Party Developers\
**Created:** [March 29, 2018, 4:10am UTC](https://forums.eveonline.com/t/search-some-help-to-finish-a-programm-which-analyse-the-all-order-in-eve-universe/66551 "2018-03-29T04:10:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meio\_Rayliegh](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/meio_rayliegh/32/391846_2.png) [@Meio\_Rayliegh](https://forums.eveonline.com/u/Meio_Rayliegh)\
**Post date:** [March 29, 2018, 4:10am UTC](https://forums.eveonline.com/t/search-some-help-to-finish-a-programm-which-analyse-the-all-order-in-eve-universe/66551/1 "2018-03-29T04:10:21Z")

</div>

hello i have a programme write on python the programme have to download all the sell order and all the buy order make a comparaison of their price and send a result when it find a great benefit.

But it have a probleme because the sell order are compare of the referral price this one is not complete and the goal is to compare the buy and the sell order.

So i search someone for help me to finish the programm because i am not able to replace the referralitem by the buy order i know how to download it but the problem is about the refferral i give you the source code

try:  
import urllib.request  
import ast  
import decimal  
import requests  
import json  
import time

except Exception as error:  
print(“ERROR: this {} module is messing”.format(error));  
exit(1);

class Transformer(ast.NodeTransformer):  
NAMES = set([‘Decimal’, ‘None’, ‘False’, ‘True’]);  
NODE\_TYPES = set([‘Expression’,‘Tuple’,‘Call’,‘Name’,‘Load’,‘Str’,‘Num’,‘List’,‘Dict’,]);

```
def visit_Name(self, node):
    if not node.id in self.NAMES:
        raise RuntimeError("Name access to {} is not allowed".format(node.id));
    return self.generic_visit(node);

def generic_visit(self, node):
    nodetype = type(node). __name__ ;
    if nodetype not in self.NODE_TYPES:
        raise RuntimeError("Invalid expression: {} not allowed".format(nodetype));
    return ast.NodeTransformer.generic_visit(self, node);

```

def fromTXT\_toSTRUCT(txtStream=""):  
parserTree = ast.parse(txtStream, mode=‘eval’);  
transformer = Transformer();  
transformer.visit(parserTree);  
clause = compile(parserTree, ‘’, ‘eval’);  
return eval(clause, dict(Decimal=decimal.Decimal));

def get\_url\_content(urlLink=“[https://www.google.com](https://www.google.com)”):  
url = urllib.request.urlopen(urlLink);  
return url;

def compare(currPage,refItems,currItems):  
print(“REGION NUMBER : %d” % currPage)  
for i in range(len(currItems)):  
for i2 in range(len(refItems)):  
if currItems[i][“type\_id”] == refItems[i2][“type\_id”]:  
ide = currItems[i][“type\_id”]  
try:  
if (refItems[i2][“average\_price”] - currItems[i][“price”]) \> 10000000:  
print("======================")  
print(“REF\_ITEM number %d :” % (ide))  
for key in refItems[i2].keys():  
if key != “type\_id”:  
print("\t%s : %s" % (key,refItems[i2][key]))  
print("----------------------")  
print(“COMPARED\_ITEM number %d :” % (ide))  
for key in currItems[i].keys():  
if key != “type\_id”:  
print("\t%s : %s" % (key,currItems[i][key]))  
print("----------------------")  
print(“DIFF:”)  
print("\t%d diff price" % (refItems[i2][“average\_price”]-currItems[i][“price”]))  
print("======================")  
except KeyError:  
print("======================")  
print(“REF\_ITEM number %d :” % (ide))  
print("\t no ref price or price NULL")  
print("======================")  
time.sleep(3.5)  
print("||||||||||||||||||||||||||||||||||||||||||||||")  
print("[INFO] refItems contain %d items" % (len(refItems)))  
print("[INFO] currItems contain %d items" % (len(currItems)))  
print("||||||||||||||||||||||||||||||||||||||||||||||")

def load\_market\_id(identifier):  
print (“Load market with id : %s” %str(identifier))  
url = “[https://esi.tech.ccp.is/v1/markets/%s/orders/?datasource=tranquility&order\_type=sell](https://esi.tech.ccp.is/v1/markets/%25s/orders/?datasource=tranquility&order_type=sell)” %identifier  
data = []  
page\_id = 0  
while True :  
res = requests.get(url, params={‘page’: page\_id}).json()  
if not res : break  
data.extend(res)  
page\_id += 1  
return data

def load\_all\_market\_id(identifier):  
data = {}  
values = load\_market\_id(identifier)  
if values :  
data[identifier] = values  
return data

def main():  
count = 0  
try:  
while True:  
refUrl = get\_url\_content(“[https://esi.tech.ccp.is/latest/markets/prices/?datasource=tranquility](https://esi.tech.ccp.is/latest/markets/prices/?datasource=tranquility)”);  
refStructuredContent = fromTXT\_toSTRUCT(refUrl.read());  
refUrl.close()  
for nRegion in range(10000003,10000023):  
values = list(load\_all\_market\_id(nRegion).values());  
if len(values) \> 0:  
values = values[0]  
compare(nRegion,refStructuredContent,values);  
print("[INFO]: REFRESH number (%d) … " % count);  
coutn += 1;  
except KeyboardInterrupt:  
print("[INFO] the program has been stopped…")  
exit(0)  
return 0;  
main();

---

<div class="post-metadata">

**Author:** ![Brock\_Khans](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/brock_khans/32/409174_2.png) [@Brock\_Khans](https://forums.eveonline.com/u/Brock_Khans)\
**Post date:** [March 29, 2018, 4:57am UTC](https://forums.eveonline.com/t/search-some-help-to-finish-a-programm-which-analyse-the-all-order-in-eve-universe/66551/2 "2018-03-29T04:57:28Z")

</div>

Module is missing. I would assume its one of your imports at the top

```auto
import urllib.request
import ast
import decimal
import requests
import json
import time

```

I suggest you check if all of those are installed on your system:

> <https://askubuntu.com/questions/588390/how-do-i-check-whether-a-module-is-installed-in-python-and-install-it-if-needed>

---

<div class="post-metadata">

**Author:** ![Meio\_Rayliegh](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/meio_rayliegh/32/391846_2.png) [@Meio\_Rayliegh](https://forums.eveonline.com/u/Meio_Rayliegh)\
**Post date:** [March 29, 2018, 7:57am UTC](https://forums.eveonline.com/t/search-some-help-to-finish-a-programm-which-analyse-the-all-order-in-eve-universe/66551/3 "2018-03-29T07:57:47Z")

</div>

yes but it is not the problem the problem is  
refUrl = get\_url\_content(“[https://esi.tech.ccp.is/latest/markets/prices/?datasource=tranquility”](https://esi.tech.ccp.is/latest/markets/prices/?datasource=tranquility%E2%80%9D));  
the referal have to be the buy order price so the data but it have already a data var so what can i do and what does i change?

---

<div class="post-metadata">

**Author:** ![Althalus\_Stenory](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/althalus_stenory/32/429792_2.png) [@Althalus\_Stenory](https://forums.eveonline.com/u/Althalus_Stenory)\
**Post date:** [March 29, 2018, 10:29am UTC](https://forums.eveonline.com/t/search-some-help-to-finish-a-programm-which-analyse-the-all-order-in-eve-universe/66551/4 "2018-03-29T10:29:25Z")

</div>

`/markets/prices/` are not the buy/sell prices. They are average / adjusted prices used for taxes, insurance etc in the game. You can generate your ID list from this one, but this one [https://esi.tech.ccp.is/ui/#/Market/get\_markets\_region\_id\_types](https://esi.tech.ccp.is/ui/#/Market/get_markets_region_id_types) is the one you should use to generate that list

If you want the order prices, you need to use the right enpoint for prices [https://esi.tech.ccp.is/ui/#!/Market/get\_markets\_region\_id\_orders](https://esi.tech.ccp.is/ui/#!/Market/get_markets_region_id_orders)  
This is where you’ll have sell / buy prices, but keep in mind this is all the order in the game, so you have to parse it, get the min/max or whatever you want, using all pages before you can display what you want.

In the future, you’d rather put code within code tags (write `` your code ``, also it’s “preformated text”)

---

<div class="post-metadata">

**Author:** ![Meio\_Rayliegh](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/meio_rayliegh/32/391846_2.png) [@Meio\_Rayliegh](https://forums.eveonline.com/u/Meio_Rayliegh)\
**Post date:** [March 29, 2018, 10:52am UTC](https://forums.eveonline.com/t/search-some-help-to-finish-a-programm-which-analyse-the-all-order-in-eve-universe/66551/5 "2018-03-29T10:52:08Z")

</div>

i know that is why i need to change it and adapt this code to my fonction

> ` import requests  
> import json

def load\_market\_sell(identifier) :  
print (“Load market with id : %s” %str(identifier))  
url = “[https://esi.tech.ccp.is/v1/markets/%s/orders/?datasource=tranquility&order\_type=sell](https://esi.tech.ccp.is/v1/markets/%25s/orders/?datasource=tranquility&order_type=sell)” %identifier  
data =   
page\_id = 0

```
while True :
	res = requests.get(url, params={'page': page_id}).json()
	if not res : break
	data.extend(res)
	page_id += 1

return data

```

def load\_all\_market\_sell(start, end) :

```
data = {}
for identifier in range(start, end) :
	values = load_market_sell(identifier)
	if values :
		data[identifier] = values

return data

```

def load\_market\_buy(identifier) :  
print (“Load market with id : %s” %str(identifier))  
url = “[https://esi.tech.ccp.is/v1/markets/%s/orders/?datasource=tranquility&order\_type=buy](https://esi.tech.ccp.is/v1/markets/%25s/orders/?datasource=tranquility&order_type=buy)” %identifier  
data1 =   
page\_id = 0

```
while True :
	res = requests.get(url, params={'page': page_id}).json()
	if not res : break
	data1.extend(res)
	page_id += 1

return data1

```

def load\_all\_market\_buy(start, end) :

```
data1 = {}
for identifier in range(start, end) :
	value = load_market_buy(identifier)
	if value :
		data1[identifier] = value

return data1  

```

for identifier, value in load\_all\_market\_buy(10000001,10000004).items():  
print (len(value))  
identifier += 1  
for identifier, values in load\_all\_market\_sell(10000001,10000004).items():  
print (len(values))  
identifier += 1`  
this code download all the buy and sell order of the market on the region 10000001 to 10000004  
but i have some problem to make the main and the compare fonction that is why i ask help i have to change the refurl and compare the two database as i make but don’t know how to do that

---

<div class="post-metadata">

**Author:** ![Meio\_Rayliegh](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/meio_rayliegh/32/391846_2.png) [@Meio\_Rayliegh](https://forums.eveonline.com/u/Meio_Rayliegh)\
**Post date:** [March 31, 2018, 5:05am UTC](https://forums.eveonline.com/t/search-some-help-to-finish-a-programm-which-analyse-the-all-order-in-eve-universe/66551/6 "2018-03-31T05:05:47Z")

</div>

i know and it is what i want to change but i ama noob in programmation so i expected some help to finish the program the script work but i have to change the ref url so change the main and compare function would you help me to change it ?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/eveonline/original/3X/4/1/41ec4921cbaca7a6f9ea556e7cc20018461eae5e.png) [@system](https://forums.eveonline.com/u/system)\
**Post date:** [June 29, 2018, 5:05am UTC](https://forums.eveonline.com/t/search-some-help-to-finish-a-programm-which-analyse-the-all-order-in-eve-universe/66551/7 "2018-06-29T05:05:49Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
