Skip to content

Commit

Permalink
Merge pull request #4 from ksysoev/improving_example_scripts
Browse files Browse the repository at this point in the history
Improving example scripts
  • Loading branch information
ksysoev authored Jul 25, 2023
2 parents c8336c7 + ba06a63 commit d7690d4
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 3 deletions.
11 changes: 11 additions & 0 deletions examples/creating_app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Create Deriv App

This Go script demonstrates how to create a new Deriv app using the Deriv API. The script uses the `deriv-api` and `deriv-api/schema` packages to interact with the Deriv API and send requests to create a new app.

To use this script, you will need to replace the `ApiToken` constant with your own API token. You can obtain an API token by logging in to your Deriv account and generating a new token in the API tokens section.

The script first creates a new `DerivAPI` instance and authorizes the connection using the provided API token. It then creates a new app registration request with a name and a set of scopes. The script also includes optional fields for specifying a redirect URI, verification URI, markup percentage, and general app info.

Finally, the script sends the app registration request to the Deriv API and logs the ID of the newly created app. You can customize the app registration request and the optional fields to suit your specific needs.

Note that this script is provided as an example and may require modifications to work with your specific environment and use case.
File renamed without changes.
13 changes: 13 additions & 0 deletions examples/simple_trading_bot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Deriv Binary Options Trading Bot

This Go script demonstrates how to use the Deriv API to create a simple trading bot for binary options. The script uses the `deriv-api` and `deriv-api/schema` packages to interact with the Deriv API and send requests to create a new proposal and buy a binary option.

To use this script, you will need to replace the `ApiToken` constant with your own API token. You can obtain an API token by logging in to your Deriv account and generating a new token in the API tokens section.

The script first creates a new `DerivAPI` instance and authorizes the connection using the provided API token. It then creates a new proposal request with a specified amount, barrier, duration, basis, contract type, currency, and symbol.

The script then sends the proposal request to the Deriv API and waits for a response. Once a proposal is received, the script creates a new buy request with the proposal ID and a specified price.

The script then subscribes to the buy request and waits for a response. Once the binary option is bought, the script logs the current spot and the contract result.

Note that this script is provided as an example and may require modifications to work with your specific environment and use case. It is important to thoroughly test any trading bot before using it with real funds.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
const ApiToken = "YOUR_API_TOKEN_HERE" // Replace with your API token

func main() {
api, err := deriv.NewDerivAPI("wss://ws.binaryws.com/websockets/v3", 1, "en", "https://www.binary.com")
api, err := deriv.NewDerivAPI("wss://ws.binaryws.com/websockets/v3", 1089, "en", "https://localhost/")

if err != nil {
log.Fatal(err)
Expand Down
11 changes: 11 additions & 0 deletions examples/tick_history/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Deriv Ticks History

This Go script demonstrates how to use the Deriv API to retrieve the ticks history for a specified symbol. The script uses the `deriv-api` and `deriv-api/schema packages` to interact with the Deriv API and send requests to subscribe to the ticks history stream.

The script first creates a new `DerivAPI` instance and authorizes the connection using the provided API token. It then creates a new ticks history subscription request with a specified symbol, start time, end time, style, and count.

The script then sends the subscription request to the Deriv API and waits for a response. Once a response is received, the script logs the historical prices for the specified symbol.

The script then subscribes to the ticks history stream and waits for new ticks to be received. Once a new tick is received, the script logs the symbol and quote for the tick.

Note that this script is provided as an example and may require modifications to work with your specific environment and use case. It is important to thoroughly test any code that interacts with the Deriv API before using it with real funds.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func main() {
api, err := deriv.NewDerivAPI("wss://ws.binaryws.com/websockets/v3", 1, "en", "https://www.binary.com")
api, err := deriv.NewDerivAPI("wss://ws.binaryws.com/websockets/v3", 1089, "en", "https://localhost/")

if err != nil {
log.Fatal(err)
Expand Down
11 changes: 11 additions & 0 deletions examples/tick_stream/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Deriv Ticks Stream

This Go script demonstrates how to use the Deriv API to subscribe to the ticks stream for a specified symbol. The script uses the `deriv-api` and `deriv-api/schema` packages to interact with the Deriv API and send requests to subscribe to the ticks stream.

The script first creates a new `DerivAPI` instance and authorizes the connection using the provided API token. It then creates a new ticks subscription request with a specified symbol.

The script then sends the subscription request to the Deriv API and waits for a response. Once a response is received, the script logs the initial tick for the specified symbol.

The script then subscribes to the ticks stream and waits for new ticks to be received. Once a new tick is received, the script logs the symbol and quote for the tick.

Note that this script is provided as an example and may require modifications to work with your specific environment and use case. It is important to thoroughly test any code that interacts with the Deriv API before using it with real funds.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func main() {
api, err := deriv.NewDerivAPI("wss://ws.binaryws.com/websockets/v3", 1, "en", "https://www.binary.com", deriv.KeepAlive)
api, err := deriv.NewDerivAPI("wss://ws.binaryws.com/websockets/v3", 1089, "en", "https://localhost/", deriv.Debug)

if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit d7690d4

Please sign in to comment.