Skip to content

Commit

Permalink
Moved examples to its own package
Browse files Browse the repository at this point in the history
  • Loading branch information
MarketDataApp committed Feb 6, 2024
1 parent c89c68e commit fc01243
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ jobs:

- name: Test
run: go test -v ./...

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8 changes: 4 additions & 4 deletions examples.go → examples/examples.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package main
package examples

import (
"fmt"

api "github.com/MarketDataApp/sdk-go/client"
)

func rawHttpResponseExample() {
func RawHttpResponseExample() {
resp, err := api.StockQuote().Symbol("AAPL").Raw()
if err != nil {
fmt.Print(err)
Expand All @@ -16,7 +16,7 @@ func rawHttpResponseExample() {
fmt.Println(resp)
}

func logExample() {
func LogExample() {
_, err := api.IndexQuotes().Symbol("VIX").FiftyTwoWeek(true).Get()
if err != nil {
fmt.Print(err)
Expand All @@ -27,7 +27,7 @@ func logExample() {

}

func marketStatusExample() {
func MarketStatusExample() {

msr, err := api.MarketStatus().From("2022-01-01").To("2022-01-10").Packed()
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions examples_indices.go → examples/examples_indices.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package examples

import (
"fmt"
Expand All @@ -7,7 +7,7 @@ import (
api "github.com/MarketDataApp/sdk-go/client"
)

func indexQuoteExample() {
func IndexQuoteExample() {
iqe, err := api.IndexQuotes().Symbol("VIX").FiftyTwoWeek(true).Packed()
if err != nil {
fmt.Print(err)
Expand All @@ -30,7 +30,7 @@ func indexQuoteExample() {

}

func indexCandlesExample() {
func IndexCandlesExample() {
oneWeekAgo := time.Now().AddDate(0, 0, -7)
ice, err := api.IndexCandles().Resolution("D").Symbol("VIX").From(oneWeekAgo).To("today").Packed()
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions examples_options.go → examples/examples_options.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package main
package examples

import (
"fmt"

api "github.com/MarketDataApp/sdk-go/client"
)

func optionsChainExample() {
func OptionsChainExample() {
resp, err := api.OptionChain().UnderlyingSymbol("AAPL").Side("call").DTE(60).StrikeLimit(2).Get()
if err != nil {
fmt.Print(err)
Expand All @@ -19,7 +19,7 @@ func optionsChainExample() {

}

func optionsQuotesExample() {
func OptionsQuotesExample() {
resp, err := api.OptionQuote().OptionSymbol("AAPL250117C00150000").Get()
if err != nil {
fmt.Print(err)
Expand All @@ -30,7 +30,7 @@ func optionsQuotesExample() {

}

func optionsStrikesExample() {
func OptionsStrikesExample() {
resp, err := api.OptionsStrikes().UnderlyingSymbol("AAPL").Get()
if err != nil {
fmt.Print(err)
Expand All @@ -42,7 +42,7 @@ func optionsStrikesExample() {
}
}

func optionsLookupExample() {
func OptionsLookupExample() {
resp, err := api.OptionLookup().UserInput("AAPL 7/28/2023 200 Call").Get()
if err != nil {
fmt.Print(err)
Expand All @@ -52,7 +52,7 @@ func optionsLookupExample() {
fmt.Println(resp)
}

func optionsExpirationsExample() {
func OptionsExpirationsExample() {
resp, err := api.OptionsExpirations().UnderlyingSymbol("AAPL").Strike(200).Get()
if err != nil {
fmt.Print(err)
Expand Down
10 changes: 5 additions & 5 deletions examples_stocks.go → examples/examples_stocks.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package main
package examples

import (
"fmt"

api "github.com/MarketDataApp/sdk-go/client"
)

func stockQuoteExample() {
func StockQuoteExample() {
sqe, err := api.StockQuote().Symbol("AAPL").FiftyTwoWeek(true).Packed()
if err != nil {
fmt.Print(err)
Expand All @@ -28,7 +28,7 @@ func stockQuoteExample() {
}
}

func stockCandlesExample() {
func StockCandlesExample() {

sce, err := api.StockCandles().Resolution("1").Symbol("AAPL").From("2023-01-01").To("2023-01-04").Packed()
if err != nil {
Expand All @@ -48,7 +48,7 @@ func stockCandlesExample() {

}

func stockEarningsExample() {
func StockEarningsExample() {
see, err := api.StockEarnings().Symbol("AAPL").From("2022-01-01").To("2022-12-31").Packed()
if err != nil {
fmt.Print(err)
Expand All @@ -70,7 +70,7 @@ func stockEarningsExample() {
}
}

func stockNewsExample() {
func StockNewsExample() {
resp, err := api.StockNews().Symbol("AAPL").Get()
if err != nil {
fmt.Print(err)
Expand Down
2 changes: 1 addition & 1 deletion examples_test.go → examples/examples_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package examples

import (
"testing"
Expand Down
6 changes: 3 additions & 3 deletions examples_v2.go → examples/examples_v2.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package examples

import (
"fmt"
Expand All @@ -10,7 +10,7 @@ import (
md "github.com/MarketDataApp/sdk-go/models"
)

func stockCandlesV2Example() {
func StockCandlesV2Example() {

sce, err := api.StockCandlesV2().Resolution("1").Symbol("AAPL").DateKey("2023-01").Packed()
if err != nil {
Expand All @@ -29,7 +29,7 @@ func stockCandlesV2Example() {
}
}

func stocksTickersV2Example() {
func StocksTickersV2Example() {
tickers, err := api.StockTickers().DateKey("2023-01-05").Packed()
if err != nil {
fmt.Print(err)
Expand Down
33 changes: 16 additions & 17 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"log"

api "github.com/MarketDataApp/sdk-go/client"

. "github.com/MarketDataApp/sdk-go/examples"
)

func main() {
Expand All @@ -16,59 +18,56 @@ func main() {

client.Debug(false)

}

/*
fmt.Println("Staring log example...")
logExample()
LogExample()
/*
//fmt.Println("Starting market status request...")
//marketstatusExample()
fmt.Println("Staring rawResponse example...")
rawHttpResponseExample()
*/
}

func optionsExamples() {
fmt.Println("Staring Options/Chain example...")
optionsChainExample()
OptionsChainExample()

fmt.Println("Staring Options/Strikes example...")
optionsStrikesExample()
OptionsStrikesExample()

fmt.Println("Staring Options/Quotes example...")
optionsQuotesExample()
OptionsQuotesExample()

fmt.Println("Staring Options/Lookup example...")
optionsLookupExample()
OptionsLookupExample()

fmt.Println("Staring Options/Expirations example...")
optionsExpirationsExample()
OptionsExpirationsExample()

}

func stocksExamples() {
fmt.Println("Staring Stocks/News example...")
stockNewsExample()
StockNewsExample()

fmt.Println("Starting stock earnings request...")
stockEarningsExample()
StockEarningsExample()

fmt.Println("Starting stock quote request...")
stockQuoteExample()
StockQuoteExample()

fmt.Println("Starting stock candles request...")
stockCandlesExample()
StockCandlesExample()

}

func indexExamples() {
fmt.Println("Starting index quote request...")
indexQuoteExample()
IndexQuoteExample()

fmt.Println("Starting index candles request...")
indexCandlesExample()
IndexCandlesExample()

}

0 comments on commit fc01243

Please sign in to comment.