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

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”):
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” %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”);
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();

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

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:

yes but it is not the problem the problem is
refUrl = get_url_content(“https://esi.tech.ccp.is/latest/markets/prices/?datasource=tranquility”);
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?

/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 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
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”)

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” %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” %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

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 ?

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