In-Development TradeDangerous: power-user trade optimizer

I edited station.csv to set the distance to -1 and uploaded to maddavo
Then I tried trade.py station --rm <system/station> and got an error about the line I'd edited
Code:
NOTE: Rebuilding cache file: this may take a moment.*** INTERNAL ERROR: CHECK constraint failed: Station
CSV File: P:\Program Files (x86)\td\data\Station.csv:294
SQL Query: INSERT INTO Station (system_id,name,ls_from_star,blackmarket,max_pad_size) VALUES((SELECT System.system_id FROM System WHERE System.name = ?),?,?,?,?)
Params: ['78 URSAE MAJORIS', 'Landis Freeport', '-1', '?', '?']
Then I edited the line and tried the command again. This time I got an error
Code:
NOTE: Rebuilding cache file: this may take a moment.P:\Program Files (x86)\td\trade.py: Station.csv:5951 ERROR Station 'Bondar City' is marked as DELETED and should not be used.
So I deleted that line from station.csv and tried again. Another error this time
Code:
NOTE: Rebuilding cache file: this may take a moment.P:\Program Files (x86)\td\trade.py: P:\Program Files (x86)\td\data\TradeDangerous.prices:429656 ERROR Unrecognized STAR/Station: "ADEO/FOOA PORT"
Looking at maddavo's site I see that the station has been changed to FODA PORT so I edited TradeDangerous.prices file and tried yet again.
Code:
NOTE: Rebuilding cache file: this may take a moment.
Traceback (most recent call last):
  File "P:\Program Files (x86)\td\trade.py", line 102, in <module>
    main(sys.argv)
  File "P:\Program Files (x86)\td\trade.py", line 52, in main
    tdb = tradedb.TradeDB(cmdenv, load=cmdenv.wantsTradeDB)
  File "P:\Program Files (x86)\td\tradedb.py", line 555, in __init__
    self.reloadCache()
  File "P:\Program Files (x86)\td\tradedb.py", line 641, in reloadCache
    cache.buildCache(self, self.tdenv)
  File "P:\Program Files (x86)\td\cache.py", line 1043, in buildCache
    processPricesFile(tdenv, tempDB, pricesPath)
  File "P:\Program Files (x86)\td\cache.py", line 745, in processPricesFile
    tdenv, pricesFh, db, defaultZero
  File "P:\Program Files (x86)\td\cache.py", line 695, in processPrices
    changeStation(matches)
  File "P:\Program Files (x86)\td\cache.py", line 584, in changeStation
    processedStations[stationID]
KeyError: -111

