Code Monkey home page Code Monkey logo

goanda's People

Contributors

awoldes avatar habuka036 avatar stewi1014 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

goanda's Issues

Authorization issue

Hi,
after I changed the code to:

package main

import (
	"log"
	"os"

	"github.com/awoldes/goanda"
	"github.com/davecgh/go-spew/spew"
	"github.com/joho/godotenv"
)

func main() {
	err := godotenv.Load()
	if err != nil {
		log.Fatal("Error loading .env file")
	}
	key := os.Getenv("OANDA_API_KEY")
	accountID := os.Getenv("OANDA_ACCOUNT_ID")
	oanda := goanda.NewConnection(accountID, key, false)
	history := oanda.GetCandles("EUR_USD", "10", "1M")
	spew.Dump(history)
}

I am getting the following error:

2018/10/23 13:46:22 /root/go_projects/src/github.com/awoldes/goanda/utils.go:22: 
OANDA API Error: {"errorMessage":"Insufficient authorization to perform request."}
On route: /instruments/EUR_USD/candles?count=10&granularity=1M

Account is good, I have tried with curl and it works.

TakeProfit?

I know there's a StopLossOnFill and that works very well, but is there a TakeProfit option which allows me to set StopLossOnFill and TakeProfit when performing a Limit Order (the API at OANDA seems to support this).

I cannot find this in the code anywhere, even though the API and interface allow this.

About log.Fatal()

Hi there,

This library uses log.Fatal() in some codes despite that causes exit the program when failed to connect for OANDA API.

So, I want to suggest the error return to the caller instead of use log.Fatal().

Of cause, my suggestion has a big impact on the Interfaces of this library. Therefore I hope someone will come up with a good idea more than my suggestion.

Thank you for this great library,

Osamu

Getting error compiling example

Hello,

I am getting the following error compiling the example:

# _/root
./main.go:20:29: not enough arguments in call to oanda.GetCandles
	have (string)
	want (string, string, string)

and doing go doc goanda.GetCandles I am getting:

func (c *OandaConnection) GetCandles(instrument string, count string, granularity string) InstrumentHistory

So is this example up-to-date?

TradeIDs is missing for Short positions in OpenPositions struct

If you look here https://developer.oanda.com/rest-live-v20/position-ep/

and open the "get open positions" API call (2nd from the top), in the second example curl: List all open Position details for Account in the output it shows that a Short position will also have "TradeIDs":

    {
      "instrument": "USD_CAD", 
      "long": {
        "pl": "-483.91941", 
        "resettablePL": "-483.91941", 
        "units": "0", 
        "unrealizedPL": "0.00000"
      }, 
      "pl": "-486.16662", 
      "resettablePL": "-486.16662", 
      "short": {
        "averagePrice": "1.28241", 
        "pl": "-2.24721", 
        "resettablePL": "-2.24721", 
        "tradeIDs": [
          "6387"
        ], 
        "units": "-600", 
        "unrealizedPL": "-0.08525"
      }, 
      "unrealizedPL": "-0.08525"
    }

However TradeIDs is only present in the OpenPositions struct for Long positions:

type OpenPositions struct {
	LastTransactionID string `json:"lastTransactionID"`
	Positions         []struct {
		Instrument string `json:"instrument"`
		Long       struct {
			AveragePrice string   `json:"averagePrice"`
			Pl           string   `json:"pl"`
			ResettablePL string   `json:"resettablePL"`
			TradeIDs     []string `json:"tradeIDs"`
			Units        string   `json:"units"`
			UnrealizedPL string   `json:"unrealizedPL"`
		} `json:"long"`
		Pl           string `json:"pl"`
		ResettablePL string `json:"resettablePL"`
		Short        struct {
			Pl           string `json:"pl"`
			ResettablePL string `json:"resettablePL"`
			Units        string `json:"units"`
			UnrealizedPL string `json:"unrealizedPL"`
		} `json:"short"`
		UnrealizedPL string `json:"unrealizedPL"`
	} `json:"positions"`
}

Note that TradeIDs is missing from the Short position there.

I assume because in the API curl example, the first position is a Long position and that was used to make the struct. However the second position in the API curl example is a Short position and shows it should be present there as well

Edit: just noticed AveragePrice also is missing for Short positions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.