Skip to content

Commit

Permalink
Initial version for tryout
Browse files Browse the repository at this point in the history
  • Loading branch information
bramjochems committed Nov 12, 2013
1 parent 8527670 commit 61b29d5
Show file tree
Hide file tree
Showing 354 changed files with 228,193 additions and 0 deletions.
51 changes: 51 additions & 0 deletions BJExcelLib.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UDFs", "UDFs", "{C34891EC-85D9-4CCE-880D-9F81F84677C3}"
ProjectSection(SolutionItems) = preProject
BJExcelLib\UDF.American.fs = BJExcelLib\UDF.American.fs
BJExcelLib\UDF.Blackscholes.fs = BJExcelLib\UDF.Blackscholes.fs
BJExcelLib\UDF.Date.fs = BJExcelLib\UDF.Date.fs
BJExcelLib\UDF.Interpolation.fs = BJExcelLib\UDF.Interpolation.fs
BJExcelLib\UDF.Misc.fs = BJExcelLib\UDF.Misc.fs
BJExcelLib\UDF.Volatility.fs = BJExcelLib\UDF.Volatility.fs
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Finance", "Finance", "{733C851A-70E4-44BF-96D5-F361562FA094}"
ProjectSection(SolutionItems) = preProject
BJExcelLib\Finance.Blackscholes.fs = BJExcelLib\Finance.Blackscholes.fs
BJExcelLib\Finance.Date.fs = BJExcelLib\Finance.Date.fs
BJExcelLib\Finance.JuZhong.fs = BJExcelLib\Finance.JuZhong.fs
BJExcelLib\Finance.SVI.fs = BJExcelLib\Finance.SVI.fs
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Math", "Math", "{99FB6D68-12D5-41DC-9272-7BC467A21501}"
ProjectSection(SolutionItems) = preProject
BJExcelLib\Math.Interpolation.fs = BJExcelLib\Math.Interpolation.fs
EndProjectSection
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BJExcelLib", "BJExcelLib\BJExcelLib.fsproj", "{CCCFFCBC-7434-4262-A7C1-730F94362E7F}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BJExcelLibTests", "BJExcelLibTests\BJExcelLibTests.fsproj", "{1F3EDE6E-7D84-45BD-9B0C-00198760A714}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CCCFFCBC-7434-4262-A7C1-730F94362E7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CCCFFCBC-7434-4262-A7C1-730F94362E7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCCFFCBC-7434-4262-A7C1-730F94362E7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCCFFCBC-7434-4262-A7C1-730F94362E7F}.Release|Any CPU.Build.0 = Release|Any CPU
{1F3EDE6E-7D84-45BD-9B0C-00198760A714}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F3EDE6E-7D84-45BD-9B0C-00198760A714}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F3EDE6E-7D84-45BD-9B0C-00198760A714}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F3EDE6E-7D84-45BD-9B0C-00198760A714}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
11 changes: 11 additions & 0 deletions BJExcelLib/BJExcelLib-AddIn.dna
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<DnaLibrary Name="BJ Excel Add-In" RuntimeVersion="v4.0">

<ExternalLibrary Path="BJExcelLib.dll" LoadFromBytes="true" Pack="true" ExplicitExports="true"/>

<Reference Path="FSharp.Core.dll" Pack="true" />
<Reference Path="FSharpx.Core.dll" Pack="true" />
<Reference Path="MathNet.Numerics.dll" Pack="true" />
<Reference Path="MathNet.Numerics.FSharp.dll" Pack="true" />
<Reference Path="MathNet.Numerics.IO.dll" Pack="true" />
<Reference Path="alglibnet2.dll" Pack="true"/>
</DnaLibrary>
12 changes: 12 additions & 0 deletions BJExcelLib/BJExcelLib-AddIn64.dna
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<DnaLibrary Name="BJ Excel Add-In" RuntimeVersion="v4.0">

<ExternalLibrary Path="BJExcelLib.dll" LoadFromBytes="true" Pack="true" ExplicitExports="true"/>

<Reference Path="FSharp.Core.dll" Pack="true" />
<Reference Path="FSharpx.Core.dll" Pack="true" />
<Reference Path="MathNet.Numerics.dll" Pack="true" />
<Reference Path="MathNet.Numerics.FSharp.dll" Pack="true" />
<Reference Path="MathNet.Numerics.IO.dll" Pack="true" />
<Reference Path="alglibnet2.dll" Pack="true"/>
</DnaLibrary>

