Browse Source

mmnode-ticker: fix market cap sort with USD row

The MMGen Project 1 month ago
parent
commit
d02c9936ef

+ 1 - 0
mmgen_node_tools/Ticker.py

@@ -539,6 +539,7 @@ def gen_data(data):
 		'percent_change_7d': 0.0,
 		'percent_change_30d': 0.0,
 		'percent_change_1y': 0.0,
+		'market_cap': 0,
 		'last_updated': None})
 
 def cache_data(data_src, no_overwrite=False):

+ 1 - 1
mmgen_node_tools/data/version

@@ -1 +1 @@
-3.6.dev9
+3.6.dev10

+ 25 - 1
test/cmdtest_d/misc.py

@@ -101,6 +101,9 @@ class CmdTestScripts(CmdTestBase):
 		('ticker30', 'ticker [--cached-data --wide --pchg-unit=btc --sort=d] (cf with config file)'),
 		('ticker31', 'ticker [--cached-data --wide --pchg-unit=usd] (cf with no USD)'),
 		('ticker32', 'ticker [--cached-data --wide --pchg-unit=gc=f]'),
+		('ticker33', 'ticker [--cached-data --wide --pchg-unit=btc --sort=c] (cfg file with USD)'),
+		('ticker34', 'ticker [--cached-data --wide --pchg-unit=btc --sort=y] (cfg file with USD)'),
+		('ticker35', 'ticker [--cached-data --wide --pchg-unit=btc --sort=p] (cfg file with USD)'),
 	)
 	}
 
@@ -475,4 +478,25 @@ class CmdTestScripts(CmdTestBase):
 				'GOLD', r'\+0.00', r'\+0.00', r'\+0.00', r'\+0.00',
 				'SILVER'
 			],
-			add_opts = ['--widest', '--pchg-unit=gc=f'])
+			add_opts = ['--widest', '--pchg-unit=gc=f', '--sort=c'])
+
+	def _ticker_cur(self, sort):
+		self.copy_file('ticker-cfg-usd.yaml', 'ticker-cfg.yaml')
+		t = self.ticker(
+			[],
+			[
+				'BITCOIN 23,250.77 1.00000000 \+0.00',
+				'US DOLLAR 1.00 0.00004301 -15.93',
+			],
+			add_opts = ['--widest', '--pchg-unit=btc', f'--sort={sort}'])
+		self.rm_file('ticker-cfg.yaml')
+		return t
+
+	def ticker33(self):
+		return self._ticker_cur(sort='c')
+
+	def ticker34(self):
+		return self._ticker_cur(sort='y')
+
+	def ticker35(self):
+		return self._ticker_cur(sort='p')

+ 11 - 0
test/ref/ticker/ticker-cfg-usd.yaml

@@ -0,0 +1,11 @@
+assets:
+  coin1:
+    - btc-bitcoin
+    - eth-ethereum
+    - xmr-monero
+  commodity:
+    - gc=f
+    - si=f
+  currency:
+    - usd-us-dollar
+    - eurusd=x