licenses
sequencelengths 1
3
| version
stringclasses 677
values | tree_hash
stringlengths 40
40
| path
stringclasses 1
value | type
stringclasses 2
values | size
stringlengths 2
8
| text
stringlengths 25
67.1M
| package_name
stringlengths 2
41
| repo
stringlengths 33
86
|
---|---|---|---|---|---|---|---|---|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | code | 3238 | module Example
using Test
using ObjectOriented
DoPrint = Ref(false)
@oodef struct IVehicle
function get_speed end
function info end
end
@oodef mutable struct Vehicle <: IVehicle
m_speed::Float64
function new(speed)
@mk begin
m_speed = speed
end
end
end
@oodef mutable struct Bus <: Vehicle
function new(speed::Float64)
@mk Vehicle(speed)
end
# override
function info(self)
""
end
# override
function get_speed(self)
return self.m_speed
end
end
@oodef struct IHouse
@property(rooms) do
get
set
end
function can_cook end
end
@oodef mutable struct House <: IHouse
m_rooms::Int
function new(rooms::Int)
@mk begin
# @base(IHouse) = IHouse()
m_rooms = rooms
end
end
@property(rooms) do
get = function (self)
self.m_rooms
end
set = function (self, value)
self.m_rooms = value
end
end
# override
function can_cook(self)
true
end
end
@oodef mutable struct HouseBus <: {Bus, House}
m_power::String
function new(speed::Float64, rooms::Int, power::String = "oil")
self = new()
self.m_power = power
set_base!(self, Bus(speed))
set_base!(self, House(rooms))
return self
# @mk begin
# @base(Bus) = Bus(speed)
# @base(House) = House(rooms)
# m_power = power
# end
end
@property(power) do
get = self -> self.m_power
set = (self, value) -> self.m_power = value
end
# override
function info(self)
"power = $(self.m_power), " *
"speed = $(self.get_speed()), " *
"rooms=$(self.rooms)"
end
end
@oodef mutable struct RailBus <: {Bus}
m_power::String
function new(speed::Float64)
@mk begin
Bus(speed)
m_power = "electricity"
end
end
@property(power) do
get = self -> self.m_power
end
# override
function info(self)
"power = $(self.m_power), " *
"speed = $(self.get_speed())"
end
end
housebuses = [
[HouseBus(60.0, 2) for i = 1:10000];
[RailBus(80.0) for i = 1:10000]
]
res = []
function f(buses::Vector)
for bus in buses
info = bus.info()
if bus isa HouseBus
cook = bus.can_cook()
if DoPrint[]
@info typeof(bus) info cook
else
push!(res, (typeof(bus), info, cook))
end
else
if DoPrint[]
@info typeof(bus) info
else
push!(res, (typeof(bus), info))
end
end
end
end
function get_speed(o::@like(IVehicle))
o.get_speed()
end
using InteractiveUtils
function runtest()
@testset "example" begin
f(housebuses)
hb = HouseBus(60.0, 2)
rb = RailBus(80.0)
get_speed(hb)
get_speed(rb)
end
end
end
| ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | code | 781 | module Inference
using ObjectOriented
using InteractiveUtils
using Test
@oodef struct IVehicle
function get_speed end
function info end
end
@oodef mutable struct Vehicle <: IVehicle
m_speed :: Float64
function new(speed)
@mk begin
m_speed = speed
end
end
end
@oodef mutable struct Bus <: Vehicle
function new(speed::Float64)
@mk begin
Vehicle(speed)
end
end
# override
function info(self)
""
end
# override
function get_speed(self)
self.m_speed
end
end
f(x) = @typed_access x.speed
@testset "inference property with @typed_access" begin
bus = Bus(1.0)
(@code_typed f(bus)).second === Float64
end
end | ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | code | 9368 | module TestModule
using Test
using ObjectOriented
module structdef
using ObjectOriented
using Test
using MLStyle: @match
import InteractiveUtils
function not_code_coverage_or_goto(e)
@match e begin
Expr(:meta, _...) => false
Expr(:code_coverage_effect, _...) => false
::Core.GotoNode => false
_ => true
end
end
# Julia's default constructor are used for structs that have fields
# 当结构体存在字段,使用Julia默认的构造器
@oodef struct A
a :: Int
b :: Int
end
@testset "default struct constructor" begin
a = A(1, 2)
@test a.a == 1
@test a.b == 2
end
# custom constructors are allowed for such case
# 这种情况下,也允许自定义构造器
@oodef struct A2
a :: Int
b :: Int
function new(a::Int, b::Int = 3) # new用来定义OO类型的构造器
@mk begin
a = a
b = b
end
end
function new(;a::Int, b::Int = 3) # new可以重载
@mk begin
a = a
b = b
end
end
end
@testset "custom struct constructor with default arguments/keyword arguments" begin
a = A2(1)
@test a.a == 1
@test a.b == 3
a = A2(a=1)
@test a.a == 1
@test a.b == 3
end
# struct can be used as a base class
# 结构体可以作为基类
@oodef struct B <: A
c :: Int
function new(a :: Int, b :: Int, c :: Int)
@mk begin
A(a, b)
c = c
end
end
end
@testset "struct inherit struct" begin
b = B(1, 2, 3)
@test b.a == 1
@test b.b == 2
@test b.c == 3
end
# empty structs and inheritances need no custom constructors
# 空结构体和其继承不需要自定义构造器
@oodef struct A3
function interface_method1 end
function interface_method2 end
@property(interface_prop) do
set
get
end
end
@oodef struct A4
@property(a) do
set
get
end
end
# 检查未实现的抽象方法
# check unimplemented abstract methods
@testset "interfaces 1" begin
@test Set(keys(ObjectOriented.check_abstract(A3))) == Set([
PropertyName(false, :interface_prop), # getter
PropertyName(true, :interface_prop), # setter
PropertyName(false, :interface_method2),
PropertyName(false, :interface_method1)
])
@test Set(keys(ObjectOriented.check_abstract(A4))) == Set([
PropertyName(false, :a), # getter
PropertyName(true, :a), # setter
])
end
# 'mutable' means 'classes'
# 'mutable' 表示'类'
@oodef mutable struct B34 <: {A3, A4}
x :: Int
function new(x)
@mk begin
#= empty struct bases can be omitted: =#
#= 空结构体基类可以省略: =#
# @base(A3) = A3()
# @base(A4) = A4()
x = x
end
end
function interface_method1(self)
println(1)
end
function interface_method2(self)
println(1)
end
@property(interface_prop) do
set = function (self, value)
self.x = value - 1
end
get = function (self)
return self.x + 1
end
end
@property(a) do
set = (self, value) -> self.x = value
get = (self) -> self.x
end
end
@testset "interfaces 2" begin
@test Set(keys(check_abstract(B34))) |> isempty
b = B34(2)
b.x = 3
@test b.x === 3
b.interface_prop = 10
@test b.x === 9
@test b.x == b.a
b.a = 11
@test b.x == 11
end
# can fetch a type's properties
# 可以获取类型的properties
@testset "propertynames" begin
issubset(
Set([:x, :a, :interface_method2, :interface_method1, :interface_prop]),
Set(propertynames(B34)))
end
# work with julia stdlib
# 能和Julia标准库一同工作
@oodef struct IRandomIndexRead{IndexType}
function getindex end
end
@oodef struct IRandomIndexWrite{IndexType, ElementType}
function setindex! end
end
Base.@inline function Base.getindex(x::@like(IRandomIndexRead{>:I}), i::I) where I
x.getindex(i)
end
Base.@inline function Base.setindex!(x::@like(IRandomIndexWrite{>:I, >:E}), i::I, value::E) where {I, E}
x.setindex!(i, value)
end
@oodef struct MyVector{T} <: {IRandomIndexRead{Integer}, IRandomIndexWrite{Integer, T}}
inner :: Vector{T}
function new(args :: T...)
@mk begin
inner = collect(args)
end
end
# constructor overloading
# 重载构造器
function new(vec :: Vector{T})
self = new{T}()
self.inner = vec
return self
# @mk begin
# inner = vec
# end
end
function getindex(self, i::Integer)
return @inbounds self.inner[i]
end
function setindex!(self, i::Integer, v::T)
@inbounds self.inner[i] = v
end
end
@testset "interface programming is multiple-dispatch compatible" begin
# 接口编程与多重派发兼容
myvec = MyVector(1, 2, 3, 5)
setindex!(myvec, 2, 3)
@test getindex(myvec, 2) == 3
# 代码被优化到最佳形式
@testset "code optimization" begin
c = InteractiveUtils.@code_typed getindex(myvec, 2)
@info :optimized_code c
# │ c =
# │ CodeInfo(
# │ 1 ─ %1 = (getfield)(x, :inner)::Vector{Int64}
# │ │ %2 = Base.arrayref(true, %1, i)::Int64
# │ └── return %2
# └ ) => Int64
@test c.second === Int
@test @match filter(not_code_coverage_or_goto, c.first.code)[2] begin
Expr(:call, f, _...) && if f == GlobalRef(Base, :arrayref) end => true
_ => false
end
@test length(filter(not_code_coverage_or_goto, c.first.code)) == 3
end
end
@oodef struct OverloadedMethodDemo
function test(self, a::Int)
"Int $a"
end
function test(self, a, b)
"2-ary"
end
end
@testset "overloading" begin
@test OverloadedMethodDemo().test(1) == "Int 1"
@test OverloadedMethodDemo().test(1, 2) == "2-ary"
end
@oodef struct TestPropertyInference
@property(a) do
get = self -> 1
end
@property(b) do
get = self -> "str"
end
end
x = TestPropertyInference()
@testset "test inferencing properties" begin
@test x.a == 1
@test x.b == "str"
@test (InteractiveUtils.@code_typed x.a).second in (Any, Union{Int, String})
f(x) = @typed_access x.a
@test Int == (InteractiveUtils.@code_typed f(x)).second
end
@oodef struct TestMissingParameterName{T}
function new(::Type{T})
new{T}()
end
end
@testset "test missing parameter names" begin
x = TestMissingParameterName(Int)
@test x isa TestMissingParameterName{Int}
end
@oodef struct TestCurlyTypeApplication{T}
function new()
new{T}()
end
end
@testset "test curly type application" begin
x = TestCurlyTypeApplication{Int}()
@test x isa TestCurlyTypeApplication{Int}
end
@testset "qualified field types" begin
@oodef struct QualifiedFieldType
b :: Core.Builtin
@property(a) do
get = self -> 1
end
end
end
macro gen()
quote
a :: Int
b :: Nothing
end |> esc
end
@oodef struct TestBlockType
@gen
begin
c :: Bool
d :: Char
end
end
@testset "blocks in struct" begin
obj = TestBlockType(1, nothing, true, 'a')
@test obj.a == 1
@test obj.b === nothing
@test obj.c === true
@test obj.d == 'a'
end
z = "2"
some_ref_val = Ref(2)
@oodef struct TestDefaultFieldsImmutable
a :: Int = 1
b :: String = begin; some_ref_val[] = 1; repeat(z, 3) end
function new()
@mk
end
function new(b::String)
@mk b = b
end
end
@testset "default fields" begin
x = TestDefaultFieldsImmutable()
@test x.a == 1
@test x.b == repeat(z, 3)
@test some_ref_val[] == 1
some_ref_val[] = 5
x = TestDefaultFieldsImmutable("sada")
@test some_ref_val[] == 5
@test x.b == "sada"
end
end
include("example.jl")
Example.DoPrint[] = false
Example.runtest()
include("inference.jl")
end | ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | docs | 138 | # ChangeLog
## 0.1.4
Date: 1/4/2024
1. Fix potential unbound recursions when `getproperty_fallback` raises. (PR #12 by @t-bltg)
| ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | docs | 4055 | # ObjectOriented
[](https://Suzhou-Tongyuan.github.io/ObjectOriented.jl/stable/)
[](https://Suzhou-Tongyuan.github.io/ObjectOriented.jl/dev/)
[](https://github.com/Suzhou-Tongyuan/ObjectOriented.jl/actions/workflows/CI.yml?query=branch%3Amain)
[ObjectOriented.jl](https://github.com/thautwarm/ObjectOriented.jl) is a mechanical OOP programming library for Julia. The design is mainly based on CPython OOP but adapted for Julia.
The supported features:
- multiple inheritances
- using dot operators to access members
- default field values
- overloaded constructors and methods
- Python-style properties (getters and setters)
- generics for the OOP system
- interfaces
Check out our [documentation](https://Suzhou-Tongyuan.github.io/ObjectOriented.jl/dev/).
We recommend you to read [How to Translate OOP into Idiomatic Julia](https://suzhou-tongyuan.github.io/ObjectOriented.jl/dev/how-to-translate-oop-into-julia) before using this package. If you understand your complaints about Julia's lack of OOP come from your refutation of the Julia coding style, feel free to use this.
For people who want to use this package in a more Julian way, you can avoid defining methods (and Python-style properties) with `@oodef`.
## Preview
```julia
@oodef mutable struct MyClass <: MySuperClass
a::Int
b::Int
function new(a::Integer, b::Integer)
self = @mk
self.a = a
self.b = b
return self
end
function compute_a_plus_b(self)
self.a + self.b
end
end
julia> inst = MyClass(1, 2)
julia> inst.compute_a_plus_b()
3
```
A more concise rewrite using `@mk` is:
```julia
@oodef mutable struct MyClass <: MySuperClass
a::Int
b::Int
function new(a::Integer, b::Integer)
@mk begin
a = a
b = b
end
end
function compute_a_plus_b(self)
self.a + self.b
end
end
julia> inst = MyClass(1, 2)
julia> inst.compute_a_plus_b()
3
```
## Hints For Professional Julia Programmers
As the dot method (`self.method()`) is purely a syntactic sugar thing, using the idiomatic Julia code like `method(self)` is usually better. Using the idiomatic Julia methods, method ambiguity can be avoided, which is of course better than OOP in this case.
You can avoid defining dot methods as shown below:
```julia
@oodef struct MyType
field1::Int
field2::Int
function new(a, b)
@mk begin
field1=a
field2=b
end
end
#= not Julian:
function some_func(self)
return self.field1 + self.field2
end
=#
end
# Julian way:
function some_func(self :: @like(MyType)) # @like(...) accepts subtypes
self.field1 + self.field2
end
@oodef struct MyDerivedType <: MyType
c::Int
function new(a, b, c)
@mk begin
MyType(a, b)
c = c
end
end
end
some_func(MyType(1, 2)) # 3
some_func(MyDerivedType(1, 2, 3)) # 3
```
## Troubleshooting
1. [The integrated debugger implemented in Julia-VSCode cannot handle `@generated` functions](https://github.com/julia-vscode/julia-vscode/issues/2441), which causes a bug when entering `@mk` expressions. A workaround can be made as follows:
```julia
@oodef mutable struct YourClass
x::Int
y::Int
function new(x, y)
# you can debug here
self = @mk begin
# you can debug here
x = x
# you can debug here
y = y
# do not reach here!
# please jump over the end of '@mk' expression!
end
# you can debug here
return self
end
end
```
| ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | docs | 2674 | ## 类型不稳定 1:字段
```julia
mutable struct X
a :: Any
end
xs = [X(1) for i = 1:10000]
function sum1(xs::AbstractVector{X})
s = 0
for x in xs
s += x.a
end
return s
end
function sum2(xs::AbstractVector{X})
s = 0
for x in xs
s += x.a :: Int
end
return s
end
@btime sum1(xs)
# 147.800 μs (9489 allocations: 148.27 KiB)
10000
@btime sum2(xs)
# 5.567 μs (1 allocation: 16 bytes)
10000
```
如果想要检测性能问题,可以使用`@code_warntype`检测类型稳定性,还可以用`@code_llvm`检测是否调用`jl_apply_generic`函数。
`@code_llvm sum1(xs)`或者 `code_llvm(sum1, (typeof(xs1), ))`,可以发现存在 `jl_apply_generic`,这意味着动态分派。
Julia动态分派的性能差。
```julia
struct SomeType{T}
f1::T
f2::T
f3::T
end
data = SomeType(1, 2, 3)
function f(x::Any)
data.f1 + data.f2 + data.f3
end
```
## 类型不稳定 2: 数组类型
```julia
using BenchmarkTools
function fslow(n)
xs = [] # equals to 'Any[]'
push!(xs, Ref(0))
s = 0
for i in 1:n
xs[end][] = i
s += xs[end][]
end
return s
end
function ffast(n)
xs = Base.RefValue{Int}[]
push!(xs, Ref(0))
s = 0
for i in 1:n
xs[end][] = i
s += xs[end][]
end
return s
end
@btime fslow(10000)
# 432.200 μs (28950 allocations: 452.44 KiB)
50005000
@btime ffast(10000)
# 4.371 μs (3 allocations: 144 bytes)
50005000
```
`InteractiveUtils.@code_warntype`可以发现类型不稳定的问题。黄色的代码表示可能存在问题,红色表示存在问题。


## 类型不稳定 3:类型不稳定的全局变量
```julia
int64_t = Int
scalar = 3
function sum_ints1(xs::Vector)
s = 0
for x in xs
if x isa int64_t
s += x * scalar
end
end
return s
end
# const Int = Int
const const_scalar = 3
function sum_ints2(xs::Vector)
s = 0
for x in xs
if x isa Int
s += x * const_scalar
end
end
return s
end
data = [i % 2 == 0 ? 1 : "2" for i = 1:1000000]
@btime sum_ints1(data)
# 18.509 ms (499830 allocations: 7.63 MiB)
1500000
@btime sum_ints2(data)
# 476.600 μs (1 allocation: 16 bytes)
1500000
```
可以用`@code_warntype`看到性能问题:

## 顶层作用域性能问题
```julia
xs = ones(Int, 1000000)
t0 = time_ns()
s = 0
for each in xs
s += each
end
s
println("time elapsed: ", time_ns() - t0, "ns")
# time elapsed: 115459800ns
@noinline test_loop(xs) = begin
t0 = time_ns()
s = 0
for each in xs
s += each
end
println("time elapsed: ", time_ns() - t0, "ns")
return s
end
test_loop(xs) === 1000000
# time elapsed: 433500ns
``` | ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | docs | 8123 | ### class
```julia
@oodef mutable struct Base1
a :: Any
function new(a::Any)
@mk begin
a = a
end
end
function identity_a(self)
self
end
end
@oodef mutable struct Base2 <: Base1
b :: Any
function new(a::Any, b::Any)
@mk begin
@base(Base1) = Base1(a)
b = b
end
end
function identity_b(self)
self
end
end
@oodef mutable struct Base3 <: Base2
c :: Any
function new(a::Any, b::Any, c::Any)
@mk begin
@base(Base2) = Base2(a, b)
c = c
end
end
function identity_c(self)
self
end
end
@oodef mutable struct Base4 <: Base3
d :: Any
function new(a::Any, b::Any, c::Any, d::Any)
@mk begin
@base(Base3) = Base3(a, b, c)
d = d
end
end
function identity_d(self)
self
end
end
@oodef mutable struct Base5 <: Base4
e :: Any
function new(a::Any, b::Any, c::Any, d::Any, e::Any)
@mk begin
@base(Base4) = Base4(a, b, c, d)
e = e
end
end
function identity_e(self)
self
end
end
class_o = Base5(1, 2, 3, 4, 5)
@btime class_o.a
@btime class_o.b
@btime class_o.c
@btime class_o.d
@btime class_o.e
@btime class_o.identity_a()
@btime class_o.identity_b()
@btime class_o.identity_c()
@btime class_o.identity_d()
@btime class_o.identity_e()
# julia> @btime class_o.a
# 15.431 ns (0 allocations: 0 bytes)
# 1
# julia> @btime class_o.b
# 15.816 ns (0 allocations: 0 bytes)
# 2
# julia> @btime class_o.c
# 14.615 ns (0 allocations: 0 bytes)
# 3
# julia> @btime class_o.d
# 14.414 ns (0 allocations: 0 bytes)
# 4
# julia> @btime class_o.e
# 14.815 ns (0 allocations: 0 bytes)
# 5
# julia> @btime class_o.identity_a()
# 24.799 ns (1 allocation: 16 bytes)
# Base5(5, Base4(4, Base3(3, Base2(2, Base1(1)))))
# julia> @btime class_o.identity_b()
# 24.473 ns (1 allocation: 16 bytes)
# Base5(5, Base4(4, Base3(3, Base2(2, Base1(1)))))
# julia> @btime class_o.identity_c()
# 23.896 ns (1 allocation: 16 bytes)
# Base5(5, Base4(4, Base3(3, Base2(2, Base1(1)))))
# julia> @btime class_o.identity_d()
# 23.771 ns (1 allocation: 16 bytes)
# Base5(5, Base4(4, Base3(3, Base2(2, Base1(1)))))
```
### struct
```julia
@oodef struct Base1
a :: Any
function new(a::Any)
@mk begin
a = a
end
end
function identity_a(self)
self
end
end
@oodef struct Base2 <: Base1
b :: Any
function new(a::Any, b::Any)
@mk begin
@base(Base1) = Base1(a)
b = b
end
end
function identity_b(self)
self
end
end
@oodef struct Base3 <: Base2
c :: Any
function new(a::Any, b::Any, c::Any)
@mk begin
@base(Base2) = Base2(a, b)
c = c
end
end
function identity_c(self)
self
end
end
@oodef struct Base4 <: Base3
d :: Any
function new(a::Any, b::Any, c::Any, d::Any)
@mk begin
@base(Base3) = Base3(a, b, c)
d = d
end
end
function identity_d(self)
self
end
end
@oodef struct Base5 <: Base4
e :: Any
function new(a::Any, b::Any, c::Any, d::Any, e::Any)
@mk begin
@base(Base4) = Base4(a, b, c, d)
e = e
end
end
function identity_e(self)
self
end
end
struct_o = Base5(1, 2, 3, 4, 5)
@btime struct_o.a
@btime struct_o.b
@btime struct_o.c
@btime struct_o.d
@btime struct_o.e
@btime struct_o.identity_a()
@btime struct_o.identity_b()
@btime struct_o.identity_c()
@btime struct_o.identity_d()
@btime struct_o.identity_e()
# julia> @btime struct_o.a
# 18.255 ns (0 allocations: 0 bytes)
# 1
# julia> @btime struct_o.b
# 18.136 ns (0 allocations: 0 bytes)
# 2
# julia> @btime struct_o.c
# 17.452 ns (0 allocations: 0 bytes)
# 3
# julia> @btime struct_o.d
# 17.836 ns (0 allocations: 0 bytes)
# 4
# julia> @btime struct_o.e
# 17.836 ns (0 allocations: 0 bytes)
# 5
# julia> @btime struct_o.identity_a()
# 35.146 ns (2 allocations: 96 bytes)
# Base5(5, Base4(4, Base3(3, Base2(2, Base1(1)))))
# julia> @btime struct_o.identity_b()
# 34.240 ns (2 allocations: 96 bytes)
# Base5(5, Base4(4, Base3(3, Base2(2, Base1(1)))))
# julia> @btime struct_o.identity_c()
# 35.484 ns (2 allocations: 96 bytes)
# Base5(5, Base4(4, Base3(3, Base2(2, Base1(1)))))
# julia> @btime struct_o.identity_d()
# 33.903 ns (2 allocations: 96 bytes)
# Base5(5, Base4(4, Base3(3, Base2(2, Base1(1)))))
# julia> @btime struct_o.identity_e()
# 33.736 ns (2 allocations: 96 bytes)
# Base5(5, Base4(4, Base3(3, Base2(2, Base1(1)))))
# julia> @btime (x -> x.a)(class_o)
# 11.900 ns (0 allocations: 0 bytes)
# 1
```
```python
class Base1:
def __init__(self, a):
self.a = a
def identity_a(self):
return self
class Base2(Base1):
def __init__(self, a, b):
super().__init__(a)
self.b = b
def identity_b(self):
return self
class Base3(Base2):
def __init__(self, a, b, c):
super().__init__(a, b)
self.c = c
def identity_c(self):
return self
class Base4(Base3):
def __init__(self, a, b, c, d):
super().__init__(a, b, c)
self.d = d
def identity_d(self):
return self
class Base5(Base4):
def __init__(self, a, b, c, d, e):
super().__init__(a, b, c, d)
self.e = e
def identity_e(self):
return self
o = Base5(1, 2, 3, 4, 5)
%timeit o.a
%timeit o.b
%timeit o.c
%timeit o.d
%timeit o.e
%timeit o.identity_a()
%timeit o.identity_b()
%timeit o.identity_c()
%timeit o.identity_d()
%timeit o.identity_e()
25.6 ns ± 0.114 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
27.1 ns ± 0.176 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
26.2 ns ± 0.0642 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
26.6 ns ± 0.142 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
31.2 ns ± 0.137 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
62.6 ns ± 0.578 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
59.5 ns ± 0.37 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
63.2 ns ± 1.01 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
63.7 ns ± 0.2 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
62.9 ns ± 0.568 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
```
### sum of concretely typed arrays
```julia
bases = [Base5(1, 2, 3, 4, 5) for i in 1:10000]
function sum_all(bases::Vector{<:@like(Base1)})
s = 0
for each in bases
s += each.a # :: Int
end
s
end
@btime sum_all(bases)
# class:
# field is Int
# julia> @btime sum_all(bases)
# 19.900 μs (1 allocation: 16 bytes)
# field is Any, annotate s :: Int
# julia> @btime sum_all(bases)
# 25.900 μs (1 allocation: 16 bytes)
# field is Any, no annotations
# julia> @btime sum_all(bases)
# 152.800 μs (9489 allocations: 148.27 KiB)
# struct
# julia> @btime sum_all(bases)
# 140.900 μs (9489 allocations: 148.27 KiB)
#
# field is Any, Int annotations
# julia> @btime sum_all(bases)
# 6.640 μs (1 allocation: 16 bytes)
# 10000
# struct Int field
# julia> @btime sum_all(bases)
# 3.237 μs (1 allocation: 16 bytes)
# 10000
```
```python
bases = [Base5(1, 2, 3, 4, 5) for i in range(10000)]
def sum_all(bases):
s = 0
for each in bases:
s += each.a
return s
%timeit sum_all(bases)
# ...: %timeit sum_all(bases)
# 410 µs ± 3.21 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
``` | ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | docs | 8324 | # ObjectOriented.jl Cheat Sheet
ObjectOriented.jl为Julia提供面向对象编程的功能,支持多继承、点操作符取成员、Python风格的properties以及接口编程。
## 1. 类型定义
定义不可变的OO结构体。
```julia
@oodef struct ImmutableData
x :: Int
y :: Int
function new(x::Int, y::Int)
@mk begin
x = x
y = y
end
end
end
d = ImmutableData(1, 2)
x = d.x
```
其中,`new`是构造器函数。构造器和方法都可以重载。
`@mk`语句块产生当前类型的实例,在随后的语句块中,形如`a = b`是设置字段,形如`BaseClass(arg1, arg2)`是基类初始化。
定义可变的OO结构体(class)。
```julia
@oodef mutable struct MutableData
x :: Int
y :: Int
function new(x::Int, y::Int)
@mk begin
x = x
y = y
end
end
end
mt = MutableData(1, 2)
mt.x += 1
```
## 默认字段
ObjectOriented.jl支持默认字段。
在为类型定义一个字段时,如果为这个字段指定默认值,那么`@mk`宏允许缺省该字段的初始化。注意,如果不定义`new`函数并使用`@mk`宏,默认字段将无效。
```julia
function get_default_field2()
println("default field2!")
return 30
end
@oodef struct MyType
field1 :: DataType = MyType
field2 :: Int = get_default_field2()
function new()
return @mk
end
function new(field2::Integer)
return @mk field2 = field2
end
end
julia> MyType()
default field2!
MyType(MyType, 30)
julia> MyType(50)
MyType(MyType, 50)
```
关于默认字段的注意点:
1. 默认字段没有性能开销。
2. 在`@mk`块显式指定字段初始化时,默认字段的求值表达式不会被执行。
3. 与`Base.@kwdef`不同,默认字段的求值表达式无法访问其他字段。
## 2. 继承
```julia
@oodef mutable struct Animal
name :: String
function new(theName::String)
@mk begin
name = theName
end
end
function move(self, distanceInMeters::Number = 0)
println("$(self.name) moved $(distanceInMeters)")
end
end
@oodef mutable struct Snake <: Animal
function new(theName::String)
@mk begin
Animal(theName) # 初始化基类
end
end
function snake_check(self)
println("Calling a snake specific method!")
end
end
sam = Snake("Sammy the Python")
sam.move()
# Sammy the Python moved 0
sam.snake_check()
# Calling a snake specific method!
```
此外,以下需要非常注意!
```julia
Snake <: Animal # false
Snake("xxx") isa Animal # false
```
记住,Julia原生类型系统并不理解两个class的子类型关系!详见[基于接口的多态抽象](@ref interface_polymorphism)。
你应该使用下列方法测试继承关系:
```julia
issubclass(Snake, Animal) # true
isinstance(Snake("xxx"), Animal) # true
Snake("xxx") isa @like(Animal) # true
```
## 4. Python-style properties
```julia
@oodef mutable struct Square
side :: Float64
@property(area) do
get = self -> self.side ^ 2
set = (self, value::Number) -> self.side = convert(Float64, sqrt(value))
end
end
square = Square()
square.side = 10
# call getter
square.area # 100.0
# call setter
square.area = 25
square.side # 5.0
```
## 5. 接口
接口类型,是大小为0(`sizeof(t) == 0`)的**不可变**OO类型。
接口类型的构造器是自动生成的,但也可以手动定义。
下面的`HasLength`是接口类型。
```julia
@oodef struct HasLength
@property(len) do
get #= 抽象property: len =#
end
end
@oodef struct Fillable
function fill! end # 空函数表示抽象方法
# 定义一个抽象的setter, 可以为全体元素赋值
@property(allvalue) do
set
end
end
@oodef struct MyVector{T} <: {HasLength, Fillable} # 多继承
xs :: Vector{T}
function new(xs::Vector{T})
@mk begin
xs = xs
end
end
end
check_abstract(MyVector)
# Dict{PropertyName, ObjectOriented.CompileTime.PropertyDefinition} with 3 entries:
# fill! (getter) => PropertyDefinition(:fill!, missing, :((Main).Fillable), MethodKind)
# len (getter) => PropertyDefinition(:len, missing, :((Main).HasLength), GetterPropertyKind)
# allvalue (setter) => PropertyDefinition(:allvalue, missing, :((Main).Fillable), SetterPropertyKind)
```
`check_abstract(MyVector)`不为空,表示`MyVector`是抽象类型,否则需要实现相应属性或方法`len`, `fill!`和`allvalue`:
```julia
@oodef struct MyVector{T} <: {HasLength, Fillable} # 多继承
# 旧代码
xs :: Vector{T}
function new(xs::Vector{T})
@mk begin
xs = xs
end
end
# 新增代码
@property(len) do
get = self -> length(self.xs)
end
@property(allvalue) do
set = (self, value::T) -> fill!(self.xs, value)
end
function fill!(self, v::T)
self.allvalue = v
end
end
vec = MyVector([1, 2, 3])
vec.allvalue = 4
vec
# MyVector{Int64}([4, 4, 4], HasLength(), Fillable())
vec.len
# 3
vec.fill!(10)
vec
# MyVector{Int64}([10, 10, 10], HasLength(), Fillable())
```
此外,接口最重要的目的是基于接口的多态抽象。见下文[基于接口的多态抽象](@ref interface_polymorphism_cn)。
## 6. 多继承
MRO(方法解析顺序)使用Python C3算法,所以多继承行为与Python基本一样。主要差异是不严格要求mixin多继承的顺序。
```julia
@oodef struct A
function calla(self) "A" end
function call(self) "A" end
end
@oodef struct B <: A
function callb(self) "B" end
function call(self) "B" end
end
@oodef mutable struct C <: A
function callc(self) "C" end
function call(self) "C" end
end
@oodef struct D <: {A, C, B}
function new()
@mk begin
A() # 可省略,因为A是接口类型
B() # 可省略,因为B是接口类型
C() # 不可省略,因为C是可变类型
# 基类初始化可写成一行: A(), B(), C()
end
end
end
d = D()
d.calla() # A
d.callb() # B
d.callc() # C
d.call() # C
[x[1] for x in ootype_mro(typeof(d))]
# 4-element Vector{DataType}:
# D
# C
# B
# A
```
## 7. [基于接口的多态抽象](@id interface_polymorphism)
下面例子给出一个容易犯错的情况:
```julia
@oodef struct A end
@oodef struct B <: A end
myapi(x :: A) = println("do something!")
myapi(A())
# do something!
myapi(B())
# ERROR: MethodError: no method matching myapi(::B)
```
记住:Julia原生类型系统并不理解两个class的子类型关系!
如果希望Julia函数`myapi`的参数只接受A或A的子类型,应该这样实现:
```julia
myapi(x :: @like(A)) = println("do something!")
myapi(B())
# do something!
myapi([])
# ERROR: MethodError: no method matching myapi(::Vector{Any})
```
## 8. 一个机器学习的OOP实例
在下面这份代码里,我们实现一个使用最小二乘法训练的机器学习模型,并让其支持Julia中ScikitLearn的接口 (ScikitLearnBase.jl)。通过下面代码,用户可以像使用一般ScikitLearn.jl的模型一样来调用这个模型,更可以在MLJ机器学习框架中使用这个模型,而不必关心该模型由面向对象还是多重分派实现。
```julia
using ObjectOriented
@oodef struct AbstractMLModel{X, Y}
function fit! end
function predict end
end
using LsqFit
@oodef mutable struct LsqModel{M<:Function} <: AbstractMLModel{Vector{Float64},Vector{Float64}}
model::M # 一个函数,代表模型的公式
param::Vector{Float64}
function new(m::M, init_param::Vector{Float64})
@mk begin
model = m
param = init_param
end
end
function fit!(self, X::Vector{Float64}, y::Vector{Float64})
fit = curve_fit(self.model, X, y, self.param)
self.param = fit.param
self
end
function predict(self, x::Float64)
self.predict([x])
end
function predict(self, X::Vector{Float64})
return self.model(X, self.param)
end
end
# 例子来自 https://github.com/JuliaNLSolvers/LsqFit.jl
@. model(x, p) = p[1] * exp(-x * p[2])
clf = LsqModel(model, [0.5, 0.5])
ptrue = [1.0, 2.0]
xdata = collect(range(0, stop = 10, length = 20));
ydata = collect(model(xdata, ptrue) + 0.01 * randn(length(xdata)));
clf.fit!(xdata, ydata) # 训练模型
clf.predict(xdata) # 预测模型
clf.param # 查看模型参数
# ScikitLearnBase提供了fit!和predict两个接口函数。
# 我们将ObjectOriented.jl的接口(@like(...))和Julia接口对接。
using ScikitLearnBase
ScikitLearnBase.is_classifier(::@like(AbstractMLModel)) = true
ScikitLearnBase.fit!(clf::@like(AbstractMLModel{X, Y}), x::X, y::Y) where {X, Y} = clf.fit!(x, y)
ScikitLearnBase.predict(clf::@like(AbstractMLModel{X}), x::X) where X = clf.predict(x)
ScikitLearnBase.fit!(clf, xdata, ydata)
ScikitLearnBase.predict(clf, xdata)
```
## 9. 性能问题
尽管ObjectOriented.jl生成的代码本身不引入开销,但由于递归调用点操作符运算 (`Base.getproperty(...)`) 的类型推断问题 (例如[这个例子](https://discourse.julialang.org/t/type-inference-problem-with-getproperty/54585/2?u=thautwarm)),尽管大多数时候ObjectOriented.jl编译出的机器码非常高效,但返回类型却忽然变成`Any`或某种`Union`类型。
这可能带来性能问题。出现该问题的情况是有限的,问题场合如下:
1. 使用Python风格的property
2. 在method里访问另一个成员,该成员再次递归调用点操作符
解决方案也很简单,使用`@typed_access`标注可能出现性能问题的代码即可。
```julia
@typed_access my_instance.method()
@typed_access my_instance.property
```
注意:上述代码中请保证`my_instance`类型已知。如果`@typed_access`标注的代码存在动态类型或类型不稳定,可能导致更严重的性能问题。
| ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | docs | 11100 | # ObjectOriented.jl cheat sheet
[中文文档](./cheat-sheet-cn.md)
ObjectOriented.jl has provided relatively complete object-oriented programming support for Julia. It supports multiple inheritances, dot-operator access to members, Python-style properties and interface programming.
## 1. Type definition
Define immutable OO structs:
```julia
@oodef struct ImmutableData
x :: Int
y :: Int
function new(x::Int, y::Int)
@mk begin
x = x
y = y
end
end
end
d = ImmutableData(1, 2)
x = d.x
```
`new`is the constructor. Constructs and methods can be overloaded.
A `@mk` block creates an instance for the current struct/class. Inside the block, an assignment statement `a = b` initializes the field `a` with the expression `b`; a call statement like `BaseType(arg1, arg2)` calls the constructor of the base class/struct `BaseType`.
Defining OO classes (mutable structs):
```julia
@oodef mutable struct MutableData
x :: Int
y :: Int
function new(x::Int, y::Int)
@mk begin
x = x
y = y
end
end
end
mt = MutableData(1, 2)
mt.x += 1
```
## Default field values
Using this feature, when defining a field for classes/structs, if a default value is provided, then the initialization for this field can be missing in the `@mk` block.
```julia
function get_default_field2()
println("default field2!")
return 30
end
@oodef struct MyType
field1 :: DataType = MyType
field2 :: Int = get_default_field2()
function new()
return @mk
end
function new(field2::Integer)
return @mk field2 = field2
end
end
julia> MyType()
default field2!
MyType(MyType, 30)
julia> MyType(50)
MyType(MyType, 50)
```
Some points of the default field values:
1. there is no performance overhead in using default field values.
2. when a field has been explicitly initialized in the `@mk` block, the expression of the default field value won't be evaluated.
3. unlike `Base.@kwdef`, default field values cannot reference each other.
## 2. Inheritance
```julia
@oodef mutable struct Animal
name :: String
function new(theName::String)
@mk begin
name = theName
end
end
function move(self, distanceInMeters::Number = 0)
println("$(self.name) moved $(distanceInMeters)")
end
end
@oodef mutable struct Snake <: Animal
function new(theName::String)
@mk begin
Animal(theName) # 初始化基类
end
end
function snake_check(self)
println("Calling a snake specific method!")
end
end
sam = Snake("Sammy the Python")
sam.move()
# Sammy the Python moved 0
sam.snake_check()
# Calling a snake specific method!
```
**CAUTION**:
```julia
Snake <: Animal # false
Snake("xxx") isa Animal # false
```
Note that Julia's native type system does not understand the subtyping relationship between two oo classes! See [Interface-based polymorphism](@ref interface_polymorphism_cn) for more details.
Use the following methods to test inheritance relationship:
```julia
issubclass(Snake, Animal) # true
isinstance(Snake("xxx"), Animal) # true
Snake("xxx") isa @like(Animal) # true
```
## 4. Python-style properties
```julia
@oodef mutable struct Square
side :: Float64
@property(area) do
get = self -> self.side ^ 2
set = (self, value::Number) -> self.side = convert(Float64, sqrt(value))
end
end
square = Square()
square.side = 10
# call getter
square.area # 100.0
# call setter
square.area = 25
square.side # 5.0
```
## 5. Interfaces
An interface in ObjectOriented.jl means an OO struct type which satisfies `sizeof(interface) == 0`.
Interface constructors are auto-generated, but custom constructors are allowed.
The following `HasLength` is an interface.
```julia
@oodef struct HasLength
@property(len) do
get # abstract getter property
end
end
@oodef struct Fillable
function fill! end # an empty function means abstract method
# define an abstract property to set all values
@property(allvalue) do
set
end
end
@oodef struct MyVector{T} <: {HasLength, Fillable} # multiple inheritance
xs :: Vector{T}
function new(xs::Vector{T})
@mk begin
xs = xs
end
end
end
check_abstract(MyVector)
# Dict{PropertyName, ObjectOriented.CompileTime.PropertyDefinition} with 3 entries:
# fill! (getter) => PropertyDefinition(:fill!, missing, :((Main).Fillable), MethodKind)
# len (getter) => PropertyDefinition(:len, missing, :((Main).HasLength), GetterPropertyKind)
# allvalue (setter) => PropertyDefinition(:allvalue, missing, :((Main).Fillable), SetterPropertyKind)
```
`check_abstract(MyVector)` is not empty. This means `MyVector` is abstract (more accurately, shall not be instantiated). Otherwise, implementing `len`, `fill!`和`allvalue` is required.
```julia
@oodef struct MyVector{T} <: {HasLength, Fillable} # multiple inheritance
xs :: Vector{T}
function new(xs::Vector{T})
@mk begin
xs = xs
end
end
# add the following definitions to
# implement `HasLength` and `Fillable`
@property(len) do
get = self -> length(self.xs)
end
@property(allvalue) do
set = (self, value::T) -> fill!(self.xs, value)
end
function fill!(self, v::T)
self.allvalue = v
end
end
vec = MyVector([1, 2, 3])
vec.allvalue = 4
vec
# MyVector{Int64}([4, 4, 4], HasLength(), Fillable())
vec.len
# 3
vec.fill!(10)
vec
# MyVector{Int64}([10, 10, 10], HasLength(), Fillable())
```
In addition, the most important reason for interfaces is the interface-based polymorphism. See [Interface-based polymorphism](@ref interface_polymorphism_cn).
## 6. Multiple inheritance
MRO (Method resolution order) is using Python's C3 algorithm, so the behaviour is mostly identical to Python. The major difference is that the order of inheriting mixin classes is less strict.
```julia
@oodef struct A
function calla(self) "A" end
function call(self) "A" end
end
@oodef struct B <: A
function callb(self) "B" end
function call(self) "B" end
end
@oodef mutable struct C <: A
function callc(self) "C" end
function call(self) "C" end
end
@oodef struct D <: {A, C, B}
function new()
@mk begin
A() # can omit. A is interface.
B() # can omit. B is interface.
C() # cannot omit. C is class (mutable struct).
# you can also write them in one line:
# A(), B(), C()
end
end
end
d = D()
d.calla() # A
d.callb() # B
d.callc() # C
d.call() # C
[x[1] for x in ootype_mro(typeof(d))]
# 4-element Vector{DataType}:
# D
# C
# B
# A
```
## 7. [Interface-based polymorphism](@id interface_polymorphism_cn)
The following example shows an inproper use of the base class (`A`):
```julia
@oodef struct A end
@oodef struct B <: A end
myapi(x :: A) = println("do something!")
myapi(A())
# do something!
myapi(B())
# ERROR: MethodError: no method matching myapi(::B)
```
Remember that Julia's type system does not understand the subtyping relationship between two OO classes!
If you expect `myapi` to accept `A` or `A`'s subtypes, you should do this:
```julia
myapi(x :: @like(A)) = println("do something!")
myapi(B())
# do something!
myapi([])
# ERROR: MethodError: no method matching myapi(::Vector{Any})
```
## 8. A machine learning example
In the following code, we implement a machine learning model trained using least squares and make it support the ScikitLearn interface (ScikitLearnBase.jl) in Julia. With the following code, users can call this model as if it were a normal ScikitLearn.jl model, and can use this model in the MLJ machine learning framework, regardless of whether the model is implemented by object-oriented features or multiple dispatch.
```julia
using ObjectOriented
@oodef struct AbstractMLModel{X, Y}
function fit! end
function predict end
end
using LsqFit
@oodef mutable struct LsqModel{M<:Function} <: AbstractMLModel{Vector{Float64},Vector{Float64}}
model :: M # a function to represent the model's formula
param :: Vector{Float64}
function new(m::M, init_param::Vector{Float64})
@mk begin
model = m
param = init_param
end
end
function fit!(self, X::Vector{Float64}, y::Vector{Float64})
fit = curve_fit(self.model, X, y, self.param)
self.param = fit.param
self
end
function predict(self, x::Float64)
self.predict([x])
end
function predict(self, X::Vector{Float64})
return self.model(X, self.param)
end
end
# the example comes from https://github.com/JuliaNLSolvers/LsqFit.jl
@. model(x, p) = p[1] * exp(-x * p[2])
clf = LsqModel(model, [0.5, 0.5])
ptrue = [1.0, 2.0]
xdata = collect(range(0, stop = 10, length = 20));
ydata = collect(model(xdata, ptrue) + 0.01 * randn(length(xdata)));
clf.fit!(xdata, ydata) # train
clf.predict(xdata) # predict
clf.param # inspect model parameters
# ScikitLearnBase provides us two interface functions 'fit!' and 'predict'.
# Now, we connect the ObjectOriented interface with Julia's idiomatic interface
# via '@like(...)'.
using ScikitLearnBase
ScikitLearnBase.is_classifier(::@like(AbstractMLModel)) = true
ScikitLearnBase.fit!(clf::@like(AbstractMLModel{X, Y}), x::X, y::Y) where {X, Y} = clf.fit!(x, y)
ScikitLearnBase.predict(clf::@like(AbstractMLModel{X}), x::X) where X = clf.predict(x)
ScikitLearnBase.fit!(clf, xdata, ydata)
ScikitLearnBase.predict(clf, xdata)
```
## 9. Performance issues
Code generated by ObjectOriented.jl does not introduce any overhead, but recursions of dot operations (`Base.getproperty(...)`) do have some issues concerning type inference (e.g., [this example](https://discourse.julialang.org/t/type-inference-problem-with-getproperty/54585/2?u=thautwarm)). Although in most cases, the code produced by ObjectOriented.jl is very efficient, the return type might suddenly becomes `Any` or some `Union` type.
This might cause performance issues, but only in enumerable cases that have been well understood:
1. Using Python-style properties
2. Visiting another member in methods, the member will recursively perform dot operations (`Base.getproperty`).
The solution is easy: use `@typed_access` to wrap a block of code which might suffer from above issues.
```julia
@typed_access my_instance.method()
@typed_access my_instance.property
```
**CAUTION**: please make sure that the type of the above `my_instance` is inferred when using `@typed_access`. Using `@typed_acccess` in dynamic code will damage your performance.
| ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | docs | 17647 | # Translating OOP into Idiomatic Julia
Multiple dispatch used by Julia gives a novel solution to the [expression problem](https://en.wikipedia.org/wiki/Expression_problem), while the so-called object-oriented programming has a different answer that is much more popular.
Although we'd admit that there are some essential differences between OOP and multiple dispatch under the hood, they are not that different. In fact, Julia's multiple dispatch definitely steps further and can fully express OOP, although certain translation (very rare) is so far never efficient (I mean, fast in execution time).
This article aims at telling people how to translate serious OOP code into idiomatic Julia. The translation is divided into the following sections:
- Julia representation of constructors
- Julia representation of methods
- Julia representation of inheritance
- Julia representation of interfaces
## Julia representation of constructors
In Python, we might simply write a class as follow.
```python
class MyClass:
def __init__(self, a):
self.a = a
self.b = a + a
MyClass(1)
```
Python encapsulates instantiation and the instance initialization into a single call `MyClass(1)`, but if we dig a little deeper, we will know that the construction of a Python object works like this:
```python
inst = MyClass.__new__(MyClass, 1)
if isinstance(inst, MyClass):
MyClass.__init__(inst, 1)
return inst
```
We have found a fresh Julia user who comes from the OOP world can be anxious about the constructor. In Julia, a struct provides a default constructor which takes arguments in order of the class fields. This asks Julia users to create an instance (like `__new__()`) manually, but OOP guys would rather only create instance initialization function (like `__init__()`) themselves.
```julia
struct MyClass
a
b
end
b = a + a
MyClass(a, b)
```
However, achieving what OOP guys need is convenient and even mechanical. "Convenient" means Julia can do the same thing in a way less verbose than others, and "mechanical" means this is a general solution to the problem, and the problem is well-studied in the used mechanism.
We post the solution as follow. For readability, the code is simplified and the functionality is incomplete in corner cases.
The solution has 2 parts, the first one is the library code which is not very readable, but it is not responsible for users to implement; the second part is the user code, it is readable and concise, exactly like what in Python.
### [Library code](@id lib_constructor)
```julia
## `new` and `init` can be overloaded for different classes
@generated function default_constructor(::Type{Cls}) where Cls
Expr(:new, Cls)
end
function new(cls, args...; kwargs...)
# call default constructor without field initialization
return default_constructor(cls)
end
function init(self, args...; kwargs...)
nothing
end
abstract type OO end
function (::Type{Cls})(args...; kwargs...) where Cls <: OO
inst = new(Cls, args...; kwargs...)
if inst isa Cls
init(inst, args...; kwargs...)
end
return inst
end
```
### User code
```julia
mutable struct MyClass <: OO
a
b
end
function init(self::MyClass, a)
self.a = a
self.b = a + a
end
MyClass(1)
```
If we mark the functions `new`, `init` or `(::Type{Cls})` with `@inline`, the code becomes as efficient as in C/C++.
However, Julia does not adopt this solution. There are many reasons, but the key one is that Julia has native support for immutability. Mutable classes can be created without initializing fields but modified later, while immutable structs never support this.
```julia
struct Data
a::Int
end
data = Data(1)
data.a = 2
ERROR: setfield!: immutable struct of type Data cannot be changed
```
The old and popular approach to object construction, like Python's `__init__`, works in the old world, but using it for a language providing new features (like immutability) is not deemed a good idea. The old solution can be provided as a library, but it discourages the use of the good features such as immutability.
ObjectOriented.jl provides the `new` function and `@mk` macro to address above issue. Using `new` and `@mk`, your code is slightly more concise than in Python, and works for both mutable structs and immutable structs.
## Julia representation of methods
In Python, we can define methods for a class so that its instance can call the method with `instance.method()`.
```python
class MyClass2:
def __init__(self, x):
self.x = x
def double(self):
return self.x * 2
MyClass2(1).double() # => 2
```
However, in Julia, field accessing is using dot operators, while method accessing is not related to instances or even types. Methods are defined juxtaposing the structs.
```julia
struct MyClass2
a::Int
end
double(self) = self.a * 2
double(MyClass2(1)) # => 2
```
The translation of dot methods is maybe the most direct translation in this article. This is because all OOP languages do the same thing as Julia under the hood.
If we DO want to support dot methods in Julia, just set up the same mechanism used by Python or any other OOP language that support bound methods (examples: C\#, Python; counter examples: Java, JavaScript).
```julia
struct BoundMethod{Func, Self}
func::Func
self::Self
end
function (boundmethod::BoundMethod{Func, Self})(args...; kwargs...) where {Func, Self}
boundmethod.func(boundmethod.self, args...; kwargs...)
end
Base.getproperty(self::MyClass2, name::Symbol) =
if name === :double
BoundMethod(double, self)
else
Base.getfield(self, name)
end
MyClass2(1).double() # 2
```
Supporting dot methods in Julia is NOT RECOMMANDED due to the poor IDE support and other conventions like "dot operators access fields".
Besides, strongly coupling methods with classes is found not a general solution. A real-world counter example is operator overloading, where Julia's multiple dispatch is the-state-of-the-art solution to the problem. The infrastructure part of deep-learning frameworks requires facilities similar to multiple dispatch, where an evidence can be found from [this discussion](https://news.ycombinator.com/item?id=29354474).
You probably don't know an interesting fact: dot methods are not really a component of OOP, it's just a historical idiom of many OOP languages.
From the perspective of programming languages, dot methods are so-called runtime single dispatch, and I've recently found that the popularity of runtime single dispatch has led to a general inability of identifying problems or requirements that are essentially multiple-dispatched. Such fact can be usually observed from the user API functions made by programmers from classic OOP languages.
## Julia representation of inheritance
Many smart programmers from the OOP world have already found the technique described above, but it seems that many of them give up in handling inheritance.
However, a general solution to inheritance in Julia is still easy until we need syntactic sugar support.
In Python, a class can inherit from other classes, and the child class can access the parents' fields and methods, or override some of the methods. We give the following example:
```python
class A:
def __init__(self):
self.x = 1
class B:
def __init__(self, *args):
self.args = args
def print_args(self):
print(self.args)
class AB(A, B):
def __init__(self, *args):
A.__init__(self)
B.__init__(self, *args)
ab = AB(1, 2, 3)
ab.x # 1
ab.print_args() # (1, 2, 3)
```
To implement inheritance, we need basic understanding of what it is.
Inheritance in different OOP languages have different underlying implementations. Many statically-typed languages such as C++/Java/C\# implement inheritance with composition, where a class instance implicitly holds base class instances (`sizeof` can be 0) as fields. However, dynamic languages such as Python provide inheritance similar to "mixin", where base classes are (usually) only related to reusing methods, and the instance is created only by the derived class's `__new__` so that instances (usually) do not hold the base class instances.
The major difference between these two implementations in the userland, other than performance, is the capability to have more than one same-name fields in different base classes or the derived class. Composition-based inheritance allows more than one same-name fields from different classes, but mixin-like inheritance implies the same name always references the the same member.
Efficient encoding of inheritance in Julia needs composition. This is because the mixin-like inheritance shares the same data (and its memory layout) for all base classes, then the instance have to be something like a dictionary, which is not preferred.
The core idea of composition-based inheritance is very simple. Suppose our class inherits a base class `BaseCls`, which has a field `base_field`. As the base class instance is stored in a field of the derived class instance, accessing `base_field` is no more than firstly access the base class instance and use it to access the `base_field` normally.
Hence, the aforementioned Python code can be translated into:
```julia
mutable struct A <: OO
x::Int
end
function init(self::A)
self.x = 1
end
mutable struct B <: OO
args
end
function init(self::B, args...)
self.args = args
end
print_args(b) = println(b.args)
mutable struct AB <: OO
_base_a::A
_base_b::B
end
function init(self::AB, args...)
self._base_a = A() # A.__init__(self)
self._base_b = B(args...) # B.__init__(self, args...)
end
Base.getproperty(self::AB, name::Symbol) =
if name === :x
self._base_a.x
elseif name === :args
self._base_b.args
else
Base.getfield(self, name)
end
ab = AB(1, 2, 3)
ab.x # 1
print_args(ab) # (1, 2, 3)
```
Note that methods applicable to base classes (e.g., `print_args`) also work for derived classes.
However, the issues is that users have to manually create `Base.getproperty`, which is definitely not acceptable. Fortunately, the above code does suggest a general and efficient solution: when defining a class, we statically resolve which field name is referencing which field from which class, and finally generate a `Base.getproperty` (and `Base.setproperty!`).
Julia allows this with runtime code generation (staging), providing us a zero-cost implementation.
Think that we use a special struct `Inherit{T}` to distinguish normal fields from the fields that store base class instances.
```julia
struct Inherit{Cls}
base_inst::Cls
end
mutable struct BaseCls <: OO
base_field::Int
end
mutable struct DerivedCls <: OO
_base::Inherit{BaseCls}
end
```
In the following subsection, given `x::DerivedCls`, we make `x.base_field` retrieves `x._base.base_inst.base_field`.
### [Library code](@ref lib_inheritance)
There is no need to fully understand the details, and the code is provided for copy-paste.
```julia
struct Inherit{Cls}
base_inst::Cls
end
Base.@pure function _pathed_fieldnames(@nospecialize(t))
t <: OO || error("Not an OO type")
fts = fieldtypes(t)
fns = fieldnames(t)
pathed_names = Tuple{Tuple, Symbol}[]
for i in eachindex(fns, fts)
ft = fts[i]
if ft <: Inherit && ft isa DataType # concrete
base_t = ft.parameters[1]
for (path, n) in _pathed_fieldnames(base_t)
if !startswith(string(n), "_")
push!(
pathed_names,
((i, 1, path...), n))
end
end
else
# make '_xxx' private
push!(pathed_names, ((i, ), fns[i]))
end
end
Tuple(pathed_names)
end
Base.@pure function _fieldnames(@nospecialize(t))
Tuple(unique!([x[2] for x in _pathed_fieldnames(t)]))
end
@inline @generated function unroll_select(f, orelse, ::Val{tuple}, x, args...) where tuple
expr = Expr(:block)
foldr(tuple, init=:(return orelse(x))) do l, r
Expr(:if,
:(x === $(QuoteNode(l))),
:(return f($(Val(l)), args...)), r)
end
end
@inline @generated function _getproperty(self::T, ::Val{fieldname}) where {T <: OO, fieldname}
pathed_names = _pathed_fieldnames(T)
for (path, name) in pathed_names
if name === fieldname
return foldl(path, init=:self) do l, r
:($getfield($l, $r))
end
end
end
return :($error("type " * string(T) * " has no field " * string(fieldname)))
end
function _do_with_field_found(typed_name::Val, self)
_getproperty(self, typed_name)
end
@inline function Base.getproperty(self::T, name::Symbol) where T <: OO
function _do_with_field_unfound(name::Symbol)
error("type $(string(T)) has no field $(string(unknown_name))")
end
unroll_select(
_do_with_field_found,
_do_with_field_unfound,
Val(_fieldnames(T)),
name,
self,
)
end
```
### User code
Using the library code above, we can avoid manual implementation of `Base.getproperty`.
```julia
mutable struct A <: OO
x::Int
end
function init(self::A)
self.x = 1
end
mutable struct B <: OO
args
end
function init(self::B, args...)
self.args = args
end
print_args(b) = println(b.args)
mutable struct AB <: OO
_base_a::Inherit{A}
_base_b::Inherit{B}
end
function init(self::AB, args...)
self._base_a = Inherit(A()) # A.__init__(self)
self._base_b = Inherit(B(args...)) # B.__init__(self, args...)
end
ab = AB(1, 2, 3)
ab.x # 1
print_args(ab) # (1, 2, 3)
```
## Julia representation of interfaces
OOP uses interfaces to specify valid behaviours of an open family of classes. It helps the following programming requirements:
1. hiding implementation details about concrete classes
2. reusing the functions for multiple classes
3. specifying constraints of input and output
Recently, many OOP languages get started supporting default method implementations for interfaces, so interfaces are now not that different from multi-inheritable, zero-field abstract classes.
Interfaces in Python are not very standard, but they do work under the help of Python's mature IDEs.
Here is an example of using interfaces in Python:
```python
class MyInterface:
def abs_func(self, arg):
raise NotImplementedError
def mixin_func(self, arg):
return "mixin " + self.abs_func(arg)
class Cls1(MyInterface):
def abs_func(self, arg):
return "cls1"
class Cls2(MyInterface):
def abs_func(self, arg):
return "cls2"
# Use interfaces!
def func_reusing_for_multi_classes(self: MyInterface, arg):
return self.mixin_func(arg)
func_reusing_for_multi_classes(Cls2(), "xxx") # "mixin cls2"
```
Such code can be translated into Julia using `abstract type`:
```julia
abstract type MyInterface end
abs_func(self::MyInterface, arg) =
error("'abs_func' is not defined for $(typeof(self)).")
mixin_func(self::MyInterface, arg) =
"mixin " * abs_func(self, arg)
struct Cls1 <: MyInterface end
struct Cls2 <: MyInterface end
abs_func(self::Cls1, arg) = "cls1"
abs_func(self::Cls2, arg) = "cls2"
# Use interfaces!
func_reusing_for_multi_classes(self::MyInterface, arg) =
mixin_func(self, arg)
func_reusing_for_multi_classes(Cls2(), "xxx") # "mixin cls2"
```
As can be seen above, the code in Julia is slightly more concise than that in Python.
## Conclusions
OOP features, such as constructors, methods, inheritance, and interfaces, have corresponding translation in Julia.
For most of tasks involving OOP, the translation is straightforward and even more concise than the original code.
However, we'd still admit such translation has limitations, while the limitation is never about missing language features.
A notable limitation is about the performance of the runtime polymorphisms. OOP's polymorphism is vtable-based runtime polymorphism, which makes OOP code run pretty fast when handling a container of abstract typed elements. Julia performs worse in this case when you translate OOP code into Julia, to which there is no general solution.
Another important limitation is about IDE support or code introspection. I'm always thinking that people are not really complaining about Julia's lack of OOP support, but the lack of dot operators, I mean, some language facility to organize and search definitions.
For instance, if I know a class is iterable, I'd like to know the available methods (such as `iterate`) or fields by simply typing `something.<TAB>`. So far we have to browse the documentation, otherwise we cannot even find out the methods intentionally defined for some abstract type.
(Possibly off-topic) I don't really want to be a boring guy who talks about how much better a FP language could be, but if possible we could learn about API organization from Erlang or Haskell. If operations for iterables are registered in a module `Iterables`, and `Iterables.<TAB>` shows `iterate` in the completion list for me, I'd be more satisfied.
| ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | docs | 12152 | ```@meta
CurrentModule = ObjectOriented
```
# ObjectOriented.jl
[ObjectOriented.jl](https://github.com/thautwarm/ObjectOriented.jl)为Julia提供一套相对完整的面向对象机制,设计上主要基于CPython的面向对象,对Julia做了适配。
其功能一览如下:
| 功能名 | 支持 | 注释 |
|:----: | :----: | :----: |
| 点操作符 | 是 | |
| 继承 | 是 | 基类、子类不能直接转换 |
| 构造器和实例方法重载 | 是 | 基于多重分派 |
| 多继承 | 是 | MRO基于变种[C3算法](https://en.wikipedia.org/wiki/C3_linearization) |
| Python风格 properties | 是 | |
| 默认字段 | 是 | |
| 泛型 | 是 | |
| 接口 | 是 | 使用空结构体类型做基类 |
| 权限封装(modifiers) | 否 | 同Python |
| 类静态方法 | 否 | 不实现,避免[type piracy](https://docs.julialang.org/en/v1/manual/style-guide/#Avoid-type-piracy) |
| 元类(metaclass) | 否 | 不实现,推荐宏处理 |
快速学习请参考[ObjectOriented.jl Cheat Sheet](./cheat-sheet-cn.md).
必须强调的是,我们非常认可Julia社区关于“不要在Julia中做OOP”的观点。
我们创建这个指南 **[将OOP翻译到地道的Julia]((./how-to-translate-oop-into-julia.md))**,以指导用户如何将OOP代码翻译为更简短、更高效的Julia代码。
我们更是花费精力将ObjectOriented.jl设计成这个样子:OOP的使用能被局限在坚定的OOP使用者的代码里,通过接口编程,这些OOP代码和正常的Julia对接,以避免不合适的代码在外部泛滥。
对于熟悉Julia编程风格的人来说,ObjectOriented.jl提供的接口编程和字段继承仍然可能帮到你。对于这样的专业Julia程序员来说,推荐只在OO类型中定义字段,不推荐定义形如`self.method()`的点操作符方法。
## OO类型定义
ObjectOriented支持定义class和struct,class使用`@oodef mutable struct`开头,struct使用`@oodef struct`开头。
```julia
using ObjectOriented
@oodef struct MyStruct
a :: Int
function new(a::Int)
@mk begin
a = a
end
end
function f(self)
self.a
end
end
@oodef mutable struct MyClass
a :: Int
function new(a::Int)
@mk begin
a = a
end
end
function f(self)
self.a
end
end
```
上述代码中,`function new(...)`用于定义构造器。
构造器的返回值应当使用`@mk begin ... end`构造一个当前类型的实例,其中,`begin`语句块中使用`字段名=值`初始化字段。
缺省构造器的行为:
- 当类型为`class`,所有字段未初始化。
- 当类型为`struct`,且存在字段,使用Julia生成的构造器(`dataclass`)
构造器可以被重载。对于空间占用为0的结构体(单例类型),构造器可以省略。
### 实例方法
实例方法须以`function 方法名(类实例, ...)`开头。类实例变量推荐命名为`self`或`this`。
前面代码里`MyClass`和`MyStruct`都实现了实例方法`f`, 它们的实例,比方说`instance::MyClass`,以`instance.f()`的语法调用该方法。
```julia
@oodef mutable struct MyClass
a :: Int
# ... 省略部分定义
function f(self)
self.a
end
end
```
实例方法支持任意形式的Julia参数,如变长参数,关键字参数,变长关键字参数,默认参数,默认关键字参数。
此外,实例方法支持泛型,且能被重载。
P.S: 如果要标注`self`参数的类型,应该使用`self :: @like(MyClass)`而不是`self :: MyClass`。这是因为实例方法可能被子类调用,而Julia不能支持隐式转换。
P.P.S: 什么是`@like`?对于一个OO类型`Parent`, 任何继承自`Parent`的子类`Child`满足`Child <: @like(Parent)`,其中`<:`是Julia原生的subtyping运算。
### 默认字段
ObjectOriented.jl支持默认字段。
在为类型定义一个字段时,如果为这个字段指定默认值,那么`@mk`宏允许缺省该字段的初始化。注意,如果不定义`new`函数并使用`@mk`宏,默认字段将无效。
```julia
function get_default_field2()
println("default field2!")
return 30
end
@oodef struct MyType
field1 :: DataType = MyType
field2 :: Int = get_default_field2()
function new()
return @mk
end
function new(field2::Integer)
return @mk field2 = field2
end
end
julia> MyType()
default field2!
MyType(MyType, 30)
julia> MyType(50)
MyType(MyType, 50)
```
关于默认字段的注意点:
1. 默认字段没有性能开销。
2. 在`@mk`块显式指定字段初始化时,默认字段的求值表达式不会被执行。
3. 与`Base.@kwdef`不同,默认字段的求值表达式无法访问其他字段。
## Python风格的构造器
以往的OO语言,如Python/C++/Java/C#,没有原生支持的不可变类型,因此构造器的工作一般设计为:
1. 创建一个新对象`self`(或this)
2. 利用构造器参数对`self`进行初始化
Julia也支持这样的构造方式,但只对`mutable struct`有效,且不推荐。写法如下:
```julia
@oodef mutable struct MySubclass <: {MySuperclass1, MySuperclass2}
field1
function new()
self = @mk
# 初始化字段
self.field1 = 1
## 记住需要返回
return self
end
```
## [继承,多继承](@id inheritance_cn)
下面是一个简单的继承例子。
首先我们用`@oodef`定义两个结构体类型:
```julia
@oodef struct A
a :: Int
end
@oodef struct B
b :: Int
end
```
随后,我们用一个类型`C`继承上面两个类型。
```julia
@oodef struct C <: {A, B}
c :: String
function new(a::Int, b::Int, c::String = "somestring")
@mk begin
A(a), B(b)
c = c
end
end
end
c = C(1, 2)
@assert c.a === 1
@assert c.b === 2
```
可以看到,我们使用在`@mk`块中使用`Base1(arg1, arg2), Base2(arg1, arg2)`来设置基类,这和Python中的`基类.__init__(self, args...)`一致。
一个子类可以继承多个基类,当多个基类出现重名属性时,使用C3线性化算法来选取成员。我们使用的C3算法是一个变种,能允许更灵活的mixin抽象。
下面给出一个mixin的例子。mixin是继承的一种常见应用:
我们定义一个基类,多边形`IPolygon`,它的子类可能有正方形、长方形、三角形乃至一般的多边形,但这些子类都共享一个标准的周长求解算法:将所有边的长度相加。
则多边形的基类,可以用如下代码定义:
```julia
using ObjectOriented
const Point = Tuple{Float64, Float64}
function distance(source::Point, destination::Point)
sqrt(
(destination[1] - source[1]) ^ 2 +
(destination[2] - source[2]) ^ 2)
end
@oodef struct IPolygon
# 抽象方法
function get_edges end
# mixin方法
function get_perimeter(self)
s = 0.0
vs = self.get_edges() :: AbstractVector{Point}
if length(vs) <= 1
0.0
end
last = vs[1] :: Point
for i = 2:length(vs)
s += distance(vs[i], last)
last = vs[i]
end
s += distance(vs[end], vs[1])
return s
end
end
```
利用上述基类`IPolygon`,我们可以实现子类,并复用其中的`get_perimeter`方法。
例如,矩形`Rectangle`:
```julia
@oodef struct Rectangle <: IPolygon
width :: Float64
height :: Float64
center :: Point
function new(width::Float64, height::Float64, center::Point)
@mk begin
width = width
height = height
center = center
end
end
function get_edges(self)
x0 = self.center[1]
y0 = self.center[2]
h = self.height / 2
w = self.width / 2
Point[
(x0 - w, y0 - h),
(x0 - w, y0 + h),
(x0 + w, y0 + h),
(x0 + w, y0 - h)
]
end
# 对特殊的子类,可以重写 get_perimeter 获得更快的求周长方法
# function get_perimeter() ... end
end
rect = Rectangle(3.0, 2.0, (5.0, 2.0))
@assert rect.get_perimeter() == 10.0
```
P.S: 由ObjectOriented.jl定义的OO类型,只能继承其他OO类型。
## Python风格的properties
在Java中,getter函数(`get_xxx`)和setter(`set_xxx`)函数用来隐藏实现细节,暴露稳定的API。
对于其中冗余,很多语言如Python提供了一种语法糖,允许抽象`self.xxx`和`self.xxx = value`,这就是property。
ObjectOriented.jl支持property,用以下的方式:
```julia
@oodef struct DemoProp
@property(value) do
get = self -> 100
set = (self, value) -> println("setting $value")
end
end
println(DemoProp().value) # => 100
DemoProp().value = 200 # => setting 200
```
下面是一个更加实际的例子:
```julia
@oodef mutable struct Square
side :: Float64
function new(side::Number)
@mk begin
side = convert(Float64, side)
end
end
@property(area) do
get = self -> self.side ^ 2
set = function (self, value)
self.side = sqrt(value)
end
end
end
square = Square(5) # => Square(5.0)
square.area # => 25.0
square.area = 16 # => 16
square.side # => 4.0
```
可以看到,在设置面积的同时,正方形的边长得到相应改变。
## [高级特性:抽象方法和抽象property](@id advanced_absmeths_and_absprops_cn)
```julia
@oodef struct AbstractSizedContainer{ElementType}
# 定义一个抽象方法
function contains end
# 定义一个抽象getter
@property(length) do
get
end
end
# 打印未实现的方法(包括property)
ObjectOriented.check_abstract(AbstractSizedContainer)
# =>
# Dict{PropertyName, ObjectOriented.CompileTime.PropertyDefinition} with 2 entries:
# contains (getter) => PropertyDefinition(:contains, missing, AbstractSizedContainer, MethodKind)
# length (getter) => PropertyDefinition(:length, missing, AbstractSizedContainer, GetterPropertyKind)
@oodef struct MyNumSet{E <: Number} <: AbstractSizedContainer{E}
inner :: Set{E}
function new(args::E...)
@mk begin
inner = Set{E}(args)
end
end
# if no annotations for 'self',
# annotations and type parameters can be added like:
# 'function contains(self :: @like(MySet{E}), e::E) where E'
function contains(self, e::E)
return e in self.inner
end
@property(length) do
get = self -> length(self.inner)
end
end
my_set = MySet(1, 2, 3)
my_set.length # => 3
my_set.contains(2) # => true
```
## 高级特性:泛型
泛型无处不在,业务中常见于容器。
在[抽象方法](@ref advanced_absmeths_and_absprops_cn)一节,我们介绍了`AbstractSizedContainer`,可以看到它有一个泛型参数`ElementType`。
```julia
@oodef struct AbstractSizedContainer{ElementType}
# (self, ::ElementType) -> Bool
function contains end
function get_length end
end
```
虽然在定义时没有用到这个类型,但在子类定义时,该类型参数能用来约束容器的元素类型。
ObjectOriented.jl支持各种形式的Julia泛型,下面是一些例子。
```julia
# 数字容器
@oodef struct AbstactNumberContainer{ElementType <: Number}
...
end
# 用来表示任意类型的可空值
@oodef struct Optional{T}
value :: Union{Nothing, Some{T}}
end
```
### 高级特性:显式泛型类型参数
下面的代码给出一个特别的例子,构造器`new`无法从参数类型推断出泛型类型参数`A`。
```julia
@oodef struct MyGenType{A}
a :: Int
function new(a::Int)
new{A}(a)
end
end
```
在这种情况下,可以显式指定泛型类型参数,构造类型实例:
```julia
my_gen_type = MyGenType{String}(1)
my_gen_type = MyGenType{Number}(1)
my_gen_type = MyGenType{Vector{Int}}(1)
```
## 高级特性:接口
ObjectOriented.jl支持接口编程:使用`@oodef struct`定义一个没有字段的结构体类型,为它添加一些抽象方法,这样就实现了接口。
除开业务上方便对接逻辑外,接口还能为代码提供合适的约束。
### `@like(ootype)`
`@like` 将具体的OO类型转为某种特殊的Julia抽象类型。
```julia
julia> @like(HasLength)
Object{>:var"HasLength::trait"}
```
在Julia的类型系统中,具体类型不能被继承。其直接影响是,Julia的多重分派无法接受子类实例,如果参数标注为父类。
```julia
@oodef struct SuperC end
@oodef struct SubC <: SuperC end
function f(::SuperC) end
f(SuperC()) # ok
f(SubC()) # err
```
`@like(ootype)` 很好地解决了这一问题。类型标注为`@like(HasLength)`的函数参量可以接受`HasLength`的任意子类型。
```julia
@oodef struct SuperC end
@oodef struct SubC <: SuperC end
function f(::@like(SuperC)) end
f(SuperC()) # ok
f(SubC()) # ok!
```
### 例子,和零开销抽象
基于下面定义的接口`HasLength`,我们定义一个普通的Julia函数`a_regular_julia_function`:
```julia
@oodef struct HasLength
function get_length end
end
function a_regular_julia_function(o :: @like(HasLength))
function some_random_logic(i::Integer)
(i * 3 + 5) ^ 2
end
some_random_logic(o.get_length())
end
```
现在,我们为`HasLength`实现一个子类`MyList`,作为`Vector`类型的包装:
```julia
@oodef struct MyList{T} <: HasLength
inner :: Vector{T}
function new(elts::T...)
@mk begin
inner = collect(T, elts)
end
end
function get_length(self)
length(self.inner)
end
end
a_regular_julia_function(MyList(1, 2, 3)) # 196
a_regular_julia_function([1]) # error
```
可以看到,只有实现了HasLength的OO类型可以应用`a_regular_julia_function`。
此外,我们指出,ObjectOriented.jl的接口编程本身不导致动态分派。如果代码是静态分派的,抽象是零开销的。
```julia
@code_typed a_regular_julia_function(MyList(1, 2, 3))
CodeInfo(
1 ─ %1 = (getfield)(o, :inner)::Vector{Int64}
│ %2 = Base.arraylen(%1)::Int64
│ %3 = Base.mul_int(%2, 3)::Int64
│ %4 = Base.add_int(%3, 5)::Int64
│ %5 = Base.mul_int(%4, %4)::Int64
└── return %5
) => Int64
julia> @code_llvm a_regular_julia_function(MyList(1, 2, 3))
; @ REPL[6]:1 within `a_regular_julia_function`
; Function Attrs: uwtable
define i64 @julia_a_regular_julia_function_1290({ {}* }* nocapture nonnull readonly align 8 dereferenceable(8) %0) #0 {
top:
%1 = bitcast { {}* }* %0 to { i8*, i64, i16, i16, i32 }**
%2 = load atomic { i8*, i64, i16, i16, i32 }*, { i8*, i64, i16, i16, i32 }** %1 unordered, align 8
%3 = getelementptr inbounds { i8*, i64, i16, i16, i32 }, { i8*, i64, i16, i16, i32 }* %2, i64 0, i32 1
%4 = load i64, i64* %3, align 8
%5 = mul i64 %4, 3
%6 = add i64 %5, 5
%7 = mul i64 %6, %6
ret i64 %7
}
```
P.S: 为接口增加默认方法可以实现著名的Mixin抽象。见[继承,多继承](@id inheritance_cn)中的`IPolygon`类型。
## 用`@typed_access`解决性能问题
因为编译器优化原因,使用Python风格的property会导致类型推导不够精准,降低性能。
对于可能的性能损失,我们提供`@typed_access`宏,在兼容julia原生语义的条件下,自动优化所有的`a.b`操作。
```julia
@typed_access begin
instance1.method(instance2.property)
end
# 等价于
ObjectOriented.typed_access(instance1, Val(:method))(
ObjectOriented.typed_access(instance, Val(:property))
)
```
`@typed_access`让动态分派更慢,让静态分派更快。对于`a.b`,如果`a`的类型被Julia成功推断,则`@typed_access a.b`不会比`a.b`慢。
| ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.1.4 | 43b678a00a1f9a096104f462d52412d2b59c1b68 | docs | 17454 | ```@meta
CurrentModule = ObjectOriented
```
# ObjectOriented.jl
[中文文档](index-cn.md)
[ObjectOriented.jl](https://github.com/Suzhou-Tongyuan/ObjectOriented.jl) provides relatively complete object-oriented programming support for Julia. This is mainly based on CPython's object-oriented programming, and adapted for Julia.
The feature list is given below:
| feature | support | notes |
|:----: | :----: | :----: |
| inheritance | yes | upcasts/downcasts are not supported |
| overloaded constructors and methods | yes | based on multiple dispatch |
| multiple inheritance | yes | MRO based on [C3](https://en.wikipedia.org/wiki/C3_linearization)|
| Python-style properties | yes | |
| default field values | yes | |
| generics | yes | |
| interfaces | yes | singleton struct types as base classes |
| modifiers | no | just like Python |
| static class methods | no | won't fix to avoid [type piracy](https://docs.julialang.org/en/v1/manual/style-guide/#Avoid-type-piracy) |
| metaclasses | no | won't fix in favour of macros |
Quick start through [ObjectOriented.jl Cheat Sheet](./cheat-sheet-en.md).
Note that we very much support the community idea "do not do OOP in Julia".
We make this guide **[Translating OOP into Idiomatic Julia](./how-to-translate-oop-into-julia.md)** to instruct users on how to translate OOP code into Julia, promising more concise, more extensible and more efficient code.
We even took the effort to design ObjectOriented.jl as what it is now: the usage of OOP can be confined to the code of committed OOP users, and through interface programming, code of OOP exports APIs in normal Julia to avoid the proliferation of inappropriate code outside.
For those familiar with the Julia programming style, ObjectOriented.jl's the interface programming and field inheritance may still help. For such professional Julia programmers, it is recommended to only define fields in OO types and not to define dot methods (`self.method()`).
## OO type definition
ObjectOriented.jl supports defining `class`es and `struct`s. A `class` definition starts with `@oodef mutable struct`, while a `struct` definition starts with `@oodef struct`.
```julia
using ObjectOriented
@oodef struct MyStruct
a :: Int
function new(a::Int)
@mk begin
a = a
end
end
function f(self)
self.a
end
end
@oodef mutable struct MyClass
a :: Int
function new(a::Int)
@mk begin
a = a
end
end
function f(self)
self.a
end
end
```
As shown above, `function new(...)` is responsible for defining class/struct constructors.
We recommand using a `@mk begin ... end` block as the return value. In the block, you can specify zero or more `field_name = field_value` to initialize fields.
The behaviour when missing constructors:
1. if the type is a `class` (mutable struct), all fields are not initialized, as well as all base instances.
2. if the type is a `struct`, using Julia's default constructor.
Constructors can be overloaded.
For the struct types whose memory consumption is `0`, constructors can be omitted.
### Instance methods
instance methods should start with `function method_name(class_instance, ...)`. The instance variable is recommended to be named `self` or `this`.
The above code in both `MyClass` and `MyStruct` implement a method `f`. The method can be invoked using the syntax `instance.f()`.
```julia
@oodef mutable struct MyClass
a :: Int
# ... this part is omitted
function f(self)
self.a
end
end
```
Instance methods support aribitrary Julia parameters, such as variadic parameters, keyword arguments, variadic keyword arguments, default positional arguments and default keyword arguments.
Besides, the instance methods support generic parameters, and can be overloaded.
(**P.S**) If you want to annotate the `self` parameter, it is recommended to use `self :: @like(MyClass)` instead of `self :: MyClass`. This is because the method might be invoked by the subclasses, while Julia does not support implicit conversions between types.
(**P.P.S**) What is `@like`? Given an OO type `Parent`, any subtype `Child` (also an OO type) inheriting `Parent` satisfies `Child <: @like(Parent)` in Julia, where `<:` is Julia's native subtyping operator. `Child <: Parent` can only be `false` in Julia.
### Default field values
Using this feature, when defining a field for classes/structs, if a default value is provided, then the initialization for this field can be missing in the `@mk` block.
```julia
function get_default_field2()
println("default field2!")
return 30
end
@oodef struct MyType
field1 :: DataType = MyType
field2 :: Int = get_default_field2()
function new()
return @mk
end
function new(field2::Integer)
return @mk field2 = field2
end
end
julia> MyType()
default field2!
MyType(MyType, 30)
julia> MyType(50)
MyType(MyType, 50)
```
Some points of the default field values:
1. there is no performance overhead in using default field values.
2. when a field has been explicitly initialized in the `@mk` block, the expression of the default field value won't be evaluated.
3. unlike `Base.@kwdef`, default field values cannot reference each other.
## Python-style constructors
The traditional OO languages such Python/C++/Java/C\# do not have native immutable types, so that the jobs of a constructor can be designed as follow:
1. creating a new instance `self` of the type.
2. invoking a constructor function to initialize the `self` instance. Side effects are introduced.
ObjectOriented.jl can support such style for classes (`mutable struct`s), but it is not our best practice.
Example:
```julia
@oodef mutable struct MySubclass <: {MySuperclass1, MySuperclass2}
field1
function new()
self = @mk
# init fields
self.field1 = 1
# remember to return self
return self
end
```
## [Inheritances and multiple inheritances](@id inheritance)
Here is a simple example of class inheritance.
We firstly define two structs using `@oodef`:
```julia
@oodef struct A
a :: Int
end
@oodef struct B
b :: Int
end
```
Then, we define a type `C` to inherit `A` and `B`:
```julia
@oodef struct C <: {A, B}
c :: String
function new(a::Int, b::Int, c::String = "somestring")
@mk begin
A(a), B(b)
c = c
end
end
end
c = C(1, 2)
@assert c.a === 1
@assert c.b === 2
```
As can be seen, in the `@mk` block, we use `Base1(arg1, arg2), Base2(arg1, arg2)` to call the base classe constructors, which corresponds to `BaseType.__init__(self, arg1, arg2)` in Python.
A struct/class can inherit multiple base classes/structs. When name collision happens, we use C3 linearization algorithm to decide which one is to select. We use a variant of C3 to allow more flexible mixin uses.
The following example introduces mixin which is a common use of (multiple) inheritances:
We define a base class `IPolygon` which might have subclasses `Square`, `Rectangle`, `Triangle` or even general polygons. Despite the differences between these possible subclasses, a standard algorithm to compute perimeters is shared: sum up the lengths of all the edges.
```julia
using ObjectOriented
const Point = Tuple{Float64, Float64}
function distance(source::Point, destination::Point)
sqrt(
(destination[1] - source[1]) ^ 2 +
(destination[2] - source[2]) ^ 2)
end
@oodef struct IPolygon
# abstract method
function get_edges end
# mixin method
function get_perimeter(self)
s = 0.0
vs = self.get_edges() :: AbstractVector{Point}
if length(vs) <= 1
0.0
end
last = vs[1] :: Point
for i = 2:length(vs)
s += distance(vs[i], last)
last = vs[i]
end
s += distance(vs[end], vs[1])
return s
end
end
```
Leveraging the above `IPolygon`, we can define subclasses, reusing the `get_perimeter` method.
For instance, `Rectangle`:
```julia
@oodef struct Rectangle <: IPolygon
width :: Float64
height :: Float64
center :: Point
function new(width::Float64, height::Float64, center::Point)
@mk begin
width = width
height = height
center = center
end
end
function get_edges(self)
x0 = self.center[1]
y0 = self.center[2]
h = self.height / 2
w = self.width / 2
Point[
(x0 - w, y0 - h),
(x0 - w, y0 + h),
(x0 + w, y0 + h),
(x0 + w, y0 - h)
]
end
# for very special subclasses, we can overwrite
# 'get_perimeter' to have a faster version:
# function get_perimeter(self) ... end
end
rect = Rectangle(3.0, 2.0, (5.0, 2.0))
@assert rect.get_perimeter() == 10.0
```
P.S: OO types shall only inherit from OO types defined using ObjectOriented.jl.
## Python-style properties
In Java, the getter functions `get_xxx` and setter functions `set_xxx` are used to encapsulate the implementation details and export more stable APIs.
The syntactic redundancies involved above can be adddressed by a syntatic sugar, which is named "properties" by many languages such as Python.
ObjectOriented.jl supports so-called "properties", in the following apprach:
```julia
@oodef struct DemoProp
@property(value) do
get = self -> 100
set = (self, value) -> println("setting $value")
end
end
println(DemoProp().value) # => 100
DemoProp().value = 200 # => setting 200
```
A more practical example is given below:
```julia
@oodef mutable struct Square
side :: Float64
function new(side::Number)
@mk begin
side = side # support auto cast
end
end
@property(area) do
get = self -> self.side ^ 2
set = function (self, value)
self.side = sqrt(value)
end
end
end
square = Square(5) # => Square(5.0)
square.area # => 25.0
square.area = 16 # => 16
square.side # => 4.0
```
As can be seen, the side length of the square changes accordingly as the area gets changed.
## [Advanced feature: Abstract methods, and abstract properties](@id advanced_absmeths_and_absprops)
```julia
@oodef struct AbstractSizedContainer{ElementType}
# abstract method
function contains end
# abstract property with only getter
@property(length) do
get
end
end
# print not implemented methods (including properties)
ObjectOriented.check_abstract(AbstractSizedContainer)
# =>
# Dict{PropertyName, ObjectOriented.CompileTime.PropertyDefinition} with 2 entries:
# contains (getter) => PropertyDefinition(:contains, missing, AbstractSizedContainer, MethodKind)
# length (getter) => PropertyDefinition(:length, missing, AbstractSizedContainer, GetterPropertyKind)
@oodef struct MyNumSet{E <: Number} <: AbstractSizedContainer{E}
inner :: Set{E}
function new(args::E...)
@mk begin
inner = Set{E}(args)
end
end
# if no annotations for 'self',
# annotations and type parameters can be added like:
# 'function contains(self :: @like(MySet{E}), e::E) where E'
function contains(self, e::E)
return e in self.inner
end
@property(length) do
get = self -> length(self.inner)
end
end
my_set = MySet(1, 2, 3)
my_set.length # => 3
my_set.contains(2) # => true
```
## Advanced feature: Generics
Generics are pervasive, and in practice very common in data structures.
At [Advanced features:Abstract methods, and abstract properties](@ref advanced_absmeths_and_absprops), we have introduced `AbstractSizedContainer`. It has a generic type parameter `ElementType`.
```julia
@oodef struct AbstractSizedContainer{ElementType}
# (self, ::ElementType) -> Bool
function contains end
@property(length) do
get
end
end
```
Although we do not use `ElementType` in the above example, it is useful if we need to specify a container's element type.
```julia
# containers of only numbers
@oodef struct AbstactNumberContainer{ElementType <: Number}
...
end
@oodef struct Optional{T}
value :: Union{Nothing, Some{T}}
end
```
### Advanced feature: Explicit generic type parameters
The following code shows a special case where the constructor `new` cannot infer the generic type parameter `A` from the arguments:
```julia
@oodef struct MyGenType{A}
a :: Int
function new(a::Int)
new{A}(a)
end
end
```
In this case, we can explicitly specify the generic type parameters to construct instances:
```julia
my_gen_type = MyGenType{String}(1)
my_gen_type = MyGenType{Number}(1)
my_gen_type = MyGenType{Vector{Int}}(1)
```
## Advanced feature: Interfaces
ObjectOriented.jl supports interface programming. Use `@oodef struct` to define a struct which has no fields, and add some abstract/mixin methods to it, in this way we achieve interface programming.
Despite the ease of connecting with the real business logic, interfaces also helps to specify proper constraints in your code.
### `@like(ootype)`
`@like` transforms a concrete OO type into a special abstract type.
```julia
julia> @like(HasLength)
Object{>:var"HasLength::trait"}
```
In Julia's type system, no concrete type can be inherited. A direct implication is that Julia's multiple dispatch does not accept a subtype instance if the parameter is annotated a base type.
```julia
@oodef struct SuperC end
@oodef struct SubC <: SuperC end
function f(::SuperC) end
f(SuperC()) # ok
f(SubC()) # err
```
`@like(ootype)` addresses this. A function parameter `@like(HasLength)` accepts instances of any type that is a subtype of `HasLength`.
```julia
@oodef struct SuperC end
@oodef struct SubC <: SuperC end
function f(::@like(SuperC)) end
f(SuperC()) # ok
f(SubC()) # ok!
```
### Examples, and zero-cost abstraction
The following code based on the interface `HasLength` defines a regular Julia function `a_regular_julia_function`:
```julia
@oodef struct HasLength
function get_length end
end
function a_regular_julia_function(o :: @like(HasLength))
function some_random_logic(i::Integer)
(i * 3 + 5) ^ 2
end
some_random_logic(o.get_length())
end
```
Now, we define a substruct `MyList` that inherits from `HasLength`, as the user wrapper of Julia's builtin `Vector` type:
```julia
@oodef struct MyList{T} <: HasLength
inner :: Vector{T}
function new(elts::T...)
@mk begin
inner = collect(T, elts)
end
end
function get_length(self)
length(self.inner)
end
end
a_regular_julia_function(MyList(1, 2, 3)) # 196
a_regular_julia_function([1]) # error
```
We can see that only the OO type that implements `HasLength` is accepted by `a_regular_julia_function`.
Additionally, we point out that such interface abstraction itself does not introduce any dynamic dispatch. If your code contains only static dispatch, the abstraction is zero-cost.
```julia
@code_typed a_regular_julia_function(MyList(1, 2, 3))
CodeInfo(
1 ─ %1 = (getfield)(o, :inner)::Vector{Int64}
│ %2 = Base.arraylen(%1)::Int64
│ %3 = Base.mul_int(%2, 3)::Int64
│ %4 = Base.add_int(%3, 5)::Int64
│ %5 = Base.mul_int(%4, %4)::Int64
└── return %5
) => Int64
julia> @code_llvm a_regular_julia_function(MyList(1, 2, 3))
; @ REPL[6]:1 within `a_regular_julia_function`
; Function Attrs: uwtable
define i64 @julia_a_regular_julia_function_1290({ {}* }* nocapture nonnull readonly align 8 dereferenceable(8) %0) #0 {
top:
%1 = bitcast { {}* }* %0 to { i8*, i64, i16, i16, i32 }**
%2 = load atomic { i8*, i64, i16, i16, i32 }*, { i8*, i64, i16, i16, i32 }** %1 unordered, align 8
%3 = getelementptr inbounds { i8*, i64, i16, i16, i32 }, { i8*, i64, i16, i16, i32 }* %2, i64 0, i32 1
%4 = load i64, i64* %3, align 8
%5 = mul i64 %4, 3
%6 = add i64 %5, 5
%7 = mul i64 %6, %6
ret i64 %7
}
```
P.S: Concrete methods defined in interfaces lead to a famous abstraction called Mixin. See `IPolygon` type at [Inheritances, and multiple inheritances](@id inheritance).
## Addressing performance issues via `@typed_access`
Because of the compiler optimization, using methods or Python-style properties might cause inaccurate type inference, and affect performance.
For possible performance issues, we provide `@typed_access` to automatically optimize all `a.b` operations in Julia-compatible semantics.
```julia
@typed_access begin
instance1.method(instance2.property)
end
# <=>
ObjectOriented.getproperty_typed(instance1, Val(:method))(
ObjectOriented.getproperty_typed(instance, Val(:property))
)
```
`@typed_access` slows down dynamic calls,but removes overheads of static calls。For `a.b`,if the type of `a` is successfully inferred, then `@typed_access a.b` is strictly faster than `a.b`.
| ObjectOriented | https://github.com/Suzhou-Tongyuan/ObjectOriented.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 2028 | using Documenter
using FinancialModelingPrep
makedocs(
sitename = "FinancialModelingPrep",
authors = "rando-brando",
format = Documenter.HTML(),
modules = [FinancialModelingPrep],
pages = [
"Introduction" => "index.md",
"Client" => "client.md",
"Endpoints" => Any[
"Price Quotes" => "pricequotes.md",
"Stock Fundamentals" => "stockfundamentals.md",
"Stock Fundamentals Analysis" => "stockfundamentalsanalysis.md",
"Institutional Stock Ownership" => "institutionalstockownership.md",
"ESG Score" => "esgscore.md",
"Private Companies Fundraising Data" => "privatecompaniesfundraisingdata.md",
"Price Target" => "pricetarget.md",
"Upgrades & Downgrades" => "upgradesdowngrades.md",
"Historical Fund Holdings" => "historicalfundholdings.md",
"Historical Number of Employees" => "historicalemployees.md",
"Executive Compensation" => "executivecompensation.md",
"Individual Beneficial Ownership" => "individualbeneficialownership.md",
"Stock Calendars" => "stockcalendars.md",
"Stock Screener" => "stockscreener.md",
"Company Information" => "companyinformation.md",
"Stock News" => "stocknews.md",
"Market Performance" => "marketperformance.md",
"Stock Statistics" => "stockstatistics.md",
"Insider Trading" => "insidertrading.md",
"Senate Trading" => "senatetrading.md",
"Economics" => "economics.md",
"Stock Price" => "stockprice.md",
"Fund Holdings" => "fundholdings.md",
"Stock List" => "stocklist.md",
"Market Indexes" => "marketindexes.md",
"Euronext" => "euronext.md",
"TSX" => "tsx.md",
"Crypto & Forex & Commodities" => "cryptoforexcommodities.md"
]
]
)
deploydocs(
repo = "github.com/rando-brando/FinancialModelingPrep.jl"
)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 4297 | module Client
include("Exceptions.jl")
import HTTP, JSON3, JSONTables
import Base: @kwdef
import .Exceptions
"""
FMP(apikey, baseurl, headers)
Creates a Financial Modeling Prep instance for interacting with the API server endpoints.
# Arguments
- `apikey::String` = `"demo"`
- `baseurl::String` = `"https://financialmodelingprep.com"`
- `headers::Dict{String, String}` = `Dict("Upgrade-Insecure-Requests" => "1")`
# Examples
``` julia
# load your FMP API key
FMP_API_KEY = ENV("FMP_API_KEY")
# create a new FMP instance, passing the API key by name
fmp = FMP(apikey = FMP_API_KEY)
```
"""
@kwdef struct FMP
apikey::String = "demo"
baseurl::String = "https://financialmodelingprep.com"
headers::Dict{String, String} = Dict{String, String}("Upgrade-Insecure-Requests" => "1")
end
"""
make_url_v3(fmp, endpoint, params...)
Creates a Financial Modeling Prep API version 3 URL.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `endpoint::String`: The api endpoint
- `params...`: Additional keyword query params.
"""
function make_url_v3(fmp::FMP, endpoint::String; params...)::Tuple{String, Dict{String, Any}}
query = Dict{String, Any}(string(k) => v for (k, v) in params if !isnothing(v))
query["apikey"] = fmp.apikey
url = "$(fmp.baseurl)/api/v3/$(endpoint)"
return url, query
end
"""
make_url_v4(fmp, endpoint, params...)
Creates a Financial Modeling Prep API version 4 URL.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `endpoint::String`: The api endpoint
- `params...`: Additional keyword query params.
"""
function make_url_v4(fmp::FMP, endpoint::String; params...)::Tuple{String, Dict{String, Any}}
query = Dict{String, Any}(string(k) => v for (k, v) in params if !isnothing(v))
query["apikey"] = fmp.apikey
url = "$(fmp.baseurl)/api/v4/$(endpoint)"
return url, query
end
"""
make_get_request(url, query, status_exception = false)
Makes a GET request to the Financial Modeling Prep API server.
# Arguments
- `url::String`: A url to make a request to.
- `query::Dict{String, Any}`: Additional query parameters for the request.
- `status_exception::Bool = false`: throw HTTP.StatusError for response status >= 300.
"""
function make_get_request(url::String, query::Dict{String, Any}; status_exception = false)::HTTP.Messages.Response
response = HTTP.get(url, query = query, status_exception = status_exception)
return response
end
"""
parse_json_object(response)
parse_json_object(response, accessor)
Parses a response from the Financial Modeling Prep API server as a JSON object.
# Arguments
- `response::HTTP.Messages.Response`: An HTTP response containing JSON data.
- `accessor::Symbol`: An accessor Symbol which contains a nested array.
"""
function parse_json_object(response::HTTP.Messages.Response, accessor)::Union{JSON3.Object, JSON3.Array}
result = JSON3.read(response.body)
# raise error when the API response does
if isa(result, JSON3.Object)
if haskey(result, "Error Message")
throw(Exceptions.PermissionError(result["Error Message"]))
end
if response.status != 200
status = response.status
method = response.request.method
target = split(response.request.target, "?")[1]
throw(HTTP.Exceptions.StatusError(status, method, target, response))
end
if haskey(result, accessor)
result = result[accessor]
end
end
return result
end
parse_json_object(response::HTTP.Messages.Response) = parse_json_object(response, nothing)
"""
parse_json_table(response)
parse_json_table(response, accessor)
Parses a response from the Financial Modeling Prep API server as a JSON table.
# Arguments
- `response::HTTP.Messages.Response`: An HTTP response containing JSON data.
- `accessor::Symbol`: An accessor Symbol which contains a nested array.
"""
function parse_json_table(response::HTTP.Messages.Response, accessor)::Union{JSONTables.Table, JSON3.Array}
result = parse_json_object(response, accessor)
if !isempty(result)
result = JSONTables.jsontable(result)
end
return result
end
parse_json_table(response::HTTP.Messages.Response) = parse_json_table(response, nothing)
end # module Client
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 169 | module Exceptions
"""
PermissionError(message)
Throws a permission error.
"""
struct PermissionError <: Exception
message::String
end
end # module Exceptions
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 6571 | module FinancialModelingPrep
include("Client.jl")
import .Client
import .Client.FMP
# exports from Client module
export FMP
# exports from pricequotes.jl
export
price_quote,
price_quotes,
historical_price_quote
# exports from stockfundamentals.jl
export
symbols_with_financials,
income_statements,
balance_sheet_statements,
cash_flow_statements,
financial_statements,
financial_reports,
revenue_segments,
shares_float,
earnings_call_transcripts,
sec_filings,
company_notes
# exports from stockfundamentalsanalysis.jl
export
financial_ratios,
financial_scores,
owners_earnings,
enterprise_values,
income_statements_growth,
balance_sheet_statements_growth,
cash_flow_statements_growth,
financial_statements_growth,
key_metrics,
company_rating,
historical_ratings,
discounted_cash_flows,
advanced_discounted_cash_flows,
historical_discounted_cash_flows
# exports from institutionalstockownership.jl
export
institutional_positions,
institutional_ownership_percentages,
institutional_ownership_weightings,
institutional_ownership_feed,
institution_search,
institution_portfolio_dates,
institution_portfolio_summary,
institution_portfolio_industry_summary,
institution_portfolio_composition
# exports from esgscore.jl
export
esg_scores,
esg_ratings,
esg_score_benchmarks
# exports from privatecompaniesfundraisingdata.jl
export
crowdfunding_offerings_feed,
crowdfunding_offerings_search,
crowdfunding_offerings,
equity_offerings_feed,
equity_offerings_search,
equity_offerings
# exports from pricetarget.jl
export
price_targets,
price_targets_by_analyst,
price_targets_by_company,
price_targets_summary,
price_targets_consensus,
price_targets_feed
# exports from upgradesdowngrades.jl
export
upgrades_and_downgrades,
upgrades_and_downgrades_feed,
upgrades_and_downgrades_consensus,
upgrades_and_downgrades_by_company
# exports from historicalfundholdings.jl
export
mutual_fund_portfolio_dates,
mutual_fund_portfolio,
mutual_fund_search,
etf_portfolio_dates,
etf_portfolio
# exports from historicalemployees
export
historical_employee_counts
# exports from executivecompensation.jl
export
executive_compensation,
executive_compensation_benchmarks
# exports from individualbeneficialownership.jl
export
beneficial_ownership
# exports from stockcalendars.jl
export
earnings_calendar,
historical_earnings_calendar,
earnings_calendar_confirmed,
ipo_calendar,
ipo_calendar_prospectus,
ipo_calendar_confirmed,
stock_split_calendar,
dividend_calendar,
historical_dividends,
economic_calendar
# exports from stockscreener.jl
export
search_symbol,
search_name,
stock_screener,
available_countries
# exports from companyinformation.jl
export
company_profile,
key_executives,
company_outlook,
stock_peers,
nyse_schedule,
delisted_companies,
symbol_changes,
company_information
# exports from stocknews.jl
export
fmp_articles,
stock_news,
stock_news_sentiment_feed,
crypto_news,
forex_news,
general_news,
press_releases
# exports from marketperformance.jl
export
sector_pe_ratios,
industry_pe_ratios,
sector_performances,
historical_sector_performances,
gainers,
losers,
most_active
# exports from stockstatistics.jl
export
historical_social_sentiment,
social_sentiment_trends,
social_sentiment_changes,
stock_grades,
earnings_surprises,
analyst_estimates,
mergers_and_acquisitions_feed,
mergers_and_acquisitions_search
# export from insidertrading.jl
export
insider_trading_types,
insider_trades,
insider_trades_feed,
insiders_list,
cik_from_insider,
cik_from_symbol,
insider_roster,
insider_roster_statistics,
fails_to_deliver
# exports from senatetrading.jl
export
senate_trades,
senate_trades_feed,
senate_disclosures,
senate_disclosure_feed
# exports from economics.jl
export
market_risk_premiums,
treasury_rates,
economic_indicator
# exports from stockprice.jl
export
otc_quote,
price_change,
historical_splits,
survivorship_bias,
technical_indicators
# exports from fundholdings.jl
export
etf_holders,
etf_summary,
institutional_holders,
mutual_fund_holders,
etf_sector_weightings,
etf_country_weightings,
etf_exposure,
institutions_list,
cik_search,
company_from_cik,
forms_13f,
filing_dates,
company_from_cusip
# exports from stocklist.jl
export
available_symbols,
tradeable_symbols,
etf_symbols
# exports from marketindexes.jl
export
available_indexes,
sp500_companies,
nasdaq_companies,
dowjones_companies
# exports from euronext.jl
export
available_euronext
# exports from tsx.jl
export
available_tsx
# exports from cryptoforexcommodities.jl
export
available_crytocurrencies,
available_forex_pairs,
exchange_rates,
available_commodities
# export preset variables
export
REPORTING_PERIODS,
REVENUE_SEGMENTS,
TIME_FREQUENCIES
const REPORTING_PERIODS = (annual = "annual", quarter = "quarter", ttm = "ttm") # reporting period options
const REVENUE_SEGMENTS = (geographic = "geographic", product = "product") # revenue segment options
const TIME_FREQUENCIES = (minutes1 = "1min", minutes5 = "5min", minutes15 = "15min", minutes30 = "30min", hours1 = "1hour", hours4 = "4hour", daily = "daily") # time period options
include("pricequotes.jl")
include("stockfundamentals.jl")
include("stockfundamentalsanalysis.jl")
include("institutionalstockownership.jl")
include("esgscore.jl")
include("privatecompaniesfundraisingdata.jl")
include("pricetarget.jl")
include("upgradesdowngrades.jl")
include("historicalfundholdings.jl")
include("historicalemployees.jl")
include("executivecompensation.jl")
include("individualbeneficialownership.jl")
include("stockcalendars.jl")
include("stockscreener.jl")
include("companyinformation.jl")
include("stocknews.jl")
include("marketperformance.jl")
include("stockstatistics.jl")
include("insidertrading.jl")
include("senatetrading.jl")
include("economics.jl")
include("stockprice.jl")
include("fundholdings.jl")
include("stocklist.jl")
include("marketindexes.jl")
include("euronext.jl")
include("tsx.jl")
include("cryptoforexcommodities.jl")
end # module FinancialModelingPrep
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 6278 | """
company_profile(fmp, symbol)
Returns the company profile for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Company-Profile]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Profile) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the company profile for AAPL
data = company_profile(fmp, "AAPL")
```
"""
function company_profile(fmp::FMP; symbol::String)
endpoint = "profile/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
company_profile(fmp::FMP, symbol::String) = company_profile(fmp; symbol)
"""
key_executives(fmp, symbol)
Returns the key executives for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Key-Executives]\
(https://site.financialmodelingprep.com/developer/docs/#Key-Executives) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the key executives for AAPL
data = key_executives(fmp, "AAPL")
```
"""
function key_executives(fmp::FMP; symbol::String)
endpoint = "key-executives/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
key_executives(fmp::FMP, symbol::String) = key_executives(fmp; symbol)
"""
company_outlook(fmp, symbol, accessor)
Returns a JSON table or dictionary of the company outlook for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `accessor::Symbol`: An accessor Symbol which contains a nested array.
See [Company-Outlook]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Outlook) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the company outlook for AAPL
data = company_outlook(fmp, "AAPL")
```
"""
function company_outlook(fmp::FMP; symbol::String, accessor = nothing)
endpoint = "company-outlook"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
if isnothing(accessor)
data = Client.parse_json_object(response)
else
data = Client.parse_json_table(response, accessor)
end
return data
end
company_outlook(fmp::FMP, symbol::String, accessor) = company_outlook(fmp; symbol, accessor)
company_outlook(fmp::FMP, symbol::String; accessor = nothing) = company_outlook(fmp; symbol, accessor)
"""
stock_peers(fmp, symbol)
Returns a JSON array of the stock peers for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Stock-Peers]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Peers) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the stock peers for AAPL
data = stock_peers(fmp, "AAPL")
```
"""
function stock_peers(fmp::FMP; symbol::String)
endpoint = "stock_peers"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response, :peersList)
return data
end
stock_peers(fmp::FMP, symbol::String) = stock_peers(fmp; symbol)
"""
nyse_schedule(fmp)
Returns a JSON dictionary of the NYSE schedule including market hours and market holidays.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [NYSE-Schedule]\
(https://site.financialmodelingprep.com/developer/docs/#NYSE-Holidays-and-Trading-Hours) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the NYSE holiday schedule
data = nyse_schedule(fmp)[:stockMarketHolidays]
```
"""
function nyse_schedule(fmp::FMP)
endpoint = "is-the-market-open"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_object(response)
return data
end
"""
delisted_companies(fmp, params...)
Returns delisted companies.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Delisted-Companies]\
(https://site.financialmodelingprep.com/developer/docs/#Delisted-Companies) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of delisted companies
data = delisted_companies(fmp, page = 0)
```
"""
function delisted_companies(fmp::FMP; params...)
endpoint = "delisted-companies"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
symbol_changes(fmp)
Returns changed symbols.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Symbol-Change]\
(https://site.financialmodelingprep.com/developer/docs/#Symbol-Change) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get symbol changes
data = symbol_changes(fmp)
```
"""
function symbol_changes(fmp::FMP)
endpoint = "symbol_change"
url, query = Client.make_url_v4(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
company_information(fmp, symbol)
Returns company information for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Stock-Peers]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Peers) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the company information for AAPL
data = company_information(fmp, "AAPL")
```
"""
function company_information(fmp::FMP; symbol::String)
endpoint = "company-core-information"
url, query = Client.make_url_v4(fmp, endpoint, symbol = symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
company_information(fmp::FMP, symbol::String) = company_information(fmp; symbol)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 2921 | """
available_crytocurrencies(fmp)
Returns all available cryptocurrencies in the API.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Cryptocurrencies-List]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-Cryptocurrencies-Price) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all available cryptocurrencies
data = available_crytocurrencies(fmp)
```
"""
function available_crytocurrencies(fmp::FMP)
endpoint = "symbol/available-cryptocurrencies"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
available_forex_pairs(fmp)
Returns all available forex pairs in the API.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Forex-Pairs-List]\
(https://site.financialmodelingprep.com/developer/docs/#Forex-(FX)) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all available forex pairs
data = available_forex_pairs(fmp)
```
"""
function available_forex_pairs(fmp::FMP)
endpoint = "symbol/available-forex-currency-pairs"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
exchange_rates(fmp)
exchange_rates(fmp, symbol)
Returns the commodity quote for the specified symbol(s).
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A commodity symbol.
See [Crypto-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Cryptocurrencies) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all fx rates
data = commodity_quote(fmp)
# get the fx rates for EURUSD
data = commodity_quote(fmp, "EURUSD")
```
"""
function exchange_rates(fmp::FMP; symbol::String = "")
endpoint = "fx/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
exchange_rates(fmp::FMP, symbol::String) = exchange_rates(fmp; symbol)
"""
available_commodities(fmp)
Returns all available commodities in the API.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Commodities-List]\
(https://site.financialmodelingprep.com/developer/docs/#Most-of-the-Major-Commodities-(Gold,-Silver,-Oil)) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all available commodities
data = available_commodities(fmp)
```
"""
function available_commodities(fmp::FMP)
endpoint = "symbol/available-commodities"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 2470 | """
market_risk_premiums(fmp)
Returns market risk premiums for each country.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Market-Risk-Premium]\
(https://site.financialmodelingprep.com/developer/docs/#Market-Risk-Premium) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all market risk premiums
data = market_risk_premiums(fmp)
```
"""
function market_risk_premiums(fmp::FMP)
endpoint = "market_risk_premium"
url, query = Client.make_url_v4(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
treasury_rates(fmp, params...)
Returns the treasury rates for the specified date range.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Treasury-Rates]\
(https://site.financialmodelingprep.com/developer/docs/#Treasury-Rates) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the treasury rates for Q1 2022
data = treasury_rates(fmp, from = "2022-01-01", to = "2022-03-31")
```
"""
function treasury_rates(fmp::FMP; params...)
endpoint = "treasury"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
economic_indicator(fmp, name, params...)
Returns the treasury rates for the specified date range.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `name::String`: An econmic indicator.
- `params...`: Additional keyword query params.
See [Economic-Indicator]\
(https://site.financialmodelingprep.com/developer/docs/#Economic-Indicator) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the real GDP for Q1 2022
data = economic_indicator(fmp, name = "realGDP", from = "2022-01-01", to = "2022-03-31")
# get the federal funds rate for Q1 2022
data = economic_indicator(fmp, name = "federalFunds", from = "2022-01-01", to = "2022-03-31")
```
"""
function economic_indicator(fmp::FMP; name::String, params...)
endpoint = "economic"
url, query = Client.make_url_v4(fmp, endpoint; name, params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
economic_indicator(fmp::FMP, name::String; params...) = economic_indicator(fmp; name, params...)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 2474 | """
esg_scores(fmp, symbol)
Returns a JSON table with the ESG scores for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [ESG-Score]\
(https://site.financialmodelingprep.com/developer/docs/#ESG-SCORE) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the esg scores for AAPL
data = esg_scores(fmp, "AAPL")
```
"""
function esg_scores(fmp::FMP; symbol::String)
endpoint = "esg-environmental-social-governance-data"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
esg_scores(fmp::FMP, symbol::String) = esg_scores(fmp; symbol)
"""
esg_ratings(fmp, symbol)
Returns a JSON table with the ESG ratings for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [ESG-Ratings]\
(https://site.financialmodelingprep.com/developer/docs/#Company-ESG-Risk-Ratings) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the esg ratings for AAPL
data = esg_ratings(fmp, "AAPL")
```
"""
function esg_ratings(fmp::FMP; symbol::String)
endpoint = "esg-environmental-social-governance-data-ratings"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
esg_ratings(fmp::FMP, symbol::String) = esg_ratings(fmp; symbol)
"""
esg_score_benchmarks(fmp, year)
Returns a JSON table with the ESG score benchmarks for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `year::Integer`: A calendar year.
See [ESG-Benchmarking]\
(https://site.financialmodelingprep.com/developer/docs/#ESG-Benchmarking-By-Sector-and-Year) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the esg score benchmarks for 2023
data = esg_score_benchmarks(fmp, year = 2023)
```
"""
function esg_score_benchmarks(fmp::FMP; year::Integer)
endpoint = "esg-environmental-social-governance-sector-benchmark"
url, query = Client.make_url_v4(fmp, endpoint; year)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
esg_score_benchmarks(fmp::FMP, year::Integer) = esg_score_benchmarks(fmp; year)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 662 | """
available_euronext(fmp)
Returns all available euronext symbols in the API.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Euronext-List]\
(https://site.financialmodelingprep.com/developer/docs/#Most-of-the-EuroNext) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all available euronext symbols
data = available_euronext(fmp)
```
"""
function available_euronext(fmp::FMP)
endpoint = "symbol/available-euronext"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 1800 | """
executive_compensation(fmp, symbol)
Returns executive compensation for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Executive-Compensation]\
(https://site.financialmodelingprep.com/developer/docs/#Executive-Compensation) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the excecutive compensation for AAPL
data = executive_compensation(fmp, "AAPL")
```
"""
function executive_compensation(fmp::FMP; symbol::String)
endpoint = "governance/executive_compensation"
url, query = Client.make_url_v4(fmp, endpoint, symbol = symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
executive_compensation(fmp::FMP, symbol::String) = executive_compensation(fmp; symbol)
"""
executive_compensation_benchmarks(fmp, year)
Returns executive compensation benchmarks for the specified year.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `year::Integer`: A calendar year.
See [Executive-Compensation]\
(https://site.financialmodelingprep.com/developer/docs/#Executive-Compensation) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the excecutive compensation benchmarks for 2020
data = executive_compensation_benchmarks(fmp, year = 2020)
```
"""
function executive_compensation_benchmarks(fmp::FMP; year::Integer)
endpoint = "executive-compensation-benchmark"
url, query = Client.make_url_v4(fmp, endpoint, year = year)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
executive_compensation_benchmarks(fmp::FMP, year::Integer) = executive_compensation_benchmarks(fmp; year)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 10176 | """
etf_holders(fmp, symbol)
Returns the etf holders of a specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: An etf symbol.
See [ETF-Holders]\
(https://site.financialmodelingprep.com/developer/docs/#ETF-Holders) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the etf holders for SPY
data = etf_holders(fmp, "SPY")
```
"""
function etf_holders(fmp::FMP; symbol::String)
endpoint = "etf-holder/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
etf_holders(fmp::FMP, symbol::String) = etf_holders(fmp; symbol)
"""
etf_summary(fmp, symbol)
Returns the etf summary for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [ETF-Info]\
(https://site.financialmodelingprep.com/developer/docs/#ETF-Expense-ratio) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the etf summary for SPY
data = etf_summary(fmp, "SPY")
```
"""
function etf_summary(fmp::FMP; symbol::String)
endpoint = "etf-info"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
etf_summary(fmp::FMP, symbol::String) = etf_summary(fmp; symbol)
"""
institutional_holders(fmp, symbol)
Returns the institutional holders of a specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Institutional-Holders]\
(https://site.financialmodelingprep.com/developer/docs/#Institutional-Holders) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the institutional holders of AAPL
data = institutional_holders(fmp, "AAPL")
```
"""
function institutional_holders(fmp::FMP; symbol::String)
endpoint = "institutional-holder/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
institutional_holders(fmp::FMP, symbol::String) = institutional_holders(fmp; symbol)
"""
mutual_fund_holders(fmp, symbol)
Returns the mutual fund holders of a specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Mutual-Fund-Holders]\
(https://site.financialmodelingprep.com/developer/docs/#Mutual-Fund-Holders) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the mutual fund holders of AAPL
data = mutual_fund_holders(fmp, "AAPL")
```
"""
function mutual_fund_holders(fmp::FMP; symbol::String)
endpoint = "mutual-fund-holder/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
mutual_fund_holders(fmp::FMP, symbol::String) = mutual_fund_holders(fmp; symbol)
"""
etf_sector_weightings(fmp, symbol)
Returns the sector weightings of a specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: An etf symbol.
See [ETF-Sector-Weightings]\
(https://site.financialmodelingprep.com/developer/docs/#ETF-Sector-Weightings) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the sector weightings of SPY
data = etf_sector_weightings(fmp, "SPY")
```
"""
function etf_sector_weightings(fmp::FMP; symbol::String)
endpoint = "etf-sector-weightings/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
etf_sector_weightings(fmp::FMP, symbol::String) = etf_sector_weightings(fmp; symbol)
"""
etf_country_weightings(fmp, symbol)
Returns the country weightings of a specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: An etf symbol.
See [ETF-Country-Weightings]\
(https://site.financialmodelingprep.com/developer/docs/#ETF-Country-Weightings) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the country weightings of SPY
data = etf_country_weightings(fmp, "SPY")
```
"""
function etf_country_weightings(fmp::FMP; symbol::String)
endpoint = "etf-country-weightings/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
etf_country_weightings(fmp::FMP, symbol::String) = etf_country_weightings(fmp; symbol)
"""
etf_exposure(fmp, symbol)
Returns the etf exposure for a specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [ETF-Stock-Exposure]\
(https://site.financialmodelingprep.com/developer/docs/#ETF-Stock-Exposure) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the etf exposure for AAPL
data = etf_exposure(fmp, "AAPL")
```
"""
function etf_exposure(fmp::FMP; symbol::String)
endpoint = "etf-stock-exposure/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
etf_exposure(fmp::FMP, symbol::String) = etf_exposure(fmp; symbol)
"""
institutions_list(fmp)
Returns all companies by CIK.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Institutions-List]\
(https://site.financialmodelingprep.com/developer/docs/#Form-13F) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all institutions
data = institutions_list(fmp)
```
"""
function institutions_list(fmp::FMP)
endpoint = "cik_list"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
cik_search(fmp, name)
Returns all CIKs matching the specified name.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `name::String`: A complete or partial institution name.
See [Form-13F-Search]\
(https://site.financialmodelingprep.com/developer/docs/#Form-13F) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all CIKs matching "Berkshire"
data = cik_search(fmp, name = "Berkshire")
```
"""
function cik_search(fmp::FMP; name::String)
endpoint = "cik-search/$(name)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
cik_search(fmp::FMP, name::String) = cik_search(fmp; name)
"""
company_from_cik(fmp, cik)
Returns all company names matching the specified CIK.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `cik::String`: A CIK.
See [CIK-Mapper]\
(https://site.financialmodelingprep.com/developer/docs/#Form-13F) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the company name matching the CIK
data = company_from_cik(fmp, cik = "0001067983")
```
"""
function company_from_cik(fmp::FMP; cik::String)
endpoint = "cik/$(cik)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
company_from_cik(fmp::FMP, cik::String) = company_from_cik(fmp; cik)
"""
forms_13f(fmp, cik, date)
Returns all form 13F filing matching the specified CIK and date.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `cik::String`: A CIK.
- `date::String`: A yyyy-mm-dd formatted date string.
See [Form-13F]\
(https://site.financialmodelingprep.com/developer/docs/#Form-13F) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all form 13F form for the CIK on June 30, 2022.
data = forms_13f(fmp, cik = "0001067983", date = "2022-06-30")
```
"""
function forms_13f(fmp::FMP; cik::String, date::String)
endpoint = "form-thirteen/$(cik)"
url, query = Client.make_url_v3(fmp, endpoint; date)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
forms_13f(fmp::FMP, cik::String, date::String) = forms_13f(fmp; cik, date)
forms_13f(fmp::FMP, cik::String; date::String) = forms_13f(fmp; cik, date)
"""
filing_dates(fmp, cik)
Returns all form 13F filing dates matching the specified CIK.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `cik::String`: A CIK.
See [Form-13F-Filing-Dates]\
(https://site.financialmodelingprep.com/developer/docs/#Form-13F) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all form 13F filing dates matching the CIK
data = filing_dates(fmp, cik = "0001067983")
```
"""
function filing_dates(fmp::FMP; cik::String)
endpoint = "form-thirteen-date/$(cik)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_object(response)
return data
end
filing_dates(fmp::FMP, cik::String) = filing_dates(fmp; cik)
"""
company_from_cusip(fmp, cusip)
Returns all companies matching the specified cusip.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- cusip::String: A cusip.
See [Cusip-Mapper]\
(https://site.financialmodelingprep.com/developer/docs/#Form-13F) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all companies matching the cusip
data = company_from_cusip(fmp, cusip = "000360206")
```
"""
function company_from_cusip(fmp::FMP; cusip::String)
endpoint = "cusip/$(cusip)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
company_from_cusip(fmp::FMP, cusip::String) = company_from_cusip(fmp; cusip)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 893 | """
historical_employee_counts(fmp, symbol)
Returns historical employee counts for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Historical-Number-of-Employees]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-Number-of-Employees) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the historical employee counts for AAPL
data = historical_employee_counts(fmp, "AAPL")
```
"""
function historical_employee_counts(fmp::FMP; symbol::String)
endpoint = "historical/employee_count"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
historical_employee_counts(fmp::FMP, symbol::String) = historical_employee_counts(fmp; symbol)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 5775 | """
mutual_fund_portfolio_dates(fmp, symbol)
mutual_fund_portfolio_dates(fmp, cik)
Returns the portfolio dates for the specified mutual fund.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `cik::String`: A CIK.
See [Historical-Mutual-Fund-Holdings-Available-Dates]\
(https://site.financialmodelingprep.com/developer/docs/#historical-mutual-fund-holdings-available-dates) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the portfolio dates for VTSAX
data = mutual_fund_portfolio_dates(fmp, "VTSAX")
# get the portfolio dates for VEXPX
data = mutual_fund_portfolio_dates(fmp, cik = "0000034066")
```
"""
function mutual_fund_portfolio_dates(fmp::FMP; symbol = nothing, cik = nothing)
endpoint = "mutual-fund-holdings/portfolio-date"
if isnothing(cik)
url, query = Client.make_url_v4(fmp, endpoint; symbol)
else
url, query = Client.make_url_v4(fmp, endpoint; cik)
end
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
mutual_fund_portfolio_dates(fmp::FMP, symbol::String) = mutual_fund_portfolio_dates(fmp; symbol)
"""
mutual_fund_portfolio(fmp, symbol, params...)
mutual_fund_portfolio(fmp, cik, params...)
Returns the portfolio for the specified mutual fund.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `cik::String`: A CIK.
- `params...`: Additional keyword query params.
See [Historical-Mutual-Fund-Holdings-Portfolio]\
(https://site.financialmodelingprep.com/developer/docs/#historical-mutual-fund-holdings-portfolio) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the portfolio for VTSAX at the end of 2021
data = mutual_fund_portfolio(fmp, "VTSAX", date = "2021-12-31")
# get the portfolio for VEXPX at the end of 2021
data = mutual_fund_portfolio(fmp, cik = "0000034066", date = "2021-12-31")
```
"""
function mutual_fund_portfolio(fmp::FMP; symbol = nothing, cik = nothing, params...)
endpoint = "mutual-fund-holdings"
if isnothing(cik)
url, query = Client.make_url_v4(fmp, endpoint; symbol, params...)
else
url, query = Client.make_url_v4(fmp, endpoint; cik, params...)
end
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
mutual_fund_portfolio(fmp::FMP, symbol::String; params...) = mutual_fund_portfolio(fmp; symbol, params...)
"""
mutual_fund_search(fmp, name)
Returns all mutual funds matching the specified name.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `name::String`: An institution name.
See [Mutual-Fund-Holdings-Search]\
(https://site.financialmodelingprep.com/developer/docs/#Mutual-fund-holdings-search) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all mutual funds from Vanguard
data = mutual_fund_search(fmp, name = "Vanguard")
```
"""
function mutual_fund_search(fmp::FMP; name::String)
endpoint = "mutual-fund-holdings/name"
url, query = Client.make_url_v4(fmp, endpoint; name)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
mutual_fund_search(fmp::FMP, name::String) = mutual_fund_search(fmp; name)
"""
etf_portfolio_dates(fmp, symbol)
etf_portfolio_dates(fmp, cik)
Returns the portfolio dates for the specified ETF.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `cik::String`: A CIK.
See [Historical-Mutual-Fund-Holdings-Available-Dates]\
(https://site.financialmodelingprep.com/developer/docs/#historical-mutual-fund-holdings-available-dates) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the portfolio dates for VOO
data = etf_portfolio_dates(fmp, "VOO")
# get the portfolio dates for DLR
data = etf_portfolio_dates(fmp, cik = "0000036405")
```
"""
function etf_portfolio_dates(fmp::FMP; symbol = nothing, cik = nothing)
endpoint = "etf-holdings/portfolio-date"
if isnothing(cik)
url, query = Client.make_url_v4(fmp, endpoint; symbol)
else
url, query = Client.make_url_v4(fmp, endpoint; cik)
end
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
etf_portfolio_dates(fmp::FMP, symbol::String) = etf_portfolio_dates(fmp; symbol)
"""
etf_portfolio(fmp, symbol, params...)
etf_portfolio(fmp, cik, params...)
Returns the portfolio for the specified ETF.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `cik::String`: A CIK.
- `params...`: Additional keyword query params.
See [Historical-Mutual-Fund-Holdings-Portfolio]\
(https://site.financialmodelingprep.com/developer/docs/#historical-mutual-fund-holdings-portfolio) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the portfolio for VOO at the end of 2021
data = etf_portfolio(fmp, "VOO", date = "2021-12-31")
# get the portfolio for DLR at the end of 2021
data = etf_portfolio(fmp, cik = "0000036405", date = "2021-12-31")
```
"""
function etf_portfolio(fmp::FMP; symbol = nothing, cik = nothing, params...)
endpoint = "etf-holdings"
if isnothing(cik)
url, query = Client.make_url_v4(fmp, endpoint; symbol, params...)
else
url, query = Client.make_url_v4(fmp, endpoint; cik, params...)
end
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
etf_portfolio(fmp::FMP, symbol::String; params...) = etf_portfolio(fmp; symbol, params...)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 881 | """
beneficial_ownership(fmp, symbol)
Returns beneficial ownership for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Individual-Beneficial-Ownership]\
(https://site.financialmodelingprep.com/developer/docs/#Individual-Beneficial-Ownership) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the beneficial ownership for AAPL
data = beneficial_ownership(fmp, "AAPL")
```
"""
function beneficial_ownership(fmp::FMP; symbol::String)
endpoint = "insider/ownership/acquisition_of_beneficial_ownership"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
beneficial_ownership(fmp::FMP, symbol::String) = beneficial_ownership(fmp; symbol)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 7183 | """
insider_trading_types(fmp)
Returns insider trading transaction types.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Insider-Trading]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the types of insider trading events
data = insider_trading_types(fmp)
```
"""
function insider_trading_types(fmp::FMP)
endpoint = "insider-trading-transaction-type"
url, query = Client.make_url_v4(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
insider_trades(fmp, params...)
Returns insider trades.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Insider-Trading]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the most recent insider purchases and sales
data = insider_trades(fmp, transactionType = ["P-Purchase", "S-Sale"], page = 0)
# get the most recent insider trades for AAPL
data = insider_trades(fmp, symbol = "AAPL", page = 0)
```
"""
function insider_trades(fmp::FMP; params...)
endpoint = "insider-trading"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
insider_trades_feed(fmp, params...)
Returns insider trades from the RSS feed.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Insider-Trading-RSS-Feed]\
(https://site.financialmodelingprep.com/developer/docs/#Insider-Trading-RSS-Feed) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the most recent insider trades from the feed
data = insider_trades_feed(fmp, page = 0)
```
"""
function insider_trades_feed(fmp::FMP; params...)
endpoint = "insider-trading-rss-feed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
insiders_list(fmp, params...)
Returns all insider names and their CIKs matching the specified parameters.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [CIK-Mapper]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all insider names and their CIKs from page 3
data = insiders_list(fmp, page = 3)
```
"""
function insiders_list(fmp::FMP; params...)
endpoint = "mapper-cik-name"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
cik_from_insider(fmp, name)
Returns all CIKs matching the specified insider name.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `name::String`: A name.
See [CIK-Mapper]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all CIKs matching "zuckerberg mark"
data = cik_from_insider(fmp, "zuckerberg%20mark")
```
"""
function cik_from_insider(fmp::FMP; name::String)
endpoint = "mapper-cik-name"
url, query = Client.make_url_v4(fmp, endpoint; name)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
cik_from_insider(fmp::FMP, name::String) = cik_from_insider(fmp; name)
"""
cik_from_symbol(fmp, symbol)
Returns all CIKs matching the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [CIK-Mapper]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the CIK for AAPL
data = cik_from_symbol(fmp, "AAPL")
```
"""
function cik_from_symbol(fmp::FMP; symbol::String)
endpoint = "mapper-cik-company/$(symbol)"
url, query = Client.make_url_v4(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
cik_from_symbol(fmp::FMP, symbol::String) = cik_from_symbol(fmp; symbol)
"""
insider_roster(fmp, symbol)
Returns a JSON table with the insider roster for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Insider-Roster]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the insider roster for AAPL
data = insider_roster(fmp, "AAPL")
```
"""
function insider_roster(fmp::FMP; symbol::String)
endpoint = "insider-roaster"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
insider_roster(fmp::FMP, symbol::String) = insider_roster(fmp; symbol)
"""
insider_roster_statistics(fmp, symbol)
Returns insider roster statistics for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Insider-Roster-Statistics]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the insider roster statistics for AAPL
data = insider_roster_statistics(fmp, "AAPL")
```
"""
function insider_roster_statistics(fmp::FMP; symbol::String)
endpoint = "insider-roaster-statistics"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
insider_roster_statistics(fmp::FMP, symbol::String) = insider_roster_statistics(fmp; symbol)
"""
fails_to_deliver(fmp, symbol, params)
Returns fails to deliver for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Fails-to-Deliver]\
(https://site.financialmodelingprep.com/developer/docs/#Fail-to-deliver) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of fails to deliver for AAPL
data = fails_to_deliver(fmp, "AAPL", page = 0)
```
"""
function fails_to_deliver(fmp::FMP; symbol::String, params...)
endpoint = "fails_to_deliver"
url, query = Client.make_url_v4(fmp, endpoint; symbol, params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
fails_to_deliver(fmp::FMP, symbol::String; params...) = fails_to_deliver(fmp; symbol, params...)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 9183 | """
institutional_positions(fmp, symbol, params...)
Returns institutional positions for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Institutional-Stock-Ownership]\
(https://site.financialmodelingprep.com/developer/docs/#Institutional-Stock-Ownership) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the institutional positions for AAPL including the current quarter
data = institutional_positions(fmp, "AAPL", includeCurrentQuarter = true)
```
"""
function institutional_positions(fmp::FMP; symbol::String, params...)
endpoint = "institutional-ownership/symbol-ownership"
url, query = Client.make_url_v4(fmp, endpoint; symbol, params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
institutional_positions(fmp::FMP, symbol::String; params...) = institutional_positions(fmp; symbol, params...)
"""
institutional_ownership_percentages(fmp, symbol, params...)
Returns institutional ownership percentages for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Stock-Ownership-by-Holders]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Ownership-by-Holders) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the institutional ownership percentages for AAPL in Q3 of 2021
data = institutional_ownership_percentages(fmp, "AAPL", date = "2021-09-30")
```
"""
function institutional_ownership_percentages(fmp::FMP; symbol::String, params...)
endpoint = "institutional-ownership/institutional-holders/symbol-ownership-percent"
url, query = Client.make_url_v4(fmp, endpoint; symbol, params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
institutional_ownership_percentages(fmp::FMP, symbol::String; params...) = institutional_ownership_percentages(fmp; symbol, params...)
"""
institutional_ownership_weightings(fmp, symbol, params...)
Returns institutional ownership weightings for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Institutional-Stock-by-Shares-Held-and-Date]\
(https://site.financialmodelingprep.com/developer/docs/#Institutional-Ownership-by-Shares-Held-and-Date) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the institutional ownership weightings for AAPL in Q3 of 2021
data = institutional_ownership_weightings(fmp, "AAPL", date = "2021-09-30")
```
"""
function institutional_ownership_weightings(fmp::FMP; symbol::String, params...)
endpoint = "institutional-ownership/institutional-holders/symbol-ownership"
url, query = Client.make_url_v4(fmp, endpoint; symbol, params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
institutional_ownership_weightings(fmp::FMP, symbol::String; params...) = institutional_ownership_weightings(fmp; symbol, params...)
"""
institutional_ownership_feed(fmp, params...)
Returns institutional ownership from the RSS feed.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Institutional-Holder-Rss-Feed]\
(https://site.financialmodelingprep.com/developer/docs/#Institutional-Holder-Rss-Feed) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of results from the RSS feed
data = institutional_ownership_feed(fmp, page = 0)
```
"""
function institutional_ownership_feed(fmp::FMP; params...)
endpoint = "institutional-ownership/rss-feed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
institution_search(fmp, name)
Returns all CIKs matching the specified institution name.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `name::String`: An institution name.
See [Institutional-Holders-Search]\
(https://site.financialmodelingprep.com/developer/docs/#Institutional-Holders-Search) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the CIKs for Berkshire Hathaway
data = institution_search(fmp, name = "Berkshire%20Hathaway%20Inc")
```
"""
function institution_search(fmp::FMP; name::String)
endpoint = "institutional-ownership/name"
url, query = Client.make_url_v4(fmp, endpoint; name)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
institution_search(fmp::FMP, name::String) = institution_search(fmp; name)
"""
institution_portfolio_dates(fmp, cik)
Returns the portfolio dates for the specified institution.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `cik::String`: A CIK.
See [Institutional-Holders-Available-Date]\
(https://site.financialmodelingprep.com/developer/docs/#Institutional-Holders-Available-Date) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the portfolio dates for Berkshire Hathaway
data = institution_portfolio_dates(fmp, cik = "0001067983")
```
"""
function institution_portfolio_dates(fmp::FMP; cik::String)
endpoint = "institutional-ownership/portfolio-date"
url, query = Client.make_url_v4(fmp, endpoint; cik)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
institution_portfolio_dates(fmp::FMP, cik::String) = institution_portfolio_dates(fmp; cik)
"""
institution_portfolio_summary(fmp, cik)
Returns the portfolio summary for the specified institution.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `cik::String`: A CIK.
See [Institutional-Holdings-Portfolio-Positions-Summary]\
(https://site.financialmodelingprep.com/developer/docs/#Institutional-Holdings-Portfolio-Positions-Summary) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the portfolio summary for Berkshire Hathaway
data = institution_portfolio_summary(fmp, cik = "0001067983")
```
"""
function institution_portfolio_summary(fmp::FMP; cik::String)
endpoint = "institutional-ownership/portfolio-holdings-summary"
url, query = Client.make_url_v4(fmp, endpoint; cik)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
institution_portfolio_summary(fmp::FMP, cik::String) = institution_portfolio_summary(fmp; cik)
"""
institution_portfolio_industry_summary(fmp, cik, params...)
Returns the portfolio industry summary for the specified institution.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `cik::String`: A CIK.
- `params...`: Additional keyword query params.
See [Institutional-Holdings-Portfolio-Industry-Summary]\
(https://site.financialmodelingprep.com/developer/docs/#Institutional-Holdings-Portfolio-Industry-Summary) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the portfolio industry summary for Berkshire Hathaway in Q3 of 2021
data = institution_portfolio_industry_summary(fmp, cik = "0001067983", date = "2021-09-30")
```
"""
function institution_portfolio_industry_summary(fmp::FMP; cik::String, params...)
endpoint = "institutional-ownership/industry/portfolio-holdings-summary"
url, query = Client.make_url_v4(fmp, endpoint; cik, params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
institution_portfolio_industry_summary(fmp::FMP, cik::String; params...) = institution_portfolio_industry_summary(fmp; cik, params...)
"""
institution_portfolio_composition(fmp, cik, params...)
Returns the portfolio composition for the specified institution.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `cik::String`: A CIK.
- `params...`: Additional keyword query params.
See [Institutional-Holdings-Portfolio-Composition]\
(https://site.financialmodelingprep.com/developer/docs/#Institutional-Holdings-Portfolio-composition) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the portfolio composition for Berkshire Hathaway in Q3 of 2021
data = institution_portfolio_composition(fmp, cik = "0001067983", date = "2021-09-30")
```
"""
function institution_portfolio_composition(fmp::FMP; cik::String, params...)
endpoint = "institutional-ownership/industry/portfolio-holdings"
url, query = Client.make_url_v4(fmp, endpoint; cik, params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
institution_portfolio_composition(fmp::FMP, cik::String; params...) = institution_portfolio_composition(fmp; cik, params...)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 3339 | """
available_indexes(fmp)
Returns all available indexes.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Available-Indexes]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-stock-index-prices) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all available indexes
data = available_indexes(fmp)
```
"""
function available_indexes(fmp::FMP)
endpoint = "symbol/index"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
sp500_companies(fmp, historical = false)
Returns all S&P 500 companies.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `historical::Bool`: Return historical or current companies.
See [List-of-S&P-500-Companies]\
(https://site.financialmodelingprep.com/developer/docs/#List-of-S&P-500-companies) for more details.\\
See [Historical-S&P-500-Companies]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-S&P-500) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all historical S&P 500 companies
data = sp500_companies(fmp, historical = true)
```
"""
function sp500_companies(fmp::FMP; historical::Bool = false)
endpoint = ("historical/" ^ historical) * "sp500_constituent"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
nasdaq_companies(fmp, historical = false)
Returns all Nasdaq companies.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `historical::Bool`: Return historical or current companies.
See [List-of-Nasdaq-100-Companies]\
(https://site.financialmodelingprep.com/developer/docs/#List-of-Nasdaq-100-companies) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all historical Nasdaq 100 companies
data = nasdaq_companies(fmp, historical = true)
```
"""
function nasdaq_companies(fmp::FMP; historical::Bool = false)
endpoint = ("historical/" ^ historical) * "nasdaq_constituent"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
dowjones_companies(fmp, historical = false)
Returns all Dow Jones companies.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `historical::Bool`: Return historical or current companies.
See [List-of-Dow-Jones-Companies]\
(https://site.financialmodelingprep.com/developer/docs/#List-of-Dow-Jones-companies) for more details.\\
See [Historical-Dow-Jones-Companies]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-Dow-Jones) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all historical Dow Jones companies
data = dowjones_companies(fmp, historical = true)
```
"""
function dowjones_companies(fmp::FMP; historical::Bool = false)
endpoint = ("historical/" ^ historical) * "dowjones_constituent"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 4722 | """
sector_pe_ratios(fmp, params...)
Returns sector pe ratios.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Sectors-PE-Ratio]\
(https://site.financialmodelingprep.com/developer/docs/#Sectors-PE-Ratio) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the sector PE ratios of the NYSE on Jan 1, 2023
data = sector_pe_ratios(fmp, date = "2023-01-01", exchange = "NYSE")
```
"""
function sector_pe_ratios(fmp::FMP; params...)
endpoint = "sector_price_earning_ratio"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
industry_pe_ratios(fmp, params...)
Returns industry pe ratios.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Industries-PE-Ratio]\
(https://site.financialmodelingprep.com/developer/docs/#Industries-PE-Ratio) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the industry PE ratios of the NYSE on Jan 1, 2023
data = industry_pe_ratios(fmp, date = "2023-01-01", exchange = "NYSE")
```
"""
function industry_pe_ratios(fmp::FMP; params...)
endpoint = "industry_price_earning_ratio"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
sector_performances(fmp)
Returns sector performances.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Sectors-Performance]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Market-Sectors-Performance) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the sector performances
data = sector_performances(fmp)
```
"""
function sector_performances(fmp::FMP)
endpoint = "sector-performance"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
historical_sector_performances(fmp, params...)
Returns historical sector perfromances.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Sectors-Performance]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Market-Sectors-Performance) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the 10 most recent historical sector performances
data = historical_sector_performances(fmp, limit = 10)
```
"""
function historical_sector_performances(fmp::FMP; params...)
endpoint = "historical-sectors-performance"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
gainers(fmp)
Returns the biggest gainers.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Most-Gainer]\
(https://site.financialmodelingprep.com/developer/docs/#Most-Gainer-Stock-Companies) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the biggest gainers
data = gainers(fmp)
```
"""
function gainers(fmp::FMP)
endpoint = "gainers"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
losers(fmp)
Returns the biggest losers.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Most-Loser]\
(https://site.financialmodelingprep.com/developer/docs/#Most-Loser-Stock-Companies) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the biggest losers
data = losers(fmp)
```
"""
function losers(fmp::FMP)
endpoint = "losers"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
most_active(fmp)
Returns the most active symbols.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Most-Active]\
(https://site.financialmodelingprep.com/developer/docs/#Most-Active-Stock-Companies) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the most active symbols
data = most_active(fmp)
```
"""
function most_active(fmp::FMP)
endpoint = "actives"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 5930 | """
price_quote(fmp, symbol)
Returns a JSON table with the price quote for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A financial symbol.
See [Company-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Quote) for more details.\\
See [Index-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Most-of-the-majors-indexes-(Dow-Jones%2C-Nasdaq%2C-S&P-500)) for more details.\\
See [Euronext-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Most-of-the-EuroNext) for more details.\\
See [TSX-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Most-of-the-TSX) for more details.\\
See [Crypto-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Cryptocurrencies) for more details.\\
See [Forex-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Forex-(FX)) for more details.\\
See [Commodity-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Most-of-the-Major-Commodities-(Gold%2C-Silver%2C-Oil)) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the price quote for AAPL
data = price_quote(fmp, "AAPL")
```
"""
function price_quote(fmp::FMP; symbol::String)
endpoint = "quote/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
price_quote(fmp::FMP, symbol::String) = price_quote(fmp; symbol)
"""
price_quotes(fmp, market)
Returns a JSON table with the price quotes for the specified market.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `market::String`: A financial market.
See [Stock-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Price) for more details.\\
See [Index-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Most-of-the-majors-indexes-(Dow-Jones%2C-Nasdaq%2C-S&P-500)) for more details.\\
See [Euronext-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Most-of-the-EuroNext) for more details.\\
See [TSX-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Most-of-the-TSX) for more details.\\
See [Crypto-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Cryptocurrencies) for more details.\\
See [Forex-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Forex-(FX)) for more details.\\
See [Commodity-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Most-of-the-Major-Commodities-(Gold%2C-Silver%2C-Oil)) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the price quotes for major indexes
data = price_quote(fmp, "index")
# get the price quotes for NYSE
data = price_quote(fmp, "nyse")
# get the price quotes for TSX
data = price_quote(fmp, "euronext")
# get the price quotes for euronext
data = price_quote(fmp, "tsx")
# get the price quotes for crypto
data = price_quote(fmp, "crypto")
# get the price quotes for forex
data = price_quote(fmp, "forex")
# get the price quotes for commodity
data = price_quote(fmp, "commodity")
```
"""
function price_quotes(fmp::FMP; market::String)
endpoint = "quotes/$(market)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
price_quotes(fmp::FMP, market::String) = price_quotes(fmp; market)
"""
historical_price_quote(fmp, symbol, frequency = TIME_FREQUENCIES.daily, params...)
Returns a JSON table with the historical price quote for the specified symbol and frequency.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `frequency::String`: A time frame.
- `params...`: Additional keyword query params.
See [Historical-Stock-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Historical-Price) for more details.\\
See [Historical-Index-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-stock-index-prices) for more details.\\
See [Historical-Euronext-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-EuroNext-prices) for more details.\\
See [Historical-TSX-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-TSX-prices) for more details.\\
See [Historical-Cryptocurrencies-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-Cryptocurrencies-Price) for more details.\\
See [Historical-Forex-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-Forex-Price) for more details.\\
See [Historical-Commodities-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-commodities-prices) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the 15m historical price quote for AAPL
data = historical_price_quote(fmp, "AAPL", frequency = TIME_FREQUENCIES.minutes15)
# get the 4hr historical price quote for BTCUSD
data = historical_price_quote(fmp, "BTCUSD", frequency = TIME_FREQUENCIES.hours4)
# get the daily historical price quote time series for EURUSD
data = historical_price_quote(fmp, "EURUSD", frequency = TIME_FREQUENCIES.daily, timeseries = 5)
```
"""
function historical_price_quote(fmp::FMP; symbol::String, frequency::String = TIME_FREQUENCIES.daily, params...)
if frequency == TIME_FREQUENCIES.daily
endpoint = "historical-price-full/$(symbol)"
else
endpoint = "historical-chart/$(frequency)/$(symbol)"
end
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response, :historical)
return data
end
historical_price_quote(fmp::FMP, symbol::String; frequency::String = TIME_FREQUENCIES.daily, params...) = historical_price_quote(fmp; symbol, frequency, params...)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 4987 | """
price_targets(fmp, symbol)
Returns price targets for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Price-Target]\
(https://site.financialmodelingprep.com/developer/docs/#Price-Target) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the price targets for AAPL
data = price_targets(fmp, "AAPL")
```
"""
function price_targets(fmp::FMP; symbol::String)
endpoint = "price-target"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
price_targets(fmp::FMP, symbol::String) = price_targets(fmp; symbol)
"""
price_targets_by_analyst(fmp, name)
Returns price targets from the specified name.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `name::String`: An analyst name.
See [Price-Target-by-Analyst-Name]\
(https://site.financialmodelingprep.com/developer/docs/#Price-Target-By-Analyst-Name) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the price targets from Tim Anderson
data = price_targets_by_analyst(fmp, name = "Tim%20Anderson")
```
"""
function price_targets_by_analyst(fmp::FMP; name::String)
endpoint = "price-target-analyst-name"
url, query = Client.make_url_v4(fmp, endpoint; name)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
price_targets_by_analyst(fmp::FMP, name::String) = price_targets_by_analyst(fmp; name)
"""
price_targets_by_company(fmp, company)
Returns price targets from the specified company.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- company::String: An analyst company name.
See [Price-Target-by-Analyst-Company]\
(https://site.financialmodelingprep.com/developer/docs/#Price-Target-by-Analyst-Company) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the price targets from Barclays
data = price_targets_by_company(fmp, company = "Barclays")
```
"""
function price_targets_by_company(fmp::FMP; company::String)
endpoint = "price-target-analyst-company"
url, query = Client.make_url_v4(fmp, endpoint; company)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
price_targets_by_company(fmp::FMP, company::String) = price_targets_by_company(fmp; company)
"""
price_targets_summary(fmp, symbol)
Returns the price targets summary for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Price-Target-Summary]\
(https://site.financialmodelingprep.com/developer/docs/#Price-target-Summary) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the price targets summary for AAPL
data = price_targets_summary(fmp, "AAPL")
```
"""
function price_targets_summary(fmp::FMP; symbol::String)
endpoint = "price-target-summary"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
price_targets_summary(fmp::FMP, symbol::String) = price_targets_summary(fmp; symbol)
"""
price_targets_consensus(fmp, symbol)
Returns the price targets consensus for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Price-Target-Consensus]\
(https://site.financialmodelingprep.com/developer/docs/#Price-Target-Consensus) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the price targets consensus for AAPL
data = price_target_consensus(fmp, "AAPL")
```
"""
function price_targets_consensus(fmp::FMP; symbol::String)
endpoint = "price-target-consensus"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
price_targets_consensus(fmp::FMP, symbol::String) = price_targets_consensus(fmp; symbol)
"""
price_targets_feed(fmp, params...)
Returns a JSON table containing the price targets feed results.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Price-Target-RSS-Feed]\
(https://site.financialmodelingprep.com/developer/docs/#Price-Target-RSS-Feed) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page from the price target feed
data = price_targets_feed(fmp, page = 0)
```
"""
function price_targets_feed(fmp::FMP; params...)
endpoint = "price-target-rss-feed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 5109 | """
crowdfunding_offerings_feed(fmp, params...)
Returns crowdfunding offerings from the RSS feed.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Crowdfunding-Offerings-Rss-Feed]\
(https://site.financialmodelingprep.com/developer/docs/#Crowdfunding-Offerings-Rss-feed) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of results from the RSS feed
data = crowdfunding_offerings_feed(fmp, page = 0)
```
"""
function crowdfunding_offerings_feed(fmp::FMP; params...)
endpoint = "crowdfunding-offerings-rss-feed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
crowdfunding_offerings_search(fmp, name)
Returns crowfunding offering dates for the specified name.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `name::String`: A company name.
See [Crowdfunding-Offerings-Company-Search]\
(https://site.financialmodelingprep.com/developer/docs/#Crowdfunding-Offerings-Company-Search) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the crowdfunding offering dates for Enotap
data = crowdfunding_offerings_search(fmp, name = "Enotap")
```
"""
function crowdfunding_offerings_search(fmp::FMP; name::String)
endpoint = "crowdfunding-offerings/search"
url, query = Client.make_url_v4(fmp, endpoint; name)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
crowdfunding_offerings_search(fmp::FMP, name::String) = crowdfunding_offerings_search(fmp; name)
"""
crowdfunding_offerings(fmp, cik)
Returns the crowdfunding offerings for the specified CIK.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `cik::String`: A CIK.
See [Crowdfunding-Offerings-by-CIK]\
(https://site.financialmodelingprep.com/developer/docs/#Crowdfunding-Offerings-by-CIK) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the crowdfundings offerings for OYO Fitness
data = crowdfunding_offerings(fmp, cik = "0001916078")
```
"""
function crowdfunding_offerings(fmp::FMP; cik::String)
endpoint = "crowdfunding-offerings"
url, query = Client.make_url_v4(fmp, endpoint; cik)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
crowdfunding_offerings(fmp::FMP, cik::String) = crowdfunding_offerings(fmp; cik)
"""
equity_offerings_feed(fmp, params...)
Returns equity offerings from the RSS feed.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Equity-Offerings-Fundraising-Rss-feed]\
(https://site.financialmodelingprep.com/developer/docs/#Equity-offerings-Fundraising-Rss-feed) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of results from the RSS feed
data = equity_offerings_feed(fmp, page = 0)
```
"""
function equity_offerings_feed(fmp::FMP; params...)
endpoint = "fundraising-rss-feed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
equity_offerings_search(fmp, name)
Returns equity offering dates for the specified name.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `name::String`: A company name.
See [Equity-Offerings-Fundraising-Company-Search]\
(https://site.financialmodelingprep.com/developer/docs/#Equity-offerings-Fundraising-Company-Search) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the equity offering dates for Marinalife
data = equity_offerings_search(fmp, name = "Marinalife")
```
"""
function equity_offerings_search(fmp::FMP; name::String)
endpoint = "fundraising/search"
url, query = Client.make_url_v4(fmp, endpoint; name)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
equity_offerings_search(fmp::FMP, name::String) = equity_offerings_search(fmp; name)
"""
equity_offerings(fmp, cik)
Returns the crowdfunding offerings for the specified CIK.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `cik::String`: A CIK.
See [Equity-Offerings-Fundraising-by-CIK]\
(https://site.financialmodelingprep.com/developer/docs/#Equity-offerings-Fundraising-by-CIK) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the equity offerings for Marinalife
data = equity_offerings(fmp, cik = "0001870523")
```
"""
function equity_offerings(fmp::FMP; cik::String)
endpoint = "fundraising"
url, query = Client.make_url_v4(fmp, endpoint, cik = cik)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
equity_offerings(fmp::FMP, cik::String) = equity_offerings(fmp; cik)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 3096 | """
senate_trades(fmp, symbol)
Returns senate trades for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Senate-Trading]\
(https://site.financialmodelingprep.com/developer/docs/#Senate-trading) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get senate trades for AAPL
data = senate_trades(fmp, "AAPL")
```
"""
function senate_trades(fmp::FMP; symbol::String)
endpoint = "senate-trading"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
senate_trades(fmp::FMP, symbol::String) = senate_trades(fmp; symbol)
"""
senate_trades_feed(fmp, params...)
Returns senate trades from the RSS feed.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Senate-Trading-RSS-Feed]\
(https://site.financialmodelingprep.com/developer/docs/#Senate-trading) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of senate trades from the RSS feed
data = senate_trades_feed(fmp, page = 0)
```
"""
function senate_trades_feed(fmp::FMP; params...)
endpoint = "senate-trading-rss-feed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
senate_disclosures(fmp, symbol)
Returns senate disclosures for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Senate-Disclosure]\
(https://site.financialmodelingprep.com/developer/docs/#Senate-disclosure) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get senate disclosures for AAPL
data = senate_disclosures(fmp, "AAPL")
```
"""
function senate_disclosures(fmp::FMP; symbol::String)
endpoint = "senate-disclosure"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
senate_disclosures(fmp::FMP, symbol::String) = senate_disclosures(fmp; symbol)
"""
senate_disclosure_feed(fmp, params...)
Returns senate disclosures from the RSS feed.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Senate-Disclosure-RSS-Feed]\
(https://site.financialmodelingprep.com/developer/docs/#Senate-disclosure) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of senate disclosures from the RSS feed
data = senate_disclosure_feed(fmp, page = 0)
```
"""
function senate_disclosure_feed(fmp::FMP; params...)
endpoint = "senate-disclosure-rss-feed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 8110 | """
earnings_calendar(fmp, params...)
Returns earnings calendar events.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Earnings-Calendar]\
(https://site.financialmodelingprep.com/developer/docs/#Earnings-Calendar) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the earnings calendar events for Q1 2022
data = earnings_calendar(fmp, from = "2022-01-01", to = "2022-03-31")
```
"""
function earnings_calendar(fmp::FMP; params...)
endpoint = "earning_calendar"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
historical_earnings_calendar(fmp, symbol, params...)
Returns historical earnings calendar events.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Earnings-Calendar]\
(https://site.financialmodelingprep.com/developer/docs/#Earnings-Calendar) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last 50 earnings calendar events for AAPL
data = historical_earnings_calendar(fmp, "AAPL", limit = 50)
```
"""
function historical_earnings_calendar(fmp::FMP; symbol::String, params...)
endpoint = "historical/earning_calendar/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
historical_earnings_calendar(fmp::FMP, symbol::String; params...) = historical_earnings_calendar(fmp; symbol, params...)
"""
earnings_calendar_confirmed(fmp, params...)
Returns the confirmed earnings calendar events.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Earnings-Calendar-Confirmed]\
(https://site.financialmodelingprep.com/developer/docs/#Earnings-Calendar-Confirmed) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the confirmed earnings calendar events for Q1 2022
data = earnings_calendar_confirmed(fmp, from = "2022-01-01", to = "2022-03-31")
```
"""
function earnings_calendar_confirmed(fmp::FMP; params...)
endpoint = "earning-calendar-confirmed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
ipo_calendar(fmp, params...)
Returns the ipo calendar events.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [IPO-Calendar]\
(https://site.financialmodelingprep.com/developer/docs/#IPO-Calendar) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the ipo calendar events for Q1 2022
data = ipo_calendar(fmp, from = "2022-01-01", to = "2022-03-31")
```
"""
function ipo_calendar(fmp::FMP; params...)
endpoint = "ipo_calendar"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
ipo_calendar_prospectus(fmp, params...)
Returns the ipo calendar events with prospectus.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [IPO-Calendar-with-Prospectus]\
(https://site.financialmodelingprep.com/developer/docs/#IPO-calendar-with-prospectus) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the ipo calendar events with prospectus for Q1 2022
data = ipo_calendar_prospectus(fmp, from = "2022-01-01", to = "2022-03-31")
```
"""
function ipo_calendar_prospectus(fmp::FMP; params...)
endpoint = "ipo-calendar-prospectus"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
ipo_calendar_confirmed(fmp, params...)
Returns the confirmed ipo calendar events.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [IPO-Calendar-Confirmed]\
(https://site.financialmodelingprep.com/developer/docs/#IPO-calendar-Confirmed) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the confirmed ipo calendar events for Q1 2022
data = ipo_calendar_confirmed(fmp, from = "2022-01-01", to = "2022-03-31")
```
"""
function ipo_calendar_confirmed(fmp::FMP; params...)
endpoint = "ipo-calendar-confirmed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
stock_split_calendar(fmp, params...)
Returns stock split calendar events.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Stock-Split-Calendar]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Split-Calendar) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the stock split calendar events for Q1 2022
data = stock_split_calendar(fmp, from = "2022-01-01", to = "2022-03-31")
```
"""
function stock_split_calendar(fmp::FMP; params...)
endpoint = "stock_split_calendar"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
dividend_calendar(fmp, params...)
Returns dividend calendar events.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Dividend-Calendar]\
(https://site.financialmodelingprep.com/developer/docs/#Dividend-Calendar) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the dividend calendar events for Q1 2022
data = dividend_calendar(fmp, from = "2022-01-01", to = "2022-03-31")
```
"""
function dividend_calendar(fmp::FMP; params...)
endpoint = "stock_dividend_calendar"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
historical_dividends(fmp, symbol)
Returns a JSON table historical dividends for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Historical-Dividends]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-Dividends) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last historical dividends for AAPL
data = historical_dividends(fmp, "AAPL")
```
"""
function historical_dividends(fmp::FMP; symbol::String)
endpoint = "historical-price-full/stock_dividend/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response, :historical)
return data
end
historical_dividends(fmp::FMP, symbol::String) = historical_dividends(fmp; symbol)
"""
economic_calendar(fmp, params...)
Returns economic calendar events.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Economic-Calendar]\
(https://site.financialmodelingprep.com/developer/docs/#Economic-Calendar) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the economic calendar events for Q1 2022
data = economic_calendar(fmp, from = "2022-01-01", to = "2022-03-31")
```
"""
function economic_calendar(fmp::FMP; params...)
endpoint = "economic_calendar"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 13992 | """
symbols_with_financials(fmp)
Returns a JSON array of symbols which have financial statements.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Financial-Statements-List]\
(https://site.financialmodelingprep.com/developer/docs#Financial-Statements-List) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all symbols with financials
data = symbols_with_financials(fmp)
```
"""
function symbols_with_financials(fmp::FMP)
endpoint = "financial-statement-symbol-lists"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_object(response)
return data
end
"""
income_statements(fmp, symbol, reported = false, params...)
Returns income statements for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `reported::Bool`: Return the reported or normalized statements.
- `params...`: Additional keyword query params.
See [Income-Statements]\
(https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements) for more details.\\
See [Income-Statements-As-Reported]\
(https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements-As-Reported) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last 10 quarterly statments for AAPL
data = income_statements(fmp, "AAPL", period = "quarter", limit = 10)
# get the last 5 annual statements as reported for AAPL
data = income_statements(fmp, "AAPL", reported = true, limit = 5)
```
"""
function income_statements(fmp::FMP; symbol::String, reported::Bool = false, params...)
endpoint = (reported ? "income-statement-as-reported" : "income-statement") * "/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
income_statements(fmp::FMP, symbol::String; reported::Bool = false, params...) = income_statements(fmp; symbol, reported, params...)
"""
balance_sheet_statements(fmp, symbol, reported = false, params...)
Returns balance sheet statements for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `reported::Bool`: Return the reported or normalized statements.
- `params...`: Additional keyword query params.
See [Balance-Sheet-Statements]\
(https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements) for more details.\\
See [Balance-Sheet-Statements-As-Reported]\
(https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements-As-Reported) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last 10 quarterly statments for AAPL
data = balance_sheet_statements(fmp, "AAPL", period = "quarter", limit = 10)
# get the last 5 annual statements as reported for AAPL
data = balance_sheet_statements(fmp, "AAPL", reported = true, limit = 5)
```
"""
function balance_sheet_statements(fmp::FMP; symbol::String, reported::Bool = false, params...)
endpoint = (reported ? "balance-sheet-statement-as-reported" : "balance-sheet-statement") * "/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
balance_sheet_statements(fmp::FMP, symbol::String; reported::Bool = false, params...) = balance_sheet_statements(fmp; symbol, reported, params...)
"""
cash_flow_statements(fmp, symbol, reported = false, params...)
Returns cash flow statements for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `reported::Bool`: Return the reported or normalized statements.
- `params...`: Additional keyword query params.
See [Cash-Flow-Statements]\
(https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements) for more details.\\
See [Cash-Flow-Statements-As-Reported]\
(https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements-As-Reported) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last 10 quarterly statments for AAPL
data = cash_flow_statements(fmp, "AAPL", period = "quarter", limit = 10)
# get the last 5 annual statements as reported for AAPL
data = cash_flow_statements(fmp, "AAPL", reported = true, limit = 5)
```
"""
function cash_flow_statements(fmp::FMP; symbol::String, reported::Bool = false, params...)
endpoint = (reported ? "cash-flow-statement-as-reported" : "cash-flow-statement") * "/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
cash_flow_statements(fmp::FMP, symbol::String; reported::Bool = false, params...) = cash_flow_statements(fmp; symbol, reported, params...)
"""
financial_statements(fmp, symbol, params...)
Returns financial statements as reported for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Full-Financial-Statements-As-Reported]\
(https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements-As-Reported) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all quarterly statements as reported for AAPL
data = financial_statements(fmp, "AAPL", period = "quarter")
```
"""
function financial_statements(fmp::FMP; symbol::String, params...)
endpoint = "financial-statement-full-as-reported/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
financial_statements(fmp::FMP, symbol::String; params...) = financial_statements(fmp; symbol, params...)
"""
financial_reports(fmp, symbol, year, period = "FY")
Returns a JSON dictionary of the financial report for the specified symbol, year and period.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `year::Integer`: A calendar year.
- `period::String`: One of "FY", "Q1", "Q2", "Q3" or "Q4".
See [Annual-Reports-on-Form-10-K]\
(https://site.financialmodelingprep.com/developer/docs#Annual-Reports-on-Form-10-K) for more details.\\
See [Quarterly-Earnings-Reports]\
(https://site.financialmodelingprep.com/developer/docs/#Quarterly-Earnings-Reports) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the 10-K for AAPL in 2022
data = financial_reports(fmp, "AAPL", year = 2022)
# get the 10-Q for AAPL in Q4 of 2022
data = financial_reports(fmp, "AAPL", 2022, period = "Q4")
```
"""
function financial_reports(fmp::FMP; symbol::String, year::Integer, period::String = "FY")
endpoint = "financial-reports-json"
url, query = Client.make_url_v4(fmp, endpoint; symbol, year, period)
response = Client.make_get_request(url, query)
data = Client.parse_json_object(response)
return data
end
financial_reports(fmp::FMP, symbol::String, year::Integer; period::String = "FY") = financial_reports(fmp; symbol, year, period)
financial_reports(fmp::FMP, symbol::String; year::Integer, period::String = "FY") = financial_reports(fmp; symbol, year, period)
"""
revenue_segments(fmp, symbol, segment = REVENUE_SEGMENTS.product, params...)
Returns a JSON table with the revenue segments for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `segment::String`: A `REVENUE_SEGMENTS` option.
- `params...`: Additional keyword query params.
See [Sales-Revenue-By-Segments]\
(https://site.financialmodelingprep.com/developer/docs/#Sales-Revenue-By-Segments) for more details.\\
See [Revenue-Geographic-by-Segments]\
(https://site.financialmodelingprep.com/developer/docs/#Revenue-Geographic-by-Segments) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all yearly geographic revenue segments for AAPL
data = revenue_segments(fmp, "AAPL", segment = REVENUE_SEGMENTS.geographic, structure = "flat")
# get all quarterly product revenue segments for AAPL
data = revenue_segments(fmp, "AAPL", segment = REVENUE_SEGMENTS.product, period = "quarter", structure = "flat")
```
"""
function revenue_segments(fmp::FMP; symbol::String, segment::String = REVENUE_SEGMENTS.product, params...)
if !(segment in REVENUE_SEGMENTS)
error("Invalid frequency value. Allowed values are $(REVENUE_SEGMENTS).")
end
endpoint = "revenue-$(segment)-segmentation"
url, query = Client.make_url_v4(fmp, endpoint; symbol, params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
revenue_segments(fmp::FMP, symbol::String, segment::String; params...) = revenue_segments(fmp; symbol, segment, params...)
revenue_segments(fmp::FMP, symbol::String; segment::String = REVENUE_SEGMENTS.product, params...) = revenue_segments(fmp; symbol, segment, params...)
"""
shares_float(fmp)
shares_float(fmp, symbol)
Returns shares float statistics for one or all symbols.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol or all symbols if not provided.
See [Shares-Float]\
(https://site.financialmodelingprep.com/developer/docs/#Shares-Float) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get shares float for all symbols
data = shares_float(fmp)
# get shares float for AAPL
data = shares_float(fmp, "AAPL")
```
"""
function shares_float(fmp::FMP; symbol::String = "all")
endpoint = "shares_float"
if symbol == "all"
url, query = Client.make_url_v4(fmp, endpoint * "/$(symbol)")
else
url, query = Client.make_url_v4(fmp, endpoint; symbol)
end
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
shares_float(fmp::FMP, symbol::String) = shares_float(fmp; symbol)
"""
earnings_call_transcripts(fmp, symbol)
earnings_call_transcripts(fmp, symbol, year)
earnings_call_transcripts(fmp, symbol, year, quarter)
Returns earnings call transcripts for a specified symbols.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol or "all" if not provided.
- `year::Integer`: A calendar year.
- `quarter::Integer`: One of 1, 2, 3 or 4.
See [Earnings-Call-Transcript]\
(https://site.financialmodelingprep.com/developer/docs/#Earning-Call-Transcript) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the available transcript dates for AAPL
data = earnings_call_transcripts(fmp, "AAPL")
# get the earnings call transcript for AAPL in Q3 of 2022
data = earnings_call_transcripts(fmp, "AAPL", year = 2022, quarter = 3)
```
"""
function earnings_call_transcripts(fmp::FMP; symbol::String, year = nothing, quarter = nothing)
if isnothing(year) & isnothing(quarter)
endpoint = "earning_call_transcript"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
else
if isnothing(quarter)
endpoint = "batch_earning_call_transcript/$(symbol)"
url, query = Client.make_url_v4(fmp, endpoint; year)
else
endpoint = "earning_call_transcript/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; year, quarter)
end
end
response = Client.make_get_request(url, query)
data = Client.parse_json_object(response)
return data
end
earnings_call_transcripts(fmp::FMP, symbol::String, year::Integer, quarter::Integer) = earnings_call_transcripts(fmp; symbol, year, quarter)
earnings_call_transcripts(fmp::FMP, symbol::String, year::Integer; quarter = nothing) = earnings_call_transcripts(fmp; symbol, year, quarter)
earnings_call_transcripts(fmp::FMP, symbol::String; year = nothing, quarter = nothing) = earnings_call_transcripts(fmp; symbol, year, quarter)
"""
sec_filings(fmp, symbol, params...)
Returns sec filings for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol or "all" if not provided.
- `params...`: Additional keyword query params.
See [SEC-Filings]\
(https://site.financialmodelingprep.com/developer/docs/#SEC-Filings) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of 10-K filings for AAPL
data = sec_filings(fmp, "AAPL", type = "10-K", page = 0)
```
"""
function sec_filings(fmp::FMP; symbol::String, params...)
endpoint = "sec_filings/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
sec_filings(fmp::FMP, symbol::String; params...) = sec_filings(fmp; symbol, params...)
"""
company_notes(fmp, symbol)
Returns notes due for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Company-Notes-Due]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Notes-due) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all notes due for AAPL
data = company_notes(fmp, "AAPL")
```
"""
function company_notes(fmp::FMP; symbol::String)
endpoint = "company-notes"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
company_notes(fmp::FMP, symbol::String; params...) = company_notes(fmp; symbol, params...)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 13799 | """
financial_ratios(fmp, symbol, params...)
Returns common financial ratios for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Financial-Ratios]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Financial-Ratios) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get financial ratios for AAPL in the last 30 quarters
data = financial_ratios(fmp, "AAPL", period = "quarter", limit = 30)
```
"""
function financial_ratios(fmp::FMP; symbol::String, params...)
endpoint = "ratios/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
financial_ratios(fmp::FMP, symbol::String; params...) = financial_ratios(fmp; symbol, params...)
"""
financial_scores(fmp, symbol)
Returns common financial scores for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Financial-Scores]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Financial-scores) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get financial scores for AAPL
data = financial_scores(fmp, "AAPL")
```
"""
function financial_scores(fmp::FMP; symbol::String)
endpoint = "score"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
financial_scores(fmp::FMP, symbol::String) = financial_scores(fmp; symbol)
"""
owners_earnings(fmp, symbol)
Returns owners earnings for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Owners-Earnings]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Financial-scores) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get ownings earnings for AAPL
data = owners_earnings(fmp, "AAPL")
```
"""
function owners_earnings(fmp::FMP; symbol::String)
endpoint = "owners-earnings"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
owners_earnings(fmp::FMP, symbol::String) = owners_earnings(fmp; symbol)
"""
enterprise_values(fmp, symbol, params...)
Returns enterprise value components for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Enterprise-Value]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Enterprise-Value) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get enterprise values for AAPL in the last 30 quarters
data = enterprise_values(fmp, "AAPL", period = "quarter", limit = 30)
```
"""
function enterprise_values(fmp::FMP; symbol::String, params...)
endpoint = "enterprise-values/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
enterprise_values(fmp::FMP, symbol::String; params...) = enterprise_values(fmp; symbol, params...)
"""
income_statements_growth(fmp, symbol, params...)
Returns income statements growth for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Income-Statements-Growth]\
(https://site.financialmodelingprep.com/developer/docs/#Financial-Statements-Growth) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last 5 annual statements growth for AAPL
data = income_statements_growth(fmp, "AAPL", limit = 5)
```
"""
function income_statements_growth(fmp::FMP; symbol::String, params...)
endpoint = "income-statement-growth/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
income_statements_growth(fmp::FMP, symbol::String; params...) = income_statements_growth(fmp; symbol, params...)
"""
balance_sheet_statements_growth(fmp, symbol, params...)
Returns balance sheet statements growth for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Balance-Sheet-Statements-Growth]\
(https://site.financialmodelingprep.com/developer/docs/#Financial-Statements-Growth) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last 5 annual statements growth for AAPL
data = balance_sheet_statements_growth(fmp, "AAPL", limit = 5)
```
"""
function balance_sheet_statements_growth(fmp::FMP; symbol::String, params...)
endpoint = "balance-sheet-statement-growth/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
balance_sheet_statements_growth(fmp::FMP, symbol::String; params...) = balance_sheet_statements_growth(fmp; symbol, params...)
"""
cash_flow_statements_growth(fmp, symbol, params...)
Returns cash flow statements growth for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Cash-Flow-Statements-Growth]\
(https://site.financialmodelingprep.com/developer/docs/#Financial-Statements-Growth) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last 5 annual statements growth for AAPL
data = cash_flow_statements_growth(fmp, "AAPL", limit = 5)
```
"""
function cash_flow_statements_growth(fmp::FMP; symbol::String, params...)
endpoint = "cash-flow-statement-growth/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
cash_flow_statements_growth(fmp::FMP, symbol::String; params...) = cash_flow_statements_growth(fmp; symbol, params...)
"""
financial_statements_growth(fmp, symbol, params...)
Returns financial statements growth for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Financial-Statements-Growth]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Financial-Growth) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last 5 annual statements growth for AAPL
data = financial_statements_growth(fmp, "AAPL", limit = 5)
```
"""
function financial_statements_growth(fmp::FMP; symbol::String, params...)
endpoint = "financial-growth/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
financial_statements_growth(fmp::FMP, symbol::String; params...) = financial_statements_growth(fmp; symbol, params...)
"""
key_metrics(fmp, symbol, period, params...)
Returns key metrics for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `period::String`: A `REPORTING_PERIODS` option.
- `params...`: Additional keyword query params.
See [Key-Metrics]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Key-Metrics) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get key metrics for AAPL in the last 30 years by ttm
data = key_metrics(fmp, "AAPL", period = REPORTING_PERIODS.ttm, limit = 30)
```
"""
function key_metrics(fmp::FMP; symbol::String, period::String = REPORTING_PERIODS.annual, params...)
if !(period in REPORTING_PERIODS)
error("Invalid frequency value. Allowed values are $(REPORTING_PERIODS).")
end
endpoint = "key-metrics" * ("-$(period)" ^ (period == REPORTING_PERIODS.ttm)) * "/$(symbol)"
if period == REPORTING_PERIODS.quarter
url, query = Client.make_url_v3(fmp, endpoint; period, params...)
else
url, query = Client.make_url_v3(fmp, endpoint; params...)
end
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
key_metrics(fmp::FMP, symbol::String, period::String; params...) = key_metrics(fmp; symbol, period, params...)
key_metrics(fmp::FMP, symbol::String; period::String = REPORTING_PERIODS.annual, params...) = key_metrics(fmp; symbol, period, params...)
"""
company_rating(fmp, symbol)
Returns ratings for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Company-Rating]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Rating) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the company rating for AAPL
data = company_rating(fmp, "AAPL")
```
"""
function company_rating(fmp::FMP; symbol::String)
endpoint = "rating/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
company_rating(fmp::FMP, symbol::String) = company_rating(fmp; symbol)
"""
historical_ratings(fmp, symbol, params...)
Returns historical ratings for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Historical-Ratings]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Rating) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last 100 ratings for AAPL
data = historical_ratings(fmp, "AAPL", limit = 100)
```
"""
function historical_ratings(fmp::FMP; symbol::String, params...)
endpoint = "historical-rating/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
historical_ratings(fmp::FMP, symbol::String; params...) = historical_ratings(fmp; symbol, params...)
"""
discounted_cash_flows(fmp, symbol)
Returns discounted cash flows for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Discounted-Cash-Flow]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Discounted-cash-flow-value) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the dcf for AAPL
data = discounted_cash_flows(fmp, "AAPL")
```
"""
function discounted_cash_flows(fmp::FMP; symbol::String)
endpoint = "discounted-cash-flow/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
discounted_cash_flows(fmp::FMP, symbol::String) = discounted_cash_flows(fmp; symbol)
"""
advanced_discounted_cash_flows(fmp, symbol, levered = false)
Returns advaned discounted cash flows for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `levered::Bool`: Return the levered dcf with including WACC.
See [Discounted-Cash-Flow]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Discounted-cash-flow-value) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the levered dcf for AAPL with WACC
data = advanced_discounted_cash_flows(fmp, "AAPL", levered = true)
```
"""
function advanced_discounted_cash_flows(fmp::FMP; symbol::String, levered::Bool = false)
if levered
endpoint = "advanced_levered_discounted_cash_flow"
else
endpoint = "advanced_discounted_cash_flow"
end
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
advanced_discounted_cash_flows(fmp::FMP, symbol::String; levered::Bool = false) = advanced_discounted_cash_flows(fmp; symbol, levered)
"""
historical_discounted_cash_flows(fmp, symbol, params...)
Returns historical discounted cash flows for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Historical-Discounted-Cash-Flow]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Discounted-cash-flow-value) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the dcf for in the last 30 quarters AAPL
data = historical_discounted_cash_flows(fmp, "AAPL", period = "quarter", limit = 30)
```
"""
function historical_discounted_cash_flows(fmp::FMP; symbol::String, params...)
endpoint = "historical-discounted-cash-flow/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
historical_discounted_cash_flows(fmp::FMP, symbol::String; params...) = historical_discounted_cash_flows(fmp; symbol, params...)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 1852 | """
available_symbols(fmp)
Returns all available symbols in the API.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Symbols-List]\
(https://site.financialmodelingprep.com/developer/docs/#Symbols-List) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all available symbols
data = available_symbols(fmp)
```
"""
function available_symbols(fmp::FMP)
endpoint = "stock/list"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
tradeable_symbols(fmp)
Returns all tradeable symbols in the API.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Tradeable-Symbols-List]\
(https://site.financialmodelingprep.com/developer/docs/#Tradable-Symbols-List) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all available symbols
data = tradeable_symbols(fmp)
```
"""
function tradeable_symbols(fmp::FMP)
endpoint = "available-traded/list"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
etf_symbols(fmp)
Returns all tradeable symbols in the API.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [ETF-Symbols]\
(https://site.financialmodelingprep.com/developer/docs/#ETF-List) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all etf symbols
data = etf_symbols(fmp)
```
"""
function etf_symbols(fmp::FMP)
endpoint = "etf/list"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 5133 | """
fmp_articles(fmp, params...)
Returns a JSON object of fmp articles.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [FMP-Articles]\
(https://site.financialmodelingprep.com/developer/docs/#FMP-Articles) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get fmp articles from page 0 and size 5
data = fmp_articles(fmp, page = 0, size = 5)
```
"""
function fmp_articles(fmp::FMP; params...)
endpoint = "fmp/articles"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_object(response)
return data
end
"""
stock_news(fmp, params...)
Returns stock news articles.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Stock-News]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-News) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the latest 50 stock news for AAPL and FB
data = stock_news(fmp, tickers = "AAPL,FB", limit = 50)
```
"""
function stock_news(fmp::FMP; params...)
endpoint = "stock_news"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
stock_news_sentiment_feed(fmp, params...)
Returns stock news article sentiment.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Stock-Sentiment]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-News) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of stock news article sentiment
data = stock_news_sentiment_feed(fmp, page = 0)
```
"""
function stock_news_sentiment_feed(fmp::FMP; params...)
endpoint = "stock-news-setniments-rss-feed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
crypto_news(fmp, params...)
Returns crypto news articles.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Crypto-News]\
(https://site.financialmodelingprep.com/developer/docs/#Crypto-news) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of news for BTCUSD
data = crypto_news(fmp, symbol = "BTCUSD", page = 0)
```
"""
function crypto_news(fmp::FMP; params...)
endpoint = "crypto_news"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
forex_news(fmp, params...)
Returns forex news articles.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Forex-News]\
(https://site.financialmodelingprep.com/developer/docs/#Forex-news) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of news for EURUSD
data = forex_news(fmp, symbol = "EURUSD", page = 0)
```
"""
function forex_news(fmp::FMP; params...)
endpoint = "forex_news"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
general_news(fmp, params...)
Returns general news articles.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [General-News]\
(https://site.financialmodelingprep.com/developer/docs/#General-news) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of general news
data = general_news(fmp, page = 0)
```
"""
function general_news(fmp::FMP; params...)
endpoint = "general_news"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
press_releases(fmp, symbol, params...)
Returns stock press releases.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Press-Releases]\
(https://site.financialmodelingprep.com/developer/docs/#Press-Releases) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get first page of press releases from AAPL
data = press_releases(fmp, symbol = "AAPL", page = 0)
```
"""
function press_releases(fmp::FMP; symbol::String, params...)
endpoint = "press-releases/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
press_releases(fmp::FMP, symbol::String; params...) = press_releases(fmp; symbol, params...)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 5260 | """
otc_quote(fmp, symbol)
Returns the price quote for the specified symbol(s).
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [OTC-Quote]\
(https://site.financialmodelingprep.com/developer/docs/#Company-Quote) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the otc quote for GBTC
data = otc_quote(fmp, "GBTC")
```
"""
function otc_quote(fmp::FMP; symbol::String)
endpoint = "otc/real-time-price/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
otc_quote(fmp::FMP, symbol::String) = otc_quote(fmp; symbol)
"""
price_change(fmp, symbol)
Returns the price change for the specified symbol(s).
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Price-Change]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-price-change) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the price change for AAPL
data = price_change(fmp, "AAPL")
```
"""
function price_change(fmp::FMP; symbol::String)
endpoint = "stock-price-change/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
price_change(fmp::FMP, symbol::String) = price_change(fmp; symbol)
"""
historical_splits(fmp, symbol)
Returns the historical stock splits for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Historical-Stock-Splits]\
(https://site.financialmodelingprep.com/developer/docs/#Historical-Stock-Splits) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the historical splits for AAPL
data = historical_splits(fmp, "AAPL")
```
"""
function historical_splits(fmp::FMP; symbol::String)
endpoint = "historical-price-full/stock_split/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response, :historical)
return data
end
historical_splits(fmp::FMP, symbol::String) = historical_splits(fmp; symbol)
"""
survivorship_bias(fmp, symbol, date)
Returns a JSON dictionary of the survivorship bias for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `date::String`: A yyyy-mm-dd formatted date string.
See [Survivorship-Bias]\
(https://site.financialmodelingprep.com/developer/docs/#Survivorship-Bias-Free-EOD) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the survivorship bias for AAPL to Jan 3, 2012
data = survivorship_bias(fmp, "AAPL", date = "2012-01-03")
```
"""
function survivorship_bias(fmp::FMP; symbol::String, date::String)
endpoint = "historical-price-full/$(symbol)/$(date)"
url, query = Client.make_url_v4(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_object(response)
return data
end
survivorship_bias(fmp::FMP, symbol::String, date::String) = survivorship_bias(fmp; symbol, date)
survivorship_bias(fmp::FMP, symbol::String; date::String) = survivorship_bias(fmp; symbol, date)
"""
technical_indicators(fmp, symbol, frequency = TIME_FREQUENCIES.daily, period = 200, type = "SMA")
Returns the historical price quote for the specified symbol and frequency.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `frequency::String`: A time frequency.
- `period::Integer`: The indicator period.
- `type::String`: The indicator type.
See [Daily-Indicators]\
(https://site.financialmodelingprep.com/developer/docs/#Daily-Indicators) for more details.\\
See [Intraday-Indicators]\
(https://site.financialmodelingprep.com/developer/docs/#Intraday-Indicators) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the daily 50 period SMA for AAPL
data = technical_indicators(fmp, "AAPL", period = 50)
# get the 15m 10 period WMA for AAPL
data = technical_indicators(fmp, "AAPL", TIME_FREQUENCIES.minutes15, period = 10, type = "wma")
```
"""
function technical_indicators(fmp::FMP; symbol::String, frequency::String = TIME_FREQUENCIES.daily, period::Integer = 200, type::String = "sma")
if !(frequency in TIME_FREQUENCIES)
error("Invalid frequency value. Allowed values are $(TIME_FREQUENCIES).")
end
endpoint = "technical_indicator/$(frequency)/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; period, type)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
technical_indicators(fmp::FMP, symbol::String, frequency::String; period::Integer = 200, type::String = "sma") = technical_indicators(fmp; symbol, frequency, period, type)
technical_indicators(fmp::FMP, symbol::String; frequency::String = TIME_FREQUENCIES.daily, period::Integer = 200, type::String = "sma") = technical_indicators(fmp; symbol, frequency, period, type)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 3519 | """
search_symbol(fmp, symbol, params...)
Returns search results for the specified symbol and filters.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Symbol-Search]\
(https://site.financialmodelingprep.com/developer/docs/#Ticker-Search) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first 10 matches where symbol is AA and exchange is NASDAQ
data = search_symbol(fmp, "AA", limit = 10, exchange = "NASDAQ")
```
"""
function search_symbol(fmp::FMP; symbol::String, params...)
endpoint = "search-ticker"
url, query = Client.make_url_v3(fmp, endpoint; query = symbol, params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
search_symbol(fmp::FMP, symbol::String; params...) = search_symbol(fmp; symbol, params...)
"""
search_name(fmp, name, params...)
Returns search results for the specified name and filters.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `name::String`: A company name.
- `params...`: Additional keyword query params.
See [Name-Search]\
(https://site.financialmodelingprep.com/developer/docs/#Ticker-Search) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first 10 matches where name is Meta and exchange is NASDAQ
data = search_name(fmp, "Meta", limit = 10, exchange = "NASDAQ")
```
"""
function search_name(fmp::FMP; name::String, params...)
endpoint = "search-name"
url, query = Client.make_url_v3(fmp, endpoint; query = name, params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
search_name(fmp::FMP, name::String; params...) = search_name(fmp; name, params...)
"""
stock_screener(fmp, params...)
Returns search results for the specified filters.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Stock-Screener]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Screener) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all tech stocks in the NASDAQ with a market cap over 100mm and a beta above 1
data = stock_screener(fmp, marketCapMoreThan = 100000000, betaMoreThan = 1, sector = "Technology", exchange = "NASDAQ")
# get the first 100 stocks in California with a price greater than 100
data = stock_screener(fmp, country = "CA", priceMoreThan = 100, limit = 100)
```
"""
function stock_screener(fmp::FMP; params...)
endpoint = "stock-screener"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
available_countries(fmp)
Returns a JSON array of all available countries in the API.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [Stock-Screener]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Screener) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all available countries
data = available_countries(fmp)
```
"""
function available_countries(fmp::FMP)
endpoint = "get-all-countries"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_object(response)
return data
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 7088 | """
historical_social_sentiment(fmp, symbol, params...)
Returns a JSON table with the historical social sentiment for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Social-Sentiment]\
(https://site.financialmodelingprep.com/developer/docs/#Social-Sentiment) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of historical social sentiment for AAPL
data = historical_social_sentiment(fmp, "AAPL", page = 0)
```
"""
function historical_social_sentiment(fmp::FMP; symbol::String, params...)
endpoint = "historical/social-sentiment"
url, query = Client.make_url_v4(fmp, endpoint; symbol, params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
historical_social_sentiment(fmp::FMP, symbol::String; params...) = historical_social_sentiment(fmp; symbol, params...)
"""
social_sentiment_trends(fmp, type, source)
Returns a JSON table with the social sentiment trends for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `type::String:` One of "bullish" or "bearish".
- `source::String:` One of "twitter" or "stocktwits".
See [Social-Sentiment]\
(https://site.financialmodelingprep.com/developer/docs/#Social-Sentiment) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all social sentiment trends
data = social_sentiment_trends(fmp)
# get all social sentiment trends from stocktwits with a bearish bias
data = social_sentiment_trends(fmp, type = "bearish", source = "stocktwits")
```
"""
function social_sentiment_trends(fmp::FMP; type = nothing, source = nothing)
endpoint = "social-sentiment/trending"
url, query = Client.make_url_v4(fmp, endpoint; type, source)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
social_sentiment_changes(fmp, type, source)
Returns a JSON table with the social sentiment changes for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `type::String:` One of "bullish" or "bearish".
- `source::String:` One of "twitter" or "stocktwits".
See [Social-Sentiment]\
(https://site.financialmodelingprep.com/developer/docs/#Social-Sentiment) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get all social sentiment changes
data = social_sentiment_trends(fmp)
# get all social sentiment changes from stocktwits with a bearish bias
data = social_sentiment_changes(fmp, type = "bearish", source = "stocktwits")
```
"""
function social_sentiment_changes(fmp::FMP; type = nothing, source = nothing)
endpoint = "social-sentiment/changes"
url, query = Client.make_url_v4(fmp, endpoint; type, source)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
stock_grades(fmp, symbol, params...)
Returns stock grades for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Stock-Grade]\
(https://site.financialmodelingprep.com/developer/docs/#Stock-Grade) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last 100 stock grades for AAPL
data = stock_grades(fmp, "AAPL", limit = 100)
```
"""
function stock_grades(fmp::FMP, symbol::String; params...)
endpoint = "grade/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
earnings_surprises(fmp, symbol)
Returns earnings suprises for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Earnings-Surprises]\
(https://site.financialmodelingprep.com/developer/docs/#Earnings-Surprises) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the latest earnings surprises for AAPL
data = earnings_surprises(fmp, "AAPL")
```
"""
function earnings_surprises(fmp::FMP, symbol::String)
endpoint = "earnings-surprises/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
analyst_estimates(fmp, symbol, params...)
Returns analyst estimates for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
- `params...`: Additional keyword query params.
See [Analyst-Estimates]\
(https://site.financialmodelingprep.com/developer/docs/#Analyst-Estimates) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the last 4 quarters of analyst estimates for AAPL
data = analyst_estimates(fmp, "AAPL", period = "quarter", limit = 4)
```
"""
function analyst_estimates(fmp::FMP, symbol::String; params...)
endpoint = "analyst-estimates/$(symbol)"
url, query = Client.make_url_v3(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
mergers_and_acquisitions_feed(fmp, params...)
Returns a JSON table containing the mergers and acquisitions feed results.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Mergers-and-Acquisitions-RSS-Feed]\
(https://site.financialmodelingprep.com/developer/docs/#MERGER-AND-ACQUISITION) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of the mergers and acquisitions rss feed
data = mergers_and_acquisitions_feed(fmp, page = 0)
```
"""
function mergers_and_acquisitions_feed(fmp::FMP; params...)
endpoint = "mergers-acquisitions-rss-feed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
mergers_and_acquisitions_search(fmp, params...)
Returns a JSON table containing mergers and acquisitions search results.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Mergers-and-Acquisitions]\
(https://site.financialmodelingprep.com/developer/docs/#MERGER-AND-ACQUISITION) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# search for mergers and acquisitions
data = mergers_and_acquisitions_search(fmp, name = "Syros")
```
"""
function mergers_and_acquisitions_search(fmp::FMP; params...)
endpoint = "mergers-acquisitions/search"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 622 | """
available_tsx(fmp)
Returns all available tsx symbols in the API.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
See [TSX-List]\
(https://site.financialmodelingprep.com/developer/docs/#Most-of-the-TSX) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get a list of all available tsx symbols
data = available_tsx(fmp)
```
"""
function available_tsx(fmp::FMP)
endpoint = "symbol/available-tsx"
url, query = Client.make_url_v3(fmp, endpoint)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 3590 | """
upgrades_and_downgrades(fmp, symbol)
Returns upgrades and downgrades for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Upgrades-&-Downgrades]\
(https://site.financialmodelingprep.com/developer/docs/#Upgrades-&-Downgrades) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the upgrades and downgrades for AAPL
data = upgrades_and_downgrades(fmp, AAPL)
```
"""
function upgrades_and_downgrades(fmp::FMP; symbol::String)
endpoint = "upgrades-downgrades"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
upgrades_and_downgrades(fmp::FMP, symbol::String) = upgrades_and_downgrades(fmp; symbol)
"""
upgrades_and_downgrades_feed(fmp, params...)
Returns upgrades and downgrades from the rss feed.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `params...`: Additional keyword query params.
See [Upgrades-&-Downgrades-RSS-Feed]\
(https://site.financialmodelingprep.com/developer/docs/#Upgrades-&-Downgrades-RSS-Feed) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the first page of upgrades and downgrades
data = upgrades_and_downgrades_feed(fmp, page = 0)
```
"""
function upgrades_and_downgrades_feed(fmp::FMP; params...)
endpoint = "upgrades-downgrades-rss-feed"
url, query = Client.make_url_v4(fmp, endpoint; params...)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
"""
upgrades_and_downgrades_consensus(fmp, symbol)
Returns consensus upgrades and downgrades for the specified symbol.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Upgrades-&-Downgrades-Consensus]\
(https://site.financialmodelingprep.com/developer/docs/#Upgrades-&-Downgrades-Consensus) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the consensus of upgrades and downgrades for AAPL
data = upgrades_and_downgrades_consensus(fmp, AAPL)
```
"""
function upgrades_and_downgrades_consensus(fmp::FMP; symbol::String)
endpoint = "upgrades-downgrades-consensus"
url, query = Client.make_url_v4(fmp, endpoint; symbol)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
upgrades_and_downgrades_consensus(fmp::FMP, symbol::String) = upgrades_and_downgrades_consensus(fmp; symbol)
"""
upgrades_and_downgrades_by_company(fmp, company)
Returns upgrades and downgrades for the specified company.
# Arguments
- `fmp::FMP`: A Financial Modeling Prep instance.
- `symbol::String`: A stock symbol.
See [Upgrades-&-Downgrades-By-Company]\
(https://site.financialmodelingprep.com/developer/docs/#Upgrades-&-Downgrades-By-Company) for more details.
# Examples
``` julia
# create a FMP API instance
fmp = FMP()
# get the consensus of upgrades and downgrades for Barclays
data = upgrades_and_downgrades_by_company(fmp, company = "Barclays")
```
"""
function upgrades_and_downgrades_by_company(fmp::FMP; company::String)
endpoint = "upgrades-downgrades-grading-company"
url, query = Client.make_url_v4(fmp, endpoint; company)
response = Client.make_get_request(url, query)
data = Client.parse_json_table(response)
return data
end
upgrades_and_downgrades_by_company(fmp::FMP, company::String) = upgrades_and_downgrades_by_company(fmp; company)
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 1508 | using FinancialModelingPrep
using Test
import DotEnv
const PermissionError = FinancialModelingPrep.Client.Exceptions.PermissionError
const JSONArray = FinancialModelingPrep.Client.JSON3.Array
const JSONObject = FinancialModelingPrep.Client.JSON3.Object
const JSONTable = FinancialModelingPrep.Client.JSONTables.Table
# load the envrionment variables
DotEnv.config("../.env")
# load the API key
FMP_API_KEY = ENV["FMP_API_KEY"]
# create a new FMP API instance
fmp = FMP()
#fmp = FMP(apikey = FMP_API_KEY)
include("test_pricequotes.jl")
include("test_stockfundamentals.jl")
include("test_stockfundamentalsanalysis.jl")
include("test_institutionalstockownership.jl")
include("test_esgscores.jl")
include("test_privatecompaniesfundraisingdata.jl")
include("test_pricetarget.jl")
include("test_upgradesdowngrades.jl")
include("test_historicalfundholdings.jl")
include("test_historicalemployees.jl")
include("test_executivecompensation.jl")
include("test_individualbeneficialownership.jl")
include("test_stockcalendars.jl")
include("test_stockscreener.jl")
include("test_companyinformation.jl")
include("test_stocknews.jl")
include("test_marketperformance.jl")
include("test_stockstatistics.jl")
include("test_insidertrading.jl")
include("test_senatetrading.jl")
include("test_economics.jl")
include("test_stockprice.jl")
include("test_fundholdings.jl")
include("test_stocklist.jl")
include("test_marketindexes.jl")
include("test_euronext.jl")
include("test_tsx.jl")
include("test_cryptoforexcommodities.jl")
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 898 | @testset "company_profile" begin
@test isa(company_profile(fmp, "AAPL"), JSONTable)
end
@testset "key_executives" begin
@test isa(key_executives(fmp, "AAPL"), JSONTable)
end
@testset "company_outlook" begin
@test_throws PermissionError company_outlook(fmp, "AAPL")
@test_throws PermissionError company_outlook(fmp, "AAPL", :profile)
@test_throws PermissionError company_outlook(fmp, "AAPL", :insideTrades)
end
@testset "stock_peers" begin
@test_throws PermissionError stock_peers(fmp, "AAPL")
end
@testset "nyse_schedule" begin
@test isa(nyse_schedule(fmp), JSONObject)
end
@testset "delisted_companies" begin
@test isa(delisted_companies(fmp, page = 0), JSONTable)
end
@testset "symbol_changes" begin
@test_throws PermissionError symbol_changes(fmp)
end
@testset "company_information" begin
@test isa(company_information(fmp, "AAPL"), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 391 | @testset "available_crytocurrencies" begin
@test isa(available_crytocurrencies(fmp), JSONTable)
end
@testset "available_forex_pairs" begin
@test isa(available_forex_pairs(fmp), JSONTable)
end
@testset "exchange_rates" begin
@test isa(exchange_rates(fmp, "EURUSD"), JSONTable)
end
@testset "available_commodities" begin
@test isa(available_commodities(fmp), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 494 | @testset "market_risk_premiums" begin
@test_throws PermissionError market_risk_premiums(fmp)
end
@testset "market_risk_premiums" begin
@test isa(treasury_rates(fmp, from = "2022-01-01", to = "2022-03-31"), JSONTable)
end
@testset "market_risk_premiums" begin
@test isa(economic_indicator(fmp, name = "realGDP", from = "2022-01-01", to = "2022-03-31"), JSONTable)
@test isa(economic_indicator(fmp, name = "federalFunds", from = "2022-01-01", to = "2022-03-31"), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 296 | @testset "esg_scores" begin
@test_throws PermissionError esg_scores(fmp, "AAPL")
end
@testset "esg_ratings" begin
@test_throws PermissionError esg_ratings(fmp, "AAPL")
end
@testset "esg_score_benchmarks" begin
@test_throws PermissionError esg_score_benchmarks(fmp, year = 2022)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 90 | @testset "available_euronext" begin
@test isa(available_euronext(fmp), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 240 | @testset "executive_compensation" begin
@test isa(executive_compensation(fmp, "AAPL"), JSONTable)
end
@testset "executive_compensation_benchmarks" begin
@test isa(executive_compensation_benchmarks(fmp, year = 2020), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 1362 | @testset "etf_holders" begin
@test_throws PermissionError etf_holders(fmp, "SPY")
end
@testset "etf_summary" begin
@test_throws PermissionError etf_summary(fmp, "SPY")
end
@testset "institutional_holders" begin
@test_throws PermissionError institutional_holders(fmp, "AAPL")
end
@testset "mutual_fund_holders" begin
@test_throws PermissionError mutual_fund_holders(fmp, "AAPL")
end
@testset "etf_sector_weightings" begin
@test_throws PermissionError etf_sector_weightings(fmp, "SPY")
end
@testset "etf_country_weightings" begin
@test_throws PermissionError etf_country_weightings(fmp, "SPY")
end
@testset "etf_exposure" begin
@test_throws PermissionError etf_exposure(fmp, "SPY")
end
@testset "institutions_list" begin
@test isa(institutions_list(fmp), JSONTable)
end
@testset "cik_search" begin
@test_throws PermissionError cik_search(fmp, "Berkshire")
end
@testset "company_from_cik" begin
@test_throws PermissionError company_from_cik(fmp, cik = "0001067983")
end
@testset "forms_13f" begin
@test_throws PermissionError forms_13f(fmp, cik = "0001067983", date = "2022-06-30")
end
@testset "filing_dates" begin
@test_throws PermissionError filing_dates(fmp, cik = "0001067983")
end
@testset "company_from_cusip" begin
@test_throws PermissionError company_from_cusip(fmp, cusip = "000360206")
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 114 | @testset "historical_employee_counts" begin
@test isa(historical_employee_counts(fmp, "AAPL"), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 956 | @testset "mutual_fund_portfolio_dates" begin
@test_throws PermissionError mutual_fund_portfolio_dates(fmp, "VTSAX")
@test_throws PermissionError mutual_fund_portfolio_dates(fmp, cik = "0000034066")
end
@testset "mutual_fund_portfolio" begin
@test_throws PermissionError mutual_fund_portfolio(fmp, "VTSAX", date = "2021-12-31")
@test_throws PermissionError mutual_fund_portfolio(fmp, cik = "0000034066", date = "2021-12-31")
end
@testset "mutual_fund_search" begin
@test_throws PermissionError mutual_fund_search(fmp, name = "Vanguard")
end
@testset "etf_portfolio_dates" begin
@test_throws PermissionError etf_portfolio_dates(fmp, "VOO")
@test_throws PermissionError etf_portfolio_dates(fmp, cik = "0000036405")
end
@testset "etf_portfolio" begin
@test_throws PermissionError etf_portfolio(fmp, "VOO", date = "2021-12-31")
@test_throws PermissionError etf_portfolio(fmp, cik = "0000036405", date = "2021-12-31")
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 109 | @testset "beneficial_ownership" begin
@test_throws PermissionError beneficial_ownership(fmp, "AAPL")
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 1082 | @testset "insider_trading_types" begin
@test_throws PermissionError insider_trading_types(fmp)
end
@testset "insider_trades" begin
@test_throws PermissionError insider_trades(fmp, transactionType = "P-Purchase,S-Sale", page = 0)
@test_throws PermissionError insider_trades(fmp, symbol = "AAPL", page = 0)
end
@testset "insider_trades_feed" begin
@test_throws PermissionError insider_trades_feed(fmp, page = 0)
end
@testset "insiders_list" begin
@test_throws PermissionError insiders_list(fmp, page = 3)
end
@testset "cik_from_insider" begin
@test_throws PermissionError cik_from_insider(fmp, name = "zuckerberg%20mark")
end
@testset "cik_from_symbol" begin
@test_throws PermissionError cik_from_symbol(fmp, "AAPL")
end
@testset "insider_roster" begin
@test_throws PermissionError insider_roster(fmp, "AAPL")
end
@testset "insider_roster_statistics" begin
@test_throws PermissionError insider_roster_statistics(fmp, "AAPL")
end
@testset "fails_to_deliver" begin
@test_throws PermissionError fails_to_deliver(fmp, "AAPL", page = 0)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 1352 | @testset "institutional_positions" begin
@test_throws PermissionError institutional_positions(fmp, "AAPL", includeCurrentQuarter = true)
end
@testset "institutional_ownership_percentages" begin
@test_throws PermissionError institutional_ownership_percentages(fmp, "AAPL", date = "2021-09-30")
end
@testset "institutional_ownership_weightings" begin
@test_throws PermissionError institutional_ownership_weightings(fmp, "AAPL", date = "2021-09-30")
end
@testset "institutional_ownership_feed" begin
@test_throws PermissionError institutional_ownership_feed(fmp, page = 0)
end
@testset "institution_search" begin
@test_throws PermissionError institution_search(fmp, name = "Berkshire%20Hathaway%20Inc")
end
@testset "institution_portfolio_dates" begin
@test_throws PermissionError institution_portfolio_dates(fmp, cik = "0001067983")
end
@testset "institution_portfolio_summary" begin
@test_throws PermissionError institution_portfolio_summary(fmp, cik = "0001067983")
end
@testset "institution_portfolio_industry_summary" begin
@test_throws PermissionError institution_portfolio_industry_summary(fmp, cik = "0001067983", date = "2021-09-30")
end
@testset "institution_portfolio_composition" begin
@test_throws PermissionError institution_portfolio_composition(fmp, cik = "0001067983", date = "2021-09-30")
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 521 | @testset "available_indexes" begin
@test isa(available_indexes(fmp), JSONTable)
end
@testset "sp500_companies" begin
@test_throws PermissionError sp500_companies(fmp)
@test_throws PermissionError sp500_companies(fmp, historical = true)
end
@testset "nasdaq_companies" begin
@test_throws PermissionError nasdaq_companies(fmp)
end
@testset "dowjones_companies" begin
@test_throws PermissionError dowjones_companies(fmp)
@test_throws PermissionError dowjones_companies(fmp, historical = true)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 703 | @testset "sector_pe_ratios" begin
@test_throws PermissionError sector_pe_ratios(fmp, date = "2023-01-01", exchange = "NYSE")
end
@testset "industry_pe_ratios" begin
@test_throws PermissionError industry_pe_ratios(fmp, date = "2023-01-01", exchange = "NYSE")
end
@testset "sector_performances" begin
@test isa(sector_performances(fmp), JSONTable)
end
@testset "historical_sector_performances" begin
@test isa(historical_sector_performances(fmp, limit = 10), JSONTable)
end
@testset "gainers" begin
@test isa(gainers(fmp), JSONTable)
end
@testset "losers" begin
@test isa(losers(fmp), JSONTable)
end
@testset "most_active" begin
@test isa(most_active(fmp), JSONTable)
end | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 1415 | @testset "price_quote" begin
@test isa(price_quote(fmp, "SPY"), JSONTable)
@test isa(price_quote(fmp, "%5EGSPC"), JSONTable)
@test isa(price_quote(fmp, "EDF.PA"), JSONTable)
@test isa(price_quote(fmp, "FNV.TO"), JSONTable)
@test isa(price_quote(fmp, "BTCUSD"), JSONTable)
@test isa(price_quote(fmp, "EURUSD"), JSONTable)
@test isa(price_quote(fmp, "ZGUSD"), JSONTable)
end
@testset "price_quotes" begin
@test isa(price_quotes(fmp, "index"), JSONTable)
@test isa(price_quotes(fmp, "nyse"), JSONTable)
@test isa(price_quotes(fmp, "euronext"), JSONTable)
@test isa(price_quotes(fmp, "tsx"), JSONTable)
@test isa(price_quotes(fmp, "crypto"), JSONTable)
@test isa(price_quotes(fmp, "forex"), JSONTable)
@test isa(price_quotes(fmp, "commodity"), JSONTable)
end
@testset "historical_price_quote" begin
@test isa(historical_price_quote(fmp, "SPY", serietype = "line"), JSONTable)
@test isa(historical_price_quote(fmp, "%5EGSPC"), JSONTable)
@test isa(historical_price_quote(fmp, "EDF.PA"), JSONTable)
@test isa(historical_price_quote(fmp, "FNV.TO"), JSONTable)
@test isa(historical_price_quote(fmp, "BTCUSD", timeseries = 5), JSONTable)
@test isa(historical_price_quote(fmp, "EURUSD", from = "2018-03-12", to = "2019-03-12"), JSONTable)
@test isa(historical_price_quote(fmp, "ZGUSD", frequency = TIME_FREQUENCIES.hours1), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 698 | @testset "price_targets" begin
@test_throws PermissionError price_targets(fmp, "AAPL")
end
@testset "price_targets_by_analyst" begin
@test_throws PermissionError price_targets_by_analyst(fmp, name = "Tim%20Anderson")
end
@testset "price_targets_by_company" begin
@test_throws PermissionError price_targets_by_company(fmp, company = "Barclays")
end
@testset "price_targets_summary" begin
@test_throws PermissionError price_targets_summary(fmp, "AAPL")
end
@testset "price_targets_consensus" begin
@test_throws PermissionError price_targets_consensus(fmp, "AAPL")
end
@testset "price_targets_feed" begin
@test_throws PermissionError price_targets_feed(fmp, page = 0)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 703 | @testset "crowdfunding_offerings_feed" begin
@test isa(crowdfunding_offerings_feed(fmp, page = 0), JSONTable)
end
@testset "crowdfunding_offerings_search" begin
@test isa(crowdfunding_offerings_search(fmp, name = "Enotap"), JSONTable)
end
@testset "crowdfunding_offerings" begin
@test isa(crowdfunding_offerings(fmp, cik = "0001916078"), JSONTable)
end
@testset "equity_offerings_feed" begin
@test isa(equity_offerings_feed(fmp, page = 0), JSONTable)
end
@testset "equity_offerings_search" begin
@test isa(equity_offerings_search(fmp, name = "Marinalife"), JSONTable)
end
@testset "equity_offerings" begin
@test isa(equity_offerings(fmp, cik = "0001870523"), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 397 | @testset "senate_trades" begin
@test isa(senate_trades(fmp, "AAPL"), JSONTable)
end
@testset "senate_trades_feed" begin
@test isa(senate_trades_feed(fmp, page = 0), JSONArray)
end
@testset "senate_disclosures" begin
@test isa(senate_disclosures(fmp, "AAPL"), JSONTable)
end
@testset "senate_disclosure_feed" begin
@test isa(senate_disclosure_feed(fmp, page = 0), JSONArray)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 1352 | @testset "earnings_calendar" begin
@test_throws PermissionError earnings_calendar(fmp, from = "2022-01-01", to = "2022-03-31")
end
@testset "historical_earnings_calendar" begin
@test_throws PermissionError historical_earnings_calendar(fmp, "AAPL", limit = 50)
end
@testset "earnings_calendar_confirmed" begin
@test_throws PermissionError earnings_calendar_confirmed(fmp, from = "2022-01-01", to = "2022-03-31")
end
@testset "ipo_calendar" begin
@test_throws PermissionError ipo_calendar(fmp, from = "2022-01-01", to = "2022-03-31")
end
@testset "ipo_calendar_prospectus" begin
@test_throws PermissionError ipo_calendar_prospectus(fmp, from = "2022-01-01", to = "2022-03-31")
end
@testset "ipo_calendar_confirmed" begin
@test_throws PermissionError ipo_calendar_confirmed(fmp, from = "2022-01-01", to = "2022-03-31")
end
@testset "stock_split_calendar" begin
@test isa(stock_split_calendar(fmp, from = "2022-01-01", to = "2022-03-31"), JSONTable)
end
@testset "dividend_calendar" begin
@test isa(dividend_calendar(fmp, from = "2022-01-01", to = "2022-03-31"), JSONTable)
end
@testset "historical_dividends" begin
@test isa(historical_dividends(fmp, "AAPL"), JSONTable)
end
@testset "economic_calendar" begin
@test_throws PermissionError economic_calendar(fmp, from = "2022-01-01", to = "2022-03-31")
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 2173 | @testset "symbols_with_financials" begin
@test isa(symbols_with_financials(fmp), JSONArray)
end
@testset "income_statements" begin
@test isa(income_statements(fmp, "AAPL", period = REPORTING_PERIODS.quarter, limit = 10), JSONTable)
@test_throws PermissionError income_statements(fmp, "AAPL", reported = true, limit = 5)
end
@testset "balance_sheet_statements" begin
@test isa(balance_sheet_statements(fmp, "AAPL", period = REPORTING_PERIODS.quarter, limit = 10), JSONTable)
@test_throws PermissionError balance_sheet_statements(fmp, "AAPL", reported = true, limit = 5)
end
@testset "cash_flow_statements" begin
@test isa(cash_flow_statements(fmp, "AAPL", period = REPORTING_PERIODS.quarter, limit = 10), JSONTable)
@test_throws PermissionError cash_flow_statements(fmp, "AAPL", reported = true, limit = 5)
end
@testset "financial_statements" begin
@test_throws PermissionError financial_statements(fmp, "AAPL", limit = 5)
@test_throws PermissionError financial_statements(fmp, "AAPL", period = REPORTING_PERIODS.quarter, limit = 4)
end
@testset "financial_reports" begin
@test_throws PermissionError financial_reports(fmp, "AAPL", 2022)
@test_throws PermissionError financial_reports(fmp, "AAPL", 2022, period = "Q4")
end
@testset "revenue_segments" begin
@test_throws PermissionError revenue_segments(fmp, "AAPL", segment = REVENUE_SEGMENTS.geographic)
@test_throws PermissionError revenue_segments(fmp, "AAPL", segment = REVENUE_SEGMENTS.product, period = REPORTING_PERIODS.quarter)
end
@testset "shares_float" begin
@test_throws PermissionError shares_float(fmp)
@test_throws PermissionError shares_float(fmp, "AAPL")
end
@testset "earnings_call_transcripts" begin
@test isa(earnings_call_transcripts(fmp, "AAPL"), JSONArray)
@test isa(earnings_call_transcripts(fmp, "AAPL", year = 2022), JSONArray)
@test isa(earnings_call_transcripts(fmp, "AAPL", year = 2022, quarter = 3), JSONArray)
end
@testset "sec_filings" begin
@test isa(sec_filings(fmp, "AAPL", type = "10-K", page = 0), JSONTable)
end
@testset "company_notes" begin
@test isa(company_notes(fmp, "AAPL"), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 2584 | @testset "financial_ratios" begin
@test isa(financial_ratios(fmp, "AAPL", period = REPORTING_PERIODS.quarter, limit = 30), JSONTable)
@test isa(financial_ratios(fmp, "AAPL", limit = 5), JSONTable)
end
@testset "financial_scores" begin
@test_throws PermissionError financial_scores(fmp, "AAPL")
end
@testset "owners_earnings" begin
@test_throws PermissionError owners_earnings(fmp, "AAPL")
end
@testset "enterprise_values" begin
@test isa(enterprise_values(fmp, "AAPL", period = REPORTING_PERIODS.quarter, limit = 30), JSONTable)
@test isa(enterprise_values(fmp, "AAPL", limit = 5), JSONTable)
end
@testset "income_statements_growth" begin
@test isa(income_statements_growth(fmp, "AAPL", period = REPORTING_PERIODS.quarter, limit = 30), JSONTable)
@test isa(income_statements_growth(fmp, "AAPL", limit = 5), JSONTable)
end
@testset "balance_sheet_statements_growth" begin
@test isa(balance_sheet_statements_growth(fmp, "AAPL", period = REPORTING_PERIODS.quarter, limit = 30), JSONTable)
@test isa(balance_sheet_statements_growth(fmp, "AAPL", limit = 5), JSONTable)
end
@testset "cash_flow_statements_growth" begin
@test isa(cash_flow_statements_growth(fmp, "AAPL", period = REPORTING_PERIODS.quarter, limit = 30), JSONTable)
@test isa(cash_flow_statements_growth(fmp, "AAPL", limit = 5), JSONTable)
end
@testset "financial_statements_growth" begin
@test isa(financial_statements_growth(fmp, "AAPL", period = REPORTING_PERIODS.quarter, limit = 30), JSONTable)
@test isa(financial_statements_growth(fmp, "AAPL", limit = 5), JSONTable)
end
@testset "key_metrics" begin
@test isa(key_metrics(fmp, "AAPL", period = REPORTING_PERIODS.ttm, limit = 30), JSONTable)
@test isa(key_metrics(fmp, "AAPL", limit = 5), JSONTable)
end
@testset "company_rating" begin
@test isa(company_rating(fmp, "AAPL"), JSONTable)
end
@testset "historical_ratings" begin
@test isa(historical_ratings(fmp, "AAPL", limit = 5), JSONTable)
end
@testset "discounted_cash_flows" begin
@test_throws PermissionError discounted_cash_flows(fmp, "AAPL")
end
@testset "advanced_discounted_cash_flows" begin
@test isa(advanced_discounted_cash_flows(fmp, "AAPL"), JSONTable)
@test isa(advanced_discounted_cash_flows(fmp, "AAPL", levered = true), JSONTable)
end
@testset "historical_discounted_cash_flows" begin
@test_throws PermissionError historical_discounted_cash_flows(fmp, "AAPL", period = REPORTING_PERIODS.quarter, limit = 30)
@test_throws PermissionError historical_discounted_cash_flows(fmp, "AAPL", limit = 5)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 254 | @testset "available_symbols" begin
@test isa(available_symbols(fmp), JSONTable)
end
@testset "tradeable_symbols" begin
@test isa(tradeable_symbols(fmp), JSONTable)
end
@testset "etf_symbols" begin
@test isa(etf_symbols(fmp), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 751 | @testset "fmp_articles" begin
@test_throws PermissionError fmp_articles(fmp, page = 0, size = 5)
end
@testset "stock_news" begin
@test isa(stock_news(fmp, tickers = "AAPL,FB", limit = 50), JSONTable)
end
@testset "stock_news_sentiment_feed" begin
@test_throws PermissionError stock_news_sentiment_feed(fmp, page = 0)
end
@testset "crypto_news" begin
@test isa(crypto_news(fmp, symbol = "BTCUSD", page = 0), JSONTable)
end
@testset "forex_news" begin
@test isa(forex_news(fmp, symbol = "EURUSD", page = 0), JSONTable)
end
@testset "general_news" begin
@test isa(general_news(fmp, page = 0), JSONTable)
end
@testset "press_releases" begin
@test_throws PermissionError press_releases(fmp, symbol = "AAPL", page = 0)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 549 | @testset "otc_quote" begin
@test isa(otc_quote(fmp, "GBTC"), JSONTable)
end
@testset "price_change" begin
@test isa(price_change(fmp, "AAPL"), JSONTable)
end
@testset "historical_splits" begin
@test isa(historical_splits(fmp, "AAPL"), JSONTable)
end
@testset "survivorship_bias" begin
@test_throws PermissionError survivorship_bias(fmp, "AAPL", "2012-01-03")
end
@testset "technical_indicators" begin
@test isa(technical_indicators(fmp, "AAPL"; frequency = TIME_FREQUENCIES.daily, period = 200, type = "sma"), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 508 | @testset "search_symbol" begin
@test isa(search_symbol(fmp, "AA", limit = 10, exchange = "NASDAQ"), JSONTable)
end
@testset "search_name" begin
@test isa(search_name(fmp, "meta", limit = 10, exchange = "NASDAQ"), JSONTable)
end
@testset "search_symbol" begin
@test isa(stock_screener(fmp, marketCapMoreThan = 100000000, betaMoreThan = 1, sector = "Technology", exchange = "NASDAQ"), JSONTable)
@test isa(stock_screener(fmp, country = "CA", priceMoreThan = 100, limit = 100), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 1154 | @testset "social_sentiment" begin
@test_throws PermissionError historical_social_sentiment(fmp, "AAPL", page = 0)
end
@testset "social_sentiment_trends" begin
@test_throws PermissionError social_sentiment_trends(fmp)
@test_throws PermissionError social_sentiment_trends(fmp, type = "bearish", source = "stocktwits")
end
@testset "social_sentiment_changes" begin
@test_throws PermissionError social_sentiment_changes(fmp)
@test_throws PermissionError social_sentiment_changes(fmp, type = "bearish", source = "twitter")
end
@testset "stock_grades" begin
@test_throws PermissionError stock_grades(fmp, "AAPL", limit = 10)
end
@testset "earnings_surprises" begin
@test_throws PermissionError earnings_surprises(fmp, "AAPL")
end
@testset "analyst_estimates" begin
@test isa(analyst_estimates(fmp, "AAPL", period = "quarter", limit = 4), JSONTable)
end
@testset "mergers_and_acquisitions_feed" begin
@test_throws PermissionError mergers_and_acquisitions_feed(fmp, page = 0)
end
@testset "mergers_and_acquisitions_search" begin
@test_throws PermissionError mergers_and_acquisitions_search(fmp, name = "Syros")
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 80 | @testset "available_tsx" begin
@test isa(available_tsx(fmp), JSONTable)
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | code | 531 | @testset "upgrades_and_downgrades" begin
@test_throws PermissionError upgrades_and_downgrades(fmp, "AAPL")
end
@testset "upgrades_and_downgrades_feed" begin
@test_throws PermissionError upgrades_and_downgrades_feed(fmp, page = 0)
end
@testset "upgrades_and_downgrades_consensus" begin
@test_throws PermissionError upgrades_and_downgrades_consensus(fmp, "AAPL")
end
@testset "upgrades_and_downgrades_by_company" begin
@test_throws PermissionError upgrades_and_downgrades_by_company(fmp, company = "Barclays")
end
| FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 26879 | # FinancialModelingPrep
[](https://github.com/rando-brando/FinancialModelingPrep.jl/actions/workflows/ci.yml)
[](https://rando-brando.github.io/FinancialModelingPrep.jl/dev)
[](https://codecov.io/gh/rando-brando/FinancialModelingPrep.jl)
[](https://github.com/rando-brando/FinancialModelingPrep.jl/stargazers)
*Financial Modeling Prep API wrapper with Julia*
## Disclaimer
Data is provided by [Financial Modeling Prep](https://financialmodelingprep.com/developer/docs/) and requires a paid subscription to access some endpoints.
Only endpoints available with a starter plan have been implemented. Function to endpoint mappings are provided below.
## Installation
``` julia
pkg> add FinancialModelingPrep
```
## Getting Started
``` julia
using FinancialModelingPrep
```
``` julia
# load your API key
FMP_API_KEY = ENV["FMP_API_KEY"]
# create a new FMP API instance
fmp = FMP(apikey = FMP_API_KEY)
```
``` julia
# pass API instance to any endpoint method
data = income_statements(fmp, "AAPL")
```
``` julia
using DataFrames
# load the response data into a data frame
df = DataFrame(data)
```
``` julia
# sample data frame output
df[1:5, 1:4]
5×4 DataFrame
Row │ incomeTaxExpense reportedCurrency incomeBeforeTaxRatio depreciationAndAmortization
│ Int64 String Float64 Int64
─────┼───────────────────────────────────────────────────────────────────────────────────────
1 │ 19300000000 USD 0.30204 11104000000
2 │ 14527000000 USD 0.298529 11284000000
3 │ 9680000000 USD 0.244398 11056000000
4 │ 10481000000 USD 0.252666 12547000000
5 │ 13372000000 USD 0.274489 10903000000
```
## Price Quotes
| Function | Endpoint(s) |
|----------|-------------|
| price_quote </br> price_quotes | [Company-Quote](https://site.financialmodelingprep.com/developer/docs/#Company-Quote) </br> [Index-Quote](https://site.financialmodelingprep.com/developer/docs/#Most-of-the-majors-indexes-(Dow-Jones,-Nasdaq,-S&P-500)) </br> [Euronext-Quote](https://site.financialmodelingprep.com/developer/docs/#Most-of-the-EuroNext) </br>[TSX-Quote](https://site.financialmodelingprep.com/developer/docs/#Most-of-the-TSX) </br> [Crypto-Quote](https://site.financialmodelingprep.com/developer/docs/#Cryptocurrencies) <br> [Forex-Quote](https://site.financialmodelingprep.com/developer/docs/#Forex-(FX)) </br> [Commodity-Quote](https://site.financialmodelingprep.com/developer/docs/#Most-of-the-Major-Commodities-(Gold,-Silver,-Oil)) |
| historical_price_quote | [Historical-Stock-Quote](https://site.financialmodelingprep.com/developer/docs/#Stock-Historical-Price) </br> [Historical-Index-Quote](https://site.financialmodelingprep.com/developer/docs/#Historical-stock-index-prices) </br> [Historical-Euronext-Quote](https://site.financialmodelingprep.com/developer/docs/#Historical-EuroNext-prices) </br> [Historical-TSX-Quote](https://site.financialmodelingprep.com/developer/docs/#Historical-TSX-prices) </br> [Historical-Cryptocurrencies-Quote](https://site.financialmodelingprep.com/developer/docs/#Historical-Cryptocurrencies-Price) </br> [Historical-Forex-Quote](https://site.financialmodelingprep.com/developer/docs/#Historical-Forex-Price) </br> [Historical-Commodities-Quote](https://site.financialmodelingprep.com/developer/docs/#Historical-commodities-prices) |
## Stock Fundamentals
| Function | Endpoint(s) |
|----------|-------------|
| symbols_with_financials | [Financial-Statements-List](https://site.financialmodelingprep.com/developer/docs#Financial-Statements-List) |
| income_statements | [Income-Statements](https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements) <br/>[Income-Statements-As-Reported](https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements-As-Reported) |
| balance_sheet_statements | [Balance-Sheet-Statements](https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements) <br/> [Balance-Sheet-Statements-As-Reported](https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements-As-Reported) |
| cash_flow_statements | [Cash-Flow-Statements](https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements) <br/>[Cash-Flow-Statements-As-Reported](https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements-As-Reported) |
| financial_statements | [Full-Financial-Statements-As-Reported](https://site.financialmodelingprep.com/developer/docs#Company-Financial-Statements-As-Reported) |
| financial_reports | [Annual-Reports-on-Form-10-K](https://site.financialmodelingprep.com/developer/docs#Annual-Reports-on-Form-10-K) <br/>[Quarterly-Earnings-Reports](https://site.financialmodelingprep.com/developer/docs/#Quarterly-Earnings-Reports) |
| revenue_segments | [Sales-Revenue-By-Segments](https://site.financialmodelingprep.com/developer/docs/#Sales-Revenue-By-Segments) <br/> [Revenue-Geographic-by-Segments](https://site.financialmodelingprep.com/developer/docs/#Revenue-Geographic-by-Segments)
| shares_float | [Shares-Float](https://site.financialmodelingprep.com/developer/docs/#Shares-Float) |
| earnings_call_transcripts | [Earnings-Call-Transcript](https://site.financialmodelingprep.com/developer/docs/#Earning-Call-Transcript) |
| sec_filings | [SEC-Filings](https://site.financialmodelingprep.com/developer/docs/#SEC-Filings) |
| company_notes | [Company-Notes-Due](https://site.financialmodelingprep.com/developer/docs/#Company-Notes-due) |
## Stock Fundamentals Analysis
| Function | Endpoint(s) |
|----------|-------------|
| financial_ratios | [Financial-Ratios](https://site.financialmodelingprep.com/developer/docs/#Company-Financial-Ratios) |
| financial_scores | [Financial-Scores](https://site.financialmodelingprep.com/developer/docs/#Stock-Financial-scores) |
| owners_earnings | [Owners-Earnings](https://site.financialmodelingprep.com/developer/docs/#Stock-Financial-scores) |
| enterprise_values | [Enterprise-Value](https://site.financialmodelingprep.com/developer/docs/#Company-Enterprise-Value) |
| income_statements_growth | [Income-Statements-Growth](https://site.financialmodelingprep.com/developer/docs/#Financial-Statements-Growth) |
| balance_sheet_statements_growth | [Balance-Sheet-Statements-Growth](https://site.financialmodelingprep.com/developer/docs/#Financial-Statements-Growth) |
| cash_flow_statements_growth | [Cash-Flow-Statements-Growth](https://site.financialmodelingprep.com/developer/docs/#Financial-Statements-Growth) |
| financial_statements_growth | [Financial-Statements-Growth](https://site.financialmodelingprep.com/developer/docs/#Company-Financial-Growth) |
| key_metrics | [Key-Metrics](https://site.financialmodelingprep.com/developer/docs/#Company-Key-Metrics) |
| company_rating | [Company-Rating](https://site.financialmodelingprep.com/developer/docs/#Company-Rating) |
| historical_ratings | [Historical-Ratings](https://site.financialmodelingprep.com/developer/docs/#Company-Rating) |
| discounted_cash_flows | [Discounted-Cash-Flow](https://site.financialmodelingprep.com/developer/docs/#Company-Discounted-cash-flow-value) |
| advanced_discounted_cash_flows | [Discounted-Cash-Flow](https://site.financialmodelingprep.com/developer/docs/#Company-Discounted-cash-flow-value) |
| historical_discounted_cash_flows | [Historical-Discounted-Cash-Flow](https://site.financialmodelingprep.com/developer/docs/#Company-Discounted-cash-flow-value) |
## Institutional Stock Ownership
| Function | Endpoint(s) |
|----------|-------------|
| institutional_positions | [Institutional-Stock-Ownership](https://site.financialmodelingprep.com/developer/docs/#Institutional-Stock-Ownership) |
| institutional_ownership_percentages | [Stock-Ownership-by-Holders](https://site.financialmodelingprep.com/developer/docs/#Stock-Ownership-by-Holders) |
| institutional_ownership_weightings | [Institutional-Stock-by-Shares-Held-and-Date](https://site.financialmodelingprep.com/developer/docs/#Institutional-Ownership-by-Shares-Held-and-Date) |
| institutional_ownership_feed | [Institutional-Holder-Rss-Feed](https://site.financialmodelingprep.com/developer/docs/#Institutional-Holder-Rss-Feed) |
| institution_search | [Institutional-Holders-Search](https://site.financialmodelingprep.com/developer/docs/#Institutional-Holders-Search) |
| institution_portfolio_dates | [Institutional-Holders-Available-Date](https://site.financialmodelingprep.com/developer/docs/#Institutional-Holders-Available-Date) |
| institution_portfolio_summary | [Institutional-Holdings-Portfolio-Positions-Summary](https://site.financialmodelingprep.com/developer/docs/#Institutional-Holdings-Portfolio-Positions-Summary) |
| institution_portfolio_industry_summary | [Institutional-Holdings-Portfolio-Industry-Summary](https://site.financialmodelingprep.com/developer/docs/#Institutional-Holdings-Portfolio-Industry-Summary) |
| institution_portfolio_composition | [Institutional-Holdings-Portfolio-Composition](https://site.financialmodelingprep.com/developer/docs/#Institutional-Holdings-Portfolio-composition) |
## ESG Score
| Function | Endpoint(s) |
|----------|-------------|
| esg_scores | [ESG-Score](https://site.financialmodelingprep.com/developer/docs/#ESG-SCORE) |
| esg_ratings | [ESG-Ratings](https://site.financialmodelingprep.com/developer/docs/#Company-ESG-Risk-Ratings) |
| esg_score_benchmarks | [ESG-Benchmarking](https://site.financialmodelingprep.com/developer/docs/#ESG-Benchmarking-By-Sector-and-Year) |
## Private Companies Fundraising Data
| Function | Endpoint(s) |
|----------|-------------|
| crowdfunding_offerings_feed | [Crowdfunding-Offerings-Rss-Feed](https://site.financialmodelingprep.com/developer/docs/#Crowdfunding-Offerings-Rss-feed) |
| crowdfunding_offerings_search | [Crowdfunding-Offerings-Company-Search](https://site.financialmodelingprep.com/developer/docs/#Crowdfunding-Offerings-Company-Search) |
| crowdfunding_offerings | [Crowdfunding-Offerings-by-CIK](https://site.financialmodelingprep.com/developer/docs/#Crowdfunding-Offerings-by-CIK) |
| equity_offerings_feed | [Equity-Offerings-Fundraising-Rss-feed](https://site.financialmodelingprep.com/developer/docs/#Equity-offerings-Fundraising-Rss-feed) |
| equity_offerings_search | [Equity-Offerings-Fundraising-Company-Search](https://site.financialmodelingprep.com/developer/docs/#Equity-offerings-Fundraising-Company-Search) |
| equity_offerings | [Equity-Offerings-Fundraising-by-CIK](https://site.financialmodelingprep.com/developer/docs/#Equity-offerings-Fundraising-by-CIK) |
## Price Target
| Function | Endpoint(s) |
|----------|-------------|
| price_targets | [Price-Target](https://site.financialmodelingprep.com/developer/docs/#Price-Target)|
| price_targets_by_analyst | [Price-Target-by-Analyst-Name](https://site.financialmodelingprep.com/developer/docs/#Price-Target-By-Analyst-Name) |
| price_targets_by_company | [Price-Target-by-Analyst-Company](https://site.financialmodelingprep.com/developer/docs/#Price-Target-by-Analyst-Company) |
| price_targets_summary | [Price-Target-Summary](https://site.financialmodelingprep.com/developer/docs/#Price-target-Summary) |
| price_targets_consensus | [Price-Target-Consensus](https://site.financialmodelingprep.com/developer/docs/#Price-Target-Consensus) |
| price_targets_feed | [Price-Target-RSS-Feed](https://site.financialmodelingprep.com/developer/docs/#Price-Target-RSS-Feed) |
## Upgrades & Downgrades
| Function | Endpoint(s) |
|----------|-------------|
| upgrades_and_downgrades | [Upgrades-&-Downgrades](https://site.financialmodelingprep.com/developer/docs/#Upgrades-&-Downgrades) |
| upgrades_and_downgrades_feed | [Upgrades-&-Downgrades-RSS-Feed](https://site.financialmodelingprep.com/developer/docs/#Upgrades-&-Downgrades-RSS-Feed) |
| upgrades_and_downgrades_consensus | [Upgrades-&-Downgrades-Consensus](https://site.financialmodelingprep.com/developer/docs/#Upgrades-&-Downgrades-Consensus) |
| upgrades_and_downgrades_by_company | [Upgrades-&-Downgrades-by-Company](https://site.financialmodelingprep.com/developer/docs/#Upgrades-&-Downgrades-By-Company) |
## Historical ETF and Mutual Fund Holdings
| Function | Endpoint(s) |
|----------|-------------|
| mutual_fund_portfolio_dates | [Historical-Mutual-Fund-Holdings-Available-Dates](https://site.financialmodelingprep.com/developer/docs/#historical-mutual-fund-holdings-available-dates) |
| mutual_fund_portfolio | [Historical-Mutual-Fund-Holdings-Portfolio](https://site.financialmodelingprep.com/developer/docs/#historical-mutual-fund-holdings-portfolio) |
| mutual_fund_search | [Mutual-Fund-Holdings-Search](https://site.financialmodelingprep.com/developer/docs/#Mutual-fund-holdings-search) |
| etf_portfolio_dates | [Historical-Mutual-Fund-Holdings-Available-Dates](https://site.financialmodelingprep.com/developer/docs/#historical-mutual-fund-holdings-available-dates) |
| etf_portfolio | [Historical-Mutual-Fund-Holdings-Portfolio](https://site.financialmodelingprep.com/developer/docs/#historical-mutual-fund-holdings-portfolio) |
## Historical Number of Employees
| Function | Endpoint(s) |
|----------|-------------|
| historical_employee_counts | [Historical-Number-of-Employees](https://site.financialmodelingprep.com/developer/docs/#Historical-Number-of-Employees) |
## Executive Compensation
| Function | Endpoint(s) |
|----------|-------------|
| executive_compensation | [Executive-Compensation](https://site.financialmodelingprep.com/developer/docs/#Executive-Compensation) |
| executive_compensation_benchmarks | [Executive-Compensation](https://site.financialmodelingprep.com/developer/docs/#Executive-Compensation) |
## Individual Beneficial Ownership
| Function | Endpoint(s) |
|----------|-------------|
| beneficial_ownership | [Individual-Beneficial-Ownership](https://site.financialmodelingprep.com/developer/docs/#Individual-Beneficial-Ownership) |
## Stock Calendars
| Function | Endpoint(s) |
|----------|-------------|
| earnings_calendar | [Earnings-Calendar](https://site.financialmodelingprep.com/developer/docs/#Earnings-Calendar) |
| historical_earnings_calendar | [Earnings-Calendar](https://site.financialmodelingprep.com/developer/docs/#Earnings-Calendar) |
| earnings_calendar_confirmed | [Earnings-Calendar-Confirmed](https://site.financialmodelingprep.com/developer/docs/#Earnings-Calendar-Confirmed) |
| ipo_calendar | [IPO-Calendar](https://site.financialmodelingprep.com/developer/docs/#IPO-Calendar) |
| ipo_calendar_with_prospectus | [IPO-Calendar-with-Prospectus](https://site.financialmodelingprep.com/developer/docs/#IPO-calendar-with-prospectus) |
| ipo_calendar_confirmed | [IPO-Calendar-Confirmed](https://site.financialmodelingprep.com/developer/docs/#IPO-calendar-Confirmed) |
| stock_split_calendar | [Stock-Split-Calendar](https://site.financialmodelingprep.com/developer/docs/#Stock-Split-Calendar) |
| dividend_calendar | [Dividend-Calendar](https://site.financialmodelingprep.com/developer/docs/#Dividend-Calendar) |
| historical_dividends | [Historical-Dividends](https://site.financialmodelingprep.com/developer/docs/#Historical-Dividends) |
| economic_calendar | [Economic-Calendar](https://site.financialmodelingprep.com/developer/docs/#Economic-Calendar) |
## Stock Look Up Tool
| Function | Endpoint(s) |
|----------|-------------|
| search_symbol | [Symbol-Search](https://site.financialmodelingprep.com/developer/docs/#Ticker-Search) |
| search_name | [Name-Search](https://site.financialmodelingprep.com/developer/docs/#Ticker-Search) |
| stock_screener | [Stock-Screener](https://site.financialmodelingprep.com/developer/docs/#Stock-Screener) |
| available_countries | [Stock-Screener](https://site.financialmodelingprep.com/developer/docs/#Stock-Screener) |
## Company Information
| Function | Endpoint(s) |
|----------|-------------|
| company_profile | [Company-Profile](https://site.financialmodelingprep.com/developer/docs/#Company-Profile) |
| key_executives | [Key-Executives](https://site.financialmodelingprep.com/developer/docs/#Key-Executives) |
| company_outlook | [Company-Outlook](https://site.financialmodelingprep.com/developer/docs/#Company-Outlook) |
| stock_peers | [Stock-Peers](https://site.financialmodelingprep.com/developer/docs/#Stock-Peers) |
| nyse_schedule | [NYSE-Schedule](https://site.financialmodelingprep.com/developer/docs/#NYSE-Holidays-and-Trading-Hours) |
| delisted_companies | [Delisted-Companies](https://site.financialmodelingprep.com/developer/docs/#Delisted-Companies) |
| symbol_changes | [Symbol-Change](https://site.financialmodelingprep.com/developer/docs/#Symbol-Change) |
| company_information | [Stock-Peers](https://site.financialmodelingprep.com/developer/docs/#Stock-Peers) |
## Stock News
| Function | Endpoint(s) |
|----------|-------------|
| fmp_articles | [FMP-Articles](https://site.financialmodelingprep.com/developer/docs/#FMP-Articles) |
| stock_news | [Stock-News](https://site.financialmodelingprep.com/developer/docs/#Stock-News) |
| stock_news_sentiment_feed | [Stock-Sentiment](https://site.financialmodelingprep.com/developer/docs/#Stock-News) |
| crypto_news | [Crypto-News](https://site.financialmodelingprep.com/developer/docs/#Crypto-news) |
| forex_news | [Forex-News](https://site.financialmodelingprep.com/developer/docs/#Forex-news) |
| general_news | [General-News](https://site.financialmodelingprep.com/developer/docs/#General-news) |
| press_releases | [Press-Releases](https://site.financialmodelingprep.com/developer/docs/#Press-Releases) |
## Market Performance
| Function | Endpoint(s) |
|----------|-------------|
| sector_pe_ratios | [Sectors-PE-Ratio](https://site.financialmodelingprep.com/developer/docs/#Sectors-PE-Ratio) |
| industry_pe_ratios | [Industries-PE-Ratio](https://site.financialmodelingprep.com/developer/docs/#Industries-PE-Ratio) |
| sector_performances | [Sectors-Performance](https://site.financialmodelingprep.com/developer/docs/#Stock-Market-Sectors-Performance) |
| historical_sector_performances | [Sectors-Performance](https://site.financialmodelingprep.com/developer/docs/#Stock-Market-Sectors-Performance) |
| gainers | [Most-Gainer](https://site.financialmodelingprep.com/developer/docs/#Most-Gainer-Stock-Companies) |
| losers | [Most-Loser](https://site.financialmodelingprep.com/developer/docs/#Most-Loser-Stock-Companies) |
| most_active | [Most-Active](https://site.financialmodelingprep.com/developer/docs/#Most-Active-Stock-Companies) |
## Advanced Data
*Skipped:*
## Stock Statistics
| Function | Endpoint(s) |
|----------|-------------|
| historical_social_sentiment | [Social-Sentiment](https://site.financialmodelingprep.com/developer/docs/#Social-Sentiment) |
| social_sentiment_trends | [Social-Sentiment](https://site.financialmodelingprep.com/developer/docs/#Social-Sentiment) |
| social_sentiment_changes | [Social-Sentiment](https://site.financialmodelingprep.com/developer/docs/#Social-Sentiment) |
| stock_grades | [Stock-Grade](https://site.financialmodelingprep.com/developer/docs/#Stock-Grade) |
| earnings_surprises | [Earnings-Surprises](https://site.financialmodelingprep.com/developer/docs/#Earnings-Surprises) |
| analyst_estimates | [Analyst-Estimates](https://site.financialmodelingprep.com/developer/docs/#Analyst-Estimates) |
| mergers_and_acquisitions_feed | [Mergers-and-Acquisitions-RSS-Feed](https://site.financialmodelingprep.com/developer/docs/#MERGER-AND-ACQUISITION) |
| mergers_and_acquisitions_search | [Mergers-and-Acquisitions](https://site.financialmodelingprep.com/developer/docs/#MERGER-AND-ACQUISITION) |
## Insider Trading
| Function | Endpoint(s) |
|----------|-------------|
| insider_trading_types | [Insider-Trading](https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) |
| insider_trades | [Insider-Trading](https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) |
| insider_trades_feed | [Insider-Trading-RSS-Feed](https://site.financialmodelingprep.com/developer/docs/#Insider-Trading-RSS-Feed) |
| insiders_list | [CIK-Mapper](https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) |
| cik_from_insider | [CIK-Mapper](https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) |
| cik_from_symbol | [CIK-Mapper](https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) |
| insider_roster | [Insider-Roster](https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) |
| insider_roster_statistics | [Insider-Roster-Statistics](https://site.financialmodelingprep.com/developer/docs/#Stock-Insider-Trading) |
| fails_to_deliver | [Fails-to-Deliver](https://site.financialmodelingprep.com/developer/docs/#Fail-to-deliver) |
## Senate Trading
| Function | Endpoint(s) |
|----------|-------------|
| senate_trades | [Senate-Trading](https://site.financialmodelingprep.com/developer/docs/#Senate-trading) |
| senate_trades_feed | [Senate-Trading-RSS-Feed](https://site.financialmodelingprep.com/developer/docs/#Senate-trading) |
| senate_disclosures | [Senate-Disclosure](https://site.financialmodelingprep.com/developer/docs/#Senate-disclosure) |
| senate_disclosures_feed | [Senate-Disclosure-RSS-Feed](https://site.financialmodelingprep.com/developer/docs/#Senate-disclosure) |
## Economics
| Function | Endpoint(s) |
|----------|-------------|
| market_risk_premium | [Market-Risk-Premium](https://site.financialmodelingprep.com/developer/docs/#Market-Risk-Premium) |
| treasury_rates | [Treasury-Rates](https://site.financialmodelingprep.com/developer/docs/#Treasury-Rates) |
| economic_indicator | [Economic-Indicator](https://site.financialmodelingprep.com/developer/docs/#Economic-Indicator) |
## Stock Price
| Function | Endpoint(s) |
|----------|-------------|
| otc_quote | [OTC-Quote](https://site.financialmodelingprep.com/developer/docs/#Company-Quote) |
| price_change | [Price-Change](https://site.financialmodelingprep.com/developer/docs/#Stock-price-change) |
| historical_splits | [Historical-Stock-Splits](https://site.financialmodelingprep.com/developer/docs/#Historical-Stock-Splits) |
| survivorship_bias | [Survivorship-Bias](https://site.financialmodelingprep.com/developer/docs/#Survivorship-Bias-Free-EOD) |
| technical_indicators | [Daily-Indicators](https://site.financialmodelingprep.com/developer/docs/#Daily-Indicators) </br> [Intraday-Indicators](https://site.financialmodelingprep.com/developer/docs/#Intraday-Indicators) |
## Fund Holdings
| Function | Endpoint(s) |
|----------|-------------|
| etf_holders | [ETF-Holders](https://site.financialmodelingprep.com/developer/docs/#ETF-Holders) |
| etf_summary | [ETF-Info](https://site.financialmodelingprep.com/developer/docs/#ETF-Expense-ratio) |
| institutional_holders | [Institutional-Holders](https://site.financialmodelingprep.com/developer/docs/#Institutional-Holders) |
| mutual_fund_holders | [Mutual-Fund-Holders](https://site.financialmodelingprep.com/developer/docs/#Mutual-Fund-Holders) |
| etf_sector_weightings | [ETF-Sector-Weightings](https://site.financialmodelingprep.com/developer/docs/#ETF-Sector-Weightings) |
| etf_country_weightings | [ETF-Country-Weightings](https://site.financialmodelingprep.com/developer/docs/#ETF-Country-Weightings) |
| etf_exposure | [ETF-Stock-Exposure](https://site.financialmodelingprep.com/developer/docs/#ETF-Stock-Exposure) |
| institutions_list | [Institutions-List](https://site.financialmodelingprep.com/developer/docs/#Form-13F) |
| cik_search | [Form-13F-Search](https://site.financialmodelingprep.com/developer/docs/#Form-13F) |
| company_from_cik | [CIK-Mapper](https://site.financialmodelingprep.com/developer/docs/#Form-13F) |
| forms_13f | [Form-13F](https://site.financialmodelingprep.com/developer/docs/#Form-13F) |
| filing_dates | [Form-13F-Filing-Dates](https://site.financialmodelingprep.com/developer/docs/#Form-13F) |
| company_from_cusip | [Cusip-Mapper](https://site.financialmodelingprep.com/developer/docs/#Form-13F) |
## Stock List
| Function | Endpoint(s) |
|----------|-------------|
| available_symbols | [Symbols-List](https://site.financialmodelingprep.com/developer/docs/#Symbols-List) |
| tradeable_symbols | [Tradeable-Symbols-List](https://site.financialmodelingprep.com/developer/docs/#Tradable-Symbols-List) |
| etf_symbols | [ETF-Symbols](https://site.financialmodelingprep.com/developer/docs/#ETF-List) |
## Bulk and Batch
*Skipped: Fund holdings endpoints require a professional plan.*
## Market Indexes
| Function | Endpoint(s) |
|----------|-------------|
| available_indexes | [Available-Indexes](https://site.financialmodelingprep.com/developer/docs/#Historical-stock-index-prices) |
| sp500_companies | [List-of-S&P-500-Companies](https://site.financialmodelingprep.com/developer/docs/#List-of-S&P-500-companies) </br> [Historical-S&P-500-Companies](https://site.financialmodelingprep.com/developer/docs/#Historical-S&P-500) |
| nasdaq_companies | [List-of-Nasdaq-100-Companies](https://site.financialmodelingprep.com/developer/docs/#List-of-Nasdaq-100-companies) |
| dowjones_companies | [List-of-Dow-Jones-Companies](https://site.financialmodelingprep.com/developer/docs/#List-of-Dow-Jones-companies) </br> [Historical-Dow-Jones-Companies](https://site.financialmodelingprep.com/developer/docs/#Historical-Dow-Jones) |
## Euronext
| Function | Endpoint(s) |
|----------|-------------|
| available_euronext | [Euronext-List](https://site.financialmodelingprep.com/developer/docs/#Most-of-the-EuroNext) |
## TSX
| Function | Endpoint(s) |
|----------|-------------|
| available_tsx | [TSX-List](https://site.financialmodelingprep.com/developer/docs/#Most-of-the-TSX) |
## Crypto, Forex, and Commodities
| Function | Endpoint(s) |
|----------|-------------|
| available_cryptocurrencies | [Cryptocurrencies-List](https://site.financialmodelingprep.com/developer/docs/#Historical-Cryptocurrencies-Price) |
| available_forex_pairs | [Forex-Pairs-List](https://site.financialmodelingprep.com/developer/docs/#Forex-(FX)) |
| exchange_rates | [Crypto-Quote](https://site.financialmodelingprep.com/developer/docs/#Cryptocurrencies) |
| available_commodities | [Commodities-List](https://site.financialmodelingprep.com/developer/docs/#Most-of-the-Major-Commodities-(Gold,-Silver,-Oil)) | | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 112 | ## FMP
```@docs
FMP
```
## PermissionError
```@docs
FinancialModelingPrep.Client.Exceptions.PermissionError
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 396 | ## company\_profile
```@docs
company_profile
```
## key\_executives
```@docs
key_executives
```
## company\_outlook
```@docs
company_outlook
```
## stock\_peers
```@docs
stock_peers
```
## nyse\_schedule
```@docs
nyse_schedule
```
## delisted\_companies
```@docs
delisted_companies
```
## symbol\_changes
```@docs
symbol_changes
```
## company\_information
```@docs
company_information
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 241 | ## available\_crytocurrencies
```@docs
available_crytocurrencies
```
## available\_forex\_pairs
```@docs
available_forex_pairs
```
## exchange\_rates
```@docs
exchange_rates
```
## available\_commodities
```@docs
available_commodities
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 163 | ## market\_risk\_premiums
```@docs
market_risk_premiums
```
## treasury\_rates
```@docs
treasury_rates
```
## economic\_indicator
```@docs
economic_indicator
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 140 | ## esg\_scores
```@docs
esg_scores
```
## esg\_ratings
```@docs
esg_ratings
```
## esg\_score\_benchmarks
```@docs
esg_score_benchmarks
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 54 | ## available\_euronext
```@docs
available_euronext
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 149 | ## executive\_compensation
```@docs
executive_compensation
```
## executive\_compensation\_benchmarks
```@docs
executive_compensation_benchmarks
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 661 | ## etf\_holders
```@docs
etf_holders
```
## etf\_summary
```@docs
etf_summary
```
## institutional\_holders
```@docs
institutional_holders
```
## mutual\_fund\_holders
```@docs
mutual_fund_holders
```
## etf\_sector\_weightings
```@docs
etf_sector_weightings
```
## etf\_country\_weightings
```@docs
etf_country_weightings
```
## etf\_exposure
```@docs
etf_exposure
```
## institutions\_list
```@docs
institutions_list
```
## cik\_search
```@docs
cik_search
```
## company\_from\_cik
```@docs
company_from_cik
```
## forms\_13f
```@docs
forms_13f
```
## filing\_dates
```@docs
filing_dates
```
## company\_from\_cusip
```@docs
company_from_cusip
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 71 | ## historical\_employee\_counts
```@docs
historical_employee_counts
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 299 | ## mutual\_fund\_portfolio\_dates
```@docs
mutual_fund_portfolio_dates
```
## mutual\_fund\_portfolio
```@docs
mutual_fund_portfolio
```
## mutual\_fund\_search
```@docs
mutual_fund_search
```
## etf\_portfolio\_dates
```@docs
etf_portfolio_dates
```
## etf\_portfolio
```@docs
etf_portfolio
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 1601 | Financial Modeling Prep API wrapper with Julia.
## Disclaimer
Data is provided by [Financial Modeling Prep](https://financialmodelingprep.com/developer/docs/) and requires a paid subscription to access some endpoints.
Only endpoints available with a starter plan have been implemented. Function to endpoint mappings are provided below.
## Installation
``` julia
pkg> add FinancialModelingPrep
```
## Getting Started
``` julia
using FinancialModelingPrep
```
``` julia
# load your API key
FMP_API_KEY = ENV["FMP_API_KEY"]
# create a new FMP API instance
fmp = FMP(apikey = FMP_API_KEY)
```
``` julia
# pass API instance to any endpoint method
data = income_statements(fmp, "AAPL")
```
``` julia
using DataFrames
# load the response data into a data frame
df = DataFrame(data)
```
``` julia
# sample data frame output
df[1:5, 1:4]
5×4 DataFrame
Row │ incomeTaxExpense reportedCurrency incomeBeforeTaxRatio depreciationAndAmortization
│ Int64 String Float64 Int64
─────┼───────────────────────────────────────────────────────────────────────────────────────
1 │ 19300000000 USD 0.30204 11104000000
2 │ 14527000000 USD 0.298529 11284000000
3 │ 9680000000 USD 0.244398 11056000000
4 │ 10481000000 USD 0.252666 12547000000
5 │ 13372000000 USD 0.274489 10903000000
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 58 | ## beneficial\_ownership
```@docs
beneficial_ownership
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 489 | ## insider\_trading\_types
```@docs
insider_trading_types
```
## insider\_trades
```@docs
insider_trades
```
## insider\_trades\_feed
```@docs
insider_trades_feed
```
## insiders_list
```@docs
insiders_list
```
## cik\_from\_insider
```@docs
cik_from_insider
```
## cik\_from\_symbol
```@docs
cik_from_symbol
```
## insider\_roster
```@docs
insider_roster
```
## insider\_roster\_statistics
```@docs
insider_roster_statistics
```
## fails\_to\_deliver
```@docs
fails_to_deliver
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 716 | ## institutional\_positions
```@docs
institutional_positions
```
## institutional\_ownership\_percentages
```@docs
institutional_ownership_percentages
```
## institutional\_ownership\_weightings
```@docs
institutional_ownership_weightings
```
## institutional\_ownership\_feed
```@docs
institutional_ownership_feed
```
## institution\_search
```@docs
institution_search
```
## institution\_portfolio\_dates
```@docs
institution_portfolio_dates
```
## institution\_portfolio\_summary
```@docs
institution_portfolio_summary
```
## institution\_portfolio\_industry\_summary
```@docs
institution_portfolio_industry_summary
```
## institution\_portfolio\_composition
```@docs
institution_portfolio_composition
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 210 | ## available\_indexes
```@docs
available_indexes
```
## sp500\_companies
```@docs
sp500_companies
```
## nasdaq\_companies
```@docs
nasdaq_companies
```
## dowjones\_companies
```@docs
dowjones_companies
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 353 | ## sector\_pe\_ratios
```@docs
sector_pe_ratios
```
## industry\_pe\_ratios
```@docs
industry_pe_ratios
```
## sector\_performances
```@docs
sector_performances
```
## historical\_sector\_performances
```@docs
historical_sector_performances
```
## gainers
```@docs
gainers
```
## losers
```@docs
losers
```
## most\_active
```@docs
most_active
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 149 | ## price\_quote
```@docs
price_quote
```
## price\_quotes
```@docs
price_quotes
```
## historical\_price\_quote
```@docs
historical_price_quote
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 371 | ## price\_targets
```@docs
price_targets
```
## price\_targets\_by\_analyst
```@docs
price_targets_by_analyst
```
## price\_targets\_by\_company
```@docs
price_targets_by_company
```
## price\_targets\_summary
```@docs
price_targets_summary
```
## price\_targets\_consensus
```@docs
price_targets_consensus
```
## price\_targets\_feed
```@docs
price_targets_feed
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 397 | ## crowdfunding\_offerings\_feed
```@docs
crowdfunding_offerings_feed
```
## crowdfunding\_offerings\_search
```@docs
crowdfunding_offerings_search
```
## crowdfunding\_offerings
```@docs
crowdfunding_offerings
```
## equity\_offerings_feed
```@docs
equity_offerings_feed
```
## equity\_offerings\_search
```@docs
equity_offerings_search
```
## equity\_offerings
```@docs
equity_offerings
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 222 | ## senate\_trades
```@docs
senate_trades
```
## senate\_trades\_feed
```@docs
senate_trades_feed
```
## senate\_disclosures
```@docs
senate_disclosures
```
## senate\_disclosure\_feed
```@docs
senate_disclosure_feed
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 609 | ## earnings\_calendar
```@docs
earnings_calendar
```
## historical\_earnings\_calendar
```@docs
historical_earnings_calendar
```
## earnings\_calendar\_confirmed
```@docs
earnings_calendar_confirmed
```
## ipo\_calendar
```@docs
ipo_calendar
```
## ipo\_calendar\_prospectus
```@docs
ipo_calendar_prospectus
```
## ipo\_calendar\_confirmed
```@docs
ipo_calendar_confirmed
```
## stock\_split\_calendar
```@docs
stock_split_calendar
```
## dividend\_calendar
```@docs
dividend_calendar
```
## historical\_dividends
```@docs
historical_dividends
```
## economic\_calendar
```@docs
economic_calendar
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 618 | ## symbols\_with\_financials
```@docs
symbols_with_financials
```
## income\_statements
```@docs
income_statements
```
## balance\_sheet\_statements
```@docs
balance_sheet_statements
```
## cash\_flow\_statements
```@docs
cash_flow_statements
```
## financial\_statements
```@docs
financial_statements
```
## financial\_reports
```@docs
financial_reports
```
## revenue\_segments
```@docs
revenue_segments
```
## shares\_float
```@docs
shares_float
```
## earnings\_call\_transcripts
```@docs
earnings_call_transcripts
```
## sec\_filings
```@docs
sec_filings
```
## company\_notes
```@docs
company_notes
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 887 | ## financial\_ratios
```@docs
financial_ratios
```
## financial\_scores
```@docs
financial_scores
```
## owners\_earnings
```@docs
owners_earnings
```
## enterprise\_values
```@docs
enterprise_values
```
## income\_statements\_growth
```@docs
income_statements_growth
```
## balance\_sheet\_statements\_growth
```@docs
balance_sheet_statements_growth
```
## cash\_flow\_statements\_growth
```@docs
cash_flow_statements_growth
```
## financial\_statements\_growth
```@docs
financial_statements_growth
```
## key\_metrics
```@docs
key_metrics
```
## company\_rating
```@docs
company_rating
```
## historical\_ratings
```@docs
historical_ratings
```
## discounted\_cash\_flows
```@docs
discounted_cash_flows
```
## advanced\_discounted\_cash\_flows
```@docs
advanced_discounted_cash_flows
```
## historical\_discounted\_cash\_flows
```@docs
historical_discounted_cash_flows
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 148 | ## available\_symbols
```@docs
available_symbols
```
## tradeable\_symbols
```@docs
tradeable_symbols
```
## etf\_symbols
```@docs
etf_symbols
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 328 | ## fmp\_articles
```@docs
fmp_articles
```
## stock\_news
```@docs
stock_news
```
## stock\_news\_sentiment\_feed
```@docs
stock_news_sentiment_feed
```
## crypto\_news
```@docs
crypto_news
```
## forex\_news
```@docs
forex_news
```
## general\_news
```@docs
general_news
```
## press\_releases
```@docs
press_releases
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
|
[
"MIT"
] | 0.2.0 | 35a2861dcb59e391069729baab1b4480474b7eb6 | docs | 248 | ## otc\_quote
```@docs
otc_quote
```
## price\_change
```@docs
price_change
```
## historical\_splits
```@docs
historical_splits
```
## survivorship\_bias
```@docs
survivorship_bias
```
## technical\_indicators
```@docs
technical_indicators
``` | FinancialModelingPrep | https://github.com/rando-brando/FinancialModelingPrep.jl.git |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.