示例#1
0
        /// <summary>
        /// OandaApiConnection constuctor
        /// Sets up the configuration and the datetime format
        /// </summary>
        /// <param name="connectionType">Type of the connection</param>
        /// <param name="accessToken">Access token for the connection</param>
        /// <param name="dateTimeFormat">Date time format to use for the connection</param>
        public OandaApiConnection(OandaConnectionType connectionType, string accessToken, DateTimeFormat dateTimeFormat = DateTimeFormat.RFC3339)
        {
            // Init configuration
            Configuration = new Configuration()
            {
                UserAgent   = $"OandaDotnetSdk/{Assembly.GetExecutingAssembly().GetName().Version}",
                BasePath    = connectionType.ToBasePath(),
                AccessToken = accessToken
            };

            // Init date time format
            DateTimeFormat = dateTimeFormat;

            // Init actual Oanda API connections from the GeriRemenyi.Oanda.V20.Client
            AccountApi     = new AccountApi(Configuration);
            InstrumentApi  = new InstrumentApi(Configuration);
            OrderApi       = new OrderApi(Configuration);
            TradeApi       = new TradeApi(Configuration);
            PositionApi    = new PositionApi(Configuration);
            TransactionApi = new TransactionApi(Configuration);
            PricingApi     = new PricingApi(Configuration);

            // Init object caches
            _accountsCache   = new Dictionary <string, IAccount>();
            _instrumentCache = new Dictionary <InstrumentName, IInstrument>();

            // Fire a really small request synchronously to check that the inited connection is OK
            // Also fill the available accounts based on this
            try
            {
                Accounts = AccountApi.GetAccounts().Accounts;
            }
            catch
            {
                throw new ConnectionInitializationException($"Unable to connect to {Configuration.BasePath} with the given token");
            }
        }
 public void Init()
 {
     instance = new InstrumentApi();
 }
 public void Init()
 {
     instance = new InstrumentApi();
 }
示例#4
0
 public InstrumentRequests()
 {
     _api = new InstrumentApi(this.Client);
 }
示例#5
0
 public InstrumentApiTests()
 {
     instance = new InstrumentApi();
 }