Stuck now. :( buildcache -f produces the same error.
 
I edited station.csv to set the distance to -1 and uploaded to maddavo
Then I tried trade.py station --rm <system/station> and got an error about the line I'd edited
Code:
NOTE: Rebuilding cache file: this may take a moment.*** INTERNAL ERROR: CHECK constraint failed: Station
CSV File: P:\Program Files (x86)\td\data\Station.csv:294
SQL Query: INSERT INTO Station (system_id,name,ls_from_star,blackmarket,max_pad_size) VALUES((SELECT System.system_id FROM System WHERE System.name = ?),?,?,?,?)
Params: ['78 URSAE MAJORIS', 'Landis Freeport', '-1', '?', '?']
Then I edited the line and tried the command again. This time I got an error
Code:
NOTE: Rebuilding cache file: this may take a moment.P:\Program Files (x86)\td\trade.py: Station.csv:5951 ERROR Station 'Bondar City' is marked as DELETED and should not be used.
So I deleted that line from station.csv and tried again. Another error this time
Code:
NOTE: Rebuilding cache file: this may take a moment.P:\Program Files (x86)\td\trade.py: P:\Program Files (x86)\td\data\TradeDangerous.prices:429656 ERROR Unrecognized STAR/Station: "ADEO/FOOA PORT"
Looking at maddavo's site I see that the station has been changed to FODA PORT so I edited TradeDangerous.prices file and tried yet again.
Code:
NOTE: Rebuilding cache file: this may take a moment.
Traceback (most recent call last):
  File "P:\Program Files (x86)\td\trade.py", line 102, in <module>
    main(sys.argv)
  File "P:\Program Files (x86)\td\trade.py", line 52, in main
    tdb = tradedb.TradeDB(cmdenv, load=cmdenv.wantsTradeDB)
  File "P:\Program Files (x86)\td\tradedb.py", line 555, in __init__
    self.reloadCache()
  File "P:\Program Files (x86)\td\tradedb.py", line 641, in reloadCache
    cache.buildCache(self, self.tdenv)
  File "P:\Program Files (x86)\td\cache.py", line 1043, in buildCache
    processPricesFile(tdenv, tempDB, pricesPath)
  File "P:\Program Files (x86)\td\cache.py", line 745, in processPricesFile
    tdenv, pricesFh, db, defaultZero
  File "P:\Program Files (x86)\td\cache.py", line 695, in processPrices
    changeStation(matches)
  File "P:\Program Files (x86)\td\cache.py", line 584, in changeStation
    processedStations[stationID]
KeyError: -111

Stuck now. :( buildcache -f produces the same error.

a/ You're running a fairly old version there, which happens to have a bug in it,
b/ You want "trade.py buildcache -f -i":

Code:
buildcache:  just rebuild the cache and exit,
    -f:  do it even if the .db file exists
    -i:  ignore "unknown station" errors and add them to the db
 
Noob question.
Once I've Exported from EliteOCR to TradeDangerous and got my import.prices files, what command should I use to :
1) Update my local TD
and
2) Upload that data for it to be shared.

I'm already sending from EliteOCR to EDDN and saving csv and bpc for contributing data elsewhere.

What brought me to TD was the desire to see Station distance and pad size updated more often and accurately.
What I find is an immensely powerful tool, even if it does come with a bit of a learning curve ...
 
Noob question.
Once I've Exported from EliteOCR to TradeDangerous and got my import.prices files, what command should I use to :
1) Update my local TD
and
2) Upload that data for it to be shared.

I'm already sending from EliteOCR to EDDN and saving csv and bpc for contributing data elsewhere.

What brought me to TD was the desire to see Station distance and pad size updated more often and accurately.
What I find is an immensely powerful tool, even if it does come with a bit of a learning curve ...

Type:

Code:
trade.py --help
trade.py import --help

The "import" command is the command that imports data from a .prices file, and by default it assumes that filename is "import.prices", so

Code:
trade.py import

is all you need to type if the "import.prices" file is in the same directory as your trade.py file.

If you are already submitting data to EDDN then it's already on its way to crowd-sourcing sites like Maddavos and you don't need to do anything else.

If you are wanting to contribute System/Station data to TradeDangerous itself:

. For Systems, see "Elite Dangerous Star Coordinator" (http://edstarcoordinator.com/) or use the "submit-distances.py" script in the trade folder,
. For Stations or station data, either submit the data to Maddavo or see the TD issue ticket: https://bitbucket.org/kfsone/tradedangerous/issue/105/collect-distance-black-market-and-pad-size)

Or if you're familiar with git, you can fork the repo and submit pull requests. If that's greek to you, I'd recommend leaving it that way ;)

If you aren't already using it, you may want to look into the "maddavo" import plugin which pulls data from one of our main crowd-sourcing efforts. I've just refreshed it so that it will better support the concept of a "merge" for system and station data, which should remove a huge obstacle to common use.
 
Noob question.
Once I've Exported from EliteOCR to TradeDangerous and got my import.prices files, what command should I use to :
1) Update my local TD
and
2) Upload that data for it to be shared.

I'm already sending from EliteOCR to EDDN and saving csv and bpc for contributing data elsewhere.

