class TradervueImporter

Extracted from github.com/tradervue/ruby-sample

Public Class Methods

new(username, password) click to toggle source
# File lib/qc/tradervue_importer.rb, line 7
def initialize(username, password)
  @auth = { :username => username, :password => password }
  @user_agent = "Qc - QuantConnect command line tool (https://github.com/jorgemanrubia/qc)"
end

Public Instance Methods

import_data(execs, tags: [], account_tag: nil) click to toggle source
# File lib/qc/tradervue_importer.rb, line 27
def import_data(execs, tags: [], account_tag: nil)
  req = {
      :allow_duplicates => false,
      :overlay_commissions => false,
      :account_tag => account_tag,
      :tags => tags,
      :executions => execs
  }

  opts = {}
  opts[:headers] = { "User-Agent" => @user_agent }
  opts[:basic_auth] = @auth
  opts[:body] = req
  resp = self.class.post("/imports", opts)

  if resp.code == 401
    return "access denied"
  end

  if resp.code == 200
    resp["status"]
  else
    resp["error"]
  end
end
status() click to toggle source
# File lib/qc/tradervue_importer.rb, line 12
def status
  opts = {}
  opts[:headers] = { "User-Agent" => @user_agent }
  opts[:basic_auth] = @auth
  resp = self.class.get("/imports", opts)
  puts resp
  if resp.code == 401
    return "access denied"
  end

  # status details about the last import in resp["info"]

  resp["status"]
end