In-Development TradeDangerous: power-user trade optimizer

@kfsone

Trying to get my feet wet using TradeDangerous in my own applications. Hopefully I'll be able to contribute more!

Is they are clean way to tell TradeDB where the data directory is? Looking at TradeDB, there are a dozen or so paths that point to ./data/somefile. I can modify each individually, but that seems fragile. Any way to just tell it where /data resides along with all the .csv, .db, .prices, etc?

I was thinking about submitting a patch for this if there's not already a way to do it.
 
Okay, I'm obviously doing something wrong here. I installed Python 3.4.1 and downloaded TD using SourceTree. I fired up the game and input the simple line from the readme to test it out, this is what I got:

Code:
>>> trade.py --sh hauler --fr chan --cr 20000
  File "<stdin>", line 1
    trade.py --sh hauler --fr chan --cr 20000
    ^
SyntaxError: invalid syntax

Trying it a few minutes later, I got this:

Code:
>>> trade.py --sh hauler --fr chan --cr 20000
  File "<stdin>", line 1
    trade.py --sh hauler --fr chan --cr 20000
                       ^
SyntaxError: invalid syntax

What am I doing wrong? I'm using a Win7 64 bit(x86) operating system.
 
Okay, I'm obviously doing something wrong here. I installed Python 3.4.1 and downloaded TD using SourceTree. I fired up the game and input the simple line from the readme to test it out, this is what I got:

Code:
>>> trade.py --sh hauler --fr chan --cr 20000
  File "<stdin>", line 1
    trade.py --sh hauler --fr chan --cr 20000
    ^
SyntaxError: invalid syntax

Trying it a few minutes later, I got this:

Code:
>>> trade.py --sh hauler --fr chan --cr 20000
  File "<stdin>", line 1
    trade.py --sh hauler --fr chan --cr 20000
                       ^
SyntaxError: invalid syntax

What am I doing wrong? I'm using a Win7 64 bit(x86) operating system.

Looks like you're trying run it from interactive mode.

Try opening a cmd prompt and doing something like:

Code:
C:\Python34\python.exe trade.py
 
Yep that >>> prompt suggests that you have started python in interactive mode. You don't need to start python at all. From the DOS prompt, you just need to type trade.py and then your parameters.
 
Looks like you're trying run it from interactive mode.

Try opening a cmd prompt and doing something like:

Code:
C:\Python34\python.exe trade.py

Yep that >>> prompt suggests that you have started python in interactive mode. You don't need to start python at all. From the DOS prompt, you just need to type trade.py and then your parameters.

Okay, I'll try that. Also, am I supposed to put that in my Python folder's "Tools" subfolder?
 
Okay, I'll try that. Also, am I supposed to put that in my Python folder's "Tools" subfolder?

I'm not clear what that means, as long as you can access "python" from the command prompt, as you appear to be doing, you're good.

After that, the system should recognize that trade.py is a python script and if you type "trade.py" at the command prompt from inside the trade dangerous folder, you should see this:

Code:
[assuming you put the trade.py and other files into c:\trade]
C:\trade\> trade.py
./trade.py: TradeDangerous provides a set of trade database facilities for Elite:Dangerous

{help text}

Your first step will probably be to get some .price data:

Code:
c:\trade\> trade.py import --maddavo -i -q

This says: Import data from maddavo's site, ignore any systems or stars we don't know about, and be quiet about it.

At this point, you should be able to ask: What stars are within 10ly of aulin:

Code:
c:\trade\> trade.py local aulin --ly 10

or, where can I buy gold within 50ly of beagle2:

Code:
c:\trade\> trade.py buy gold --near beagle2 --ly 50

how can I get from beagle2 to sol if my ship can only do 15ly jumps?

Code:
c:\trade\> trade.py nav beagle2 sol --ly 15

Ok, so my ship has a capacity of 40 units of cargo, it can jump 15 ly max when loaded, and I have 50,000 credits. What could I take from beagle2 to sol? Assume 2 station stops (stop on the way, stop at sol), and allow upto 3 jumps per stop.

Code:
c:\trade\> trade.py run --from beagle2 --to sol --cap 40 --ly 15 --cr 50000 --hops 2 --jumps 3

Maybe you want more detail in the answer:

Code:
c:\trade\> trade.py run -vvv --from beagle2 --to sol --cap 40 --ly 15 --cr 50000 --hops 2 --jumps 3

Or maybe you'd like it as a checklist while you fly so you don't lose track of where you are:

Code:
c:\trade\> trade.py run --checklist --from beagle2 --to sol --cap 40 --ly 15 --cr 50000 --hops 2 --jumps 3
(or use '--ch' for short)

And if you have an X52, you can have the steps show up on your MFD.

Code:
c:\trade\> trade.py run --from beagle2 --to sol --cap 40 --ly 15 --cr 50000 --hops 2 --jumps 3 --ch --x52

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

@kfsone

Trying to get my feet wet using TradeDangerous in my own applications. Hopefully I'll be able to contribute more!

Is they are clean way to tell TradeDB where the data directory is? Looking at TradeDB, there are a dozen or so paths that point to ./data/somefile. I can modify each individually, but that seems fragile. Any way to just tell it where /data resides along with all the .csv, .db, .prices, etc?

