FIN 4453 – PROJECT 2 Fall 2024

Java与Python在金融项目中的应用

Java Python FIN 4453 – PROJECT 2 (10 Questions)

Fall 2024

1. (15 Points) Use the Excel file Asset Allocation Data to determine the following:

a. Using EXCEL’s Data Table Feature, create a one-way data table that determines the different means and standard deviations for combinations of Portfolio 1 and Portfolio 2 by varying the proportion of Portfolio 1.

b. Graph the combinations of the portfolios from the one-way data table and add the individual asset means and standard deviations to the graph.

c. Using EXCEL’s Text Box feature, explain why the envelope portfolios may or may not be on the efficient frontier?

d. Using Solver or Goal Seek, find an envelope portfolio that would yield an expected return of 4.75%.  What would be the corresponding portfolio standard deviation?

e. Using Solver or Goal Seek, find two envelope portfolios that would yield a standard deviation of 6.25%.  What would be the corresponding expected returns for each of these portfolios?

f. Using Solver, find the envelope portfolio that would yield the smallest (minimum) standard deviation.  What would be the corresponding expected return and standard deviation for this portfolio?

2. (10 Points) Use the Excel file Data for Two Stocks to determine the following:

a. Using EXCEL’s Data Table Feature, create a one-way data table that determines the different means and standard deviations for portfolios consisting of combinations of Stock A and Stock B by varying the correlation coefficient value between Stock A and Stock B through the full range of possible correlation coefficient values.  Use increments of 0.125 for the possible correlation coefficient values.

b. Graph the correlation coefficients, the means, and the standard deviations of the portfolios from the one-way data table.  Be sure to include a title for the graph and label the axes.

c. Use Excel’s Text Box Feature to explain how the portfolio means are affected by changing the correlation coefficient values.

d. Use Excel’s Text Box Feature to explain how the portfolio standard deviations are affected by changing the correlation coefficient values.

3. (10 Points) Use the Variance – Covariance matrix in the Excel file: Efficient Portfolios Data.

Construct a model to determine the following:

a. Calculate an envelope portfolio assuming the risk-free rate is 2%.

b. Calculate an envelope portfolio assuming the risk-free rate is 16%.

c. Using EXCEL’s Data Table Feature, create a one-way data table that determines the different means and standard deviations for combinations of Envelope Portfolio 1 and Envelope Portfolio 2 by varying the proportion of Portfolio 1 from -10 to +10 in increments of 1.00.

d. Graph the combinations of the portfolios from the one-way data table and add the individual asset means and standard deviations to the graph.

e. Provide a title on the graph FIN 4453 – PROJECT 2 Fall 2024 and label the axes of the graph.

f. Using EXCEL’s Text Box feature, explain whether the portfolio combinations could be on the efficient frontier.

4. (15 Points) The Excel file Stock Data contains monthly return data for seven (7) stocks.

a. Use these returns and the Matrix of Excess Returns to compute the Variance-Covariance Matrix for these seven (7) stocks. (Do not use the varcovar VBA function).

b. Use the Variance - Covariance Matrix for these seven (7) stocks to compute the individual stock proportions for the Global Minimum Variance Portfolio (GMVP).

c. Calculate the Expected Return and Risk (Standard Deviation) for the Global Minimum Variance Portfolio (GMVP).

5. (10 Points) The Excel file Stock Data contains monthly return data for seven (7) stocks.

a. Compute the Correlation Matrix for the seven (7) stocks.

b. Using EXCEL’s Text Box feature explain/identify

i. The characteristics of the Correlation Matrix.

ii. What the correlation coefficient measures.

iii. How the correlation coefficient values are used in portfolio theory, i.e., the role of the correlation coefficient in portfolio theory.

6. (8 Points) Provide Benninga’s definitions for the following:

a. Envelope Portfolio

b. Efficient Portfolio

c. Feasible Portfolio

d. Infeasible Portfolio

7. (8 Points) Solve the following system of equations using Matrix Algebra.

3A + 5B – 4D + 6E = 80

6A + 4B + 8C – 3D + 2E = 70

7A – 6C + 2D + 3E = 60

6A – 5B + 4D + 2E = 50

4A + 9B + 3D – 4E = 40

8. (8 Points) The Excel file Portfolio Weights Data contains information about two portfolios.

a. Using Matrix Algebra compute the portfolio asset weights for Portfolio C if Portfolio C has 42% of its funds invested in Portfolio A and 58% of its funds invested in Portfolio B.

b. Using EXCEL’s Data Table Feature, create a one-way data table to compute the Portfolio C asset weights by varying the proportion of funds invested in Portfolio A from 0 to +1.0 in increments of 0.125.  Portfolio C will consist of the appropriate proportion of funds invested in Portfolio A and the remainder of the funds invested in Portfolio B.

9. (8 Points) Describe the characteristics of a variance-covariance matrix.  Also, explain how to read a variance-covariance matrix, what the individual values in a variance-covariance matrix represent, what the individual values in a variance-covariance matrix measure, and how the variance-covariance matrix is used.  Use EXCEL’s Text Box feature when you input your response.