127 changes: 127 additions & 0 deletions BJExcelLib/BJExcelLib.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>cccffcbc-7434-4262-a7c1-730f94362e7f</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>BJExcelLib</RootNamespace>
<AssemblyName>BJExcelLib</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<Name>BJExcelLib</Name>
<TargetFSharpCoreVersion>4.3.0.0</TargetFSharpCoreVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\BJExcelLib.XML</DocumentationFile>
<StartAction>Program</StartAction>
<StartProgram>C:\Program Files\Microsoft Office 15\root\office15\EXCEL.EXE</StartProgram>
<StartArguments>D:\Programmeren\BJExcelLib\BJExcelLib\bin\Debug\BJExcelLib-Addin.xll</StartArguments>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\BJExcelLib.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
<ItemGroup>
<Compile Include="Util.Extensions.fs" />
<Compile Include="ExcelDna.IO.fs" />
<Compile Include="ExcelDna.Cache.fs" />
<Compile Include="Math.Constants.fs" />
<Compile Include="NormalDistribution.fs" />
<Compile Include="Math.Interpolation.fs" />
<Compile Include="Math.Interpolation2D.fs" />
<Compile Include="Math.Optimization.fs" />
<Compile Include="Finance.Date.fs" />
<Compile Include="Finance.SVI.fs" />
<Compile Include="Finance.Blackscholes.fs" />
<Compile Include="Finance.JuZhong.fs" />
<Compile Include="UDF.Date.fs" />
<Compile Include="UDF.Interpolation.fs" />
<Compile Include="UDF.Volatility.fs" />
<Compile Include="UDF.Blackscholes.fs" />
<Compile Include="UDF.American.fs" />
<Compile Include="UDF.CalendarManager.fs" />
<Compile Include="UDF.Misc.fs" />
<None Include="packages.config" />
<Content Include="BJExcelLib-AddIn.dna">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="BJExcelLib-AddIn64.dna">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Reference Include="alglibnet2">
<HintPath>C:\Programming\alglib 3.8.0\alglibnet2.dll</HintPath>
</Reference>
<Reference Include="ExcelDna.Integration">
<HintPath>..\packages\Excel-DNA.0.30.3\lib\ExcelDna.Integration.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>True</Private>
</Reference>
<Reference Include="FSharpx.Core">
<HintPath>..\packages\FSharpx.Core.1.8.39\lib\40\FSharpx.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MathNet.Numerics">
<HintPath>..\packages\MathNet.Numerics.2.6.1\lib\net40\MathNet.Numerics.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MathNet.Numerics.FSharp">
<HintPath>..\packages\MathNet.Numerics.FSharp.2.6.0\lib\net40\MathNet.Numerics.FSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MathNet.Numerics.IO">
<HintPath>..\packages\MathNet.Numerics.2.6.1\lib\net40\MathNet.Numerics.IO.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<PropertyGroup>
<PostBuildEvent>echo F | xcopy "D:\Programmeren\BJExcelLib\packages\Excel-DNA.0.30.3\tools\ExcelDna.xll" "$(TargetDir)BJExcelLib-AddIn.xll" /C /Y
echo F | xcopy "D:\Programmeren\BJExcelLib\packages\Excel-DNA.0.30.3\tools\ExcelDna64.xll" "$(TargetDir)BJExcelLib-AddIn64.xll" /C /Y
"D:\Programmeren\BJExcelLib\packages\Excel-DNA.0.30.3\tools\ExcelDnaPack.exe" "$(TargetDir)BJExcelLib-AddIn.dna" /Y
"D:\Programmeren\BJExcelLib\packages\Excel-DNA.0.30.3\tools\ExcelDnaPack.exe" "$(TargetDir)BJExcelLib-AddIn64.dna" /Y</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
56 changes: 56 additions & 0 deletions BJExcelLib/ExcelDna.Cache.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
namespace BJExcelLib.ExcelDna

open ExcelDna.Integration
open ExcelDna.Integration.Rtd
open System.Collections.Generic


/// Module that allows creation of persistent objects from excel. Got the idea
/// (and a big part of the code) from the ExcelDNA group in a post by "DC":
/// https://groups.google.com/forum/#!searchin/exceldna/xlcache/exceldna/E4vIOSNwHm0/yHmVTW4FHA0J
module public Cache =

/// The cache that holds objects indexed by a key
let private cache = Dictionary<_,_>()
let private tagstore = Dictionary<_,_>()

/// Registers an object in the cache. The tag is an id for the category the object belongs to
/// The tag is not equal to the final handle the object gets, because a counter will be prepared
let public register tag o =
let counter =
match tagstore.TryGetValue tag with
| true, c -> c + 1
| _ -> 1

tagstore.[tag] <- counter
let handle = tag + "." + counter.ToString()
cache.[handle] <- box o
XlCall.RTD("BJExcelLib.ExcelDna.CacheRTD", null, handle)

/// Removes a given handle from the cache
let public unregister handle =
if cache.ContainsKey(handle) then cache.Remove(handle) |> ignore

/// resets the cache by removing all values in there
let public reset =
cache.Clear()
tagstore.Clear()

/// Finds a value in the cache. If no value is found, None is returned. If a value is found, then
/// the the result is wrapped in Some and returned, otherwise None is returned.
let lookup handle =
match cache.TryGetValue handle with
| true, value -> Some(value)
| _ -> None

/// Excel RTD server to handle the registering/unregistering of object handles
type public CacheRTD() =
inherit ExcelRtdServer()
let _topics = new Dictionary<ExcelRtdServer.Topic, string>()
override x.ConnectData(topic:ExcelRtdServer.Topic, topicInfo:IList<string>, newValues:bool byref) =
let name = topicInfo.Item(0)
_topics.[topic] <- name
name |> box
override x.DisconnectData(topic:ExcelRtdServer.Topic) =
_topics.[topic] |> Cache.unregister
_topics.Remove(topic) |> ignore
Loading

0 comments on commit 61b29d5

Please sign in to comment.