Class: InteractiveBrokers2TastyWorks
- Inherits:
-
Object
- Object
- InteractiveBrokers2TastyWorks
- Defined in:
- lib/interactive_brokers_2_tasty_works.rb,
lib/interactive_brokers_2_tasty_works/version.rb
Defined Under Namespace
Modules: Utils
Constant Summary collapse
- OUTPUT_HEADER =
['Date', 'Type', 'Action', 'Symbol', 'Instrument Type', 'Description', 'Value', 'Quantity', 'Average Price', 'Commissions', 'Fees', 'Multiplier', 'Underlying Symbol', 'Expiration Date', 'Strike Price', 'Call or Put']
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#file_format ⇒ Object
readonly
Returns the value of attribute file_format.
-
#input_path ⇒ Object
readonly
Returns the value of attribute input_path.
Instance Method Summary collapse
-
#initialize(data_hash: nil, input_path: nil, file_format: :xml) ⇒ InteractiveBrokers2TastyWorks
constructor
A new instance of InteractiveBrokers2TastyWorks.
- #output ⇒ Object
- #save_as(output_path) ⇒ Object
Constructor Details
#initialize(data_hash: nil, input_path: nil, file_format: :xml) ⇒ InteractiveBrokers2TastyWorks
Returns a new instance of InteractiveBrokers2TastyWorks.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/interactive_brokers_2_tasty_works.rb', line 22 def initialize(data_hash: nil, input_path: nil, file_format: :xml) @data_hash = data_hash @input_path = input_path @file_format = file_format raise ArgumenrError.new("Must specify `data_hash` or `input_path`.") if data_hash.empty? && input_path.empty? if !input_path.empty? file_format = input_path.split(".").last.to_sym if file_format.empty? file_format = file_format.to_s.to_sym unless file_format.is_a?(Symbol) raise ArgumentError.new("Unknown file format: #{file_format}") unless i(xml json).include?(file_format) end end |
Instance Attribute Details
#file_format ⇒ Object (readonly)
Returns the value of attribute file_format.
16 17 18 |
# File 'lib/interactive_brokers_2_tasty_works.rb', line 16 def file_format @file_format end |
#input_path ⇒ Object (readonly)
Returns the value of attribute input_path.
16 17 18 |
# File 'lib/interactive_brokers_2_tasty_works.rb', line 16 def input_path @input_path end |
Instance Method Details
#output ⇒ Object
42 43 44 |
# File 'lib/interactive_brokers_2_tasty_works.rb', line 42 def output @output ||= convert! end |
#save_as(output_path) ⇒ Object
36 37 38 39 40 |
# File 'lib/interactive_brokers_2_tasty_works.rb', line 36 def save_as(output_path) File.open(File.(output_path), 'w') do |f| output.each { |o| f.write(o.to_csv) } end end |