Skip to content

Commit

Permalink
Clean FetchOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
rluisr committed Sep 26, 2022
1 parent 7ac0bfb commit 2d75077
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
4 changes: 2 additions & 2 deletions example/curl.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
POST /tv

TP/SL: price
curl -s -XPOST -H "Content-Type: application/json" -d '{"is_test_net": true, "api_key": "OReF54nygvv9IwbC0h", "api_secret_key": "fyyoeWmaLVj74gHsIaThT9WK8T7CpCBjNBFK", "order": { "symbol": "BTCUSDT", "type": "Market", "price": 0, "side": "Sell", "qty": 0.03, "tp": "0", "sl": "0" } }' http://localhost:3001/tv
curl -s -XPOST -H "Content-Type: application/json" -d '{"is_test_net": true, "api_key": "OReF54nygvv9IwbC0h", "api_secret_key": "fyyoeWmaLVj74gHsIaThT9WK8T7CpCBjNBFK", "order": { "name": "test", "symbol": "BTCUSDT", "type": "Market", "price": 0, "side": "Sell", "qty": 0.03, "tp": "0", "sl": "0" } }' http://localhost:3001/tv

TP/SL: percent
curl -s -XPOST -H "Content-Type: application/json" -d '{"is_test_net": true, "api_key": "OReF54nygvv9IwbC0h", "api_secret_key": "fyyoeWmaLVj74gHsIaThT9WK8T7CpCBjNBFK", "order": { "symbol": "BTCUSDT", "type": "Market", "price": 0, "side": "Buy", "qty": 0.01, "tp": "1%", "sl": "5%" } }' http://localhost:3001/tv
curl -s -XPOST -H "Content-Type: application/json" -d '{"is_test_net": true, "api_key": "OReF54nygvv9IwbC0h", "api_secret_key": "fyyoeWmaLVj74gHsIaThT9WK8T7CpCBjNBFK", "order": { "name": "test", "symbol": "BTCUSDT", "type": "Market", "price": 0, "side": "Buy", "qty": 0.01, "tp": "1%", "sl": "5%" } }' http://localhost:3001/tv

GET /setting

Expand Down
12 changes: 2 additions & 10 deletions pkg/adapter/gateway/bybit_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,13 @@ func (r *BybitRepository) CreateOrder(req domain.TV) (string, error) {

// FetchOrder is set entry price
func (r *BybitRepository) FetchOrder(req *domain.TV, orderID string) error {
req.Order = domain.TVOrder{
OrderID: orderID,
Type: req.Order.Type,
Symbol: req.Order.Symbol,
Side: req.Order.Side,
QTY: req.Order.QTY,
TP: req.Order.TP,
SL: req.Order.SL,
}

entryPrice, err := r.getEntryPrice(req)
if err != nil {
return err
}

req.Order.EntryPrice = *entryPrice
req.Order.OrderID = orderID

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/domain/tv.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type TV struct {

type TVOrder struct {
gorm.Model
Name string `gorm:"type:varchar(255)" json:"name"` // alert name, description or something
Name string `gorm:"type:varchar(255);default:null" json:"name"` // alert name, description or something
CEX string `gorm:"type:varchar(255);not null" json:"-"`
SettingID uint64 `gorm:"type:uint;not null" json:"-"`
OrderID string `gorm:"type:varchar(255);uniqueIndex:order_id;not null"`
Expand Down

0 comments on commit 2d75077

Please sign in to comment.