floda/yahoo_finance 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

floda/yahoo_finance

Composer 安装命令:

composer require floda/yahoo_finance

包简介

Yahoo Finance market data

README 文档

README

Total Downloads License

Since APIs have been discontinued in November 2017, this client is using non-official API endpoints for quotes, search and historical data.

WARNING: These non-official APIs cannot be assumed stable and might break any time. Also, you might violate Yahoo's terms of service. So use them at your own risk.

Installation

$ composer require "floda/yahoo_finance"

Usage

If your project has not an autoloder, just include once this line:

require_once __DIR__ . "/../vendor/autoload.php";

For Laravel 5, Symfony, just instance object and use functions


Historical Data

<?php

// Instance Object
$yf = new \floda\yahoo_finance\YF();

//Params
$symbol ="TRAN.BA";       //tickers with no .XX, API will return US stock market ticker  
                          //for example: $symbol="AAPL";
                          // For another countries, you can use for example:
                          // .BA -> Argentina -> Buenos Aires Stock Exchange (BYMA)

$time_ago = "3 months";   //you can use xx days, xx weeks, xx months, xx years, etc

$historical = $yf->getHistorical($symbol, $time_ago);
/*
Array
(
  [0] => Array
      (
          [date] => 2019-10-04
          [open] => 21.950001
          [high] => 22.9
          [low] => 21.950001
          [close] => 22.9
          [adjClose] => 22.9
          [volume] => 277948
      )

  ....
  ....

  [59] => Array
      (
          [date] => 2020-01-03
          [open] => 25.5
          [high] => 25.549999
          [low] => 24.5
          [close] => 24.950001
          [adjClose] => 24.950001
          [volume] => 229283
      )
)
*/

All Exchanges

Sufix Country City Sufix Country City
.BA Argentina Buenos Aires (BYMA) .NS India National of India
.VI Austria Vienna .JK Indonesia Indonesia (IDX)
.AX Australia Australian (ASX) .IR Ireland Euronext Dublin
.BR Belgium Euronext Brussels .TA Israel Tel Aviv
.SA Brazil Sao Paolo (BOVESPA) .TI Italy EuroTLX
.CN Canada Canadian Securities .MI Italy Italian
.NE Canada NEO Exchange .T Japan Tokyo
.TO Canada Toronto (TSX) .RG Latvia Nasdaq OMX Riga
.V Canada TSX Venture Exchange (TSXV) .VS Lithuania Nasdaq OMX Vilnius
.SN Chile Santiago .KL Malaysia Malaysian
.SS China Shanghai .MX Mexico Mexico (BMV)
.SZ China Shenzhen .AS Netherlands Euronext Amsterdam
.PR Czech Republic Prague Index .NZ New Zealand New Zealand (NZX)
.CO Denmark Nasdaq OMX Copenhagen .OL Norway Oslo
.CA Egypt Egyptian Index (EGID) .LS Portugal Euronext Lisbon
.TL Estonia Nasdaq OMX Tallinn .QA Qatar Qatar
.HE Finland Nasdaq OMX Helsinki .ME Russia Moscow Exchange (MOEX)
.NX France Euronext .SI Singapore Singapore (SGX)
.PA France Euronext Paris .JO South Africa Johannesburg
.BE Germany Berlin .KS South Korea Korea
.BM Germany Bremen .KQ South Korea KOSDAQ
.DU Germany Dusseldorf .MC Spain Madrid SE C.A.T.S.
.F Germany Frankfurt .SAU Saudi Arabia Saudi (Tadawul)
.HM Germany Hamburg .ST Sweden Nasdaq OMX Stockholm
.HA Germany Hanover .SW Switzerland Swiss Exchange (SIX)
.MU Germany Munich .TWO Taiwan Taiwan OTC Exchange
.SG Germany Stuttgart .TW Taiwan Taiwan (TWSE)
.DE Germany Deutsche Boerse XETRA .BK Thailand (SET)
.AT Greece Athens (ATHEX) .IS Turkey Borsa İstanbul
.HK Hong Kong Hong Kong (HKEX) .L United Kingdom London
.BD Hungary Budapest .IL United Kingdom London
.IC Iceland Nasdaq OMX Iceland .CR Venezuela Caracas
.BO India Bombay

FOREX PAIRS

<?php

// Instance Object
$yf = new \floda\yahoo_finance\YF();

//Params
$currency_1="USD";
$currency_2="ARS";

$fx = $yf->getFX($currency_1,$currency_2);

/*
Array
(
    [symbol] => USDARS=X
    [date] => 2020-01-04 5:55:51
    [bid] => 59.729
    [ask] => 59.734
    [high] => 59.73
    [low] => 59.729
    [open] => 59.73
    [previous] => 59.729
    [price] => 59.729
)
*/

