DrPaulBrewer / single-market-robot-simulator-viz-plotly

middleware for generating charts with plotly from single-market-robot-simulator simulation logs
Other
1 stars 0 forks source link

2D histogram: buyerValue vs sellerCost (count trades) shows trades that are not in the trade log #14

Closed DrPaulBrewer closed 4 years ago

DrPaulBrewer commented 4 years ago

Ran 100,000 periods of a market populated by "Truthful" agents.

The 2D Histrogram for trades, buyerValue vs. sellerCost is showing a positive z value for cases where cost exceeds value.

The histogram can be seen here

Trades where sellerCost exceeds buyerValue should not occur.

Because of this, the "trades.csv" file was isolated and loaded into an sqlite3 database to search for these trades.

However, the log/database shows no trades where cost exceeds value -- as expected.

zip file: 20200720T064506.zip

the contained file: trades.csv

was loaded into sqlite3

sqlite> select count(*) as n, buyerValue, sellerCost from trades where buyerValue=200 group by buyerValue, sellerCost;
435,200,200
sqlite> select count(*) as n, buyerValue, sellerCost from trades where buyerValue<sellerCost group by buyerValue, sellerCost;
sqlite> select count(*) as n, buyerValue, sellerCost from trades where buyerValue=290 group by buyerValue, sellerCost;
2724,290,200
2996,290,230
3055,290,260
3281,290,290
DrPaulBrewer commented 4 years ago

The sampler was used for the first, incorrect figure and is associated with this issue.

The period filter seems to work ok and produced the upper triangular expected result.

Here

DrPaulBrewer commented 4 years ago

The extract() call handles sampling and filtering.

Extract is called twice, once for each element of chart.names (the x-axis variable and the y-axis variable)

https://github.com/DrPaulBrewer/single-market-robot-simulator-viz-plotly/blob/2c7bda4a98b177cd71a65d79f9e496fc3db18ee6/src/index.js#L684-L693

Instead, what is needed is to call extract once, and transpluck to get related x and y variables instead of unrelated.

DrPaulBrewer commented 4 years ago

Thoughts:

DrPaulBrewer commented 4 years ago

Confirmed fixed in 6.0.1. Got expected triangular 2D histogram for trade values/cost.