Class: TradervueImporter
- Inherits:
-
Object
- Object
- TradervueImporter
- Includes:
- HTTParty
- Defined in:
- lib/qc/tradervue_importer.rb
Overview
Extracted from github.com/tradervue/ruby-sample
Instance Method Summary collapse
- #import_data(execs, tags: [], account_tag: nil) ⇒ Object
-
#initialize(username, password) ⇒ TradervueImporter
constructor
A new instance of TradervueImporter.
- #status ⇒ Object
Constructor Details
#initialize(username, password) ⇒ TradervueImporter
Returns a new instance of TradervueImporter.
7 8 9 10 |
# 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 |
Instance Method Details
#import_data(execs, tags: [], account_tag: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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 => , :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 ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# 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 |