I was thinking about submitting a patch for this if there's not already a way to do it.

I'll get back to you on that but that's a good idea. I have a branch I'm working on to introduce a config file using the stock python config parser, and for that I was going to make it say "%(datadir)/Added.csv", etc.

If you've done work to make it so that the "data" part isn't hard coded, definitely submit a pull request - we can discuss any problems over the code :)

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

I've imported 155 new systems into the System.csv in the main branch. There were some Systems with names ending with a "2" that I could not find in the game, so I didn't import those.

Please note that Maddavo seems to have rebuilt his systems.csv from ed-systems which is where the weird utf8 characters are coming from.

-Oliver
 
Ive just started to get a lot an anomalous results;
.
NINSUN/Ramanujan Dock -> SINANN/Jones Point:
Load from NINSUN/Ramanujan Dock:
10 x Advanced Catalysers 10cr each, 100cr total
Jump NINSUN -> LHS 3333 -> MOKOSH => Gain 30,460cr (3,046cr/ton) => 248,46
Load from MOKOSH/Bethe Station:
16 x Superconductors 6,277cr each, 100,432cr total
Jump MOKOSH -> LHS 3333 -> NINSUN => Gain 19,952cr (1,247cr/ton) => 268,41
Load from NINSUN/Ramanujan Dock:
10 x Advanced Catalysers 10cr each, 100cr total
Jump NINSUN -> G 139-50 -> SINANN => Gain 33,520cr (3,352cr/ton) => 301,93
--------------------------------------------------------------------------
Finish at SINANN/Jones Point gaining 83,932cr => est 301,932cr total

.
Items apparently at 10cr each. Any ideas? Just updated all files from maddavo's site.
 
Items apparently at 10cr each. Any ideas? Just updated all files from maddavo's site.

Looks like someone uploaded bogus market data for Ninsun/Ramanujan Dock to maddavo's site. You can check the "TradeDangerous.prices" file with an text editor and remove those items.

Code:
...
   + Technology
      Advanced Catalysers        10      10         ?       10?  2014-11-26 19:39:29
      Animal Monitors            10      10         ?       10?  2014-11-26 19:39:29
      Aquaponic Systems          10      10         ?       10?  2014-11-26 19:39:29
...
 
Ive just started to get a lot an anomalous results;
.
NINSUN/Ramanujan Dock -> SINANN/Jones Point:
Load from NINSUN/Ramanujan Dock:
10 x Advanced Catalysers 10cr each, 100cr total
Jump NINSUN -> LHS 3333 -> MOKOSH => Gain 30,460cr (3,046cr/ton) => 248,46
Load from MOKOSH/Bethe Station:
16 x Superconductors 6,277cr each, 100,432cr total
Jump MOKOSH -> LHS 3333 -> NINSUN => Gain 19,952cr (1,247cr/ton) => 268,41
Load from NINSUN/Ramanujan Dock:
10 x Advanced Catalysers 10cr each, 100cr total
Jump NINSUN -> G 139-50 -> SINANN => Gain 33,520cr (3,352cr/ton) => 301,93
--------------------------------------------------------------------------
Finish at SINANN/Jones Point gaining 83,932cr => est 301,932cr total

.
Items apparently at 10cr each. Any ideas? Just updated all files from maddavo's site.

Looks like someone uploaded bogus market data for Ninsun/Ramanujan Dock to maddavo's site. You can check the "TradeDangerous.prices" file with an text editor and remove those items.

Code:
...
   + Technology
      Advanced Catalysers        10      10         ?       10?  2014-11-26 19:39:29
      Animal Monitors            10      10         ?       10?  2014-11-26 19:39:29
      Aquaponic Systems          10      10         ?       10?  2014-11-26 19:39:29
...

The edit though means that the station won't be used in any calculations (for those commodities). If you are in that part of space, you can visit that station, and 'trade.py update Ramanujan -GF', then upload the .prices file back to maddavo's site.

[It's also worth noting that the timestamp is over a week old. Maybe they were that price a week ago. It's up to EVERYBODY using this data to maintain it and send maddavo the updates. We should seed as well as leech. ;) ]
 
Last edited:
Can I get that command to auto upload the prices? It looks like it wants me to type them all in.

You may type as many or as few as you wish. The important thing is accuracy. If there are none in the database, then the editor will be completely empty.
 
I get it. Sorry for daft questions, but I only got it working yesterday. I don't see a "submit" button when the data entry window pops up. Is that another command line thing?

Typing them all would take ages, so I guess I wont bother with low value commodities first. Stick to the potential high earners.
 
I get it. Sorry for daft questions, but I only got it working yesterday. I don't see a "submit" button when the data entry window pops up. Is that another command line thing?

Typing them all would take ages, so I guess I wont bother with low value commodities first. Stick to the potential high earners.

At the moment I think the update to Maddavo's Market Data is manual. When you close the data entry screen it will create a file called update.prices

You upload that file to the website http://www.davek.com.au/td/default.asp

