Skip to content

Commit

Permalink
Improves Readme for the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ksysoev committed Aug 9, 2023
1 parent 00911eb commit e6d47c8
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,32 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/ksysoev/deriv-api.svg)](https://pkg.go.dev/github.com/ksysoev/deriv-api)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

This is unofficial library for working with [Deriv API](https://api.deriv.com)

**This is unofficial library for working with [Deriv API](https://api.deriv.com)**

DerivAPI is a Go package that provides a client for the Deriv API. It allows you to connect to the Deriv API and make requests to retrieve data and perform actions on your or your client's Deriv account.

## Installation

To install deriv-api, use `go get`:
To use DerivAPI in your Go project, you can install it using go get:

```
go get github.com/ksysoev/deriv-api
```

## Usage

### Subscribing on tick stream
### Tick stream

Here's an example of how to use DerivAPI to connect to the Deriv API and subscribe on market data updates:

```golang
import (
"fmt"
"log"

"github.com/ksysoev/deriv-api"
"github.com/ksysoev/deriv-api/schema"
)


Expand All @@ -38,7 +44,7 @@ if err != nil {

defer api.Disconnect()

resp, sub, err := api.SubscribeTicks(deriv.Ticks{Ticks: "R_50"})
resp, sub, err := api.SubscribeTicks(schema.Ticks{Ticks: "R_50"})

if err != nil {
log.Fatal(err)
Expand All @@ -54,11 +60,14 @@ for tick := range sub.Stream {

### Buying a contract

Here's another example of how to use DerivAPI to buy contract and listen for updates for this contract.

```golang
import (
"log"

"github.com/ksysoev/deriv-api"
"github.com/ksysoev/deriv-api/schema"
)

apiToken := "YOU_API_TOKEN_HERE"
Expand All @@ -71,7 +80,7 @@ if err != nil {
defer api.Disconnect()

// First, we need to authorize the connection
reqAuth := deriv.Authorize{Authorize: apiToken}
reqAuth := schema.Authorize{Authorize: apiToken}
_, err = api.Authorize(reqAuth)

if err != nil {
Expand All @@ -81,9 +90,9 @@ if err != nil {
amount := 100.0
barrier := "+0.001"
duration := 5
basis := deriv.ProposalBasisPayout
basis := schema.ProposalBasisPayout

reqProp := deriv.Proposal{
reqProp := schema.Proposal{
Proposal: 1,
Amount: &amount,
Barrier: &barrier,
Expand All @@ -102,7 +111,7 @@ if err != nil {
log.Fatal(err)
}

buyReq := deriv.Buy{
buyReq := schema.Buy{
Buy: proposal.Proposal.Id,
Price: 100.0,
}
Expand Down

0 comments on commit e6d47c8

Please sign in to comment.