In-Development TradeDangerous: power-user trade optimizer

I think TradeDangerous does not support loading up cargo and taking it further away than one hop?!

It does not support the notion of buying goods from two different stations to sell simultaneously at a third.

a) It's a fairly rare use case,
b) When it's a practical use case, there's usually a better option,
c) It specifically defeats one of the optimizations that allows TD to solve the "NP Hard" version of the BPC problem,

(The NP hard version is the one that figures out that the 4th-best trade from Sol which leads to a 3rd best trade at Barnard's star ... is better than the obvious trade from Sol which leads to a dead end at Alpha Centauri carrying biowaste for 1/cr a ton for a hop).

It's possible it could be added as an option in future, but for now, it's one of those things where if you find a practical use case where this is demonstrably the best thing to do, you can work around it, e.g. by reducing your supplied capacity to treat some of the cargo capacity as reserved.

I'm assuming here that you're not confusing "hop" and "jump"; TD will quite happily make as many jumps between systems as you like before docking and trading, this is controlled by --jumps.

-Oliver
 
How do you enter system or station names that have spaces in them?

For example say I want to go to HIP 100035.

If I add the command
"--to HIP" it isn't going to know which HIP i want and naturally returns the following
"System/Station lookup: "HILL" could match HIP 100035, HIP 10046, HIP 100063,..."

If I add the full name
"--to HIP 100035" then it returns
"ERROR: unrecognized arguments: 100035"

Well, as explained in the README and the wiki, you can just leave the space out or enclose the word in quotes:


Windows, Powershell, Unixy-shells:
Code:
C:\Dev\trade>trade.py local "hip 100035" --ly 0
System              Dist
------------------------
HIP 100035          0.00

C:\Dev\trade>trade.py local hip100035 --ly 0
System              Dist
------------------------
HIP 100035          0.00

Powershell, Unixy-shells:
Code:
PS C:\dev\trade> .\trade.py local 'hip 100035' --ly 0
System              Dist
------------------------
HIP 100035          0.00

Unixy-shells:
Code:
osmith@WOTSIT /c/dev/trade (master)
$ trade.py local 'hip 100035' --ly 0
System              Dist
------------------------
HIP 100035          0.00

osmith@WOTSIT /c/dev/trade (master)
$ trade.py local hip\ 100035 --ly 0
System              Dist
------------------------
HIP 100035          0.00

Also note that TD's parser always tries to be lenient and allow you to type the least possible number of unique characters. This applies to station and system names as well as command line options.

Please section titled Command Line Parameters 101 in the wiki.
 
Last edited:
@Epicenter
Use single or double quotes around the full name
--to 'HIP 100035'

@kfsone
How do you want to handle locations with apostrophes? @MIKUNN/Spassky's Inheritance
I just took out the apostrophe when I updated Stations.csv locally, but having the name incorrect will make it not function right if you try to interop with other tools.

What is wrong with the current approach?

Station.csv:
Code:
'URSITOARE','Lucy Young''s Orbital Happy Home',329,'Y','L'

This is the normal way in CSV file to quote and quote-escape (we're using the batteries-included csv parser).

Code:
osmith@WOTSIT /c/dev/trade (master)
[b]$ trade.py local ur/happy --ly 0[/b]
System              Dist
------------------------
URSITOARE           0.00

osmith@WOTSIT /c/dev/trade (master)
[b]$ trade.py local ur/happy -v --ly 0[/b]
System              Dist
  /  Station                               StnLs Age/days BMkt Pad
------------------------------------------------------------------
URSITOARE           0.00
  /  Lucy Young's Orbital Happy Home         329     2.88  Yes Lrg
  /  Milestones                              907     2.87  Yes Lrg

osmith@WOTSIT /c/dev/trade (master)
[b]$ trade.py local @ursitoare/lucy -v --ly 0[/b]
System              Dist
  /  Station                               StnLs Age/days BMkt Pad
------------------------------------------------------------------
URSITOARE           0.00
  /  Lucy Young's Orbital Happy Home         329     2.88  Yes Lrg
  /  Milestones                              907     2.87  Yes Lrg

osmith@WOTSIT /c/dev/trade (master)
[b]$ trade.py local @ursitoare/lucyyoung -v --ly 0[/b]
System              Dist
  /  Station                               StnLs Age/days BMkt Pad
------------------------------------------------------------------
URSITOARE           0.00
  /  Lucy Young's Orbital Happy Home         329     2.88  Yes Lrg
  /  Milestones                              907     2.87  Yes Lrg

osmith@WOTSIT /c/dev/trade (master)
[b]$ trade.py local lucyyoung -v --ly 0[/b]
System              Dist
  /  Station                               StnLs Age/days BMkt Pad
------------------------------------------------------------------
URSITOARE           0.00
  /  Lucy Young's Orbital Happy Home         329     2.88  Yes Lrg
  /  Milestones                              907     2.87  Yes Lrg

osmith@WOTSIT /c/dev/trade (master)
[b]$ trade.py local lucyyoung\'s -v --ly 0[/b]
System              Dist
  /  Station                               StnLs Age/days BMkt Pad
------------------------------------------------------------------
URSITOARE           0.00
  /  Lucy Young's Orbital Happy Home         329     2.88  Yes Lrg
  /  Milestones                              907     2.87  Yes Lrg

osmith@WOTSIT /c/dev/trade (master)
[b]$ trade.py local "lucyyoung's" -v --ly 0[/b]
System              Dist
  /  Station                               StnLs Age/days BMkt Pad
------------------------------------------------------------------
URSITOARE           0.00
  /  Lucy Young's Orbital Happy Home         329     2.88  Yes Lrg
  /  Milestones                              907     2.87  Yes Lrg

osmith@WOTSIT /c/dev/trade (master)
[b]$ trade.py local "lucy young's" -v --ly 0[/b]
System              Dist
  /  Station                               StnLs Age/days BMkt Pad
------------------------------------------------------------------
URSITOARE           0.00
  /  Lucy Young's Orbital Happy Home         329     2.88  Yes Lrg
  /  Milestones                              907     2.87  Yes Lrg

The Window's command prompt doesn't treat apostrophe specially, so you can do this:

Code:
[b]c:\dev\trade>trade.py local lucyyoung --ly 0 -v[/b]
System              Dist
  /  Station                               StnLs Age/days BMkt Pad
------------------------------------------------------------------
URSITOARE           0.00
  /  Lucy Young's Orbital Happy Home         329     2.88  Yes Lrg
  /  Milestones                              907     2.87  Yes Lrg

[b]c:\dev\trade>trade.py local lucyyoung's --ly 0 -v[/b]
System              Dist
  /  Station                               StnLs Age/days BMkt Pad
------------------------------------------------------------------
URSITOARE           0.00
  /  Lucy Young's Orbital Happy Home         329     2.88  Yes Lrg
  /  Milestones                              907     2.87  Yes Lrg

but you can't do that under powershell.

Code:
PS c:\dev\trade> c:\dev\trade>trade.py local lucyyoung's --ly 0 -v
>>

(the ">>" means continuation)

Which is why I advise using double quotes around names in the README/wiki ("Nobody can hear your spaces")
 
Last edited:
I wonder how difficult it would be to hack TradeDangerous to support rare goods.

What I'm looking for is a route, where I load up rare goods at every stop and sell some at the same time. But try to sell at the maximum price (which is about 150ly away).

So, what I'm thinking is, create a special TradeDangerous.prices file which
  1. has only stations that sell rare goods
  2. has only entries for rare goods - no other trade data
  3. have the available stock hard coded
  4. have the station selling price hard coded
  5. have the station buying price approximated by the distance to the selling system


1-4 can be extracted from the spreadsheet here: https://docs.google.com/spreadsheets/d/1haUVaFIxFq5IPqZugJ8cfCEqBrZvFFzcA-uXB4pTfW4/edit#gid=0
5 can be calculated by this formula: https://forums.frontier.co.uk/showthread.php?t=66538.

Further infos on rare goods can be found here: https://forums.frontier.co.uk/showthread.php?t=63119


Now the big question, would that work with TradeDangerous?

That depends on what you mean by "work". TD can plan long routes for you no problem. But the primary BPC is directionaly agnostic - it doesn't try to "move" towards a destination, it just grinds away until it finds the best run or the best run that happens to end in the target system when you specify one. It also doesn't support empty-travel, although it's on the todo list. But mostly the current BPC is focused on maximizing profit-per-hop and subsequently total-profit.

It's probably something TD will have better support for over the next month but there's a couple of other large changes inbound first.
 
And I just checked in the "rare" subcommand:

Code:
$ trade.py rare neto --ly 50
Station                   Rare                             Cost DistLy  Alloc
-----------------------------------------------------------------------------
LFT 1421/Ehrlich Orbital  Void Extract Coffee             2,357  26.45      0
VEGA/Taylor City          Vega Slimweed                   2,398  33.44      0
V1090 HERCULIS/Kaku Plant Herculis Body Rub                 160  37.33     20
ALTAIR/Solo Orbiter       Altairian Skin                    489  39.78     18
XIHE/Zhen Dock            Xihe Biomorphic Companions      4,482  48.10      7
MULACHI/Clark Terminal    Mulachi Giant Fungus               86  49.31      0

$ trade.py rare @neto --ly 100 --pri --lim 3
Station                           Rare                           Cost DistLy  Alloc
-----------------------------------------------------------------------------------
JARADHARRE/Gohar Station          Jaradharre Puzzle Box        12,706  84.34      4
SHINRARTA DEZHRA/Jameson Memorial Waters of Shintara            7,495  97.84      5
DEA MOTRONA/Pinzon Dock           Motrona Experience Jelly      7,420  62.51      0

./trade.py: TradeDangerous help

usage: trade.py rare [--ly LY] [--limit LIMIT] [--price-sort] [-h] [--debug]
                     [--detail] [--quiet] [--db DBFILENAME] [--cwd CWD]
                     [--link-ly MAXSYSTEMLINKLY]
                     near

Required Arguments:
  near                  Your current system.

Optional Switches:
  --ly LY               Maximum distance to search.
  --limit LIMIT         Maximum number of results to list.
  --price-sort, -P      (When using --near) Sort by price not distance

...
 
Downloaded the new version, ran update and this is what it says:
Code:
trade.py: System.csv:110 ERROR System '22 Lyncis' is deprecated and should be replaced with 'PEPPER'.
 
Downloaded the new version, ran update and this is what it says:
Code:
trade.py: System.csv:110 ERROR System '22 Lyncis' is deprecated and should be replaced with 'PEPPER'.

Same here, if i delete the line from the System.csv i just get the next deprecated one? should we edit the System.vsc changing the names to the replaced name suggested?


Thanks
 
[Suggestion] NAV integration into RUN

Currently, at least as far as I can tell, a User cannot request a route between X System to Y System where TD reports the most profitable trades between X and Y. For instance, lets say I'm in Tsohoda and plan on making a long journey to Fujin. The current version of TD can tell me exactly what to buy in Tsohoda to bring to Fujin. However, it will not tell me all the various profitable trades in between in order to maximize the income along the route. The new NAV system, if incorporated into RUN would be able to accomplish just what I am proposing. NAV can pull the Systems to build the route while RUN determines what commodity to buy and sell along the predetermined route.

If the above is already possible, can someone suggest a command line to build from in order to accomplish the stated goal.
 
Last edited:
Same here, if i delete the line from the System.csv i just get the next deprecated one? should we edit the System.vsc changing the names to the replaced name suggested?


Thanks

I went ahead and edited the System.csv with the deprecated changes and received the following output:
Code:
NOTE: Rebuilding cache file: this may take a moment*** INTERNAL ERROR: NOT NULL constraint failed: RareItem.station_id
CSV File: F:\Users\Documents\Trade Dangerous\data\RareItem.csv:4
SQL Query: INSERT INTO RareItem (station_id,name,cost,max_allocation) VALUES((SELECT Station.station_id FROM Station INNER JOIN System USING(system_id) WHERE System.name = ? AND Station.name = ?),?,?,?)
Params: ['AERIAL', 'Andrade Legacy', 'Edan Apples of Aerial', '621', '15']
 
How do I avoid small stations with larger ships? What to do regarding incorrect data?

I have two questions for more experienced users/dev...

Is there a way I can avoid the smaller stations with ships that are unable to land at them? I have searched through everything I can think of and have been unable to find any information regarding this. I did notice that in the station files the size of available landing pads is tracked and through trial and error have been unable to find any combination of commands that would allow me to exploit this data and there is also no information in -h regarding this. Is this not possible to do at this time or am I just missing something? If this is not possible at this time is it something slated for the future?

Also I have noticed in several instances that there is incorrect data regarding the transport of prohibited goods such as slaves. In the particular instance I am referring to they were unavailable for purchase at the station that TD said they were. I apologize I don't have the specifics in front of me at the moment, but the only way I have found to circumnavigate this issue is to --avoid slaves. However, this removes the chance that I might find results that are valid to sell slaves from. Is there a way to report issues like this as all I have found to do at the moment is update my personal files via Elite_OCR meaning other people might have the same issue. I am currently using Maddavo's information if that matters.

I apologize if these questions are simple and I have just missed the answers through currently available information but I was unable to find anything.

-Protecursac
 
However, it will not tell me all the various profitable trades in between in order to maximize the income along the route.

You use the 'hops' argument for this. This tells TD how many stops to make along the way between X and Y. If you KNOW that you have <n> items already at X that you want to take to Y, then reduce the cargo hold total by <n> using the capacity argument.
 
Last edited:
You use the 'hops' argument for this. This tells TD how many stops to make along the way between X and Y. If you KNOW that you have <n> items already at X that you want to take to Y, then reduce the cargo hold total by <x> using the capacity argument.

Ah excellent, thank you.
 
I went ahead and edited the System.csv with the deprecated changes and received the following output:
Code:
NOTE: Rebuilding cache file: this may take a moment*** INTERNAL ERROR: NOT NULL constraint failed: RareItem.station_id
CSV File: F:\Users\Documents\Trade Dangerous\data\RareItem.csv:4
SQL Query: INSERT INTO RareItem (station_id,name,cost,max_allocation) VALUES((SELECT Station.station_id FROM Station INNER JOIN System USING(system_id) WHERE System.name = ? AND Station.name = ?),?,?,?)
Params: ['AERIAL', 'Andrade Legacy', 'Edan Apples of Aerial', '621', '15']

the only way i could get it to finish after editing the csv was to either delete the rareitem.csv or rename it, then it completes but i guess next time we resync from maddavo feed we will be in the same loop, and also missing the rare items....

Thanks
 
I have two questions for more experienced users/dev...

Is there a way I can avoid the smaller stations with ships that are unable to land at them? I have searched through everything I can think of and have been unable to find any information regarding this. I did notice that in the station files the size of available landing pads is tracked and through trial and error have been unable to find any combination of commands that would allow me to exploit this data and there is also no information in -h regarding this. Is this not possible to do at this time or am I just missing something? If this is not possible at this time is it something slated for the future?

...

-Protecursac


Code:
 trade.py local <SystemNameHere>
will give you what you are looking for with regard to station info (if it is in the stations.csv list - it is only as accurate/complete as the data listed there).

Using -h with that command will show you more options, and -v (or -vv or -vvv) usually provides additional levels of detail for most td commands
 
Last edited:
Currently, at least as far as I can tell, a User cannot request a route between X System to Y System where TD reports the most profitable trades between X and Y. For instance, lets say I'm in Tsohoda and plan on making a long journey to Fujin. The current version of TD can tell me exactly what to buy in Tsohoda to bring to Fujin. However, it will not tell me all the various profitable trades in between in order to maximize the income along the route. The new NAV system, if incorporated into RUN would be able to accomplish just what I am proposing. NAV can pull the Systems to build the route while RUN determines what commodity to buy and sell along the predetermined route.

If the above is already possible, can someone suggest a command line to build from in order to accomplish the stated goal.

How is that not:

$ trade.py run -vv --from tsohoda --to fujin --hops 6 --jumps 4 --max 5 --lsp 2.5 ...

This says: find a trading run between the tsohoda system and the fujin system. Jump upto 4 times between stations for a total of 6 jumps. Limit data to 5 days in age and penalize stations at 2.5% of their profit margin per 1000ls.

You can fit the resulting trade run closer to a direct route by limiting jumps and increasing hops.
 
I went ahead and edited the System.csv with the deprecated changes and received the following output:
Code:
NOTE: Rebuilding cache file: this may take a moment*** INTERNAL ERROR: NOT NULL constraint failed: RareItem.station_id
CSV File: F:\Users\Documents\Trade Dangerous\data\RareItem.csv:4
SQL Query: INSERT INTO RareItem (station_id,name,cost,max_allocation) VALUES((SELECT Station.station_id FROM Station INNER JOIN System USING(system_id) WHERE System.name = ? AND Station.name = ?),?,?,?)
Params: ['AERIAL', 'Andrade Legacy', 'Edan Apples of Aerial', '621', '15']

So what's happened here is that you've had a big glut of data added to the TD database - Systems, Stations and RareItems, and Dave hasn't yet had chance to undo the damage, so to speak, from TD source getting ahead of him. You can either temporarily nuke the RareItem file entirely (it'll be the source of most of the conflicts, I added stations for ALL the systems all of the rares are in, i.e. a couple hundred stations, as well as adding a huge number of systems from ed star coordinator).

It might be easier if I made it so that TD came with "default" csv files that get used if and when you don't have .csv files. But right now my main focus is making TD use it's .db file as the local source of authority and other files for accepting /inputs/.

-Oliver

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

the only way i could get it to finish after editing the csv was to either delete the rareitem.csv or rename it, then it completes but i guess next time we resync from maddavo feed we will be in the same loop, and also missing the rare items....

Thanks

Once Dave has chance to update his systems file, we can upload the new station file, and then it should all be good. Right now the system breaks when TD gets ahead, and that's my fault. See above.
 
Last edited:
Code:
osmith@WOTSIT /c/dev/trade (master)
[color=orange]$ rm data/maddavo.stamp[/color]

osmith@WOTSIT /c/dev/trade (master)
[color=orange]$ tdimad[/color]
$ /c/dev/trade/trade.py import --plug=maddavo
NOTE: Stale/missing local copy, downloading full .prices file.
Connecting to server: http://www.davek.com.au/td/prices.asp
import.prices: 5,594,673/5,594,673 bytes |  47.05KB/s | 100.00%
1167 stations updated:
Aztlan/Tannhauser Gate, LFT 1667/Shkaplerov Mines, 36 Ursae Majoris/Aristotle Platform, LTT 15899/Kekule Orbital, Yota/Baturin Vision, Aphra
/Beckman Terminal, Cerno/Kanwar Enterprise, Olgrea/Warner Station, Kwatee/Cartier Dock, Sheela Na Gig/Mitchell Hub, ...
import.prices:1548 WARNING Unrecognized STAR/Station: "72 OPHIUCHI/GERST GATEWAY"
import.prices:1611 WARNING Unrecognized STAR/Station: "72 OPHIUCHI/VERNADSKY CITY"
import.prices:12006 WARNING Unrecognized STAR/Station: "CAIHE/RENNIE HUB"
import.prices:71216 WARNING Unrecognized STAR/Station: "UALAME/LESSING HANGER"
Import completed despite warnings


In a bash environment, you can automate adding missing stations like this:

Code:
osmith@WOTSIT /c/dev/trade (master)
[color=orange]$ tdimad[/color]
{ list of missing systems }
[i]NOTE: The import file is saved as "import.prices"[/i]

osmith@WOTSIT /c/dev/trade (master)
[color=orange]$ trade.py import -i import.prices | sed -ne 's!^.*Station: \(".*"\).*!misc/add-station.py \1! p' | tee addstn.sh[/color]
misc/add-station.py "72 OPHIUCHI/GERST GATEWAY"
misc/add-station.py "72 OPHIUCHI/VERNADSKY CITY"
misc/add-station.py "CAIHE/RENNIE HUB"
misc/add-station.py "UALAME/LESSING HANGER"

osmith@WOTSIT /c/dev/trade (master)
[color=orange]$ bash addstn.sh[/color]
ADDED: #2511: 72 OPHIUCHI/Gerst Gateway ls=0, bm=?, pad=?
ADDED: #2512: 72 OPHIUCHI/Vernadsky City ls=0, bm=?, pad=?
ADDED: #2513: CAIHE/Rennie Hub ls=0, bm=?, pad=?
ADDED: #2514: UALAME/Lessing Hanger ls=0, bm=?, pad=?

osmith@WOTSIT /c/dev/trade (master)
[color=orange]$ trade.py export --table Station[/color]
Using database 'C:\Dev\trade\data\TradeDangerous.db'
Export Table 'Station'
 
Last edited:
avoiding small stations

Code:
 trade.py local <SystemNameHere>
will give you what you are looking for with regard to station info (if it is in the stations.csv list - it is only as accurate/complete as the data listed there).

Using -h with that command will show you more options, and -v (or -vv or -vvv) usually provides additional levels of detail for most td commands

Is there a way that to ask for that information using the run command such that

trade.py run --fr eravate/ack --to eravate/ack --via ******** --cr**** --cap 112 --ly-per 12.5 --insurance ****

If this run ends up being 10-20 hops total is there a way to tell TD to exclude stations other than large platforms. While searching each system is possible that is rather time consuming when attempting to plan a long route. As up to now that is exactly what I have been doing in the Station.csv file. It adds 20-30 min to route planning for long distance runs. Even trying to find a 3 hop "triangle" that is decently profitable can take hours searching with this method.

Appreciate the help

Also ever since the last update I am getting an error regarding RareItem Table for the new rare search function he just added. (I'm not an experienced user and can't figure out how to copy/paste code from cmd window). If anyone knows how to fix this it would be greatly appreciated
 
Is there a way that to ask for that information using the run command such that

trade.py run --fr eravate/ack --to eravate/ack --via ******** --cr**** --cap 112 --ly-per 12.5 --insurance ****

If this run ends up being 10-20 hops total is there a way to tell TD to exclude stations other than large platforms. While searching each system is possible that is rather time consuming when attempting to plan a long route. As up to now that is exactly what I have been doing in the Station.csv file. It adds 20-30 min to route planning for long distance runs. Even trying to find a 3 hop "triangle" that is decently profitable can take hours searching with this method.

Appreciate the help

Also ever since the last update I am getting an error regarding RareItem Table for the new rare search function he just added. (I'm not an experienced user and can't figure out how to copy/paste code from cmd window). If anyone knows how to fix this it would be greatly appreciated

In reverse order:

. Click the top-left corner of the command window (c:\ icon), select edit-mark (keyboard shortcut: { alt+space, e, k }). Then use the mouse to "paint" the are you want to copy and hit return. It's now copied.

. The "rare" issue is because "--opt=syscsv" and "--opt=stncsv" cause TD to download the System and Station data from Maddavo's site instead of using TD's System and Station data, and the RareItem.csv file references a station that Maddavo doesn't have yet;

Option 1:
-- Refresh the "System.csv" and "Station.csv" from the TD source (I've already pushed several updates today),
-- Don't include the "--opt=syscsv" and "--opt=stncsv" options on the import command line, e.g:
c:\blah\trade\> trade.py import --plug=maddavo
Option 2:
-- Delete or rename the RareItem.csv file in the "data" directory for the time being,

. Pad size limiting hasn't been implemented yet, but I might add it today.

Bear in mind that TD is still in a rapid development phase, and I don't always post announcements here. The downside to this approach is a bit of an entry barrier as you wrap your head around keeping synced, and I'm working on changes to eliminate this as an issue.
 
Back
Top Bottom