What brought me to TD was the desire to see Station distance and pad size updated more often and accurately.
What I find is an immensely powerful tool, even if it does come with a bit of a learning curve ...

To update local TD using EliteOCR export (EliteOCR creates an import.prices file):

Code:
trade.py import import.prices

You do not need to upload prices if you send to EDDN with EliteOCR - we use EDDN.

To upload stations to be shared:
Code:
python -m misc.madupload data/Station.csv

EDIT: HAHA Ninja'd!
 
Last edited:
Version 6.10.0 - some subtle but major changes

Version 6.10.0 is in bitbucket, and this has some subtle but fairly major changes.

1. Maddavo Merges

Code:
trade.py import --plug=maddavo --opt=stncsv --opt=syscsv

This feature was confusing for people; it downloaded mad's files and overwrote your own local files, which is not what most people wanted.

So I've changed the plugin significantly: It will now merge mad's data with the local data. That means: It will add systems/stations he has that you don't; it will fill in blanks (ls from star, black market, etc).

One catch: If both you and maddavo have a value for something (star coordinates, station ls from star, etc) the maddavo value wins. So make sure you upload your local changes to him before you merge.

I've replaced "--opt=syscsv" with "--opt=systems" and "--opt=stncsv" with "--opt=stations" so that people are made aware of this transition.


2. "--progress"

The "run" command can get kinda slow, and rather than watching ... nothing ... you may want to use "--progress" to tell that it's not stopped.

3. "--gain-per-ton" (--gpt)

This lets you set a lower-boundary on what trades to even think about. Using this can significantly speed up TD calculation of routes but it may also limit you.

Code:
tdrun lhs1914 --hops 6 --jumps 5 --gpt 900

This will only consider trades that make a profit of at least 900 cr/ton.

Caveat Emptor: You can easily lock yourself into a sub-optimal route with this option. Sometimes you have to take a low-profit hop to connect to a much higher profit track, and using this option can prevent that. However, if you just want to run some quick profits, this can be a quick way to generate some routes fast.

4. Over 130 new Systems added.

Unfortunately, as the size of the known-space sphere grows, less and less people are "confirming" each other's EDSC submissions. If you'd like to help with that, send me a private message.

5. Several internal API changes

It's now easier for plugin/3rd party users to access trading data. I changed the way that TradeCalc decides what trades to load (so we don't have to check things for the avoidance list) and added TradeCalc.getProfitables.


Code:
v6.10.0 Feb 14 2015
. (kfsone) Major changes to the 'maddavo' plugin:
    - The plugin now supports "merging" of Systems and Stations from
      maddavo's site into your local db. It does not, by default, write
      these to the ".csv" files.
    - Removed "--opt=syscsv" and "--opt=stncsv",
    - Added "--opt=systems" and "--opt=stations" and "--exportcsv",
    - Assorted cleanup
Also:
. (kfsone) "run" with "--progress" is less silent,
. (kfsone) Fixed 'set changed size' error in run command
. (kfsone) Improvements to the TradeCalc api for accessing station trades
. (kfsone) Added "--gain-per-ton" (--gpt) to run command
. (kfsone) Added "CSVStream" class to transfers.py
. (kfsone) Added "Progress" progress-bar class to misc/progress.py
+ 130 new systems from EDSC
 
The last two times I tried to use trade dangerous, it is trying to send me to places that don't exist.
BRANI/Naddoddur Terminal and BRANI/Ride Ring
Is there a way to stop this so I stop losing money?

Code:
C:\Trade>trade.py run --from "Verbigeni/Archambault" --credits 4292 --capacity 4
 --ly-per 6.96 --jumps 5 -vv