Personally I've been updating every price at stations I visit to ensure all the data is up to date. Yes, this takes me a few minutes each visit, a little longer if I have to add new items for sale. I may hold off updating if I visit the station several times in a session. But I will update the prices at least once.
 
I get it. Sorry for daft questions, but I only got it working yesterday. I don't see a "submit" button when the data entry window pops up. Is that another command line thing?

Typing them all would take ages, so I guess I wont bother with low value commodities first. Stick to the potential high earners.

There's no such thing as a daft question (though you may get patronising answers on these forums from some people). ;)

There is no submit button. Just close the window. If there's an error in the form, you'll see it on the command line.

It's always worth adding everything you can buy at the very least. You can use commands like "trade.py buy <commodity> --near <where I am> to decide whether it's worth accepting the 'go fetch me' missions.

I use Windows speech recognition and a headset to 'chant' all the data into the form. Takes a couple of minutes. My wife thinks it's hilarious. :)

Press One Zero Three tab Two six One tab three seven eight ELL tab down arrow down arrow ...

An alternative input method like this is looking promising. Not tried it yet.
 
Last edited:
So there's a station called "Guest City" in the "Zeta Trianguli Australis" system, and a station called "Guest City" in the "HIP 74255" system. There was already prices for the HIP 74255 one and it was in the Station.csv . For the moment I have added the Zeta Trianguli Australis station as "Guest City2", but looking for some direction from kfsone: What should we do?
 
I coulda sworn I just replied to this thread. I guess I'm going nuts.

- I'll add a Save button to the Update UI - I keep looking for it myself when I've entered a bunch of data,
- In the places that have been converted to use the new qualified name schema, it works like this:
@blah = find a star name containing "blah",
/ibble = find a station name containing "ibble",
@blah/ibble = find a station with "ibble" in its name at a star with "blah" in its name

So: "@pri/bea" (or just "pri/bea") matches "Asellus Primus/Beagle 2". There is weighting that favors whole word matches.

- Bad Data:

Bad data is going to happen, I can probably shore things up a little. I'm going to make it a little harder to accidentally screw up.

Taking a look at maddavo's data from just now, it seems relatively limited:

Code:
sqlite> .mode col
sqlite> SELECT  sys.name, stn.name, itm.name,
   ...>                 ss.price - sb.price AS diff
   ...>   FROM  Item as itm
   ...>                 INNER JOIN StationSelling AS ss
   ...>                         USING (item_id)
   ...>                 INNER JOIN StationBuying AS sb
   ...>                         USING (station_id, item_id)
   ...>                 INNER JOIN Station AS stn
   ...>                         USING (station_id)
   ...>                 INNER JOIN System AS sys
   ...>                         USING (system_id)
   ...>  ORDER  BY diff DESC
   ...>  LIMIT  10
   ...> ;
HIP 72353   Caidin Station  Beryllium   69093
Lu Yupik    Bagian Survey   Supercondu  3073
Hahgwe      Skripochka Hor  Tantalum    2045
Gulngaba    Galindo Dock    Indite      1040
Kivah       Sadi Carnot Ri  Uraninite   427
LP 448-41   Hopkins Landin  Uranium     391
70 Ophiuch  Luk Station     Semiconduc  323
Sinann      Jones Point     Beryllium   201
LHS 3447    Fairbairn Stat  Palladium   189
LP 448-41   Bhabha Refiner  Gallium     148

Ok, that first one looks pretty bad:

#1
Code:
      Beryllium                  7677   76770          ?     8542?  2014-11-22 18:46:42

I could make TD reject this or detect that BUY = SELL*10 and fix it. Not sure how I feel about that.

#2
Code:
      Superconductors            3761    6834          ?        5?  2014-11-24 13:10:54

Hrm. Well, firstly that's fairly old data. And secondly, yeah, that doesn't look good.

#3
Code:
      Tantalum                   4063    6108          ?     4076L  2014-11-29 21:52:19

#4
Code:
      Indite                     1843    2883          ?   140812?  2014-11-23 10:39:54

That's some fat fingering.

Ok. So digging a little further reveals the following:

Code:
-- Calculate 90th percentile of price diffs
CREATE TEMPORARY TABLE differences AS
SELECT	sys.name, stn.name, itm.name,
		ss.price - sb.price AS diff
  FROM	Item as itm
  		INNER JOIN StationSelling AS ss
  			USING (item_id)
  		INNER JOIN StationBuying AS sb
  			USING (station_id, item_id)
  		INNER JOIN Station AS stn
  			USING (station_id)
  		INNER JOIN System AS sys
  			USING (system_id)
;
SELECT diff FROM differences ORDER BY diff LIMIT 1
OFFSET (SELECT COUNT(*) FROM differences) * 90 / 100 - 1;

p90: 69c, p95: 91cr, p99: 127cr, p99.5: 137cr

(This means that 90% of items have a 'buy' price that is within 69cr of the sale price, 95% are within 91cr and 99% are within 127cr)

So there's just 0.5% of purchases where the station asks more than 137cr more than it will buy them back for.

It looks like 150cr is a good cut-off. I'll dig further and see if there is also a ratio.
 
Last edited:
Back
Top Bottom