Skip to content

Commit 321a338

Browse files
authored
Merge pull request #29 from yubing744/owen/fixbug-tp-sl
feat: ok
2 parents 217da80 + 1b8c3db commit 321a338

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: clean build unit-test run docker-* tag release
22

33
NAME=trading-gpt
4-
VERSION=0.23.1
4+
VERSION=0.23.3
55

66
clean:
77
rm -rf build/*

pkg/env/exchange/exchange_entity.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (ent *ExchangeEntity) Actions() []*ttypes.ActionDesc {
7171
Description: "open long position",
7272
Args: []ttypes.ArgmentDesc{
7373
{
74-
Name: "stop_loss_trigge_price",
74+
Name: "stop_loss_trigger_price",
7575
Description: "Stop-loss trigger price",
7676
},
7777
{
@@ -254,12 +254,10 @@ func (ent *ExchangeEntity) HandleCommand(ctx context.Context, cmd string, args m
254254
}
255255
}
256256

257-
log.Infof("open %s position for signal %v, reason: %s", ent.symbol, side, "")
258-
259257
opts := make([]interface{}, 0)
260258

261259
// config stop losss
262-
if stopLoss, ok := args["stop_loss_trigger_price"]; ok {
260+
if stopLoss, ok := args["stop_loss_trigger_price"]; ok && stopLoss != "" {
263261
stopLoss, err := utils.ParseStopLoss(ent.vm, side, closePrice, stopLoss)
264262
if err != nil {
265263
return errors.Wrapf(err, "the stop loss invalid: %s", stopLoss)
@@ -273,7 +271,7 @@ func (ent *ExchangeEntity) HandleCommand(ctx context.Context, cmd string, args m
273271
}
274272

275273
// config take profix
276-
if takeProfix, ok := args["take_profit_trigger_price"]; ok {
274+
if takeProfix, ok := args["take_profit_trigger_price"]; ok && takeProfix != "" {
277275
takeProfix, err := utils.ParseTakeProfit(ent.vm, side, closePrice, takeProfix)
278276
if err != nil {
279277
return errors.Wrapf(err, "the take profit invalid: %s", takeProfix)
@@ -286,6 +284,8 @@ func (ent *ExchangeEntity) HandleCommand(ctx context.Context, cmd string, args m
286284
}
287285
}
288286

287+
log.Infof("open %s position for signal %v, options: %v", ent.symbol, side, opts)
288+
289289
if cmd == "open_long_position" || cmd == "open_short_position" {
290290
err := ent.OpenPosition(ctx, side, closePrice, opts...)
291291
if err != nil {

0 commit comments

Comments
 (0)