awoldes / goanda Goto Github PK
View Code? Open in Web Editor NEWA Go package for interacting with Oanda's Forex REST and Streaming API
License: MIT License
A Go package for interacting with Oanda's Forex REST and Streaming API
License: MIT License
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
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.
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?
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.