VERBIGENI/Archambault Plant -> SUN TAKUSH/McNair Gateway (score: 4179.067940)
  Load from VERBIGENI/Archambault Plant (234ls/star, No/bm, Med/pad):
        2 x Lithium           1,445cr vs    1,952cr, 4 days vs 2 days
        2 x Cobalt              603cr vs      948cr, 4 days vs 2 days
  Jump VERBIGENI -> BRANI
  Unload at [B]BRANI/Naddoddur Terminal[/B] (no details) => Gain 1,704cr (426cr/ton) =>
 5,996cr
  Load from [B]BRANI/Naddoddur Terminal[/B] (no details):
        3 x Robotics          1,511cr vs    2,207cr, 2 days vs 6 days
        1 x Semiconductors      783cr vs    1,172cr, 2 days vs 6 days
  Jump BRANI -> NLTT 48288 -> ALRAI SECTOR LC-V B2-4 -> SUN TAKUSH
  Unload at SUN TAKUSH/McNair Gateway (1,384ls/star, No/bm, Lrg/pad) => Gain 2,4
77cr (619.25cr/ton) => 8,473cr
  ----------------------------------------------------------------------------
  Finish at SUN TAKUSH/McNair Gateway (1,384ls/star, No/bm, Lrg/pad) gaining 4,1
81cr => est 8,473cr total

Code:
C:\Trade>trade.py run --from "Brani/Akiyama Market" --credits 3786 --capacity 4
--ly-per 6.96 --jumps 5 -vv
BRANI/Akiyama Market -> ABUKUNIN/Reilly Hub (score: 4166.471600)
  Load from BRANI/Akiyama Market (46ls/star, No/bm, Lrg/pad):
        3 x Coffee                1,194cr vs    1,640cr, 4 days vs 2 days
        1 x Mineral Oil             119cr vs      327cr, 4 days vs 2 days
  Jump BRANI
  Unload at [B]BRANI/Ride Ring[/B] (no details) => Gain 1,546cr (386.5cr/ton) => 5,332c
r
  Load from [B]BRANI/Ride Ring[/B] (no details):
        3 x Non-Lethal Weapons    1,497cr vs    2,200cr, 2 days vs 4 days
        1 x Agri-Medicines          801cr vs    1,312cr, 2 days vs 4 days
  Jump BRANI -> VERBIGENI -> ABUKUNIN
  Unload at ABUKUNIN/Reilly Hub (171ls/star, Yes/bm, Lrg/pad) => Gain 2,620cr (6
55cr/ton) => 7,952cr
  ----------------------------------------------------------------------------
  Finish at ABUKUNIN/Reilly Hub (171ls/star, Yes/bm, Lrg/pad) gaining 4,166cr =>
 est 7,952cr total
 
Also using new version trying to import

C:\Trade>trade.py import --plug=maddavo --opt=systems --opt=stations
Traceback (most recent call last):
File "C:\Trade\trade.py", line 102, in <module>
main(sys.argv)
File "C:\Trade\trade.py", line 76, in main
results = cmdenv.run(tdb)
File "C:\Trade\commands\commandenv.py", line 80, in run
return self._cmd.run(results, self, tdb)
File "C:\Trade\commands\import_cmd.py", line 96, in run
if not plugin.run():
File "C:\Trade\plugins\maddavo_plug.py", line 305, in run
tdb.load(maxSystemLinkLy=tdenv.maxSystemLinkLy)
File "C:\Trade\tradedb.py", line 1856, in load
self._loadSystems()
File "C:\Trade\tradedb.py", line 673, in _loadSystems
self.cur.execute(stmt)
sqlite3.OperationalError: no such table: System
 
The last two times I tried to use trade dangerous, it is trying to send me to places that don't exist.
BRANI/Naddoddur Terminal and BRANI/Ride Ring
Is there a way to stop this so I stop losing money?

There are a lot of options available to you; remove the station, use the --avoid command, use the --age command to eliminate data from before the patch that changed the station data, talk to your crowd-sourcer to find out how to remove a bad entry, use your own personal "Station.csv".

You can also use "trade.py sell itemname --near brani" to find an alternate destination.

- - - - - Additional Content Posted / Auto Merge - - - - -

