基金稳赢算法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 基金
{
class Program
{
static void Main(string[] args)
{
Random random1 = new Random();//做波动幅度
Random random2 = new Random();//决定是上涨还是下跌
double capital = 100;//玩的资金
double bdRange = 0;//波动幅度
double[] checkRangeArray = { 0.05, 0.04, 0.03, 0.02, 0.01 };//判断范围,从大到小排序
double lossFund = 0;//亏损资金
double profit = 0;//盈利
double lossBFB = 0;
double profitBFB = 0;
int fallCount = 0;//下跌次数
int riseCount = 0;//上涨次数
int checkNumber = 0;
//下跌超过5%时加注
//以此推算1%加注10%
//运行次数
for (int i = 0; i < 100; i++)
{
bdRange = ((double)random1.Next(0, 69) / 1000);
checkNumber = random2.Next(0, 100);
//上涨概率
if (checkNumber > 60)
{
lossFund += capital * bdRange;
lossBFB += bdRange;
fallCount++;
for (int j = 0; j < checkRangeArray.Length; j++)
{
if(bdRange>=checkRangeArray[0])
{
capital += capital * 0.5;
break;
}
if (bdRange >= checkRangeArray[j])
{
capital += capital * checkRangeArray[j];
break;
}
}
}
else
{
profit += capital * bdRange;
profitBFB += bdRange;
riseCount++;
for (int j = 0; j < checkRangeArray.Length; j++)
{
if (bdRange >= checkRangeArray[0])
{
capital -= capital * 0.5;
break;
}
if (bdRange >= checkRangeArray[j])
{
capital -= capital * checkRangeArray[j];
break;
}
}
}
}
Console.WriteLine(“下跌幅度(总):” + lossBFB + “,上涨幅度(总):” + profitBFB);
Console.WriteLine(“下跌次数:” + fallCount + “,上涨次数:” + riseCount);
Console.WriteLine(“亏损:” + lossFund + “,盈利:” + profit);
Console.WriteLine(“总盈利:” + (profit - lossFund));
Console.ReadKey();
}
}
}

此套算法仅针对于上涨总幅度超过下跌总幅度的盈利情况,如果你有更好的方案,欢迎指教

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值