10. (8 Points) The EXCEL file Stock Return Probability Distribution contains the probability distribution for a stock.

a. Compute the Expected Return for this stock.

b. Compute the Risk for this stock         

<think>我们正在讨论LWIP中的FIN_WAIT_2状态。在TCP连接终止过程中,当一方(我们称为A)发送了FIN并收到另一方的ACK(但尚未收到对方的FIN)时,A进入FIN_WAIT_2状态。在LWIP中,这个状态的处理有一些特点,特别是关于超时和资源回收。 在标准TCP中,FIN_WAIT_2状态可以持续直到收到对方的FIN,但为了防止无限等待,通常有一个超时(在Linux中默认60秒)。在LWIP中,这个超时由TCP_FIN_WAIT_TIMEOUT控制。 另外,在LWIP中,当连接处于FIN_WAIT_2状态时,它会被放在一个叫做tcp_tw_pcbs的链表中(如果开启了LWIP_TCP_TIMESTAMPS,则使用另一种方式管理)。然后,在慢定时器(tcp_slowtmr)中会检查这些连接的超时。 下面将详细解读LWIP中FIN_WAIT_2状态的处理,包括状态转移、超时机制和资源回收。 注意:LWIP的版本不同实现可能略有不同,这里以较新的版本(如2.1.2)为例。</think>### LWIP中FIN_WAIT_2状态解析 在lwIP的TCP协议栈中,`FIN_WAIT_2`是TCP连接终止过程中的关键状态之一。它发生在主动关闭方发送FIN并收到ACK后,等待对方发送FIN的阶段。以下是深度解析: #### 状态转移机制 ```mermaid stateDiagram-v2 [*] --> ESTABLISHED ESTABLISHED --> FIN_WAIT_1: 主动关闭方发送FIN FIN_WAIT_1 --> FIN_WAIT_2: 收到ACK(未收到FINFIN_WAIT_2 --> TIME_WAIT: 收到对方FIN TIME_WAIT --> [*]: 2MSL超时 FIN_WAIT_2 --> CLOSED: 超时或异常终止 ``` #### 核心处理逻辑 在`tcp_slowtmr()`中实现状态管理(`src/core/tcp.c`): ```c void tcp_slowtmr(void) { for (pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb_next) { switch (pcb->state) { case FIN_WAIT_2: /* 检查FIN_WAIT_2超时 */ if (++pcb->tmr > tcp_fin_wait_2_timeout) { tcp_abort(pcb); // 强制终止连接 } break; } } } ``` #### 关键配置参数 在`lwipopts.h`中定义: ```c #define TCP_FIN_WAIT_TIMEOUT 60000 // FIN_WAIT_2超时时间(ms),默认60秒 #define TCP_MAX_MSL 60000 // MSL时间(ms),影响TIME_WAIT时长 ``` #### 状态特性与挑战 1. **资源占用问题** - 每个`FIN_WAIT_2`连接占用: - 约200字节内存(PCB结构体) - 1个TCP端口资源 - 高并发场景易导致资源耗尽 2. **超时管理机制** ```c // 默认超时计算(tcp.c) #define tcp_fin_wait_2_timeout (TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) ``` - 实际超时检测在慢定时器中间隔执行(默认500ms) 3. **异常处理场景** - **被动方崩溃**:依赖`TCP_FIN_WAIT_TIMEOUT`回收资源 - **网络丢包**:重传机制不适用于FIN_WAIT_2状态 - **资源耗尽**:触发`tcp_abort()`强制关闭 #### 优化策略 1. **调整超时参数** ```c // 减少FIN_WAIT_2持续时间 #define TCP_FIN_WAIT_TIMEOUT 30000 // 30秒 ``` 2. **启用端口复用** ```c #define SO_REUSE 1 // 允许TIME_WAIT端口重用 ``` 3. **主动关闭优化** ```c // 应用层设置SO_LINGER选项 struct linger lin = { .l_onoff = 1, .l_linger = 0 }; setsockopt(sock, SOL_SOCKET, SO_LINGER, &lin, sizeof(lin)); ``` #### 状态转移矩阵 | 事件 | 动作 | 新状态 | |------|------|--------| | 收到FIN | 发送ACK | TIME_WAIT | | 超时 | 释放PCB | CLOSED | | 收到数据 | 发送RST | CLOSED | | 应用关闭 | 无操作 | 保持状态 | #### 典型问题解决方案 **场景**:服务器出现大量FIN_WAIT_2连接<br> **诊断命令**: ```bash netstat -n | awk '/FIN_WAIT_2/{print $5}' | cut -d: -f1 | sort | uniq -c ``` **解决步骤**: 1. 检查被动关闭方是否正常发送FIN 2. 调整`TCP_FIN_WAIT_TIMEOUT` 3. 启用`SO_REUSEADDR` 4. 优化应用关闭逻辑
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值