Also using new version trying to import

C:\Trade>trade.py import --plug=maddavo --opt=systems --opt=stations
Traceback (most recent call last):
File "C:\Trade\trade.py", line 102, in <module>
main(sys.argv)
File "C:\Trade\trade.py", line 76, in main
results = cmdenv.run(tdb)
File "C:\Trade\commands\commandenv.py", line 80, in run
return self._cmd.run(results, self, tdb)
File "C:\Trade\commands\import_cmd.py", line 96, in run
if not plugin.run():
File "C:\Trade\plugins\maddavo_plug.py", line 305, in run
tdb.load(maxSystemLinkLy=tdenv.maxSystemLinkLy)
File "C:\Trade\tradedb.py", line 1856, in load
self._loadSystems()
File "C:\Trade\tradedb.py", line 673, in _loadSystems
self.cur.execute(stmt)
sqlite3.OperationalError: no such table: System

Either do a "trade.py buildcache -f -i" or download the latest code and try again.
 
Hi. I'm a big fan of this tool and have been using it for a while.
I've just upgraded to the latest version by copying down the latest version and overwriting my locally held files. I run this on a Mac so I've update the opening line of trade.py to Python 3. However when calculating a run it just hangs now... not a bean from the script. I have to break in to the script to stop it running.
Any ideas anyone?
 
Hi. I'm a big fan of this tool and have been using it for a while.
I've just upgraded to the latest version by copying down the latest version and overwriting my locally held files. I run this on a Mac so I've update the opening line of trade.py to Python 3. However when calculating a run it just hangs now... not a bean from the script. I have to break in to the script to stop it running.
Any ideas anyone?
Ok it seems that I'm too impatient... the output that used to show "Hops 1" updating to Hops X, etc... is now missing.
 
Thanks for the replies chasps :)

I DO have a git/bitbucket thingy but "familiar" is a term I'd not use with it.
Greek I'm a little more familiar with ... but not much

trying out that Circular Route command in the CookBook. doesn't want to work for me.
Have the commands changed or maybe the Data doesn't have the example stations anymore ... ?

Update
OK. Tried my own stations and getting a response now :cool:
 
Last edited:
Ok it seems that I'm too impatient... the output that used to show "Hops 1" updating to Hops X, etc... is now missing.

Add the "--progress" (--pro for short) option. This is because it got *more* spammy :)

Three small tips for using td: You can use some form of "--help" in most places (trade.py --help, trade.py run --help, trade.py import --plug=maddavo --opt=help, etc); td tries to let you get away with typing less in most cases (try "trade.py st he/gam"), you can usually shorten switches to their minimum distinct letters (--cr for --credits, --tow for --towards); update often.

Also, since you're using a mac, you can take advantage of the "scripts" directory, which lets you use shortcuts (see "ls scripts" for the list), e.g. tdrun --from aulin instead of "trade.py run --cr 2030410 --cap 104 --ly 15.6 --pr --fr aulin"

There's a "README" in the scripts directory.

-Oliver
 
To update local TD using EliteOCR export (EliteOCR creates an import.prices file):

Code:
trade.py import import.prices

You do not need to upload prices if you send to EDDN with EliteOCR - we use EDDN.

To upload stations to be shared:
Code:
python -m misc.madupload data/Station.csv

EDIT: HAHA Ninja'd!

Thanks for that, most useful.
I've just set my Win7 PATH to avoid having to cd for TD Python stuff but the misc.madupload only appears to work when I HAVE cd'ed to the TD folder ... Is there a way around that?

Using your upload command now, also updating Station/Station data via ROSS.
Hopefully those changes will filter through to all the tools I've bee using.
Was driving me mad getting to a Station only to find there was no Large Landing Pad ...
 
Thanks for that, most useful.
I've just set my Win7 PATH to avoid having to cd for TD Python stuff but the misc.madupload only appears to work when I HAVE cd'ed to the TD folder ... Is there a way around that?

