是否有Dart的REPL进行试验?
我尝试在Dartium的devtools中输入dart代码,但也没有用.
所以我找不到一种简单的方法来玩飞镖中的各种API.
我试图使用Quantlib(v1.2)SWIG包装器在python中为一个非常基本的浮动利率债券定价.我修改了文档中包含的示例.
我的债券有4年的到期期限.libor设定为10%,债券的差价为0.我的问题是,如果我以10%的比率打折,为什么债券的PV不是100?我的值为99.54.
谢谢!
from QuantLib import *
frequency_enum, settle_date = 4, Date(5, 1, 2010)
maturity_date = Date(5, 1, 2014)
face_amount = 100.0
settlement_days = 0
fixing_days = 0
calendar = NullCalendar()
settle_date = calendar.adjust(settle_date)
todays_date = calendar.advance(settle_date, -fixing_days, Days)
Settings.instance().evaluationDate = todays_date
rate = 10.0 / 100.0
flat_forward = FlatForward(settle_date,
rate,
Thirty360(),
Compounded,
frequency_enum)
discounting_term_structure = RelinkableYieldTermStructureHandle(flat_forward)
index_term_structure = RelinkableYieldTermStructureHandle(flat_forward)
index = USDLibor(Period(3, Months), index_term_structure)
schedule = Schedule(settle_date,
maturity_date, Period(frequency_enum),
NullCalendar(),
Unadjusted, Unadjusted,
DateGeneration.Forward, False)
floating_bond = FloatingRateBond(settlement_days,
face_amount,
schedule, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Apache POI 3.9 从字符串中读取 excel 文件,但没有成功。我对java不太熟悉。
为了澄清一下,在我的程序中,我已经将 excel 文件作为字符串,并且我正在使用 readFile 函数来模拟该行为。
程序:
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
public class Test {
static String readFile(String path, Charset encoding) throws IOException
{
byte[] encoded = Files.readAllBytes(Paths.get(path));
return encoding.decode(ByteBuffer.wrap(encoded)).toString();
}
public static void main(String[] args) throws IOException, InvalidFormatException {
String result = readFile("data.xlsx", StandardCharsets.UTF_8);
InputStream is = new ByteArrayInputStream(result.getBytes("UTF-8"));
Workbook book = WorkbookFactory.create(is);
}
} …
Run Code Online (Sandbox Code Playgroud) 我有一个很大的 csv 文件,我想只读取部分文件,比如说前 1000 行。
我计划使用fast-csv包或node-csv-parse。
该任务并不像读取 1000 行那么简单,因为一行可能具有多行值。
有人可以帮助我吗?
谢谢!