Quote, Order Book, AfterMarket Prices, Financial & Stats

<?php

// Instance Object
$yf = new \floda\yahoo_finance\YF();

//Params
$symbol = "YPF";

$quote = $yf->getQuote($symbol);

/*
Array
(
    [symbol] => YPF
    [price] => 11.16
    [date] => 2020-01-03 21:02:00
    [book] => Array
        (
            [bidSize] => 31
            [bid] => 11.14
            [ask] => 11.57
            [askSize] => 9
        )

    [today] => Array
        (
            [high] => 11.49
            [low] => 10.86
            [open] => 11.24
            [previousDay] => 11.26
            [volume] => 2732642
            [change] => -0.10000038
            [changePercent] => -0.8881029
        )

    [AfterMarket] => Array
        (
            [price] => 11.0746
            [change] => -0.08539963
            [changePercent] => -0.76522964
            [lastTrade] => 2020-01-03 21:26:02
        )

    [financials] => Array
        (
            [name] => YPF Sociedad Anonima
            [mktCap] => 4389372928
            [sharesOutstanding] => 393312992
            [volumeAvg3Month] => 2095557
            [bookValue] => 33.975
            [eps12Month] => 3.125
            [dividendRate] => 0.089
            [dividendYield] => 0.007904085
        )

    [stats] => Array
        (
            [SMA50] => 10.16606
            [SMA200] => 11.737482
            [1yrHigh] => 18.73
            [1yrHighChangePercent] => -0.40416443
            [1yrLow] => 8.04
            [1yrLowChangePercent] => 0.38805968
        )

)
*/

Symbol - Expiration Dates

<?php

// Instance Object
$yf = new \floda\yahoo_finance\YF();

//Params
$symbol="YPF";

$expirations = $yf->getExpirations($symbol);
/*
Array
(
  [0] => Array
      (
          [unix] => 1578614400
          [days] => 6
          [expiration] => 2020-01-10
      )

  ...
  ...

  [9] => Array
      (
          [unix] => 1642723200
          [days] => 748
          [expiration] => 2022-01-21
      )
)
*/

Symbol - Expiration - Option Chain

<?php

// Instance Object
$yf = new \floda\yahoo_finance\YF();

//Params
$symbol="AAPL";

$expirations = $yf->getExpirations($symbol);
$contracts = $yf->getContracts($symbol,$expirations[0]['unix']);

/*
Array
(
    [0] => Array
        (
            [symbol] => AAPL
            [spot] => 297.43
            [expiration] => 2020-01-10
            [strike] => 230
            [otm_abs] => 22.67
            [call_contract] => AAPL200110C00230000
            [call_bid] => 67.85
            [call_ask] => 69.6
            [call_lastPrice] => 68.99
            [call_volume] => 18
            [call_openInterest] => 0
            [call_lastTradeDateUNIX] => 1578069878
            [call_lastTradeDate] => 2020-01-03
            [put_contract] => AAPL200110P00230000
            [put_bid] => 0.02
            [put_ask] => 0.03
            [put_lastPrice] => 0.03
            [put_volume] => 6
            [put_openInterest] => 0
            [put_lastTradeDateUNIX] => 1578061990
            [put_lastTradeDate] => 2020-01-03
            [IV] => 95.9
        )

    ...
    ...

    [37] => Array
        (
           [symbol] => AAPL
           [spot] => 297.43
           [expiration] => 2020-01-10
           [strike] => 350
           [otm_abs] => 17.67
           [call_contract] => AAPL200110C00350000
           [call_bid] => 0.02
           [call_ask] => 0.03
           [call_lastPrice] => 0.05
           [call_volume] => 405
           [call_openInterest] => 0
           [call_lastTradeDateUNIX] => 1578084931
           [call_lastTradeDate] => 2020-01-03
           [put_contract] => AAPL200110P00350000
           [put_bid] => 51
           [put_ask] => 51.85
           [put_lastPrice] => 51.7
           [put_volume] => 2
           [put_openInterest] => 0
           [put_lastTradeDateUNIX] => 1577983464
           [put_lastTradeDate] => 2020-01-02
           [IV] => 45.31
        )
)
*/

Configuration

It doesnt need any configuration line

Enjoy it! ❤️


Credits

scheb/yahoo-finance-api


License

MIT

floda/yahoo_finance 适用场景与选型建议

floda/yahoo_finance 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 25, 最近一次更新时间为 2020 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 floda/yahoo_finance 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 floda/yahoo_finance 我们能提供哪些服务?
定制开发 / 二次开发

基于 floda/yahoo_finance 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 20
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 25
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 25
  • Watchers: 2
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-04