One thing you could do is create a "tradecmd.bat" batch file (.bat):

Code:
SET TRADEDIR="C:\Dev\Trade"
SET CMDR="[i]your commander name here[/i]"

cd %TRADEDIR%

cmd

Then you can just create a shortcut to it and put that onto your taskbar/start menu/wherever is convenient for you.

Once you've used it a couple of times, you should find that you can hit the windows key and start typing "trade" and it'll find it for you, so you can just hit return...
 
It looks like some OCR derps made it into maddavo's Station.csv file.

Code:
trade.py local --ly=0 Branglal -vv
System              Dist
  /  Station                               StnLs Age/days BMkt Pad Itms
-----------------------------------------------------------------------
BRANGLAL            0.00
  /  Gibson Horizons                         882     2.89   No Lrg   66
  /  Skripochka Gateway                      882     0.00   No Lrg   66
  /  Skripochr Gateway                         ?        -    ?   ?    0

What is the official way to get these Stations and their trade data removed locally and remotely?
 
T

trying out that Circular Route command in the CookBook. doesn't want to work for me.
Have the commands changed or maybe the Data doesn't have the example stations anymore ... ?

Update
OK. Tried my own stations and getting a response now :cool:

My bad - the example was from my own local database of data as I do not use the crowdsourced one, and wanted to use one that I knew would work if someone tried it. If they had the data. Oops. Unfortunately I generally don't hang out in the main areas that are common to most, but at the fringes of known space, so likely do not have a better example in my database (I might have something around one of the starter systems, will check). If you have a better example that would be more likely in the crowdsourced data, please add it to the wiki.

kfsone, just in case you were wondering, I have been out of action with Real Life(tm) issues combined with East Coast Snowpocalypse I and II the past couple of weeks. Hopefully things are getting back to what passes for normal now and I will have some more time to get going on the UI again this coming weekend hopefully.

Edit: somewhere about halfway back in this thread is another example that may use more common systems, if anyone wants to look for it and add it to the wiki.
 
Last edited:
One thing you could do is create a "tradecmd.bat" batch file (.bat):

Code:
SET TRADEDIR="C:\Dev\Trade"
SET CMDR="[i]your commander name here[/i]"

cd %TRADEDIR%

cmd

Then you can just create a shortcut to it and put that onto your taskbar/start menu/wherever is convenient for you.

Once you've used it a couple of times, you should find that you can hit the windows key and start typing "trade" and it'll find it for you, so you can just hit return...
Thanks for the tips.

I'm guessing the:
Code:
SET CMDR="[i]your commander name here[/i]"
refers to something else other than the trade.py command ?

I made a batch file up as you suggested but my problem is not with the trade.py related stuff.
It's the:
Code:
python -m misc.madupload data/Station.csv
that doesn't run unless I'm cd'ed to the TradeDangerous dir
 
My bad - the example was from my own local database of data as I do not use the crowdsourced one, and wanted to use one that I knew would work if someone tried it. If they had the data. Oops. Unfortunately I generally don't hang out in the main areas that are common to most, but at the fringes of known space, so likely do not have a better example in my database (I might have something around one of the starter systems, will check). If you have a better example that would be more likely in the crowdsourced data, please add it to the wiki.

kfsone, just in case you were wondering, I have been out of action with Real Life(tm) issues combined with East Coast Snowpocalypse I and II the past couple of weeks. Hopefully things are getting back to what passes for normal now and I will have some more time to get going on the UI again this coming weekend hopefully.

Edit: somewhere about halfway back in this thread is another example that may use more common systems, if anyone wants to look for it and add it to the wiki.

I did this; keeping as close as possible to your original command:
https://bitbucket.org/kfsone/tradedangerous/wiki/CookBook#markdown-header-how-can-i-correct-the-padblackmarketdistance-of-a-station
 
Back
Top Bottom