Skip to content

Commit 08f5295

Browse files
authored
Update to allow using a cash instance to create a Position (#15)
1 parent eea68f4 commit 08f5295

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uuid = "2a4f3d17-849a-48a1-809e-d780c70a95a0"
33
license = "MIT"
44
desc = "Financial Instruments"
55
authors = ["Eric Forgy <Eric.Forgy@cavalre.com>", "ScottPJones <scottjones@alum.mit.edu>"]
6-
version = "0.7.0"
6+
version = "0.8.0"
77

88
[deps]
99
Currencies = "0fd90b74-7c1f-579e-9252-02cd883047b9"

README.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,10 @@
1-
[pkg-url]: https://github.com/JuliaFinance/Instruments.jl.git
2-
3-
[release]: https://img.shields.io/github/release/JuliaFinance/Instruments.jl.svg
4-
[release-date]: https://img.shields.io/github/release-date/JuliaFinance/Instruments.jl.svg
5-
6-
[license-img]: http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat
7-
[license-url]: LICENSE.md
8-
[julia-url]: https://github.com/JuliaLang/julia
9-
[julia-release]: https://img.shields.io/github/release/JuliaLang/julia.svg
10-
111
[travis-url]: https://travis-ci.org/JuliaFinance/Instruments.jl
12-
[travis-s-img]: https://travis-ci.org/JuliaFinance/Instruments.jl.svg
13-
[travis-m-img]: https://travis-ci.org/JuliaFinance/Instruments.jl.svg?branch=master
14-
15-
[contrib]: https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat
2+
[travis-img]: https://travis-ci.org/JuliaFinance/Instruments.jl.svg
163

174
[codecov-url]: https://codecov.io/gh/JuliaFinance/Instruments.jl
185
[codecov-img]: https://codecov.io/gh/JuliaFinance/Instruments.jl/branch/master/graph/badge.svg
196

20-
| **Julia Version** | **Unit Tests** | **Code Coverage** |
21-
|:------------------:|:------------------:|:---------------------:|
22-
| [![][julia-release]][julia-url] | [![][travis-s-img]][travis-url] | [![][codecov-img]][codecov-url]
23-
| Latest | [![][travis-m-img]][travis-url] | [![][codecov-img]][codecov-url]
7+
[![][travis-img]][travis-url] [![][codecov-img]][codecov-url]
248

259
# Instruments.jl
2610

src/Instruments.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ Base.:*(p::Position, k::Real) = k * p
8888
Base.:*(val::Real, ::Type{I}) where {I<:Instrument} = Position{I}(val)
8989
Base.:*(::Type{I}, val::Real) where {I<:Instrument} = Position{I}(val)
9090

91+
# Handle instances of Instruments also
92+
Base.:*(val::Real, ::I) where {I<:Instrument} = Position{I}(val)
93+
Base.:*(::I, val::Real) where {I<:Instrument} = Position{I}(val)
94+
9195
Base.show(io::IO, ::I) where {I<:Instrument} = print(io, symbol(I))
9296
Base.show(io::IO, p::Position{I}) where {I<:Instrument} = print(io, p.amount, symbol(I))
9397

0 commit comments

Comments
 (0)