Skip to content

Commit

Permalink
feat: add models for gtt
Browse files Browse the repository at this point in the history
  • Loading branch information
rhnvrm committed Nov 27, 2019
1 parent b65f2ab commit f294102
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/ticker/ticker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

kiteconnect "github.com/zerodhatech/gokiteconnect"
"github.com/zerodhatech/gokiteconnect/ticker"
kiteticker "github.com/zerodhatech/gokiteconnect/ticker"
)

const (
Expand Down Expand Up @@ -53,7 +53,7 @@ func onNoReconnect(attempt int) {

// Triggered when order update is received
func onOrderUpdate(order kiteconnect.Order) {
fmt.Printf("Order: ", order.OrderID)
fmt.Printf("Order: %s", order.OrderID)
}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/zerodhatech/gokiteconnect

require (
github.com/gocarina/gocsv v0.0.0-20180809181117-b8c38cb1ba36
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135
github.com/google/go-querystring v1.0.0
github.com/gorilla/websocket v1.4.0
gopkg.in/jarcoal/httpmock.v1 v1.0.0-20180719183105-8007e27cdb32
)
64 changes: 64 additions & 0 deletions gtt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package kiteconnect

type TriggerType string

const (
Single TriggerType = "single"
TwoLeg TriggerType = "two-leg"
)

type Triggers []Trigger

type GTTMeta struct {
RejectionReason string `json:"rejection_reason"`
}

type GTTCondition struct {
Exchange string `json:"exchange"`
LastPrice float64 `json:"last_price"`
Tradingsymbol string `json:"tradingsymbol"`
TriggerValues []float64 `json:"trigger_values"`
}

type Trigger struct {
ID int `json:"id"`
UserID string `json:"user_id"`
ParentTrigger interface{} `json:"parent_trigger"`
Type string `json:"type"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ExpiresAt string `json:"expires_at"`
Status string `json:"status"`
Condition GTTCondition `json:"condition"`
Orders []Order `json:"orders"`
Meta GTTMeta `json:"meta"`
}

type GTTOrderParams struct {
Tradingsymbol string
Exchange string
LastPrice float64
Type TriggerType
TriggerValues []float64
Orders []Order
}

func AddTrigger(o GTTOrderParams) error {
return nil
}

func UpdateTrigger(triggerID int) error {
return nil
}

func GetTriggers() (Triggers, error) {
return nil, nil
}

func GetTrigger(triggerID int) (Trigger, error) {
return Trigger{}, nil
}

func RemoveTrigger(triggerID int) error {
return nil
}

0 comments on commit f294102

Please sign in to comment.