return { "average": D("0.000001") }
if c1 == "ETH" and c2 == "BTC":
return { "average": D("0.1") }
+ if c1 == "FOO" and c2 == "BTC":
+ return { "average": D("0.1") }
self.fail("Should not be called with {}, {}".format(c1, c2))
get_ticker.side_effect = _get_ticker
repartition.return_value = {
- "DOGE": (D("0.25"), "short"),
- "BTC": (D("0.25"), "long"),
- "ETH": (D("0.25"), "long"),
- "XMR": (D("0.25"), "long"),
+ "DOGE": (D("0.20"), "short"),
+ "BTC": (D("0.20"), "long"),
+ "ETH": (D("0.20"), "long"),
+ "XMR": (D("0.20"), "long"),
+ "FOO": (D("0.20"), "long"),
}
m = market.Market(self.ccxt, self.market_args())
self.ccxt.fetch_all_balances.return_value = {
"total": D("5.0")
},
"BTC": {
- "exchange_free": D("0.075"),
+ "exchange_free": D("0.065"),
"exchange_used": D("0.02"),
- "exchange_total": D("0.095"),
- "margin_available": D("0.025"),
+ "exchange_total": D("0.085"),
+ "margin_available": D("0.035"),
"margin_in_position": D("0.01"),
- "margin_total": D("0.035"),
+ "margin_total": D("0.045"),
"total": D("0.13")
},
"ETH": {
"exchange_total": D("1.0"),
"total": D("1.0")
},
+ "FOO": {
+ "exchange_free": D("0.1"),
+ "exchange_used": D("0.0"),
+ "exchange_total": D("0.1"),
+ "total": D("0.1"),
+ },
}
m.balances.fetch_balances(tag="tag")
self.assertEqual(portfolio.Amount("BTC", "-0.025"),
new_repartition["DOGE"] - values_in_base["DOGE"])
- self.assertEqual(portfolio.Amount("BTC", "0.025"),
- new_repartition["ETH"] - values_in_base["ETH"])
self.assertEqual(0,
- new_repartition["ZRC"] - values_in_base["ZRC"])
+ new_repartition["ETH"] - values_in_base["ETH"])
+ self.assertIsNone(new_repartition.get("ZRC"))
self.assertEqual(portfolio.Amount("BTC", "0.025"),
new_repartition["XMR"])
+ self.assertEqual(portfolio.Amount("BTC", "0.015"),
+ new_repartition["FOO"] - values_in_base["FOO"])
compute_trades.reset_mock()
with self.subTest(available_balance_only=True, balance=0),\
store_report.assert_called_once()
log_error.assert_not_called()
+ process.reset_mock()
+ log_error.reset_mock()
+ store_report.reset_mock()
+ with self.subTest(authentication_error=True):
+ m.ccxt.check_required_credentials.side_effect = market.ccxt.AuthenticationError
+
+ m.process(["some_action"], before=True)
+ log_error.assert_called_with("market_authentication", message="Impossible to authenticate to market")
+ store_report.assert_called_once()
+
+ m.ccxt.check_required_credentials.side_effect = True
process.reset_mock()
log_error.reset_mock()
store_report.reset_mock()