...
 
Commits (6)
## ChangeLog
### 0.4.1 - 2019-07-25
- Fix limit sell by price to respect Binance tick size. Reported by
user in Telegram.
- Fix issue where clicking on a symbol changes the trade view back to
the default.
- Push down notification are so the tool icon can be clicked.
[Full Changelog](https://gitlab.com/crankykernel/maker/compare/0.4.0...0.4.1)
### 0.4.0 - 2019-04-06
- New command line option to set the data directory where the
maker.yaml, maker.db and log files are stored. This replaces the
......
......@@ -781,12 +781,24 @@ func (s *TradeService) limitSellByPrice(trade *types.Trade, price float64) error
}
s.addClientOrderId(trade, clientOrderId)
log.WithFields(log.Fields{
"price": fmt.Sprintf("%.8f", price),
"symbol": trade.State.Symbol,
"tradeId": trade.State.TradeID,
"quantity": trade.State.SellableQuantity,
}).Debugf("Posting limit sell order at price.")
tickSize, err := s.binanceExchangeInfo.GetTickSize(trade.State.Symbol)
if err != nil {
log.WithError(err).WithFields(log.Fields{
"symbol": trade.State.Symbol,
}).Errorf("Limit sell by price failed, no tick size for symbol")
return err
}
// Adjust price for tick size.
fixedPrice := util.Roundx(price, 1/tickSize)
logFields := log.Fields{
"price": fmt.Sprintf("%.8f", price),
"symbol": trade.State.Symbol,
"tradeId": trade.State.TradeID,
"quantity": trade.State.SellableQuantity,
"tickSizeAdjustedPrice": fmt.Sprintf("%.8f", fixedPrice),
}
order := binanceapi.OrderParameters{
Symbol: trade.State.Symbol,
......@@ -794,19 +806,17 @@ func (s *TradeService) limitSellByPrice(trade *types.Trade, price float64) error
Type: binanceapi.OrderTypeLimit,
TimeInForce: binanceapi.TimeInForceGTC,
Quantity: trade.State.SellableQuantity,
Price: price,
Price: fixedPrice,
NewClientOrderId: clientOrderId,
}
_, err = binanceex.GetBinanceRestClient().PostOrder(order)
if err != nil {
log.WithFields(log.Fields{}).WithError(err).Error("Failed to send sell order.")
log.WithFields(logFields).WithError(err).Error("Failed to send sell order.")
return err
}
log.WithFields(log.Fields{
"price": price,
"symbol": trade.State.Symbol,
"tradeId": trade.State.TradeID,
}).Info("Sell order posted.")
log.WithFields(logFields).Infof("Posting limit sell order at price")
db.DbUpdateTrade(trade)
return nil
}
......
......@@ -31,6 +31,7 @@ export interface ToastrOptions {
export class ToastrService {
constructor() {
toastr.options.toastClass = "toastr";
}
success(msg: string, title?: string, options?: ToastrOptions) {
......
<td class="nowrap">
<a [routerLink]="['/trade', {symbol: trade.Symbol}]">{{trade.Symbol}}</a>
<a [routerLink]="['/trade']" [queryParams]="{symbol: trade.Symbol}" queryParamsHandling="merge">{{trade.Symbol}}</a>
<br/>
{{trade.Status}}
<br/>
......@@ -137,7 +137,7 @@
<tr>
<td></td>
<td>
<b style="color: grey">-- Limit Sell--</b>
<b style="color: grey">-- Limit Sell--</b>
</td>
</tr>
......
......@@ -13,13 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import {
AfterViewInit,
Component,
Input,
OnDestroy,
OnInit
} from "@angular/core";
import {AfterViewInit, Component, Input, OnDestroy, OnInit} from "@angular/core";
import {MakerService, TradeStatus} from "../maker.service";
import {Logger, LoggerService} from "../logger.service";
import {ToastrService} from "../toastr.service";
......
......@@ -113,13 +113,10 @@ export class TradeTableComponent implements OnInit, OnChanges {
}
switchTradeView(what) {
let params = Object.assign({}, this.route.snapshot.params);
if (what === null) {
delete (params["viewTrades"]);
} else {
params.viewTrades = what;
}
this.router.navigate([".", params], {
let params = Object.assign({}, this.route.snapshot.queryParams);
params.viewTrades = what;
this.router.navigate(["."], {
queryParams: params,
queryParamsHandling: "merge",
});
}
......
......@@ -219,7 +219,7 @@ export class TradeComponent implements OnInit, OnDestroy, AfterViewInit {
}
this.binance.isReady$.subscribe(() => {
this.route.params.subscribe((params) => {
let s = this.route.queryParams.subscribe((params) => {
const newSymbol = params.symbol;
if (newSymbol && newSymbol != this.orderFormSettings.symbol) {
this.changeSymbol(newSymbol);
......@@ -236,7 +236,8 @@ export class TradeComponent implements OnInit, OnDestroy, AfterViewInit {
this.viewTrades = "all";
break;
}
})
});
this.subs.push(s);
});
let s = this.maker.binanceAccountInfo$.subscribe((accountInfo) => {
......@@ -337,7 +338,12 @@ export class TradeComponent implements OnInit, OnDestroy, AfterViewInit {
symbol = this.orderFormSettings.symbol;
}
this.router.navigate(["/trade", {symbol: symbol}])
this.router.navigate(["/trade"], {
queryParams: {
symbol: symbol,
},
queryParamsHandling: "merge",
});
if (!symbol) {
this.saveState();
......
......@@ -45,3 +45,10 @@ html {
.toast {
opacity: 1 !important;
}
// Shift the Toastr display down so the settings button in the navigation bar can
// still be pressed when displayed.
.toast-top-right {
top: 42px;
right: 12px;
}