1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-08 05:20:03 +03:00

Fixes Trade Dangerous .prices export.

Confirmed by Snake Man on EDCD Discordin #edmc

Snake Man : looks ok I guess (never done much of these manual imports)

	python3 trade.py import ../Daurtu.Panshin.Terminal.2019-09-12T12.29.27.prices
	NOTE: Import complete: 93 updated items over 1 stations in 1 systems

Snake Man : trade.py market -vv daurtu/panshin command looks fine too. and trade.py run --cap 500 --cr 20m --ly 12 --fr daurtu/pans gives trading results, looks good indeed
This commit is contained in:
Athanasius 2019-09-12 12:43:45 +01:00
parent c932bee929
commit 5caf861172

9
td.py
View File

@ -29,7 +29,7 @@ def export(data):
timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.strptime(data['timestamp'], '%Y-%m-%dT%H:%M:%SZ'))
# Format described here: https://bitbucket.org/kfsone/tradedangerous/wiki/Price%20Data
h = open(filename, 'wt') # codecs can't automatically handle line endings, so encode manually where required
h = open(filename, 'wb') # codecs can't automatically handle line endings, so encode manually where required
h.write(('#! trade.py import -\n# Created by %s %s on %s%s.\n#\n# <item name> <sellCR> <buyCR> <demand> <stock> <timestamp>\n\n@ %s/%s\n' % (applongname, appversion, platform=='darwin' and "Mac OS" or system(), not config.getint('anonymous') and ' for Cmdr '+data['commander']['name'].strip() or '', data['lastSystem']['name'].strip(), data['lastStarport']['name'].strip())).encode('utf-8'))
# sort commodities by category
@ -38,10 +38,11 @@ def export(data):
bycategory[commodity['categoryname']].append(commodity)
for category in sorted(bycategory):
h.write(' + %s\n' % category)
h.write(' + {}\n'.format(category).encode('utf-8'))
# corrections to commodity names can change the sort order
for commodity in sorted(bycategory[category], key=itemgetter('name')):
h.write(' %-23s %7d %7d %9s%c %8s%c %s\n' % (
#h.write(' %-23s %7d %7d %9s%c %8s%c %s\n'.format(
h.write(' {:<23} {:7d} {:7d} {:9}{:1} {:8}{:1} {}\n'.format(
commodity['name'],
int(commodity['sellPrice']),
int(commodity['buyPrice']),
@ -49,6 +50,6 @@ def export(data):
demandbracketmap[commodity['demandBracket']],
int(commodity['stock']) if commodity['stockBracket'] else '',
stockbracketmap[commodity['stockBracket']],
timestamp))
timestamp).encode('utf-8'))
h.close()